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/gateway/gateway_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/services/api/devices_api.dart';
|
||||
import 'package:syncrow_app/services/api/network_exception.dart';
|
||||
@ -73,8 +73,8 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
return const DoorView();
|
||||
case DeviceType.Curtain:
|
||||
return const CurtainView();
|
||||
case DeviceType.ThreeGang:
|
||||
return const ThreeGangSwitchesView();
|
||||
// case DeviceType.ThreeGang:
|
||||
// return const ThreeGangSwitchesView();
|
||||
case DeviceType.Gateway:
|
||||
return const GateWayView();
|
||||
default:
|
||||
|
@ -1,7 +1,11 @@
|
||||
import 'dart:js_util';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.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/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/default_container.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) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (device.productType == DeviceType.AC) {
|
||||
Navigator.push(
|
||||
context,
|
||||
CustomPageRoute(
|
||||
builder: (context) => AcInterface(deviceModel: device),
|
||||
),
|
||||
);
|
||||
// if (device.productType == DeviceType.AC) {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// CustomPageRoute(
|
||||
// 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(
|
||||
|
@ -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/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class ThreeGangSwitch extends StatelessWidget {
|
||||
const ThreeGangSwitch({
|
||||
class GangSwitch extends StatelessWidget {
|
||||
const GangSwitch({
|
||||
super.key,
|
||||
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/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/utils/resource_manager/color_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class ThreeGangSwitchesView extends StatelessWidget {
|
||||
const ThreeGangSwitchesView({super.key});
|
||||
class ThreeGangInterface extends StatelessWidget {
|
||||
const ThreeGangInterface({super.key, required this.gangSwitch});
|
||||
|
||||
final DeviceModel gangSwitch;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnnotatedRegion(
|
||||
@ -47,8 +48,8 @@ class ThreeGangSwitchesView extends StatelessWidget {
|
||||
right: Constants.defaultPadding,
|
||||
bottom: Constants.bottomNavBarHeight,
|
||||
),
|
||||
child: ThreeGangBody(
|
||||
device: DeviceModel(),
|
||||
child: ThreeGangInterfaceBody(
|
||||
device: gangSwitch,
|
||||
),
|
||||
),
|
||||
);
|
@ -1,13 +1,13 @@
|
||||
import 'package:flutter/material.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/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/utils/context_extension.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class ThreeGangBody extends StatelessWidget {
|
||||
const ThreeGangBody({
|
||||
class ThreeGangInterfaceBody extends StatelessWidget {
|
||||
const ThreeGangInterfaceBody({
|
||||
super.key,
|
||||
required this.device,
|
||||
});
|
||||
@ -27,7 +27,7 @@ class ThreeGangBody extends StatelessWidget {
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
ThreeGangSwitch(
|
||||
GangSwitch(
|
||||
control: DeviceControlModel(
|
||||
deviceId: 'bfe10693d4fd263206ocq9',
|
||||
code: 'switch_1',
|
||||
@ -47,7 +47,7 @@ class ThreeGangBody extends StatelessWidget {
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
ThreeGangSwitch(
|
||||
GangSwitch(
|
||||
control: DeviceControlModel(
|
||||
deviceId: 'bfe10693d4fd263206ocq9',
|
||||
code: 'switch_2',
|
||||
@ -67,7 +67,7 @@ class ThreeGangBody extends StatelessWidget {
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
ThreeGangSwitch(
|
||||
GangSwitch(
|
||||
control: DeviceControlModel(
|
||||
deviceId: 'bfe10693d4fd263206ocq9',
|
||||
code: 'switch_3',
|
Reference in New Issue
Block a user