three touch

This commit is contained in:
mohammad
2024-10-01 17:01:50 +03:00
parent 908533dc9e
commit 0d5492d626
4 changed files with 53 additions and 309 deletions
@@ -725,7 +725,6 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
'Restart Memory': 'last',
},
};
final selectedControl = controlMap[optionSelected]?[statusSelected];
if (selectedControl != null) {
await DevicesAPI.controlDevice(
@@ -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<ThreeTouchBloc>(
context)
.add(
BlocProvider.of<ThreeTouchBloc>( 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<ThreeTouchBloc>(
// 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<ThreeTouchBloc>(
// 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,
// ),
// ),
// ],
// ),
],
),
),
@@ -28,7 +28,7 @@ class ThreeTouchSetting extends StatelessWidget {
..add(const InitialEvent(groupScreen: false)),
child: BlocBuilder<ThreeTouchBloc, ThreeTouchState>(
builder: (context, state) {
final twoTouchBloc = BlocProvider.of<ThreeTouchBloc>(context);
final threeTouchBloc = BlocProvider.of<ThreeTouchBloc>(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,
),
@@ -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';