From 5030b3f31391629e897fe9a83c7aac59dcb496b5 Mon Sep 17 00:00:00 2001 From: mohammad Date: Sun, 29 Sep 2024 16:35:24 +0300 Subject: [PATCH] one touch --- .../widgets/one_touch/one_touch_screen.dart | 11 ++--- .../widgets/one_touch/one_touch_setting.dart | 46 +++++++++++++++++++ 2 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 lib/features/devices/view/widgets/one_touch/one_touch_setting.dart diff --git a/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart b/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart index 0987e01..386befe 100644 --- a/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart +++ b/lib/features/devices/view/widgets/one_touch/one_touch_screen.dart @@ -9,6 +9,7 @@ import 'package:syncrow_app/features/devices/model/group_one_touch_model.dart'; import 'package:syncrow_app/features/devices/model/one_touch_model.dart'; import 'package:syncrow_app/features/devices/view/widgets/circular_button.dart'; import 'package:syncrow_app/features/devices/view/widgets/device_appbar.dart'; +import 'package:syncrow_app/features/devices/view/widgets/one_touch/one_touch_setting.dart'; import 'package:syncrow_app/features/devices/view/widgets/one_touch/one_touch_timer_screen.dart'; import 'package:syncrow_app/features/devices/view/widgets/three_gang/gang_switch.dart'; import 'package:syncrow_app/features/shared_widgets/default_container.dart'; @@ -183,7 +184,7 @@ class OneTouchScreen extends StatelessWidget { ), CircularButton( device: device, - icons: Icons.access_time, + icons: Icons.settings, label: 'Setting', onTap: () { Navigator.push( @@ -192,13 +193,7 @@ class OneTouchScreen extends StatelessWidget { pageBuilder: (context, animation1, animation2) => - TimerScheduleScreen( - switchCode: - 'switch_1', - device: device!, - deviceCode: - 'countdown_1', - ))); + OneTouchSetting())); }, ), ], diff --git a/lib/features/devices/view/widgets/one_touch/one_touch_setting.dart b/lib/features/devices/view/widgets/one_touch/one_touch_setting.dart new file mode 100644 index 0000000..480ec38 --- /dev/null +++ b/lib/features/devices/view/widgets/one_touch/one_touch_setting.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:syncrow_app/features/devices/bloc/one_gang_bloc/one_gang_bloc.dart'; +import 'package:syncrow_app/features/devices/bloc/one_gang_bloc/one_gang_event.dart'; +import 'package:syncrow_app/features/devices/bloc/one_gang_bloc/one_gang_state.dart'; +import 'package:syncrow_app/features/devices/model/device_model.dart'; +import 'package:syncrow_app/features/devices/model/group_one_gang_model.dart'; +import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_list.dart'; +import 'package:syncrow_app/features/shared_widgets/default_container.dart'; +import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart'; + +class OneTouchSetting extends StatelessWidget { + const OneTouchSetting({super.key, this.device}); + + final DeviceModel? device; + + @override + Widget build(BuildContext context) { + List groupOneGangModel = []; + + return DefaultScaffold( + child: BlocProvider( + create: (context) => + OneGangBloc(switchCode: '', oneGangId: device?.uuid ?? '') + ..add(InitialWizardEvent()), + child: BlocBuilder( + builder: (context, state) { + bool allSwitchesOn = false; + + if (state is UpdateGroupState) { + groupOneGangModel = state.oneGangList; + allSwitchesOn = state.allSwitches; + } + return state is LoadingInitialState + ? const Center( + child: DefaultContainer( + width: 50, + height: 50, + child: CircularProgressIndicator()), + ) + : Container(); + }, + ), + )); + } +}