mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
setting
This commit is contained in:
@ -26,7 +26,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
bool oneGangGroup = false;
|
||||
List<DeviceModel> devicesList = [];
|
||||
|
||||
OneGangBloc({required this.oneGangId, required this.switchCode}) : super(InitialState()) {
|
||||
OneGangBloc({required this.oneGangId, required this.switchCode})
|
||||
: super(InitialState()) {
|
||||
on<InitialEvent>(_fetchOneGangStatus);
|
||||
on<OneGangUpdated>(_oneGangUpdated);
|
||||
on<ChangeFirstSwitchStatusEvent>(_changeFirstSwitch);
|
||||
@ -49,7 +50,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
on<GroupAllOffEvent>(_groupAllOff);
|
||||
}
|
||||
|
||||
void _fetchOneGangStatus(InitialEvent event, Emitter<OneGangState> emit) async {
|
||||
void _fetchOneGangStatus(
|
||||
InitialEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(oneGangId);
|
||||
@ -68,18 +70,21 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$oneGangId');
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$oneGangId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) async {
|
||||
if (_timer != null) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
statusList.add(StatusModel(code: element['code'], value: element['value']));
|
||||
statusList
|
||||
.add(StatusModel(code: element['code'], value: element['value']));
|
||||
});
|
||||
|
||||
deviceStatus = OneGangModel.fromJson(statusList);
|
||||
@ -94,7 +99,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
emit(UpdateState(oneGangModel: deviceStatus));
|
||||
}
|
||||
|
||||
void _changeFirstSwitch(ChangeFirstSwitchStatusEvent event, Emitter<OneGangState> emit) async {
|
||||
void _changeFirstSwitch(
|
||||
ChangeFirstSwitchStatusEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingNewSate(oneGangModel: deviceStatus));
|
||||
try {
|
||||
deviceStatus.firstSwitch = !event.value;
|
||||
@ -119,17 +125,20 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _changeSliding(ChangeSlidingSegment event, Emitter<OneGangState> emit) async {
|
||||
void _changeSliding(
|
||||
ChangeSlidingSegment event, Emitter<OneGangState> emit) async {
|
||||
emit(ChangeSlidingSegmentState(value: event.value));
|
||||
}
|
||||
|
||||
void _setCounterValue(SetCounterValue event, Emitter<OneGangState> emit) async {
|
||||
void _setCounterValue(
|
||||
SetCounterValue event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingNewSate(oneGangModel: deviceStatus));
|
||||
int seconds = 0;
|
||||
try {
|
||||
seconds = event.duration.inSeconds;
|
||||
final response = await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(deviceId: oneGangId, code: event.deviceCode, value: seconds),
|
||||
DeviceControlModel(
|
||||
deviceId: oneGangId, code: event.deviceCode, value: seconds),
|
||||
oneGangId);
|
||||
|
||||
if (response['success'] ?? false) {
|
||||
@ -152,7 +161,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _getCounterValue(GetCounterEvent event, Emitter<OneGangState> emit) async {
|
||||
void _getCounterValue(
|
||||
GetCounterEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(oneGangId);
|
||||
@ -241,7 +251,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
deviceId: oneGangId,
|
||||
);
|
||||
List<dynamic> jsonData = response;
|
||||
listSchedule = jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
listSchedule =
|
||||
jsonData.map((item) => ScheduleModel.fromJson(item)).toList();
|
||||
emit(InitialState());
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
@ -252,12 +263,13 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
|
||||
int? getTimeStampWithoutSeconds(DateTime? dateTime) {
|
||||
if (dateTime == null) return null;
|
||||
DateTime dateTimeWithoutSeconds =
|
||||
DateTime(dateTime.year, dateTime.month, dateTime.day, dateTime.hour, dateTime.minute);
|
||||
DateTime dateTimeWithoutSeconds = DateTime(dateTime.year, dateTime.month,
|
||||
dateTime.day, dateTime.hour, dateTime.minute);
|
||||
return dateTimeWithoutSeconds.millisecondsSinceEpoch ~/ 1000;
|
||||
}
|
||||
|
||||
Future toggleChange(ToggleScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
Future toggleChange(
|
||||
ToggleScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
final response = await DevicesAPI.changeSchedule(
|
||||
@ -276,7 +288,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future deleteSchedule(DeleteScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
Future deleteSchedule(
|
||||
DeleteScheduleEvent event, Emitter<OneGangState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
final response = await DevicesAPI.deleteSchedule(
|
||||
@ -296,8 +309,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void toggleCreateSchedule(ToggleCreateScheduleEvent event, Emitter<OneGangState> emit) {
|
||||
void toggleCreateSchedule(
|
||||
ToggleCreateScheduleEvent event, Emitter<OneGangState> emit) {
|
||||
emit(LoadingInitialState());
|
||||
createSchedule = !createSchedule;
|
||||
selectedDays.clear();
|
||||
@ -326,7 +339,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
|
||||
int selectedTabIndex = 0;
|
||||
|
||||
void toggleSelectedIndex(ToggleSelectedEvent event, Emitter<OneGangState> emit) {
|
||||
void toggleSelectedIndex(
|
||||
ToggleSelectedEvent event, Emitter<OneGangState> emit) {
|
||||
emit(LoadingInitialState());
|
||||
selectedTabIndex = event.index;
|
||||
emit(ChangeSlidingSegmentState(value: selectedTabIndex));
|
||||
@ -335,7 +349,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
List<GroupOneGangModel> groupOneGangList = [];
|
||||
bool allSwitchesOn = true;
|
||||
|
||||
void _fetchOneGangWizardStatus(InitialWizardEvent event, Emitter<OneGangState> emit) async {
|
||||
void _fetchOneGangWizardStatus(
|
||||
InitialWizardEvent event, Emitter<OneGangState> emit) async {
|
||||
emit(LoadingInitialState());
|
||||
try {
|
||||
devicesList = [];
|
||||
@ -345,7 +360,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
HomeCubit.getInstance().selectedSpace?.id ?? '', '1G');
|
||||
|
||||
for (int i = 0; i < devicesList.length; i++) {
|
||||
var response = await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
var response =
|
||||
await DevicesAPI.getDeviceStatus(devicesList[i].uuid ?? '');
|
||||
List<StatusModel> statusModelList = [];
|
||||
for (var status in response['status']) {
|
||||
statusModelList.add(StatusModel.fromJson(status));
|
||||
@ -366,15 +382,16 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: allSwitchesOn));
|
||||
emit(UpdateGroupState(
|
||||
oneGangList: groupOneGangList, allSwitches: allSwitchesOn));
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void _changeFirstWizardSwitch(
|
||||
ChangeFirstWizardSwitchStatusEvent event, Emitter<OneGangState> emit) async {
|
||||
void _changeFirstWizardSwitch(ChangeFirstWizardSwitchStatusEvent event,
|
||||
Emitter<OneGangState> emit) async {
|
||||
emit(LoadingNewSate(oneGangModel: deviceStatus));
|
||||
try {
|
||||
bool allSwitchesValue = true;
|
||||
@ -387,7 +404,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
});
|
||||
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: allSwitchesValue));
|
||||
emit(UpdateGroupState(
|
||||
oneGangList: groupOneGangList, allSwitches: allSwitchesValue));
|
||||
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
code: 'switch_1',
|
||||
@ -415,7 +433,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: true));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds = groupOneGangList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds =
|
||||
groupOneGangList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
@ -447,7 +466,8 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
emit(UpdateGroupState(oneGangList: groupOneGangList, allSwitches: false));
|
||||
|
||||
// Get a list of all device IDs
|
||||
List<String> allDeviceIds = groupOneGangList.map((device) => device.deviceId).toList();
|
||||
List<String> allDeviceIds =
|
||||
groupOneGangList.map((device) => device.deviceId).toList();
|
||||
|
||||
// First call for switch_1
|
||||
final response = await DevicesAPI.deviceBatchController(
|
||||
|
@ -13,6 +13,7 @@ import 'package:syncrow_app/features/devices/model/schedule_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
import 'package:syncrow_app/services/api/devices_api.dart';
|
||||
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
final String oneTouchId;
|
||||
@ -20,7 +21,9 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
OneTouchModel deviceStatus = OneTouchModel(
|
||||
firstSwitch: false,
|
||||
firstCountDown: 0,
|
||||
);
|
||||
light_mode: '',
|
||||
relay: status.off,
|
||||
relay_status_1: '');
|
||||
Timer? _timer;
|
||||
|
||||
bool oneTouchGroup = false;
|
||||
@ -47,6 +50,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
on<ChangeFirstWizardSwitchStatusEvent>(_changeFirstWizardSwitch);
|
||||
on<GroupAllOnEvent>(_groupAllOn);
|
||||
on<GroupAllOffEvent>(_groupAllOff);
|
||||
on<ChangeStatusEvent>(_changeStatus);
|
||||
}
|
||||
|
||||
void _fetchOneTouchStatus(
|
||||
@ -500,4 +504,124 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
add(const InitialEvent(groupScreen: true));
|
||||
}
|
||||
}
|
||||
|
||||
String statusSelected = '';
|
||||
String optionSelected = '';
|
||||
// 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));
|
||||
// }
|
||||
// }
|
||||
|
||||
void _changeStatus(
|
||||
ChangeStatusEvent event, Emitter<OneTouchState> emit) async {
|
||||
// emit(LoadingNewState(oneTouchModel: deviceStatus));
|
||||
emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
try {
|
||||
emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
await _handleDeviceControl(event.deviceId);
|
||||
add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
} catch (error) {
|
||||
print('Error controlling device: $error');
|
||||
add(InitialEvent(groupScreen: oneTouchGroup));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleDeviceControl(String deviceId) async {
|
||||
final Map<String, Map<String, String>> controlMap = {
|
||||
"relay_status": {
|
||||
'Power On': 'power_on',
|
||||
'Power Off': 'power_off',
|
||||
'Restart Memory': 'last',
|
||||
},
|
||||
"light_mode": {
|
||||
'Off': 'none',
|
||||
'On/Off Status': 'relay',
|
||||
'Switch Position': 'pos',
|
||||
},
|
||||
"relay_status_1": {
|
||||
'Power On': 'power_off',
|
||||
'Power Off': 'power_on',
|
||||
'Restart Memory': 'last',
|
||||
},
|
||||
};
|
||||
|
||||
final selectedControl = controlMap[optionSelected]?[statusSelected];
|
||||
if (selectedControl != null) {
|
||||
await DevicesAPI.controlDevice(
|
||||
DeviceControlModel(
|
||||
deviceId: oneTouchId, code: optionSelected, value: selectedControl),
|
||||
oneTouchId,
|
||||
);
|
||||
} else {
|
||||
print('Invalid statusSelected or optionSelected');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,3 +139,8 @@ class ChangeFirstWizardSwitchStatusEvent extends OneTouchEvent {
|
||||
@override
|
||||
List<Object> get props => [value, deviceId];
|
||||
}
|
||||
|
||||
class ChangeStatusEvent extends OneTouchEvent {
|
||||
final String deviceId;
|
||||
const ChangeStatusEvent({this.deviceId = ''});
|
||||
}
|
||||
|
@ -1,28 +1,74 @@
|
||||
// import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
|
||||
// class OneTouchModel {
|
||||
// bool firstSwitch;
|
||||
// int firstCountDown;
|
||||
|
||||
// OneTouchModel({
|
||||
// required this.firstSwitch,
|
||||
// required this.firstCountDown,
|
||||
// });
|
||||
|
||||
// factory OneTouchModel.fromJson(List<StatusModel> jsonList) {
|
||||
// late bool _switch;
|
||||
// late int _count;
|
||||
|
||||
// for (int i = 0; i < jsonList.length; i++) {
|
||||
// if (jsonList[i].code == 'switch_1') {
|
||||
// _switch = jsonList[i].value ?? false;
|
||||
// } else if (jsonList[i].code == 'countdown_1') {
|
||||
// _count = jsonList[i].value ?? 0;
|
||||
// }
|
||||
// }
|
||||
// return OneTouchModel(
|
||||
// firstSwitch: _switch,
|
||||
// firstCountDown: _count,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
import 'package:syncrow_app/features/devices/model/status_model.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class OneTouchModel {
|
||||
bool firstSwitch;
|
||||
int firstCountDown;
|
||||
status relay;
|
||||
String light_mode;
|
||||
String relay_status_1;
|
||||
|
||||
OneTouchModel({
|
||||
required this.firstSwitch,
|
||||
OneTouchModel(
|
||||
{required this.firstSwitch,
|
||||
required this.firstCountDown,
|
||||
});
|
||||
required this.light_mode,
|
||||
required this.relay,
|
||||
required this.relay_status_1});
|
||||
|
||||
factory OneTouchModel.fromJson(List<StatusModel> jsonList) {
|
||||
late bool _switch;
|
||||
late int _count;
|
||||
late String _relay;
|
||||
late String _light_mode;
|
||||
late String relay_status_1;
|
||||
|
||||
for (int i = 0; i < jsonList.length; i++) {
|
||||
if (jsonList[i].code == 'switch_1') {
|
||||
_switch = jsonList[i].value ?? false;
|
||||
} else if (jsonList[i].code == 'countdown_1') {
|
||||
_count = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'relay_status') {
|
||||
_relay = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'light_mode') {
|
||||
_light_mode = jsonList[i].value ?? 0;
|
||||
} else if (jsonList[i].code == 'relay_status_1') {
|
||||
relay_status_1 = jsonList[i].value ?? 0;
|
||||
}
|
||||
}
|
||||
return OneTouchModel(
|
||||
firstSwitch: _switch,
|
||||
firstCountDown: _count,
|
||||
);
|
||||
light_mode: _light_mode,
|
||||
relay: StatusExtension.fromString(_relay ) ,
|
||||
relay_status_1: relay_status_1);
|
||||
}
|
||||
}
|
||||
|
@ -31,17 +31,7 @@ class CircularButton extends StatelessWidget {
|
||||
),
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
// () {
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// PageRouteBuilder(
|
||||
// pageBuilder: (context, animation1, animation2) =>
|
||||
// TimerScheduleScreen(
|
||||
// switchCode: 'switch_1',
|
||||
// device: device!,
|
||||
// deviceCode: 'countdown_1',
|
||||
// )));
|
||||
// },
|
||||
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
|
@ -78,7 +78,9 @@ class OneTouchScreen extends StatelessWidget {
|
||||
OneTouchModel oneTouchModel = OneTouchModel(
|
||||
firstSwitch: false,
|
||||
firstCountDown: 0,
|
||||
);
|
||||
light_mode: '',
|
||||
relay: status.off,
|
||||
relay_status_1: '');
|
||||
|
||||
List<GroupOneTouchModel> groupOneTouchModel = [];
|
||||
bool allSwitchesOn = false;
|
||||
@ -193,7 +195,9 @@ class OneTouchScreen extends StatelessWidget {
|
||||
pageBuilder: (context,
|
||||
animation1,
|
||||
animation2) =>
|
||||
OneTouchSetting()));
|
||||
OneTouchSetting(
|
||||
device: device,
|
||||
)));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -1,13 +1,16 @@
|
||||
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/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';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class OneTouchSetting extends StatelessWidget {
|
||||
const OneTouchSetting({super.key, this.device});
|
||||
@ -16,19 +19,22 @@ class OneTouchSetting extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<GroupOneGangModel> groupOneGangModel = [];
|
||||
List<GroupOneTouchModel> groupOneTouchModel = [];
|
||||
|
||||
return DefaultScaffold(
|
||||
title: 'Setting',
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
OneGangBloc(switchCode: '', oneGangId: device?.uuid ?? '')
|
||||
OneTouchBloc(switchCode: '', oneTouchId: device?.uuid ?? '')
|
||||
..add(InitialWizardEvent()),
|
||||
child: BlocBuilder<OneGangBloc, OneGangState>(
|
||||
child: BlocBuilder<OneTouchBloc, OneTouchState>(
|
||||
builder: (context, state) {
|
||||
final oneTouchBloc = BlocProvider.of<OneTouchBloc>(context);
|
||||
|
||||
bool allSwitchesOn = false;
|
||||
|
||||
if (state is UpdateGroupState) {
|
||||
groupOneGangModel = state.oneGangList;
|
||||
groupOneTouchModel = state.oneTouchList;
|
||||
allSwitchesOn = state.allSwitches;
|
||||
}
|
||||
return state is LoadingInitialState
|
||||
@ -38,9 +44,445 @@ class OneTouchSetting extends StatelessWidget {
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: Container();
|
||||
: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: DefaultContainer(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
oneTouchBloc.optionSelected =
|
||||
'relay_status';
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: () {
|
||||
oneTouchBloc.add(ChangeStatusEvent(
|
||||
deviceId: device!.uuid!));
|
||||
},
|
||||
title: 'Restart Status',
|
||||
label1: 'Power Off',
|
||||
label2: 'Power On',
|
||||
label3: 'Restart Memory',
|
||||
onTapLabel1: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel2: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel3: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 10, top: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyLarge(
|
||||
fontSize: 15,
|
||||
text: 'Restart Status',
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text: oneTouchBloc
|
||||
.deviceStatus.relay.value,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
const Divider(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 10, top: 10),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
oneTouchBloc.optionSelected =
|
||||
'light_mode';
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: () {
|
||||
oneTouchBloc.add(
|
||||
const ChangeStatusEvent());
|
||||
},
|
||||
title: 'Indicator Status',
|
||||
label1: 'Off',
|
||||
label2: 'On/Off Status',
|
||||
label3: 'Switch Position',
|
||||
onTapLabel1: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel2: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
onTapLabel3: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: SizedBox(
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyLarge(
|
||||
fontSize: 15,
|
||||
text: 'Indicator Status',
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text: oneTouchBloc
|
||||
.deviceStatus.light_mode,
|
||||
fontColor: ColorsManager.textGray,
|
||||
),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
color: ColorsManager.graysColor,
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 10, top: 10),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
oneTouchBloc.optionSelected =
|
||||
'relay_status_1';
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return RestartStatusDialog(
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: () {},
|
||||
title: 'Restart Status 1',
|
||||
label1: 'Power Off',
|
||||
label2: 'Power On',
|
||||
label3: 'Restart Memory',
|
||||
onTapLabel1: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
print(
|
||||
'Selected: $selected for Label 1');
|
||||
},
|
||||
onTapLabel2: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
print(
|
||||
'Selected: $selected for Label 2');
|
||||
},
|
||||
onTapLabel3: (selected) {
|
||||
oneTouchBloc.statusSelected =
|
||||
selected;
|
||||
print(
|
||||
'Selected: $selected for Label 3');
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const BodyLarge(
|
||||
fontSize: 15,
|
||||
text: 'Restart Status 1',
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
BodyMedium(
|
||||
fontSize: 13,
|
||||
text: oneTouchBloc.deviceStatus
|
||||
.relay_status_1,
|
||||
fontColor:
|
||||
ColorsManager.textGray,
|
||||
),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class RestartStatusDialog extends StatefulWidget {
|
||||
final String label1;
|
||||
final String label2;
|
||||
final String label3;
|
||||
final String title;
|
||||
|
||||
// Add onTap callbacks as parameters
|
||||
final Function(String)? onTapLabel1;
|
||||
final Function(String)? onTapLabel2;
|
||||
final Function(String)? onTapLabel3;
|
||||
final Function()? cancelTab;
|
||||
final Function()? confirmTab;
|
||||
|
||||
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,
|
||||
});
|
||||
|
||||
@override
|
||||
_RestartStatusDialogState createState() => _RestartStatusDialogState();
|
||||
}
|
||||
|
||||
class _RestartStatusDialogState extends State<RestartStatusDialog> {
|
||||
String _selectedOption = '';
|
||||
|
||||
@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, // True if the current option is selected
|
||||
onChanged: (bool? value) {
|
||||
if (value == true) {
|
||||
setState(() {
|
||||
_selectedOption = label; // Select only one option
|
||||
});
|
||||
if (onTap != null) {
|
||||
onTap(label); // Call the passed onTap callback
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class DevicesAPI {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.controlDevice.replaceAll('{deviceUuid}', deviceId),
|
||||
body: controlModel.toJson(),
|
||||
showServerMessage: false,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
@ -72,7 +72,8 @@ class DevicesAPI {
|
||||
|
||||
static Future<Map<String, dynamic>> getDeviceStatus(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{deviceUuid}', deviceId),
|
||||
path: ApiEndpoints.deviceFunctionsStatus
|
||||
.replaceAll('{deviceUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -82,7 +83,9 @@ class DevicesAPI {
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> renamePass(
|
||||
{required String name, required String doorLockUuid, required String passwordId}) async {
|
||||
{required String name,
|
||||
required String doorLockUuid,
|
||||
required String passwordId}) async {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.renamePassword
|
||||
.replaceAll('{doorLockUuid}', doorLockUuid)
|
||||
@ -107,7 +110,8 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDeviceByGroupName(String unitId, String groupName) async {
|
||||
static Future<List<DeviceModel>> getDeviceByGroupName(
|
||||
String unitId, String groupName) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.devicesByGroupName
|
||||
.replaceAll('{unitUuid}', unitId)
|
||||
@ -146,7 +150,8 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||
String gatewayId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||
showServerMessage: false,
|
||||
@ -168,7 +173,8 @@ class DevicesAPI {
|
||||
String deviceId,
|
||||
) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.getTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -179,7 +185,8 @@ class DevicesAPI {
|
||||
|
||||
static Future getOneTimePasswords(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.getOneTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -190,7 +197,8 @@ class DevicesAPI {
|
||||
|
||||
static Future getTimeLimitPasswords(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getMultipleTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.getMultipleTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -215,10 +223,12 @@ class DevicesAPI {
|
||||
"invalidTime": invalidTime,
|
||||
};
|
||||
if (scheduleList != null) {
|
||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
body["scheduleList"] =
|
||||
scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
}
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.addTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
body: body,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json,
|
||||
@ -229,7 +239,8 @@ class DevicesAPI {
|
||||
static Future generateOneTimePassword({deviceId}) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.addOneTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -241,10 +252,12 @@ class DevicesAPI {
|
||||
}
|
||||
}
|
||||
|
||||
static Future generateMultiTimePassword({deviceId, effectiveTime, invalidTime}) async {
|
||||
static Future generateMultiTimePassword(
|
||||
{deviceId, effectiveTime, invalidTime}) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addMultipleTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.addMultipleTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: true,
|
||||
body: {"effectiveTime": effectiveTime, "invalidTime": invalidTime},
|
||||
expectedResponseModel: (json) {
|
||||
|
@ -27,4 +27,5 @@ abstract class ColorsManager {
|
||||
static const Color red = Colors.red;
|
||||
static const Color graysColor = Color(0xffEBEBEB);
|
||||
static const Color textGray = Color(0xffD5D5D5);
|
||||
|
||||
}
|
||||
|
@ -618,3 +618,35 @@ List<Map<String, Object>> members = [
|
||||
'role': MemberRole.FamilyMember,
|
||||
},
|
||||
];
|
||||
|
||||
enum status {
|
||||
on,
|
||||
off,
|
||||
restart,
|
||||
}
|
||||
|
||||
extension StatusExtension on status {
|
||||
String get value {
|
||||
switch (this) {
|
||||
case status.on:
|
||||
return "Power Off";
|
||||
case status.off:
|
||||
return "Power On";
|
||||
case status.restart:
|
||||
return "Restart Memory";
|
||||
}
|
||||
}
|
||||
|
||||
static status fromString(String value) {
|
||||
switch (value) {
|
||||
case "power_off":
|
||||
return status.off;
|
||||
case "power_on":
|
||||
return status.on;
|
||||
case "last":
|
||||
return status.restart;
|
||||
default:
|
||||
throw ArgumentError("Invalid access type: $value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user