mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
touch wizard 1gt and 2 gt and 3gt
This commit is contained in:
@ -511,6 +511,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
|
||||
Future<void> _changeStatus(
|
||||
ChangeStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
|
||||
final Map<String, Map<String, String>> controlMap = {
|
||||
@ -538,108 +539,13 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
deviceId: oneTouchId, code: optionSelected, value: selectedControl),
|
||||
oneTouchId,
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
add(const InitialEvent(groupScreen: false));
|
||||
});
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
|
||||
});
|
||||
|
||||
// add(const InitialEvent(groupScreen: false));
|
||||
} else {
|
||||
print('Invalid statusSelected or optionSelected');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
emit(FailedState(error: errorMessage.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// void _changeStatus(
|
||||
// ChangeStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
// emit(LoadingNewSate(oneTouchModel: deviceStatus));
|
||||
// try {
|
||||
// // deviceStatus.firstSwitch = !event.value;
|
||||
// emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
// print('statusSelected====${statusSelected}');
|
||||
// if (optionSelected == "relay_status") {
|
||||
// if (statusSelected == 'Power On') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId,
|
||||
// code: 'relay_status',
|
||||
// value: 'power_on'),
|
||||
// oneTouchId);
|
||||
// } else if (statusSelected == 'Power Off') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId,
|
||||
// code: 'relay_status',
|
||||
// value: 'power_off'),
|
||||
// oneTouchId);
|
||||
// } else if (statusSelected == 'Restart Memory') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId, code: 'relay_status', value: 'last'),
|
||||
// oneTouchId);
|
||||
// }
|
||||
// } else if (optionSelected == "light_mode") {
|
||||
// if (statusSelected == 'Off') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId, code: 'light_mode', value: 'none'),
|
||||
// oneTouchId);
|
||||
// } else if (statusSelected == 'On/Off Status') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId, code: 'light_mode', value: 'relay'),
|
||||
// oneTouchId);
|
||||
// } else if (statusSelected == 'Switch Position') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId, code: 'relay_status', value: 'pos'),
|
||||
// oneTouchId);
|
||||
// }
|
||||
// } else if (optionSelected == "relay_status_1") {
|
||||
// if (statusSelected == 'Power On') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId,
|
||||
// code: 'relay_status_1',
|
||||
// value: 'power_off'),
|
||||
// oneTouchId);
|
||||
// } else if (statusSelected == 'Power Off') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId,
|
||||
// code: 'relay_status_1',
|
||||
// value: 'power_on'),
|
||||
// oneTouchId);
|
||||
// } else if (statusSelected == 'Restart Memory') {
|
||||
// final response = await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: oneTouchId, code: 'relay_status_1', value: 'last'),
|
||||
// oneTouchId);
|
||||
// }
|
||||
// }
|
||||
// add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
// } catch (_) {
|
||||
// add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<void> _changeStatus(
|
||||
// ChangeStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
// try {
|
||||
// emit(LoadingInitialState());
|
||||
// // emit(LoadingNewSate(oneTouchModel: deviceStatus));
|
||||
// await _handleDeviceControl(event.deviceId, event.context);
|
||||
// Future.delayed(const Duration(seconds: 1), () async {
|
||||
// add(const InitialEvent(groupScreen: false));
|
||||
// });
|
||||
// emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
// } catch (error) {
|
||||
// print('Error controlling device: $error');
|
||||
// add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
// }
|
||||
// }
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:firebase_database/firebase_database.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/three_touch_bloc/three_touch_event.dart';
|
||||
@ -64,6 +65,19 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
||||
on<ToggleSelectedEvent>(toggleSelectedIndex);
|
||||
on<ToggleCreateScheduleEvent>(toggleCreateSchedule);
|
||||
on<ChangeStatusEvent>(_changeStatus);
|
||||
on<InitialSettingDevises>(_fetchTouchStatus);
|
||||
}
|
||||
|
||||
_fetchTouchStatus(
|
||||
InitialSettingDevises event, Emitter<ThreeTouchState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
var response = await DevicesAPI.getDeviceStatus(event.id);
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
}
|
||||
deviceStatus = ThreeTouchModel.fromJson(statusModelList);
|
||||
emit(ChangeStateSetting());
|
||||
}
|
||||
|
||||
void _fetchThreeTouchStatus(
|
||||
@ -696,8 +710,11 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
||||
|
||||
Future<void> _changeStatus(
|
||||
ChangeStatusEvent event, Emitter<ThreeTouchState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
|
||||
print(optionSelected);
|
||||
print(statusSelected);
|
||||
final Map<String, Map<String, String>> controlMap = {
|
||||
"relay_status": {
|
||||
'Power On': 'power_on',
|
||||
@ -725,6 +742,7 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
||||
'Restart Memory': 'last',
|
||||
},
|
||||
};
|
||||
|
||||
final selectedControl = controlMap[optionSelected]?[statusSelected];
|
||||
if (selectedControl != null) {
|
||||
await DevicesAPI.controlDevice(
|
||||
@ -734,14 +752,13 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
||||
value: selectedControl),
|
||||
threeTouchId,
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
add(const InitialEvent(groupScreen: false));
|
||||
});
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
emit(UpdateState(threeTouchModel: deviceStatus));
|
||||
});
|
||||
} else {
|
||||
print('Invalid statusSelected or optionSelected');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
emit(FailedState(error: errorMessage.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,3 +145,8 @@ class ChangeStatusEvent extends ThreeTouchEvent {
|
||||
final BuildContext context;
|
||||
const ChangeStatusEvent({this.deviceId = '', required this.context});
|
||||
}
|
||||
|
||||
class InitialSettingDevises extends ThreeTouchEvent {
|
||||
final String id;
|
||||
const InitialSettingDevises({required this.id});
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_three_touch_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/three_touch_model.dart';
|
||||
|
||||
|
||||
class ThreeTouchState extends Equatable {
|
||||
const ThreeTouchState();
|
||||
|
||||
@ -34,7 +33,8 @@ class UpdateGroupState extends ThreeTouchState {
|
||||
final List<GroupThreeTouchModel> threeTouchList;
|
||||
final bool allSwitches;
|
||||
|
||||
const UpdateGroupState({required this.threeTouchList, required this.allSwitches});
|
||||
const UpdateGroupState(
|
||||
{required this.threeTouchList, required this.allSwitches});
|
||||
|
||||
@override
|
||||
List<Object> get props => [threeTouchList, allSwitches];
|
||||
@ -77,14 +77,20 @@ class TimerRunInProgress extends ThreeTouchState {
|
||||
|
||||
class TimerRunComplete extends ThreeTouchState {}
|
||||
|
||||
|
||||
class ThreeTouchSaveSchedule extends ThreeTouchState {}
|
||||
|
||||
class IsToggleState extends ThreeTouchState {
|
||||
final bool? onOff;
|
||||
const IsToggleState({this.onOff});
|
||||
}
|
||||
|
||||
class ChangeTimeState extends ThreeTouchState {}
|
||||
|
||||
class UpdateCreateScheduleState extends ThreeTouchState {
|
||||
final bool createSchedule;
|
||||
UpdateCreateScheduleState(this.createSchedule);
|
||||
}
|
||||
|
||||
class ChangeStateSetting extends ThreeTouchState {
|
||||
const ChangeStateSetting();
|
||||
}
|
||||
|
@ -641,10 +641,8 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
|
||||
|
||||
Future<void> _changeStatus(
|
||||
ChangeStatusEvent event, Emitter<TwoTouchState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
|
||||
print(optionSelected);
|
||||
print(statusSelected);
|
||||
final Map<String, Map<String, String>> controlMap = {
|
||||
"relay_status": {
|
||||
'Power On': 'power_on',
|
||||
@ -672,17 +670,18 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
|
||||
if (selectedControl != null) {
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: twoTouchId, code: optionSelected, value: selectedControl),
|
||||
deviceId: twoTouchId,
|
||||
code: optionSelected,
|
||||
value: selectedControl),
|
||||
twoTouchId,
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
add(const InitialEvent());
|
||||
});
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
emit(UpdateState(twoTouchModel: deviceStatus));
|
||||
});
|
||||
} else {
|
||||
print('Invalid statusSelected or optionSelected');
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
emit(FailedState(error: errorMessage.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ class ThreeTouchModel {
|
||||
late int _firstCount;
|
||||
late int _secondCount;
|
||||
late int _thirdCount;
|
||||
late int _thirdCountDown;
|
||||
late String _relay;
|
||||
late String _light_mode;
|
||||
late String _relay_status_1;
|
||||
|
@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/group_one_touch_model.dart';
|
||||
|
||||
import 'package:syncrow_app/features/shared_widgets/devices_default_switch.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
|
||||
|
||||
class OneTouchList extends StatelessWidget {
|
||||
const OneTouchList(
|
||||
{super.key, required this.oneTouchList, required this.allSwitches});
|
||||
|
||||
final List<GroupOneTouchModel> oneTouchList;
|
||||
final bool allSwitches;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<OneTouchBloc, OneTouchState>(
|
||||
builder: (context, state) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
const BodySmall(text: 'All Lights'),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: allSwitches,
|
||||
action: () {
|
||||
BlocProvider.of<OneTouchBloc>(context).add(GroupAllOnEvent());
|
||||
},
|
||||
secondAction: () {
|
||||
BlocProvider.of<OneTouchBloc>(context).add(GroupAllOffEvent());
|
||||
},
|
||||
),
|
||||
ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: oneTouchList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
BodySmall(text: oneTouchList[index].deviceName),
|
||||
const SizedBox(height: 5),
|
||||
DevicesDefaultSwitch(
|
||||
switchValue: oneTouchList[index].firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<OneTouchBloc>(context).add(
|
||||
ChangeFirstWizardSwitchStatusEvent(
|
||||
value: oneTouchList[index].firstSwitch,
|
||||
deviceId: oneTouchList[index].deviceId));
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_event
|
||||
import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/one_touch_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/restart_status_dialog.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
@ -65,8 +66,8 @@ class OneTouchSetting extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
initialSelectedLabel:
|
||||
oneTouchModel!.relay.value,
|
||||
initialSelectedLabel: oneTouchBloc
|
||||
.deviceStatus.relay.value,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -96,11 +97,11 @@ class OneTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
// Future.delayed(const Duration(seconds: 1),
|
||||
// () async {
|
||||
// oneTouchBloc.add(const InitialEvent(
|
||||
// groupScreen: false));
|
||||
// });
|
||||
Future.delayed(const Duration(seconds: 2),
|
||||
() async {
|
||||
oneTouchBloc.add(const InitialEvent(
|
||||
groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
@ -119,8 +120,8 @@ class OneTouchSetting extends StatelessWidget {
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text:
|
||||
oneTouchModel!.relay.value,
|
||||
text: oneTouchBloc
|
||||
.deviceStatus.relay.value,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
),
|
||||
@ -141,7 +142,8 @@ class OneTouchSetting extends StatelessWidget {
|
||||
bottom: 10, top: 10),
|
||||
child: InkWell(
|
||||
onTap: () async {
|
||||
oneTouchBloc.optionSelected ='light_mode';
|
||||
oneTouchBloc.optionSelected =
|
||||
'light_mode';
|
||||
final result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@ -178,8 +180,12 @@ class OneTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
// oneTouchBloc.add(const InitialEvent(
|
||||
// groupScreen: false));
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
oneTouchBloc.add(const InitialEvent(
|
||||
groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
@ -196,7 +202,7 @@ class OneTouchSetting extends StatelessWidget {
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text: oneTouchBloc.deviceStatus
|
||||
text: oneTouchModel
|
||||
.light_mode.value,
|
||||
fontColor: ColorsManager.textGray,
|
||||
),
|
||||
@ -242,19 +248,14 @@ class OneTouchSetting extends StatelessWidget {
|
||||
label2: 'Power On',
|
||||
label3: 'Restart Memory',
|
||||
onTapLabel1: (selected) {
|
||||
print(selected);
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel2: (selected) {
|
||||
print(selected);
|
||||
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel3: (selected) {
|
||||
print(selected);
|
||||
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
@ -262,8 +263,12 @@ class OneTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
oneTouchBloc.add(const InitialEvent(
|
||||
groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
@ -279,7 +284,7 @@ class OneTouchSetting extends StatelessWidget {
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text: oneTouchBloc.deviceStatus
|
||||
text: oneTouchModel
|
||||
.relay_status_1.value,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
@ -304,228 +309,3 @@ class OneTouchSetting extends StatelessWidget {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class RestartStatusDialog extends StatefulWidget {
|
||||
final String label1;
|
||||
final String label2;
|
||||
final String label3;
|
||||
final String title;
|
||||
|
||||
final Function(String)? onTapLabel1;
|
||||
final Function(String)? onTapLabel2;
|
||||
final Function(String)? onTapLabel3;
|
||||
final Function()? cancelTab;
|
||||
final Function()? confirmTab;
|
||||
|
||||
final String? initialSelectedLabel;
|
||||
|
||||
RestartStatusDialog({
|
||||
required this.label1,
|
||||
required this.label2,
|
||||
required this.label3,
|
||||
required this.title,
|
||||
this.onTapLabel1,
|
||||
this.onTapLabel2,
|
||||
this.onTapLabel3,
|
||||
required this.cancelTab,
|
||||
required this.confirmTab,
|
||||
this.initialSelectedLabel,
|
||||
});
|
||||
|
||||
@override
|
||||
_RestartStatusDialogState createState() => _RestartStatusDialogState();
|
||||
}
|
||||
|
||||
class _RestartStatusDialogState extends State<RestartStatusDialog> {
|
||||
late String _selectedOption;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_selectedOption = widget.initialSelectedLabel ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyLarge(
|
||||
text: widget.title,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontColor: ColorsManager.primaryColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Divider(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildCheckboxOption(
|
||||
label: widget.label1,
|
||||
onTap: widget.onTapLabel1,
|
||||
),
|
||||
_buildCheckboxOption(
|
||||
label: widget.label2,
|
||||
onTap: widget.onTapLabel2,
|
||||
),
|
||||
_buildCheckboxOption(
|
||||
label: widget.label3,
|
||||
onTap: widget.onTapLabel3,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: SizedBox(
|
||||
child: InkWell(
|
||||
onTap: widget.cancelTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.textGray,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: InkWell(
|
||||
onTap: widget.confirmTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.primaryColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCheckboxOption(
|
||||
{required String label, Function(String)? onTap}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10, top: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: label,
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w400),
|
||||
),
|
||||
CircularCheckbox(
|
||||
value: _selectedOption == label,
|
||||
onChanged: (bool? value) {
|
||||
if (value == true) {
|
||||
setState(() {
|
||||
_selectedOption = label;
|
||||
});
|
||||
if (onTap != null) {
|
||||
onTap(label);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CircularCheckbox extends StatefulWidget {
|
||||
final bool value;
|
||||
final ValueChanged<bool?> onChanged;
|
||||
|
||||
CircularCheckbox({required this.value, required this.onChanged});
|
||||
|
||||
@override
|
||||
_CircularCheckboxState createState() => _CircularCheckboxState();
|
||||
}
|
||||
|
||||
class _CircularCheckboxState extends State<CircularCheckbox> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
widget.onChanged(!widget.value);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: widget.value
|
||||
? ColorsManager.primaryColorWithOpacity.withOpacity(0.01)
|
||||
: Colors.grey,
|
||||
width: 2.0,
|
||||
),
|
||||
color: widget.value
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: Colors.transparent,
|
||||
),
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: widget.value
|
||||
? const Icon(
|
||||
Icons.check,
|
||||
color: Colors.white,
|
||||
size: 16.0,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +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/bloc/one_touch_bloc/one_touch_bloc.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_event.dart';
|
||||
import 'package:syncrow_app/features/devices/bloc/one_touch_bloc/one_touch_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/devices/model/group_one_touch_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_touch/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 OneGangWizard extends StatelessWidget {
|
||||
const OneGangWizard({super.key, this.device});
|
||||
class OneTouchWizard extends StatelessWidget {
|
||||
const OneTouchWizard({super.key, this.device});
|
||||
|
||||
final DeviceModel? device;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<GroupOneGangModel> groupOneGangModel = [];
|
||||
List<GroupOneTouchModel> groupOneTouchModel = [];
|
||||
|
||||
return DefaultScaffold(
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
OneGangBloc(switchCode: '', oneGangId: device?.uuid ?? '')..add(InitialWizardEvent()),
|
||||
child: BlocBuilder<OneGangBloc, OneGangState>(
|
||||
OneTouchBloc(switchCode: '', oneTouchId: device?.uuid ?? '')
|
||||
..add(InitialWizardEvent()),
|
||||
child: BlocBuilder<OneTouchBloc, OneTouchState>(
|
||||
builder: (context, state) {
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is UpdateGroupState) {
|
||||
groupOneGangModel = state.oneGangList;
|
||||
groupOneTouchModel = state.oneTouchList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child:
|
||||
DefaultContainer(width: 50, height: 50, child: CircularProgressIndicator()),
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: OneGangList(
|
||||
oneGangList: groupOneGangModel,
|
||||
: OneTouchList(
|
||||
oneTouchList: groupOneTouchModel,
|
||||
allSwitches: allSwitchesOn,
|
||||
);
|
||||
},
|
||||
|
@ -79,8 +79,7 @@ class ThreeTouchScreen extends StatelessWidget {
|
||||
threeGangSwitch: device!,
|
||||
value: threeTouchModel.firstSwitch,
|
||||
action: () {
|
||||
BlocProvider.of<ThreeTouchBloc>(
|
||||
context)
|
||||
BlocProvider.of<ThreeTouchBloc>(context)
|
||||
.add(ChangeFirstSwitchStatusEvent(
|
||||
value: threeTouchModel
|
||||
.firstSwitch));
|
||||
|
@ -25,7 +25,7 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
ThreeTouchBloc(switchCode: '', threeTouchId: device?.uuid ?? '')
|
||||
..add(const InitialEvent(groupScreen: false)),
|
||||
..add(InitialEvent(groupScreen: false)),
|
||||
child: BlocBuilder<ThreeTouchBloc, ThreeTouchState>(
|
||||
builder: (context, state) {
|
||||
final threeTouchBloc = BlocProvider.of<ThreeTouchBloc>(context);
|
||||
@ -42,9 +42,16 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
relay_status_2: status.off,
|
||||
relay_status_3: status.off,
|
||||
);
|
||||
if (state is UpdateState) {
|
||||
if (state is LoadingNewSate) {
|
||||
deviceStatus = state.threeTouchModel;
|
||||
} else if (state is UpdateState) {
|
||||
deviceStatus = state.threeTouchModel;
|
||||
}
|
||||
// if (state is ChangeStateSetting) {
|
||||
// // Navigator.of(context).pop(true);
|
||||
// threeTouchBloc
|
||||
// .add(InitialSettingDevises(id: device?.uuid ?? ''));
|
||||
// }
|
||||
return state is LoadingInitialState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
@ -69,8 +76,8 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
initialSelectedLabel:
|
||||
deviceStatus.relay.value,
|
||||
initialSelectedLabel: threeTouchBloc
|
||||
.deviceStatus.relay.value,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -101,11 +108,11 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
// Future.delayed(const Duration(seconds: 1),
|
||||
// () async {
|
||||
// oneTouchBloc.add(const InitialEvent(
|
||||
// groupScreen: false));
|
||||
// });
|
||||
Future.delayed(const Duration(seconds: 2),
|
||||
() async {
|
||||
threeTouchBloc.add(
|
||||
InitialEvent(groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
@ -124,7 +131,8 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text: deviceStatus.relay.value,
|
||||
text: threeTouchBloc
|
||||
.deviceStatus.relay.value,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
),
|
||||
@ -151,8 +159,8 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
initialSelectedLabel:
|
||||
deviceStatus.light_mode.value,
|
||||
initialSelectedLabel: threeTouchBloc
|
||||
.deviceStatus.light_mode.value,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -183,8 +191,12 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
threeTouchBloc.add(const InitialEvent(
|
||||
groupScreen: false));
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
threeTouchBloc.add(
|
||||
InitialEvent(groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
@ -229,7 +241,8 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
initialSelectedLabel: deviceStatus
|
||||
initialSelectedLabel:
|
||||
threeTouchBloc.deviceStatus
|
||||
.relay_status_1.value,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
@ -261,8 +274,13 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
threeTouchBloc.add(const InitialEvent(
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
threeTouchBloc.add(
|
||||
const InitialEvent(
|
||||
groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
@ -308,7 +326,8 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
initialSelectedLabel: deviceStatus
|
||||
initialSelectedLabel:
|
||||
threeTouchBloc.deviceStatus
|
||||
.relay_status_2.value,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
@ -340,8 +359,16 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
threeTouchBloc.add(const InitialEvent(
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
threeTouchBloc.add(
|
||||
const InitialEvent(
|
||||
groupScreen: false));
|
||||
threeTouchBloc.add(
|
||||
const InitialEvent(
|
||||
groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
@ -387,7 +414,8 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
initialSelectedLabel: deviceStatus
|
||||
initialSelectedLabel:
|
||||
threeTouchBloc.deviceStatus
|
||||
.relay_status_3.value,
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
@ -419,8 +447,16 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
threeTouchBloc.add(const InitialEvent(
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
threeTouchBloc.add(
|
||||
const InitialEvent(
|
||||
groupScreen: false));
|
||||
threeTouchBloc.add(
|
||||
const InitialEvent(
|
||||
groupScreen: false));
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
@ -438,7 +474,7 @@ class ThreeTouchSetting extends StatelessWidget {
|
||||
fontSize: 13,
|
||||
text: threeTouchBloc
|
||||
.deviceStatus
|
||||
.relay_status_1
|
||||
.relay_status_3
|
||||
.value,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
|
@ -5,6 +5,7 @@ import 'package:syncrow_app/features/devices/bloc/two_touch_bloc/two_touch_event
|
||||
import 'package:syncrow_app/features/devices/bloc/two_touch_bloc/two_touch_state.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/two_touch_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/restart_status_dialog.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
@ -99,11 +100,10 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
// Future.delayed(const Duration(seconds: 1),
|
||||
// () async {
|
||||
// oneTouchBloc.add(const InitialEvent(
|
||||
// groupScreen: false));
|
||||
// });
|
||||
Future.delayed(const Duration(seconds: 2),
|
||||
() async {
|
||||
twoTouchBloc.add(const InitialEvent());
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
@ -122,8 +122,7 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text:
|
||||
twoTouchModel.relay.value,
|
||||
text: twoTouchModel.relay.value,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
),
|
||||
@ -182,8 +181,12 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
// oneTouchBloc.add(const InitialEvent(
|
||||
// groupScreen: false));
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
twoTouchBloc
|
||||
.add(const InitialEvent());
|
||||
});
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
@ -261,8 +264,12 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
// twoTouchBloc
|
||||
// .add(const InitialEvent());
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
twoTouchBloc
|
||||
.add(const InitialEvent());
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
@ -324,19 +331,14 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
label2: 'Power On',
|
||||
label3: 'Restart Memory',
|
||||
onTapLabel1: (selected) {
|
||||
print('selected===$selected');
|
||||
twoTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel2: (selected) {
|
||||
print('selected===$selected');
|
||||
|
||||
twoTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel3: (selected) {
|
||||
print('selected===$selected');
|
||||
|
||||
twoTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
@ -344,8 +346,12 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
// twoTouchBloc
|
||||
// .add(const InitialEvent());
|
||||
Future.delayed(
|
||||
const Duration(seconds: 2),
|
||||
() async {
|
||||
twoTouchBloc
|
||||
.add(const InitialEvent());
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
@ -362,7 +368,7 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text: twoTouchBloc.deviceStatus
|
||||
.relay_status_1.value,
|
||||
.relay_status_2.value,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
),
|
||||
@ -386,228 +392,3 @@ class TwoTouchSetting extends StatelessWidget {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class RestartStatusDialog extends StatefulWidget {
|
||||
final String label1;
|
||||
final String label2;
|
||||
final String label3;
|
||||
final String title;
|
||||
|
||||
final Function(String)? onTapLabel1;
|
||||
final Function(String)? onTapLabel2;
|
||||
final Function(String)? onTapLabel3;
|
||||
final Function()? cancelTab;
|
||||
final Function()? confirmTab;
|
||||
|
||||
final String? initialSelectedLabel;
|
||||
|
||||
RestartStatusDialog({
|
||||
required this.label1,
|
||||
required this.label2,
|
||||
required this.label3,
|
||||
required this.title,
|
||||
this.onTapLabel1,
|
||||
this.onTapLabel2,
|
||||
this.onTapLabel3,
|
||||
required this.cancelTab,
|
||||
required this.confirmTab,
|
||||
this.initialSelectedLabel,
|
||||
});
|
||||
|
||||
@override
|
||||
_RestartStatusDialogState createState() => _RestartStatusDialogState();
|
||||
}
|
||||
|
||||
class _RestartStatusDialogState extends State<RestartStatusDialog> {
|
||||
late String _selectedOption;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_selectedOption = widget.initialSelectedLabel ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
BodyLarge(
|
||||
text: widget.title,
|
||||
fontWeight: FontWeight.w700,
|
||||
fontColor: ColorsManager.primaryColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 15, right: 15),
|
||||
child: Divider(
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15, right: 15),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildCheckboxOption(
|
||||
label: widget.label1,
|
||||
onTap: widget.onTapLabel1,
|
||||
),
|
||||
_buildCheckboxOption(
|
||||
label: widget.label2,
|
||||
onTap: widget.onTapLabel2,
|
||||
),
|
||||
_buildCheckboxOption(
|
||||
label: widget.label3,
|
||||
onTap: widget.onTapLabel3,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: SizedBox(
|
||||
child: InkWell(
|
||||
onTap: widget.cancelTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.textGray,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 0.5,
|
||||
),
|
||||
top: BorderSide(
|
||||
color: ColorsManager.textGray,
|
||||
width: 1.0,
|
||||
),
|
||||
)),
|
||||
child: InkWell(
|
||||
onTap: widget.confirmTab,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Confirm',
|
||||
style: TextStyle(
|
||||
color: ColorsManager.primaryColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
),
|
||||
)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCheckboxOption(
|
||||
{required String label, Function(String)? onTap}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10, top: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodyMedium(
|
||||
text: label,
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w400),
|
||||
),
|
||||
CircularCheckbox(
|
||||
value: _selectedOption == label,
|
||||
onChanged: (bool? value) {
|
||||
if (value == true) {
|
||||
setState(() {
|
||||
_selectedOption = label;
|
||||
});
|
||||
if (onTap != null) {
|
||||
onTap(label);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CircularCheckbox extends StatefulWidget {
|
||||
final bool value;
|
||||
final ValueChanged<bool?> onChanged;
|
||||
|
||||
CircularCheckbox({required this.value, required this.onChanged});
|
||||
|
||||
@override
|
||||
_CircularCheckboxState createState() => _CircularCheckboxState();
|
||||
}
|
||||
|
||||
class _CircularCheckboxState extends State<CircularCheckbox> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
widget.onChanged(!widget.value);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: widget.value
|
||||
? ColorsManager.primaryColorWithOpacity.withOpacity(0.01)
|
||||
: Colors.grey,
|
||||
width: 2.0,
|
||||
),
|
||||
color: widget.value
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: Colors.transparent,
|
||||
),
|
||||
width: 24.0,
|
||||
height: 24.0,
|
||||
child: widget.value
|
||||
? const Icon(
|
||||
Icons.check,
|
||||
color: Colors.white,
|
||||
size: 16.0,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,11 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_view.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_gang/one_gang_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/one_touch/one_touch_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/three_touch/three_touch_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/two_gang/two_gang_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/two_touch/two_touch_wizard.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/water_heater/wh_wizard.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
|
||||
@ -64,6 +67,30 @@ class WizardPage extends StatelessWidget {
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const WHWizard()));
|
||||
}
|
||||
|
||||
if (groupsList[index].name == '1GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const OneTouchWizard()));
|
||||
}
|
||||
|
||||
if (groupsList[index].name == '2GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const TwoTouchWizard()));
|
||||
}
|
||||
|
||||
if (groupsList[index].name == '3GT') {
|
||||
Navigator.push(
|
||||
context,
|
||||
PageRouteBuilder(
|
||||
pageBuilder: (context, animation1, animation2) =>
|
||||
const ThreeTouchWizard()));
|
||||
}
|
||||
},
|
||||
child: DefaultContainer(
|
||||
padding: const EdgeInsets.all(15),
|
||||
|
Reference in New Issue
Block a user