mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 07:49:40 +00:00
Add support for different device types in RoomPageSwitch
-Update the navigation approch to be device type orianted to the corresponding interface when tapped. -Add three gang switch interface and related components
This commit is contained in:
@ -12,7 +12,7 @@ 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/curtains/curtain_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/gateway/gateway_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/lights/lights_view.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_switches.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_view.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/smart_door/door_view.dart';
|
||||||
import 'package:syncrow_app/services/api/devices_api.dart';
|
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||||
import 'package:syncrow_app/services/api/network_exception.dart';
|
import 'package:syncrow_app/services/api/network_exception.dart';
|
||||||
@ -73,8 +73,8 @@ class DevicesCubit extends Cubit<DevicesState> {
|
|||||||
return const DoorView();
|
return const DoorView();
|
||||||
case DeviceType.Curtain:
|
case DeviceType.Curtain:
|
||||||
return const CurtainView();
|
return const CurtainView();
|
||||||
case DeviceType.ThreeGang:
|
// case DeviceType.ThreeGang:
|
||||||
return const ThreeGangSwitchesView();
|
// return const ThreeGangSwitchesView();
|
||||||
case DeviceType.Gateway:
|
case DeviceType.Gateway:
|
||||||
return const GateWayView();
|
return const GateWayView();
|
||||||
default:
|
default:
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
import 'dart:js_util';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.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/view/widgets/ACs/ac_interface.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/lights/light_interface.dart';
|
||||||
|
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/custom_switch.dart';
|
import 'package:syncrow_app/features/shared_widgets/custom_switch.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||||
@ -21,13 +25,53 @@ class RoomPageSwitch extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (device.productType == DeviceType.AC) {
|
// if (device.productType == DeviceType.AC) {
|
||||||
Navigator.push(
|
// Navigator.push(
|
||||||
context,
|
// context,
|
||||||
CustomPageRoute(
|
// CustomPageRoute(
|
||||||
builder: (context) => AcInterface(deviceModel: device),
|
// builder: (context) => AcInterface(deviceModel: device),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
|
// }
|
||||||
|
switch (device.productType) {
|
||||||
|
case DeviceType.AC:
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CustomPageRoute(
|
||||||
|
builder: (context) => AcInterface(deviceModel: device),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case DeviceType.WallSensor:
|
||||||
|
break;
|
||||||
|
case DeviceType.CeilingSensor:
|
||||||
|
break;
|
||||||
|
case DeviceType.Curtain:
|
||||||
|
break;
|
||||||
|
case DeviceType.Blind:
|
||||||
|
break;
|
||||||
|
case DeviceType.DoorLock:
|
||||||
|
break;
|
||||||
|
case DeviceType.Gateway:
|
||||||
|
break;
|
||||||
|
case DeviceType.LightBulb:
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CustomPageRoute(
|
||||||
|
builder: (context) => LightInterface(light: device),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
case DeviceType.ThreeGang:
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CustomPageRoute(
|
||||||
|
builder: (context) => ThreeGangInterface(
|
||||||
|
gangSwitch: device,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: DefaultContainer(
|
child: DefaultContainer(
|
||||||
|
@ -6,8 +6,8 @@ import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
|||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class ThreeGangSwitch extends StatelessWidget {
|
class GangSwitch extends StatelessWidget {
|
||||||
const ThreeGangSwitch({
|
const GangSwitch({
|
||||||
super.key,
|
super.key,
|
||||||
required this.control,
|
required this.control,
|
||||||
});
|
});
|
@ -5,14 +5,15 @@ import 'package:syncrow_app/features/app_layout/bloc/home_cubit.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/view/widgets/ACs/category_view_app_bar.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/ACs/category_view_app_bar.dart';
|
||||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_body.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface_body.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.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';
|
||||||
|
|
||||||
class ThreeGangSwitchesView extends StatelessWidget {
|
class ThreeGangInterface extends StatelessWidget {
|
||||||
const ThreeGangSwitchesView({super.key});
|
const ThreeGangInterface({super.key, required this.gangSwitch});
|
||||||
|
|
||||||
|
final DeviceModel gangSwitch;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AnnotatedRegion(
|
return AnnotatedRegion(
|
||||||
@ -47,8 +48,8 @@ class ThreeGangSwitchesView extends StatelessWidget {
|
|||||||
right: Constants.defaultPadding,
|
right: Constants.defaultPadding,
|
||||||
bottom: Constants.bottomNavBarHeight,
|
bottom: Constants.bottomNavBarHeight,
|
||||||
),
|
),
|
||||||
child: ThreeGangBody(
|
child: ThreeGangInterfaceBody(
|
||||||
device: DeviceModel(),
|
device: gangSwitch,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
@ -1,13 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_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/view/widgets/three_gang/three_gang_switch.dart';
|
import 'package:syncrow_app/features/devices/view/widgets/three_gang/gang_switch.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.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';
|
||||||
|
|
||||||
class ThreeGangBody extends StatelessWidget {
|
class ThreeGangInterfaceBody extends StatelessWidget {
|
||||||
const ThreeGangBody({
|
const ThreeGangInterfaceBody({
|
||||||
super.key,
|
super.key,
|
||||||
required this.device,
|
required this.device,
|
||||||
});
|
});
|
||||||
@ -27,7 +27,7 @@ class ThreeGangBody extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
ThreeGangSwitch(
|
GangSwitch(
|
||||||
control: DeviceControlModel(
|
control: DeviceControlModel(
|
||||||
deviceId: 'bfe10693d4fd263206ocq9',
|
deviceId: 'bfe10693d4fd263206ocq9',
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
@ -47,7 +47,7 @@ class ThreeGangBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
ThreeGangSwitch(
|
GangSwitch(
|
||||||
control: DeviceControlModel(
|
control: DeviceControlModel(
|
||||||
deviceId: 'bfe10693d4fd263206ocq9',
|
deviceId: 'bfe10693d4fd263206ocq9',
|
||||||
code: 'switch_2',
|
code: 'switch_2',
|
||||||
@ -67,7 +67,7 @@ class ThreeGangBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
ThreeGangSwitch(
|
GangSwitch(
|
||||||
control: DeviceControlModel(
|
control: DeviceControlModel(
|
||||||
deviceId: 'bfe10693d4fd263206ocq9',
|
deviceId: 'bfe10693d4fd263206ocq9',
|
||||||
code: 'switch_3',
|
code: 'switch_3',
|
Reference in New Issue
Block a user