mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 10:06:16 +00:00
Removed location from models
Added the spaces models Added the rooms models Added the Spaces cubit Implemented the home dropdown functionality
This commit is contained in:
BIN
assets/images/blind.png
Normal file
BIN
assets/images/blind.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/curtain.png
Normal file
BIN
assets/images/curtain.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
133
lib/features/app_layout/bloc/spaces_cubit.dart
Normal file
133
lib/features/app_layout/bloc/spaces_cubit.dart
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/curtain_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/gateway/gateway_view.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_view.dart';
|
||||||
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
|
|
||||||
|
part 'spaces_state.dart';
|
||||||
|
|
||||||
|
class SpacesCubit extends Cubit<SpacesState> {
|
||||||
|
SpacesCubit() : super(SpacesInitial());
|
||||||
|
|
||||||
|
static SpacesCubit get(context) => BlocProvider.of(context);
|
||||||
|
|
||||||
|
static List<SpaceModel> spaces = [
|
||||||
|
SpaceModel(
|
||||||
|
id: '0',
|
||||||
|
name: 'Home',
|
||||||
|
rooms: [],
|
||||||
|
),
|
||||||
|
SpaceModel(
|
||||||
|
id: '1',
|
||||||
|
name: 'Office',
|
||||||
|
rooms: [],
|
||||||
|
),
|
||||||
|
SpaceModel(
|
||||||
|
id: '2',
|
||||||
|
name: 'Parent\'s House',
|
||||||
|
rooms: [],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
List<RoomModel> rooms = [
|
||||||
|
RoomModel(id: '0', name: 'Living Room', categories: [
|
||||||
|
DevicesCategoryModel(
|
||||||
|
devices: [
|
||||||
|
ACModel(
|
||||||
|
name: "Living Room AC",
|
||||||
|
id: '0',
|
||||||
|
status: false,
|
||||||
|
temperature: 20,
|
||||||
|
fanSpeed: 0,
|
||||||
|
tempMode: 0,
|
||||||
|
coolTo: 20,
|
||||||
|
type: '',
|
||||||
|
image: '',
|
||||||
|
timer: null,
|
||||||
|
bounds: Bounds(
|
||||||
|
min: 20,
|
||||||
|
max: 30,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
icon: Assets.iconsAC,
|
||||||
|
name: 'ACs',
|
||||||
|
type: DeviceType.AC,
|
||||||
|
page: const ACsView(),
|
||||||
|
),
|
||||||
|
DevicesCategoryModel(
|
||||||
|
devices: [
|
||||||
|
LightModel(
|
||||||
|
name: "Living Room Light",
|
||||||
|
id: '0',
|
||||||
|
status: false,
|
||||||
|
color: 0,
|
||||||
|
brightness: 20,
|
||||||
|
lightingMode: 1,
|
||||||
|
timer: null,
|
||||||
|
type: '',
|
||||||
|
image: '',
|
||||||
|
recentColors: [
|
||||||
|
0xFF83D9FF,
|
||||||
|
0xFFFC3E81,
|
||||||
|
0xFFC0FF66,
|
||||||
|
0xFFFDC242,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
icon: Assets.iconsLight,
|
||||||
|
name: 'Lights',
|
||||||
|
type: DeviceType.Lights,
|
||||||
|
page: const LightsView(),
|
||||||
|
),
|
||||||
|
DevicesCategoryModel(
|
||||||
|
devices: [],
|
||||||
|
icon: Assets.iconsDoorLock,
|
||||||
|
name: 'Doors',
|
||||||
|
type: DeviceType.Door,
|
||||||
|
page: const DoorView(),
|
||||||
|
),
|
||||||
|
DevicesCategoryModel(
|
||||||
|
devices: [
|
||||||
|
CurtainModel(
|
||||||
|
openPercentage: 10,
|
||||||
|
id: "1",
|
||||||
|
name: "Living Room Curtain",
|
||||||
|
status: false,
|
||||||
|
type: '',
|
||||||
|
image: '',
|
||||||
|
timer: null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
icon: Assets.iconsCurtain,
|
||||||
|
name: 'Curtains',
|
||||||
|
type: DeviceType.Curtain,
|
||||||
|
page: const CurtainView(),
|
||||||
|
),
|
||||||
|
DevicesCategoryModel(
|
||||||
|
devices: [],
|
||||||
|
icon: Assets.iconsScreen,
|
||||||
|
name: 'Gateway',
|
||||||
|
type: DeviceType.Gateway,
|
||||||
|
page: const GateWayView(),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
RoomModel(id: '1', name: 'Bedroom', categories: []),
|
||||||
|
];
|
||||||
|
|
||||||
|
SpaceModel selectedSpace = spaces.first;
|
||||||
|
|
||||||
|
selectSpace(SpaceModel space) {
|
||||||
|
selectedSpace = space;
|
||||||
|
emit(SpacesSelected(space));
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO implement the methods to fetch the spaces from the API
|
||||||
|
}
|
19
lib/features/app_layout/bloc/spaces_state.dart
Normal file
19
lib/features/app_layout/bloc/spaces_state.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
part of 'spaces_cubit.dart';
|
||||||
|
|
||||||
|
abstract class SpacesState {}
|
||||||
|
|
||||||
|
class SpacesInitial extends SpacesState {}
|
||||||
|
|
||||||
|
class SpacesLoading extends SpacesState {}
|
||||||
|
|
||||||
|
class SpacesLoaded extends SpacesState {
|
||||||
|
final List<SpaceModel> spaces;
|
||||||
|
|
||||||
|
SpacesLoaded(this.spaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
class SpacesSelected extends SpacesState {
|
||||||
|
final SpaceModel space;
|
||||||
|
|
||||||
|
SpacesSelected(this.space);
|
||||||
|
}
|
29
lib/features/app_layout/model/space_model.dart
Normal file
29
lib/features/app_layout/model/space_model.dart
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
||||||
|
|
||||||
|
class SpaceModel {
|
||||||
|
final String id;
|
||||||
|
final String name;
|
||||||
|
final List<RoomModel> rooms;
|
||||||
|
|
||||||
|
SpaceModel({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.rooms,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'name': name,
|
||||||
|
'rooms': rooms,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory SpaceModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return SpaceModel(
|
||||||
|
id: json['id'],
|
||||||
|
name: json['name'],
|
||||||
|
rooms: json['rooms'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,12 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
|
import 'package:syncrow_app/utils/context_extension.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
import '../../../../generated/assets.dart';
|
import '../../../../generated/assets.dart';
|
||||||
import '../../../shared_widgets/text_widgets/body_large.dart';
|
|
||||||
|
|
||||||
class AppBarHomeDropdown extends StatelessWidget {
|
class AppBarHomeDropdown extends StatelessWidget {
|
||||||
const AppBarHomeDropdown({
|
const AppBarHomeDropdown({
|
||||||
@ -12,13 +15,26 @@ class AppBarHomeDropdown extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TextButton(
|
return BlocBuilder<SpacesCubit, SpacesState>(
|
||||||
onPressed: () {},
|
builder: (context, state) {
|
||||||
|
return DropdownButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.expand_more,
|
||||||
|
color: Colors.black,
|
||||||
|
size: 25,
|
||||||
|
),
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
value: SpacesCubit.get(context).selectedSpace,
|
||||||
|
items: SpacesCubit.spaces.map((space) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: space,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 150,
|
width: 100,
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
Assets.iconsHome,
|
Assets.iconsHome,
|
||||||
@ -30,15 +46,26 @@ class AppBarHomeDropdown extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
const BodyLarge(text: 'Home'),
|
Expanded(
|
||||||
const SizedBox(width: 5),
|
child: BodyMedium(
|
||||||
const Icon(
|
text: space.name,
|
||||||
Icons.expand_more,
|
style: context.bodyMedium.copyWith(
|
||||||
color: Colors.black,
|
fontSize: 15,
|
||||||
)
|
color: ColorsManager.textPrimaryColor,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (value) {
|
||||||
|
SpacesCubit.get(context).selectSpace(value!);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class AcCubit extends Cubit<AcState> {
|
|||||||
|
|
||||||
static AcCubit get(context) => BlocProvider.of(context);
|
static AcCubit get(context) => BlocProvider.of(context);
|
||||||
|
|
||||||
static DevicesCategoryModel category = DevicesCubit.categories[0];
|
static DevicesCategoryModel category = DevicesCubit.allCategories[0];
|
||||||
|
|
||||||
ACModel? getSelectedAC() {
|
ACModel? getSelectedAC() {
|
||||||
for (var ac in category.devices) {
|
for (var ac in category.devices) {
|
||||||
|
@ -9,5 +9,5 @@ class CurtainsCubit extends Cubit<CurtainsState> {
|
|||||||
|
|
||||||
static CurtainsCubit get(context) => BlocProvider.of(context);
|
static CurtainsCubit get(context) => BlocProvider.of(context);
|
||||||
|
|
||||||
static DevicesCategoryModel category = DevicesCubit.categories[4];
|
static DevicesCategoryModel category = DevicesCubit.allCategories[3];
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
import 'package:syncrow_app/features/devices/model/ac_model.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/model/curtain_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
import 'package:syncrow_app/features/devices/model/light_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/curtains/curtain_view.dart';
|
||||||
@ -20,7 +21,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
|
|
||||||
static DevicesCubit get(context) => BlocProvider.of(context);
|
static DevicesCubit get(context) => BlocProvider.of(context);
|
||||||
|
|
||||||
static List<DevicesCategoryModel> categories = [
|
static List<DevicesCategoryModel> allCategories = [
|
||||||
DevicesCategoryModel(
|
DevicesCategoryModel(
|
||||||
devices: [
|
devices: [
|
||||||
ACModel(
|
ACModel(
|
||||||
@ -32,7 +33,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
tempMode: 0,
|
tempMode: 0,
|
||||||
coolTo: 20,
|
coolTo: 20,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
timer: null,
|
timer: null,
|
||||||
bounds: Bounds(
|
bounds: Bounds(
|
||||||
@ -49,7 +49,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
tempMode: 0,
|
tempMode: 0,
|
||||||
coolTo: 20,
|
coolTo: 20,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
timer: null,
|
timer: null,
|
||||||
bounds: Bounds(
|
bounds: Bounds(
|
||||||
@ -66,7 +65,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
tempMode: 0,
|
tempMode: 0,
|
||||||
coolTo: 20,
|
coolTo: 20,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
timer: null,
|
timer: null,
|
||||||
bounds: Bounds(
|
bounds: Bounds(
|
||||||
@ -83,7 +81,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
tempMode: 0,
|
tempMode: 0,
|
||||||
coolTo: 20,
|
coolTo: 20,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
timer: null,
|
timer: null,
|
||||||
bounds: Bounds(
|
bounds: Bounds(
|
||||||
@ -108,7 +105,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
lightingMode: 1,
|
lightingMode: 1,
|
||||||
timer: null,
|
timer: null,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
recentColors: [
|
recentColors: [
|
||||||
0xFF83D9FF,
|
0xFF83D9FF,
|
||||||
@ -126,7 +122,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
lightingMode: 1,
|
lightingMode: 1,
|
||||||
timer: null,
|
timer: null,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
recentColors: [
|
recentColors: [
|
||||||
0xFF83D9FF,
|
0xFF83D9FF,
|
||||||
@ -144,7 +139,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
lightingMode: 1,
|
lightingMode: 1,
|
||||||
timer: null,
|
timer: null,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
recentColors: [
|
recentColors: [
|
||||||
0xFF83D9FF,
|
0xFF83D9FF,
|
||||||
@ -162,7 +156,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
lightingMode: 1,
|
lightingMode: 1,
|
||||||
timer: null,
|
timer: null,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
recentColors: [
|
recentColors: [
|
||||||
0xFF83D9FF,
|
0xFF83D9FF,
|
||||||
@ -180,7 +173,6 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
lightingMode: 1,
|
lightingMode: 1,
|
||||||
timer: null,
|
timer: null,
|
||||||
type: '',
|
type: '',
|
||||||
location: '',
|
|
||||||
image: '',
|
image: '',
|
||||||
recentColors: [
|
recentColors: [
|
||||||
0xFF83D9FF,
|
0xFF83D9FF,
|
||||||
@ -203,7 +195,26 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
page: const DoorView(),
|
page: const DoorView(),
|
||||||
),
|
),
|
||||||
DevicesCategoryModel(
|
DevicesCategoryModel(
|
||||||
devices: [],
|
devices: [
|
||||||
|
CurtainModel(
|
||||||
|
openPercentage: 10,
|
||||||
|
id: "1",
|
||||||
|
name: "Living Room Curtain",
|
||||||
|
status: false,
|
||||||
|
type: '',
|
||||||
|
image: '',
|
||||||
|
timer: null,
|
||||||
|
),
|
||||||
|
CurtainModel(
|
||||||
|
openPercentage: 20,
|
||||||
|
id: "2",
|
||||||
|
name: "Master Bedroom Curtain",
|
||||||
|
status: false,
|
||||||
|
type: '',
|
||||||
|
image: '',
|
||||||
|
timer: null,
|
||||||
|
),
|
||||||
|
],
|
||||||
icon: Assets.iconsCurtain,
|
icon: Assets.iconsCurtain,
|
||||||
name: 'Curtains',
|
name: 'Curtains',
|
||||||
type: DeviceType.Curtain,
|
type: DeviceType.Curtain,
|
||||||
@ -226,25 +237,25 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
selectCategory(int index) {
|
selectCategory(int index) {
|
||||||
for (var i = 0; i < categories.length; i++) {
|
for (var i = 0; i < allCategories.length; i++) {
|
||||||
if (i == index) {
|
if (i == index) {
|
||||||
categories[i].isSelected = true;
|
allCategories[i].isSelected = true;
|
||||||
} else {
|
} else {
|
||||||
categories[i].isSelected = false;
|
allCategories[i].isSelected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit(DevicesCategoryChanged());
|
emit(DevicesCategoryChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
unselectAllCategories() {
|
unselectAllCategories() {
|
||||||
for (var category in categories) {
|
for (var category in allCategories) {
|
||||||
category.isSelected = false;
|
category.isSelected = false;
|
||||||
}
|
}
|
||||||
emit(DevicesCategoryChanged());
|
emit(DevicesCategoryChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget? get chosenCategoryView {
|
Widget? get chosenCategoryView {
|
||||||
for (var category in categories) {
|
for (var category in allCategories) {
|
||||||
if (category.isSelected) {
|
if (category.isSelected) {
|
||||||
return category.page;
|
return category.page;
|
||||||
}
|
}
|
||||||
@ -253,7 +264,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectDevice(DeviceModel device) {
|
selectDevice(DeviceModel device) {
|
||||||
for (var category in categories) {
|
for (var category in allCategories) {
|
||||||
for (var device in category.devices) {
|
for (var device in category.devices) {
|
||||||
if (device.isSelected) {
|
if (device.isSelected) {
|
||||||
category.isSelected = false;
|
category.isSelected = false;
|
||||||
@ -267,7 +278,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeviceModel? getSelectedDevice() {
|
DeviceModel? getSelectedDevice() {
|
||||||
for (var category in categories) {
|
for (var category in allCategories) {
|
||||||
for (var device in category.devices) {
|
for (var device in category.devices) {
|
||||||
if (device.isSelected) {
|
if (device.isSelected) {
|
||||||
return device;
|
return device;
|
||||||
@ -296,8 +307,8 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
|
|
||||||
turnOnOffDevice(DeviceModel device) {
|
turnOnOffDevice(DeviceModel device) {
|
||||||
device.status = !device.status!;
|
device.status = !device.status!;
|
||||||
DevicesCategoryModel category =
|
DevicesCategoryModel category = allCategories
|
||||||
categories.firstWhere((category) => category.devices.contains(device));
|
.firstWhere((category) => category.devices.contains(device));
|
||||||
updateDevicesStatus(category);
|
updateDevicesStatus(category);
|
||||||
emit(DeviceSwitchChanged());
|
emit(DeviceSwitchChanged());
|
||||||
}
|
}
|
||||||
@ -354,7 +365,7 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearCategoriesSelection(BuildContext context) {
|
clearCategoriesSelection(BuildContext context) {
|
||||||
for (var category in categories) {
|
for (var category in allCategories) {
|
||||||
category.isSelected = false;
|
category.isSelected = false;
|
||||||
for (var device in category.devices) {
|
for (var device in category.devices) {
|
||||||
device.isSelected = false;
|
device.isSelected = false;
|
||||||
|
@ -21,7 +21,6 @@ class ACModel extends DeviceModel {
|
|||||||
required super.name,
|
required super.name,
|
||||||
required super.type,
|
required super.type,
|
||||||
required super.status,
|
required super.status,
|
||||||
required super.location,
|
|
||||||
required super.image,
|
required super.image,
|
||||||
required super.timer,
|
required super.timer,
|
||||||
});
|
});
|
||||||
@ -36,7 +35,6 @@ class ACModel extends DeviceModel {
|
|||||||
'name': name,
|
'name': name,
|
||||||
'status': status,
|
'status': status,
|
||||||
'type': type,
|
'type': type,
|
||||||
'location': location,
|
|
||||||
'image': image,
|
'image': image,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -50,7 +48,6 @@ class ACModel extends DeviceModel {
|
|||||||
fanSpeed: json['fanSpeed'],
|
fanSpeed: json['fanSpeed'],
|
||||||
tempMode: json['tempMode'],
|
tempMode: json['tempMode'],
|
||||||
type: json['type'],
|
type: json['type'],
|
||||||
location: json['location'],
|
|
||||||
image: json['image'],
|
image: json['image'],
|
||||||
timer: json['timer'],
|
timer: json['timer'],
|
||||||
coolTo: json['coolTo'],
|
coolTo: json['coolTo'],
|
||||||
|
@ -9,7 +9,6 @@ class CurtainModel extends DeviceModel {
|
|||||||
required super.name,
|
required super.name,
|
||||||
required super.type,
|
required super.type,
|
||||||
required super.status,
|
required super.status,
|
||||||
required super.location,
|
|
||||||
required super.image,
|
required super.image,
|
||||||
required super.timer,
|
required super.timer,
|
||||||
});
|
});
|
||||||
@ -22,7 +21,6 @@ class CurtainModel extends DeviceModel {
|
|||||||
'name': name,
|
'name': name,
|
||||||
'status': status,
|
'status': status,
|
||||||
'type': type,
|
'type': type,
|
||||||
'location': location,
|
|
||||||
'image': image,
|
'image': image,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -35,7 +33,6 @@ class CurtainModel extends DeviceModel {
|
|||||||
openPercentage: json['openPercentage'],
|
openPercentage: json['openPercentage'],
|
||||||
timer: json['timer'],
|
timer: json['timer'],
|
||||||
type: json['type'],
|
type: json['type'],
|
||||||
location: json['location'],
|
|
||||||
image: json['image'],
|
image: json['image'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ abstract class DeviceModel {
|
|||||||
final String? name;
|
final String? name;
|
||||||
final String? type;
|
final String? type;
|
||||||
bool? status;
|
bool? status;
|
||||||
final String? location;
|
|
||||||
final String? image;
|
final String? image;
|
||||||
final double? timer;
|
final double? timer;
|
||||||
bool isSelected = false;
|
bool isSelected = false;
|
||||||
@ -13,7 +12,6 @@ abstract class DeviceModel {
|
|||||||
required this.name,
|
required this.name,
|
||||||
required this.type,
|
required this.type,
|
||||||
required this.status,
|
required this.status,
|
||||||
required this.location,
|
|
||||||
required this.image,
|
required this.image,
|
||||||
required this.timer,
|
required this.timer,
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,6 @@ class LightModel extends DeviceModel {
|
|||||||
required super.name,
|
required super.name,
|
||||||
required super.type,
|
required super.type,
|
||||||
required super.status,
|
required super.status,
|
||||||
required super.location,
|
|
||||||
required super.image,
|
required super.image,
|
||||||
required super.timer,
|
required super.timer,
|
||||||
});
|
});
|
||||||
@ -33,7 +32,6 @@ class LightModel extends DeviceModel {
|
|||||||
'name': name,
|
'name': name,
|
||||||
'status': status,
|
'status': status,
|
||||||
'type': type,
|
'type': type,
|
||||||
'location': location,
|
|
||||||
'image': image,
|
'image': image,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -48,7 +46,6 @@ class LightModel extends DeviceModel {
|
|||||||
lightingMode: json['lightingMode'],
|
lightingMode: json['lightingMode'],
|
||||||
timer: json['timer'],
|
timer: json['timer'],
|
||||||
type: json['type'],
|
type: json['type'],
|
||||||
location: json['location'],
|
|
||||||
image: json['image'],
|
image: json['image'],
|
||||||
recentColors: json['recentColors'],
|
recentColors: json['recentColors'],
|
||||||
);
|
);
|
||||||
|
30
lib/features/devices/model/room_model.dart
Normal file
30
lib/features/devices/model/room_model.dart
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||||
|
|
||||||
|
class RoomModel {
|
||||||
|
final String id;
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
final List<DevicesCategoryModel> categories;
|
||||||
|
|
||||||
|
RoomModel({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.categories,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return {
|
||||||
|
'id': id,
|
||||||
|
'name': name,
|
||||||
|
'devices': categories,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
factory RoomModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RoomModel(
|
||||||
|
id: json['id'],
|
||||||
|
name: json['name'],
|
||||||
|
categories: json['devices'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -36,40 +36,19 @@ class CurtainList extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
itemCount: CurtainsCubit.category.devices.length,
|
itemCount: CurtainsCubit.category.devices.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
CurtainModel ac =
|
CurtainModel curtain =
|
||||||
CurtainsCubit.category.devices[index] as CurtainModel;
|
CurtainsCubit.category.devices[index] as CurtainModel;
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
const SizedBox(height: 20),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
BodySmall(
|
BodySmall(
|
||||||
text:
|
text:
|
||||||
CurtainsCubit.category.devices[index].name ??
|
CurtainsCubit.category.devices[index].name ?? ""),
|
||||||
""),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
DevicesCubit.get(context).selectDevice(ac);
|
|
||||||
},
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.arrow_forward_ios,
|
|
||||||
),
|
|
||||||
style: ButtonStyle(
|
|
||||||
padding: MaterialStateProperty.all(
|
|
||||||
const EdgeInsets.all(0),
|
|
||||||
),
|
|
||||||
iconSize: MaterialStateProperty.all(15),
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 5),
|
||||||
if (CurtainsCubit.category.devices[index] is CurtainModel)
|
if (CurtainsCubit.category.devices[index] is CurtainModel)
|
||||||
DevicesDefaultSwitch(
|
DevicesDefaultSwitch(
|
||||||
model: ac,
|
model: curtain,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/devices_categories_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/wizard_page.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
child: PageView(
|
child: PageView(
|
||||||
controller: pageController,
|
controller: pageController,
|
||||||
children: const [
|
children: const [
|
||||||
DevicesCategoriesView(),
|
WizardPage(),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: Constants.defaultPadding),
|
horizontal: Constants.defaultPadding),
|
||||||
|
@ -28,7 +28,7 @@ class LightsView extends StatelessWidget {
|
|||||||
DevicesCubit.get(context).getSelectedDevice() as LightModel;
|
DevicesCubit.get(context).getSelectedDevice() as LightModel;
|
||||||
}
|
}
|
||||||
List<LightModel> lights = [];
|
List<LightModel> lights = [];
|
||||||
for (var device in DevicesCubit.categories[1].devices) {
|
for (var device in DevicesCubit.allCategories[1].devices) {
|
||||||
if (device is LightModel) {
|
if (device is LightModel) {
|
||||||
lights.add(device);
|
lights.add(device);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class LightsViewList extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const BodySmall(text: "All Lights"),
|
const BodySmall(text: "All Lights"),
|
||||||
UniversalSwitch(
|
UniversalSwitch(
|
||||||
category: DevicesCubit.categories[1],
|
category: DevicesCubit.allCategories[1],
|
||||||
),
|
),
|
||||||
LightsList(lights: lights),
|
LightsList(lights: lights),
|
||||||
],
|
],
|
||||||
|
@ -28,7 +28,7 @@ class Switches extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(top: 10),
|
padding: const EdgeInsets.only(top: 10),
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemCount: DevicesCubit.categories.length,
|
itemCount: DevicesCubit.allCategories.length,
|
||||||
itemBuilder: (_, index) {
|
itemBuilder: (_, index) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -51,11 +51,11 @@ class Switches extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
DevicesCubit.categories[index].icon,
|
DevicesCubit.allCategories[index].icon,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
),
|
),
|
||||||
CustomSwitch(
|
CustomSwitch(
|
||||||
category: DevicesCubit.categories[index],
|
category: DevicesCubit.allCategories[index],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -63,7 +63,7 @@ class Switches extends StatelessWidget {
|
|||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: BodyLarge(
|
child: BodyLarge(
|
||||||
text: DevicesCubit.categories[index].name,
|
text: DevicesCubit.allCategories[index].name,
|
||||||
style: context.bodyLarge.copyWith(
|
style: context.bodyLarge.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
height: 0,
|
height: 0,
|
||||||
|
@ -7,8 +7,8 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.da
|
|||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/strings_manager.dart';
|
||||||
|
|
||||||
class DevicesCategoriesView extends StatelessWidget {
|
class WizardPage extends StatelessWidget {
|
||||||
const DevicesCategoriesView({
|
const WizardPage({
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_app/features/app_layout/bloc/nav_cubit.dart';
|
import 'package:syncrow_app/features/app_layout/bloc/nav_cubit.dart';
|
||||||
|
import 'package:syncrow_app/features/app_layout/bloc/spaces_cubit.dart';
|
||||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
@ -29,6 +30,9 @@ class MyApp extends StatelessWidget {
|
|||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => NavCubit(),
|
create: (context) => NavCubit(),
|
||||||
),
|
),
|
||||||
|
BlocProvider(
|
||||||
|
create: (context) => SpacesCubit(),
|
||||||
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) => DevicesCubit(),
|
create: (context) => DevicesCubit(),
|
||||||
),
|
),
|
||||||
|
@ -140,6 +140,38 @@ abstract class ThemeManager {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
|
dropdownMenuTheme: const DropdownMenuThemeData(
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontFamily: FontsManager.fontFamily,
|
||||||
|
fontSize: FontSize.s16,
|
||||||
|
fontWeight: FontsManager.regular,
|
||||||
|
color: ColorsManager.textPrimaryColor,
|
||||||
|
),
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: Colors.grey),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderSide: BorderSide(color: ColorsManager.primaryColor),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||||
|
),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
fontFamily: FontsManager.fontFamily,
|
||||||
|
color: Colors.grey,
|
||||||
|
fontSize: FontSize.s16,
|
||||||
|
fontWeight: FontsManager.regular,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
menuStyle: MenuStyle(
|
||||||
|
backgroundColor: MaterialStatePropertyAll(Colors.white),
|
||||||
|
padding: MaterialStatePropertyAll(EdgeInsets.all(8)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
///input decoration theme
|
///input decoration theme
|
||||||
inputDecorationTheme: const InputDecorationTheme(
|
inputDecorationTheme: const InputDecorationTheme(
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
|
48
pubspec.lock
48
pubspec.lock
@ -389,30 +389,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.7"
|
version: "0.6.7"
|
||||||
leak_tracker:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: leak_tracker
|
|
||||||
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "10.0.0"
|
|
||||||
leak_tracker_flutter_testing:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: leak_tracker_flutter_testing
|
|
||||||
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.1"
|
|
||||||
leak_tracker_testing:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: leak_tracker_testing
|
|
||||||
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.1"
|
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -425,26 +401,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.16+1"
|
version: "0.12.16"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.8.0"
|
version: "0.5.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.0"
|
version: "1.10.0"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -465,10 +441,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.8.3"
|
||||||
path_parsing:
|
path_parsing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -834,14 +810,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
vm_service:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vm_service
|
|
||||||
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "13.0.0"
|
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
Reference in New Issue
Block a user