diff --git a/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart b/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart index 6f11773..b1d860a 100644 --- a/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart +++ b/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart @@ -725,7 +725,6 @@ class ThreeTouchBloc extends Bloc { 'Restart Memory': 'last', }, }; - final selectedControl = controlMap[optionSelected]?[statusSelected]; if (selectedControl != null) { await DevicesAPI.controlDevice( diff --git a/lib/features/devices/view/widgets/three_touch/three_touch_screen.dart b/lib/features/devices/view/widgets/three_touch/three_touch_screen.dart index 82d2b4e..3f57f89 100644 --- a/lib/features/devices/view/widgets/three_touch/three_touch_screen.dart +++ b/lib/features/devices/view/widgets/three_touch/three_touch_screen.dart @@ -9,8 +9,7 @@ import 'package:syncrow_app/features/devices/model/three_touch_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/circular_button.dart'; import 'package:syncrow_app/features/devices/view/widgets/three_gang/gang_switch.dart'; import 'package:syncrow_app/features/devices/view/widgets/three_touch/schedule_screen.dart'; -import 'package:syncrow_app/features/devices/view/widgets/three_touch/two_touch_setting.dart'; -import 'package:syncrow_app/features/devices/view/widgets/two_touch/two_touch_setting.dart'; +import 'package:syncrow_app/features/devices/view/widgets/three_touch/three_touch_setting.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart'; import 'package:syncrow_app/utils/resource_manager/color_manager.dart'; @@ -86,13 +85,6 @@ class ThreeTouchScreen extends StatelessWidget { value: threeTouchModel .firstSwitch)); }, - // control: DeviceControlModel( - // deviceId: device.uuid, - // // code: 'switch_1', - // code: device.status[0].code, - // // value: true, - // value: device.status[0].value, - // ), ), const SizedBox(height: 20), const SizedBox( @@ -112,21 +104,11 @@ class ThreeTouchScreen extends StatelessWidget { threeGangSwitch: device!, value: threeTouchModel.secondSwitch, action: () { - BlocProvider.of( - context) - .add( + BlocProvider.of( context) .add( ChangeSecondSwitchStatusEvent( value: threeTouchModel .secondSwitch)); }, - // control: DeviceControlModel( - // // deviceId: 'bfe10693d4fd263206ocq9', - // // code: 'switch_2', - // // value: true, - // deviceId: device.uuid, - // code: device.status[1].code, - // value: device.status[1].value, - // ), ), const SizedBox(height: 20), const SizedBox( @@ -182,98 +164,9 @@ class ThreeTouchScreen extends StatelessWidget { .add(AllOnEvent()); }, ), - // Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Card( - // elevation: 3, - // shape: RoundedRectangleBorder( - // borderRadius: - // BorderRadius.circular(100), - // ), - // child: GestureDetector( - // onTap: () { - // // DevicesCubit.getInstance().deviceControl( - // // DeviceControlModel( - // // deviceId: device.uuid, - // // code: 'switch_1', - // // value: true, - // // ), - // // device.uuid!, - // // ); - // // DevicesCubit.getInstance().deviceControl( - // // DeviceControlModel( - // // deviceId: device.uuid, - // // code: 'switch_2', - // // value: true, - // // ), - // // device.uuid!, - // // ); - // // DevicesCubit.getInstance().deviceControl( - // // DeviceControlModel( - // // deviceId: device.uuid, - // // code: 'switch_3', - // // value: true, - // // ), - // // device.uuid!, - // // ); - // BlocProvider.of( - // context) - // .add(AllOnEvent()); - // }, - // child: Stack( - // alignment: Alignment.center, - // children: [ - // Container( - // width: 60, - // height: 60, - // decoration: BoxDecoration( - // color: Colors.grey[300], - // borderRadius: - // BorderRadius.circular( - // 100), - // ), - // ), - // Container( - // width: 40, - // height: 40, - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: - // BorderRadius.circular( - // 100), - // ), - // child: Center( - // child: BodySmall( - // text: "On", - // style: context.bodyMedium - // .copyWith( - // color: ColorsManager - // .primaryColorWithOpacity, - // fontWeight: - // FontWeight - // .bold), - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // const SizedBox(height: 10), - // BodySmall( - // text: "All On", - // style: context.bodyMedium.copyWith( - // color: ColorsManager.textPrimaryColor, - // ), - // ), - // ], - // ), - const SizedBox( width: 20, ), - CircularButton( device: device, icons: Icons.access_time, @@ -289,7 +182,6 @@ class ThreeTouchScreen extends StatelessWidget { ))); }, ), - const SizedBox( width: 20, ), @@ -308,75 +200,9 @@ class ThreeTouchScreen extends StatelessWidget { ))); }, ), - // Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Card( - // elevation: 3, - // shape: RoundedRectangleBorder( - // borderRadius: - // BorderRadius.circular(100), - // ), - // child: GestureDetector( - // onTap: () { - // Navigator.push( - // context, - // PageRouteBuilder( - // pageBuilder: (context, - // animation1, - // animation2) => - // ScheduleScreen( - // device: device!, - // ))); - // }, - // child: Stack( - // alignment: Alignment.center, - // children: [ - // Container( - // width: 60, - // height: 60, - // decoration: BoxDecoration( - // color: Colors.grey[300], - // borderRadius: - // BorderRadius.circular( - // 100), - // ), - // ), - // Container( - // width: 40, - // height: 40, - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: - // BorderRadius.circular( - // 100), - // ), - // child: Center( - // child: Icon( - // Icons.access_time, - // color: ColorsManager - // .primaryColorWithOpacity, - // size: 25, - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // const SizedBox(height: 10), - // BodySmall( - // text: "Timer", - // style: context.bodyMedium.copyWith( - // color: ColorsManager.textPrimaryColor, - // ), - // ), - // ], - // ), const SizedBox( width: 20, ), - CircularButton( device: device, icons: Icons.u_turn_left, @@ -386,93 +212,6 @@ class ThreeTouchScreen extends StatelessWidget { .add(AllOffEvent()); }, ), - // Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Card( - // elevation: 3, - // shape: RoundedRectangleBorder( - // borderRadius: - // BorderRadius.circular(100), - // ), - // child: GestureDetector( - // onTap: () { - // // DevicesCubit.getInstance().deviceControl( - // // DeviceControlModel( - // // deviceId: device.uuid, - // // code: 'switch_1', - // // value: false, - // // ), - // // device.uuid!, - // // ); - // // DevicesCubit.getInstance().deviceControl( - // // DeviceControlModel( - // // deviceId: device.uuid, - // // code: 'switch_2', - // // value: false, - // // ), - // // device.uuid!, - // // ); - // // DevicesCubit.getInstance().deviceControl( - // // DeviceControlModel( - // // deviceId: device.uuid, - // // code: 'switch_3', - // // value: false, - // // ), - // // device.uuid!, - // // ); - // BlocProvider.of( - // context) - // .add(AllOffEvent()); - // }, - // child: Stack( - // alignment: Alignment.center, - // children: [ - // Container( - // width: 60, - // height: 60, - // decoration: BoxDecoration( - // color: Colors.grey[300], - // borderRadius: - // BorderRadius.circular( - // 100), - // ), - // ), - // Container( - // width: 40, - // height: 40, - // decoration: BoxDecoration( - // color: Colors.white, - // borderRadius: - // BorderRadius.circular( - // 100), - // ), - // child: Center( - // child: BodySmall( - // text: "Off", - // style: context.bodyMedium - // .copyWith( - // color: ColorsManager - // .primaryColorWithOpacity, - // fontWeight: - // FontWeight - // .bold), - // ), - // ), - // ), - // ], - // ), - // ), - // ), - // const SizedBox(height: 10), - // BodySmall( - // text: "All Off", - // style: context.bodyMedium.copyWith( - // color: ColorsManager.textPrimaryColor, - // ), - // ), - // ], - // ), ], ), ), diff --git a/lib/features/devices/view/widgets/three_touch/two_touch_setting.dart b/lib/features/devices/view/widgets/three_touch/three_touch_setting.dart similarity index 87% rename from lib/features/devices/view/widgets/three_touch/two_touch_setting.dart rename to lib/features/devices/view/widgets/three_touch/three_touch_setting.dart index aee4528..0b8eaf2 100644 --- a/lib/features/devices/view/widgets/three_touch/two_touch_setting.dart +++ b/lib/features/devices/view/widgets/three_touch/three_touch_setting.dart @@ -28,7 +28,7 @@ class ThreeTouchSetting extends StatelessWidget { ..add(const InitialEvent(groupScreen: false)), child: BlocBuilder( builder: (context, state) { - final twoTouchBloc = BlocProvider.of(context); + final threeTouchBloc = BlocProvider.of(context); ThreeTouchModel deviceStatus = ThreeTouchModel( firstSwitch: false, secondSwitch: false, @@ -63,7 +63,7 @@ class ThreeTouchSetting extends StatelessWidget { children: [ InkWell( onTap: () async { - twoTouchBloc.optionSelected = + threeTouchBloc.optionSelected = 'relay_status'; final result = await showDialog( context: context, @@ -75,9 +75,10 @@ class ThreeTouchSetting extends StatelessWidget { Navigator.of(context).pop(); }, confirmTab: () { - twoTouchBloc.add(ChangeStatusEvent( - deviceId: device!.uuid!, - context: context)); + threeTouchBloc.add( + ChangeStatusEvent( + deviceId: device!.uuid!, + context: context)); Navigator.of(context).pop(true); }, title: 'Restart Status', @@ -85,15 +86,15 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, ); @@ -144,7 +145,7 @@ class ThreeTouchSetting extends StatelessWidget { bottom: 10, top: 10), child: InkWell( onTap: () async { - twoTouchBloc.optionSelected = + threeTouchBloc.optionSelected = 'light_mode'; final result = await showDialog( context: context, @@ -156,7 +157,7 @@ class ThreeTouchSetting extends StatelessWidget { Navigator.of(context).pop(); }, confirmTab: () { - twoTouchBloc.add( + threeTouchBloc.add( ChangeStatusEvent( deviceId: device!.uuid!, context: context)); @@ -167,23 +168,23 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'On/Off Status', label3: 'Switch Position', onTapLabel1: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - // oneTouchBloc.add(const InitialEvent( - // groupScreen: false)); + threeTouchBloc.add(const InitialEvent( + groupScreen: false)); } }, child: SizedBox( @@ -200,7 +201,7 @@ class ThreeTouchSetting extends StatelessWidget { children: [ BodyMedium( fontSize: 13, - text: twoTouchBloc.deviceStatus + text: threeTouchBloc.deviceStatus .light_mode.value, fontColor: ColorsManager.textGray, ), @@ -222,7 +223,7 @@ class ThreeTouchSetting extends StatelessWidget { bottom: 10, top: 10), child: InkWell( onTap: () async { - twoTouchBloc.optionSelected = + threeTouchBloc.optionSelected = 'relay_status_1'; final result = await showDialog( context: context, @@ -234,7 +235,7 @@ class ThreeTouchSetting extends StatelessWidget { Navigator.of(context).pop(); }, confirmTab: () { - twoTouchBloc.add( + threeTouchBloc.add( ChangeStatusEvent( deviceId: device!.uuid!, context: context)); @@ -245,23 +246,23 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - // twoTouchBloc - // .add(const InitialEvent()); + threeTouchBloc.add(const InitialEvent( + groupScreen: false)); } }, child: Row( @@ -277,8 +278,10 @@ class ThreeTouchSetting extends StatelessWidget { children: [ BodyMedium( fontSize: 13, - text: twoTouchBloc.deviceStatus - .relay_status_1.value, + text: threeTouchBloc + .deviceStatus + .relay_status_1 + .value, fontColor: ColorsManager.textGray, ), @@ -299,7 +302,7 @@ class ThreeTouchSetting extends StatelessWidget { bottom: 10, top: 10), child: InkWell( onTap: () async { - twoTouchBloc.optionSelected = + threeTouchBloc.optionSelected = 'relay_status_2'; final result = await showDialog( context: context, @@ -311,7 +314,7 @@ class ThreeTouchSetting extends StatelessWidget { Navigator.of(context).pop(); }, confirmTab: () { - twoTouchBloc.add( + threeTouchBloc.add( ChangeStatusEvent( deviceId: device!.uuid!, context: context)); @@ -322,23 +325,23 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - // twoTouchBloc - // .add(const InitialEvent()); + threeTouchBloc.add(const InitialEvent( + groupScreen: false)); } }, child: Row( @@ -354,8 +357,10 @@ class ThreeTouchSetting extends StatelessWidget { children: [ BodyMedium( fontSize: 13, - text: twoTouchBloc.deviceStatus - .relay_status_1.value, + text: threeTouchBloc + .deviceStatus + .relay_status_2 + .value, fontColor: ColorsManager.textGray, ), @@ -376,19 +381,19 @@ class ThreeTouchSetting extends StatelessWidget { bottom: 10, top: 10), child: InkWell( onTap: () async { - twoTouchBloc.optionSelected = + threeTouchBloc.optionSelected = 'relay_status_3'; final result = await showDialog( context: context, builder: (context) { return RestartStatusDialog( initialSelectedLabel: deviceStatus - .relay_status_2.value, + .relay_status_3.value, cancelTab: () { Navigator.of(context).pop(); }, confirmTab: () { - twoTouchBloc.add( + threeTouchBloc.add( ChangeStatusEvent( deviceId: device!.uuid!, context: context)); @@ -399,23 +404,23 @@ class ThreeTouchSetting extends StatelessWidget { label2: 'Power On', label3: 'Restart Memory', onTapLabel1: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel2: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, onTapLabel3: (selected) { - twoTouchBloc.statusSelected = + threeTouchBloc.statusSelected = selected; }, ); }, ); if (result == true) { - // twoTouchBloc - // .add(const InitialEvent()); + threeTouchBloc.add(const InitialEvent( + groupScreen: false)); } }, child: Row( @@ -431,8 +436,10 @@ class ThreeTouchSetting extends StatelessWidget { children: [ BodyMedium( fontSize: 13, - text: twoTouchBloc.deviceStatus - .relay_status_1.value, + text: threeTouchBloc + .deviceStatus + .relay_status_1 + .value, fontColor: ColorsManager.textGray, ), diff --git a/lib/features/devices/view/widgets/three_touch/timer_screen.dart b/lib/features/devices/view/widgets/three_touch/timer_screen.dart index d264d66..37fcab7 100644 --- a/lib/features/devices/view/widgets/three_touch/timer_screen.dart +++ b/lib/features/devices/view/widgets/three_touch/timer_screen.dart @@ -6,7 +6,6 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart'; import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_event.dart'; import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_state.dart'; - import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/shared_widgets/create_schedule.dart'; import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';