Compare commits

..

2 Commits

10 changed files with 76 additions and 92 deletions

View File

@ -6,6 +6,7 @@ import 'package:syncrow_web/pages/device_managment/garage_door/bloc/garage_door_
import 'package:syncrow_web/pages/device_managment/garage_door/helper/garage_door_helper.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/helper/garage_door_helper.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/models/garage_door_model.dart';
import 'package:syncrow_web/pages/device_managment/garage_door/schedule_view/schedule_garage_view.dart'; import 'package:syncrow_web/pages/device_managment/garage_door/schedule_view/schedule_garage_view.dart';
import 'package:syncrow_web/pages/device_managment/schedule_device/schedule_widgets/schedual_view.dart';
import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart'; import 'package:syncrow_web/pages/device_managment/shared/icon_name_status_container.dart';
import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart'; import 'package:syncrow_web/pages/device_managment/shared/table/report_table.dart';
import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart'; import 'package:syncrow_web/pages/device_managment/shared/toggle_widget.dart';
@ -94,11 +95,18 @@ class GarageDoorControlView extends StatelessWidget
FetchGarageDoorSchedulesEvent( FetchGarageDoorSchedulesEvent(
deviceId: deviceId, category: 'doorcontact_state'), deviceId: deviceId, category: 'doorcontact_state'),
); );
showDialog(
showDialog<void>(
context: context, context: context,
builder: (ctx) => BlocProvider.value( builder: (ctx) => BlocProvider.value(
value: BlocProvider.of<GarageDoorBloc>(context), value: BlocProvider.of<GarageDoorBloc>(context),
child: BuildGarageDoorScheduleView(status: status), child: BuildScheduleView(
deviceUuid: deviceId,
category: 'Timer',
code: 'doorcontact_state',
countdownCode: 'Timer',
deviceType: 'GD',
),
)); ));
}, },
name: 'Scheduling', name: 'Scheduling',

View File

@ -287,7 +287,8 @@ class ScheduleBloc extends Bloc<ScheduleEvent, ScheduleState> {
try { try {
if (state is ScheduleLoaded) { if (state is ScheduleLoaded) {
Status status = Status(code: '', value: ''); Status status = Status(code: '', value: '');
if (event.deviceType == 'CUR_2') { if (event.deviceType == 'CUR_2' ||
event.deviceType == 'GD' ) {
status = status.copyWith( status = status.copyWith(
code: 'control', code: 'control',
value: event.functionOn == true ? 'open' : 'close'); value: event.functionOn == true ? 'open' : 'close');

View File

@ -69,7 +69,7 @@ class CountdownModeButtons extends StatelessWidget {
countDownCode: countDownCode), countDownCode: countDownCode),
); );
}, },
backgroundColor: ColorsManager.primaryColorWithOpacity, backgroundColor: ColorsManager.secondaryColor,
child: const Text('Save'), child: const Text('Save'),
), ),
), ),

View File

@ -63,7 +63,7 @@ class InchingModeButtons extends StatelessWidget {
), ),
); );
}, },
backgroundColor: ColorsManager.primaryColor, backgroundColor: ColorsManager.secondaryColor,
child: const Text('Save'), child: const Text('Save'),
), ),
), ),

View File

@ -31,11 +31,12 @@ class BuildScheduleView extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider( return BlocProvider(
create: (_) => ScheduleBloc(deviceId: deviceUuid,) create: (_) => ScheduleBloc(
deviceId: deviceUuid,
)
..add(ScheduleGetEvent(category: category)) ..add(ScheduleGetEvent(category: category))
..add(ScheduleFetchStatusEvent( ..add(ScheduleFetchStatusEvent(
deviceId: deviceUuid, deviceId: deviceUuid, countdownCode: countdownCode ?? '')),
countdownCode: countdownCode ?? '')),
child: Dialog( child: Dialog(
backgroundColor: Colors.white, backgroundColor: Colors.white,
insetPadding: const EdgeInsets.all(20), insetPadding: const EdgeInsets.all(20),
@ -56,7 +57,7 @@ class BuildScheduleView extends StatelessWidget {
children: [ children: [
const ScheduleHeader(), const ScheduleHeader(),
const SizedBox(height: 20), const SizedBox(height: 20),
if (deviceType == 'CUR_2') if (deviceType == 'CUR_2' || deviceType == 'GD')
const SizedBox() const SizedBox()
else else
ScheduleModeSelector( ScheduleModeSelector(
@ -76,8 +77,7 @@ class BuildScheduleView extends StatelessWidget {
category: category, category: category,
time: '', time: '',
function: Status( function: Status(
code: code.toString(), code: code.toString(), value: true),
value: true),
days: [], days: [],
), ),
isEdit: false, isEdit: false,
@ -96,7 +96,7 @@ class BuildScheduleView extends StatelessWidget {
} }
}, },
), ),
if (deviceType != 'CUR_2') if (deviceType != 'CUR_2'|| deviceType != 'GD')
if (state.scheduleMode == ScheduleModes.countdown || if (state.scheduleMode == ScheduleModes.countdown ||
state.scheduleMode == ScheduleModes.inching) state.scheduleMode == ScheduleModes.inching)
CountdownInchingView( CountdownInchingView(

View File

@ -24,12 +24,13 @@ class ScheduleManagementUI extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox( SizedBox(
width: 170, width: 177,
height: 40, height: 40,
child: DefaultButton( child: DefaultButton(
borderColor: ColorsManager.grayColor.withOpacity(0.5), borderWidth: 4,
padding: 2, borderColor: ColorsManager.neutralGray,
backgroundColor: ColorsManager.graysColor, padding: 8,
backgroundColor: ColorsManager.textFieldGreyColor,
borderRadius: 15, borderRadius: 15,
onPressed: onAddSchedule, onPressed: onAddSchedule,
child: Row( child: Row(

View File

@ -39,7 +39,7 @@ class ScheduleModeButtons extends StatelessWidget {
borderRadius: 8, borderRadius: 8,
height: 40, height: 40,
onPressed: onSave, onPressed: onSave,
backgroundColor: ColorsManager.primaryColorWithOpacity, backgroundColor: ColorsManager.secondaryColor,
child: const Text('Save'), child: const Text('Save'),
), ),
), ),

View File

@ -194,7 +194,7 @@ class _ScheduleTableView extends StatelessWidget {
child: Text(_getSelectedDays( child: Text(_getSelectedDays(
ScheduleModel.parseSelectedDays(schedule.days)))), ScheduleModel.parseSelectedDays(schedule.days)))),
Center(child: Text(formatIsoStringToTime(schedule.time, context))), Center(child: Text(formatIsoStringToTime(schedule.time, context))),
if (deviceType == 'CUR_2') if (deviceType == 'CUR_2' || deviceType == 'GD')
Center( Center(
child: Text(schedule.function.value == true ? 'open' : 'close')) child: Text(schedule.function.value == true ? 'open' : 'close'))
else else

View File

@ -23,7 +23,7 @@ class ScheduleDialogHelper {
required String deviceType, required String deviceType,
}) { }) {
bool temp; bool temp;
if (deviceType == 'CUR_2') { if (deviceType == 'CUR_2' || deviceType == 'GD') {
temp = schedule!.function.value == 'open' ? true : false; temp = schedule!.function.value == 'open' ? true : false;
} else { } else {
temp = schedule!.function.value; temp = schedule!.function.value;
@ -116,7 +116,7 @@ class ScheduleDialogHelper {
ScheduleModeButtons( ScheduleModeButtons(
onSave: () { onSave: () {
dynamic temp; dynamic temp;
if (deviceType == 'CUR_2') { if (deviceType == 'CUR_2' || deviceType == 'GD') {
temp = functionOn! ? 'open' : 'close'; temp = functionOn! ? 'open' : 'close';
} else { } else {
temp = functionOn; temp = functionOn;
@ -202,18 +202,23 @@ class ScheduleDialogHelper {
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
Radio<bool>( Radio<bool>(
activeColor: ColorsManager.secondaryColor,
focusColor: ColorsManager.secondaryColor,
value: true, value: true,
groupValue: isOn, groupValue: isOn,
onChanged: (val) => onChanged(true), onChanged: (val) => onChanged(true),
), ),
Text(categor == 'CUR_2' ? 'open' : 'On'), Text(categor == 'CUR_2' || categor == 'GD' ? 'open' : 'On'),
const SizedBox(width: 10), const SizedBox(width: 10),
Radio<bool>( Radio<bool>(
activeColor: ColorsManager.secondaryColor,
focusColor: ColorsManager.secondaryColor,
value: false, value: false,
groupValue: isOn, groupValue: isOn,
onChanged: (val) => onChanged(false), onChanged: (val) => onChanged(false),
), ),
Text(categor == 'CUR_2' ? 'close' : 'Off'), Text(categor == 'CUR_2' || categor == 'GD' ? 'close' : 'Off'),
], ],
); );
} }

View File

@ -39,8 +39,7 @@ class VisitorPasswordDialog extends StatelessWidget {
title: 'Sent Successfully', title: 'Sent Successfully',
widgeta: Column( widgeta: Column(
children: [ children: [
if (visitorBloc if (visitorBloc.passwordStatus!.failedOperations.isNotEmpty)
.passwordStatus!.failedOperations.isNotEmpty)
Column( Column(
children: [ children: [
const Text('Failed Devices'), const Text('Failed Devices'),
@ -55,23 +54,18 @@ class VisitorPasswordDialog extends StatelessWidget {
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Container( return Container(
margin: const EdgeInsets.all(5), margin: const EdgeInsets.all(5),
padding: const EdgeInsets.symmetric(
horizontal: 10),
decoration: containerDecoration, decoration: containerDecoration,
height: 45, height: 45,
child: Center( child: Center(
child: Text(visitorBloc child: Text(visitorBloc.passwordStatus!
.passwordStatus! .failedOperations[index].deviceName)),
.failedOperations[index]
.deviceName)),
); );
}, },
), ),
), ),
], ],
), ),
if (visitorBloc if (visitorBloc.passwordStatus!.successOperations.isNotEmpty)
.passwordStatus!.successOperations.isNotEmpty)
Column( Column(
children: [ children: [
const Text('Success Devices'), const Text('Success Devices'),
@ -86,15 +80,11 @@ class VisitorPasswordDialog extends StatelessWidget {
itemBuilder: (context, index) { itemBuilder: (context, index) {
return Container( return Container(
margin: const EdgeInsets.all(5), margin: const EdgeInsets.all(5),
padding: const EdgeInsets.symmetric(
horizontal: 10),
decoration: containerDecoration, decoration: containerDecoration,
height: 45, height: 45,
child: Center( child: Center(
child: Text(visitorBloc child: Text(visitorBloc.passwordStatus!
.passwordStatus! .successOperations[index].deviceName)),
.successOperations[index]
.deviceName)),
); );
}, },
), ),
@ -124,9 +114,7 @@ class VisitorPasswordDialog extends StatelessWidget {
title: Text( title: Text(
'Create visitor password', 'Create visitor password',
style: Theme.of(context).textTheme.headlineLarge!.copyWith( style: Theme.of(context).textTheme.headlineLarge!.copyWith(
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400, fontSize: 24, color: Colors.black),
fontSize: 24,
color: Colors.black),
), ),
content: state is LoadingInitialState content: state is LoadingInitialState
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
@ -312,14 +300,12 @@ class VisitorPasswordDialog extends StatelessWidget {
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected ==
'Offline Password') { 'Offline Password') {
visitorBloc.add(SelectTimeEvent( visitorBloc.add(SelectTimeEvent(
context: context, context: context, isEffective: false));
isEffective: false));
} else { } else {
visitorBloc.add( visitorBloc.add(SelectTimeVisitorPassword(
SelectTimeVisitorPassword( context: context,
context: context, isStart: false,
isStart: false, isRepeat: false));
isRepeat: false));
} }
}, },
startTime: () { startTime: () {
@ -328,23 +314,21 @@ class VisitorPasswordDialog extends StatelessWidget {
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected ==
'Offline Password') { 'Offline Password') {
visitorBloc.add(SelectTimeEvent( visitorBloc.add(SelectTimeEvent(
context: context, context: context, isEffective: true));
isEffective: true));
} else { } else {
visitorBloc.add( visitorBloc.add(SelectTimeVisitorPassword(
SelectTimeVisitorPassword( context: context,
context: context, isStart: true,
isStart: true, isRepeat: false));
isRepeat: false));
} }
}, },
firstString: (visitorBloc firstString:
.usageFrequencySelected == (visitorBloc.usageFrequencySelected ==
'Periodic' && 'Periodic' &&
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected ==
'Offline Password') 'Offline Password')
? visitorBloc.effectiveTime ? visitorBloc.effectiveTime
: visitorBloc.startTimeAccess, : visitorBloc.startTimeAccess,
secondString: (visitorBloc secondString: (visitorBloc
.usageFrequencySelected == .usageFrequencySelected ==
'Periodic' && 'Periodic' &&
@ -411,8 +395,7 @@ class VisitorPasswordDialog extends StatelessWidget {
child: CupertinoSwitch( child: CupertinoSwitch(
value: visitorBloc.repeat, value: visitorBloc.repeat,
onChanged: (value) { onChanged: (value) {
visitorBloc visitorBloc.add(ToggleRepeatEvent());
.add(ToggleRepeatEvent());
}, },
applyTheme: true, applyTheme: true,
), ),
@ -443,8 +426,7 @@ class VisitorPasswordDialog extends StatelessWidget {
}, },
).then((listDevice) { ).then((listDevice) {
if (listDevice != null) { if (listDevice != null) {
visitorBloc.selectedDevices = visitorBloc.selectedDevices = listDevice;
listDevice;
} }
}); });
}, },
@ -456,8 +438,7 @@ class VisitorPasswordDialog extends StatelessWidget {
.bodySmall! .bodySmall!
.copyWith( .copyWith(
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
color: color: ColorsManager.whiteColors,
ColorsManager.whiteColors,
fontSize: 12), fontSize: 12),
), ),
), ),
@ -496,23 +477,19 @@ class VisitorPasswordDialog extends StatelessWidget {
onPressed: () { onPressed: () {
if (visitorBloc.forgetFormKey.currentState!.validate()) { if (visitorBloc.forgetFormKey.currentState!.validate()) {
if (visitorBloc.selectedDevices.isNotEmpty) { if (visitorBloc.selectedDevices.isNotEmpty) {
if (visitorBloc.usageFrequencySelected == if (visitorBloc.usageFrequencySelected == 'One-Time' &&
'One-Time' && visitorBloc.accessTypeSelected == 'Offline Password') {
visitorBloc.accessTypeSelected ==
'Offline Password') {
setPasswordFunction(context, size, visitorBloc); setPasswordFunction(context, size, visitorBloc);
} else if (visitorBloc.usageFrequencySelected == } else if (visitorBloc.usageFrequencySelected ==
'Periodic' && 'Periodic' &&
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected == 'Offline Password') {
'Offline Password') {
if (visitorBloc.expirationTime != 'End Time' && if (visitorBloc.expirationTime != 'End Time' &&
visitorBloc.effectiveTime != 'Start Time') { visitorBloc.effectiveTime != 'Start Time') {
setPasswordFunction(context, size, visitorBloc); setPasswordFunction(context, size, visitorBloc);
} else { } else {
visitorBloc.stateDialog( visitorBloc.stateDialog(
context: context, context: context,
message: message: 'Please select Access Period to continue',
'Please select Access Period to continue',
title: 'Access Period'); title: 'Access Period');
} }
} else if (visitorBloc.endTimeAccess != 'End Time' && } else if (visitorBloc.endTimeAccess != 'End Time' &&
@ -523,8 +500,7 @@ class VisitorPasswordDialog extends StatelessWidget {
if (visitorBloc.expirationTime != 'End Time' && if (visitorBloc.expirationTime != 'End Time' &&
visitorBloc.effectiveTime != 'Start Time' && visitorBloc.effectiveTime != 'Start Time' &&
visitorBloc.selectedDays.isNotEmpty) { visitorBloc.selectedDays.isNotEmpty) {
setPasswordFunction( setPasswordFunction(context, size, visitorBloc);
context, size, visitorBloc);
} else { } else {
visitorBloc.stateDialog( visitorBloc.stateDialog(
context: context, context: context,
@ -538,15 +514,13 @@ class VisitorPasswordDialog extends StatelessWidget {
} else { } else {
visitorBloc.stateDialog( visitorBloc.stateDialog(
context: context, context: context,
message: message: 'Please select Access Period to continue',
'Please select Access Period to continue',
title: 'Access Period'); title: 'Access Period');
} }
} else { } else {
visitorBloc.stateDialog( visitorBloc.stateDialog(
context: context, context: context,
message: message: 'Please select Access Period to continue',
'Please select Access Period to continue',
title: 'Access Period'); title: 'Access Period');
} }
} else { } else {
@ -593,8 +567,7 @@ class VisitorPasswordDialog extends StatelessWidget {
content: SizedBox( content: SizedBox(
height: size.height * 0.25, height: size.height * 0.25,
child: const Center( child: const Center(
child: child: CircularProgressIndicator(), // Display a loading spinner
CircularProgressIndicator(), // Display a loading spinner
), ),
), ),
); );
@ -667,8 +640,7 @@ class VisitorPasswordDialog extends StatelessWidget {
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
if (visitorBloc.usageFrequencySelected == 'One-Time' && if (visitorBloc.usageFrequencySelected == 'One-Time' &&
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected == 'Online Password') {
'Online Password') {
visitorBloc.add(OnlineOneTimePasswordEvent( visitorBloc.add(OnlineOneTimePasswordEvent(
context: context, context: context,
passwordName: visitorBloc.userNameController.text, passwordName: visitorBloc.userNameController.text,
@ -676,8 +648,7 @@ class VisitorPasswordDialog extends StatelessWidget {
)); ));
} else if (visitorBloc.usageFrequencySelected == } else if (visitorBloc.usageFrequencySelected ==
'Periodic' && 'Periodic' &&
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected == 'Online Password') {
'Online Password') {
visitorBloc.add(OnlineMultipleTimePasswordEvent( visitorBloc.add(OnlineMultipleTimePasswordEvent(
passwordName: visitorBloc.userNameController.text, passwordName: visitorBloc.userNameController.text,
email: visitorBloc.emailController.text, email: visitorBloc.emailController.text,
@ -688,8 +659,7 @@ class VisitorPasswordDialog extends StatelessWidget {
)); ));
} else if (visitorBloc.usageFrequencySelected == } else if (visitorBloc.usageFrequencySelected ==
'One-Time' && 'One-Time' &&
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected == 'Offline Password') {
'Offline Password') {
visitorBloc.add(OfflineOneTimePasswordEvent( visitorBloc.add(OfflineOneTimePasswordEvent(
context: context, context: context,
passwordName: visitorBloc.userNameController.text, passwordName: visitorBloc.userNameController.text,
@ -697,8 +667,7 @@ class VisitorPasswordDialog extends StatelessWidget {
)); ));
} else if (visitorBloc.usageFrequencySelected == } else if (visitorBloc.usageFrequencySelected ==
'Periodic' && 'Periodic' &&
visitorBloc.accessTypeSelected == visitorBloc.accessTypeSelected == 'Offline Password') {
'Offline Password') {
visitorBloc.add(OfflineMultipleTimePasswordEvent( visitorBloc.add(OfflineMultipleTimePasswordEvent(
passwordName: visitorBloc.userNameController.text, passwordName: visitorBloc.userNameController.text,
email: visitorBloc.emailController.text, email: visitorBloc.emailController.text,