mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fix bugs
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'dart:math';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@ -7,6 +8,7 @@ import 'package:syncrow_web/pages/common/hour_picker_dialog.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_event.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_state.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/model/failed_operation.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/model/schedule_model.dart';
|
||||
import 'package:syncrow_web/services/access_mang_api.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
@ -62,7 +64,7 @@ class VisitorPasswordBloc
|
||||
|
||||
String startTimeAccess = 'Start Time';
|
||||
String endTimeAccess = 'End Time';
|
||||
|
||||
PasswordStatus? passwordStatus;
|
||||
selectAccessType(
|
||||
SelectPasswordType event, Emitter<VisitorPasswordState> emit) {
|
||||
accessTypeSelected = event.type;
|
||||
@ -197,26 +199,23 @@ class VisitorPasswordBloc
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
generate7DigitNumber();
|
||||
bool res = await AccessMangApi().postOnlineOneTime(
|
||||
var res = await AccessMangApi().postOnlineOneTime(
|
||||
email: event.email,
|
||||
password: passwordController,
|
||||
devicesUuid: selectedDevices,
|
||||
passwordName: event.passwordName,
|
||||
effectiveTime: effectiveTimeTimeStamp.toString(),
|
||||
invalidTime: expirationTimeTimeStamp.toString());
|
||||
if (res == true) {
|
||||
if(res['statusCode']==201){
|
||||
passwordStatus= PasswordStatus.fromJson(res['data']);
|
||||
emit(SuccessState());
|
||||
} else {
|
||||
throw Exception('Failed to create password');
|
||||
}
|
||||
emit(TableLoaded(data));
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
Navigator.pop(event.context!);
|
||||
stateDialog(
|
||||
context: event.context!,
|
||||
message: e.toString(),
|
||||
title: 'Something Wrong');
|
||||
} on DioException catch (e){
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
print('errorMessage==$errorData');
|
||||
emit(FailedState(errorMessage.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,13 +227,12 @@ class VisitorPasswordBloc
|
||||
emit(LoadingInitialState());
|
||||
|
||||
await generate7DigitNumber();
|
||||
bool res = await AccessMangApi().postOnlineMultipleTime(
|
||||
var res = await AccessMangApi().postOnlineMultipleTime(
|
||||
scheduleList: [
|
||||
if (repeat)
|
||||
Schedule(
|
||||
effectiveTime: getTimeFromDateTimeString(expirationTime),
|
||||
invalidTime:
|
||||
getTimeFromDateTimeString(effectiveTime).toString(),
|
||||
invalidTime: getTimeFromDateTimeString(effectiveTime).toString(),
|
||||
workingDay: selectedDays,
|
||||
),
|
||||
],
|
||||
@ -244,47 +242,42 @@ class VisitorPasswordBloc
|
||||
email: event.email,
|
||||
devicesUuid: selectedDevices,
|
||||
passwordName: event.passwordName);
|
||||
if (res == true) {
|
||||
if(res['statusCode']==201){
|
||||
passwordStatus= PasswordStatus.fromJson(res['data']);
|
||||
emit(SuccessState());
|
||||
}else {
|
||||
throw Exception('Failed to create password');
|
||||
}
|
||||
emit(TableLoaded(data));
|
||||
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
Navigator.pop(event.context!);
|
||||
stateDialog(
|
||||
context: event.context!,
|
||||
message: e.toString(),
|
||||
title: 'Something Wrong');
|
||||
} on DioException catch (e){
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
print('errorMessage==$errorData');
|
||||
emit(FailedState(errorMessage.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
//offline password
|
||||
Future<void> postOfflineOneTimePassword(OfflineOneTimePasswordEvent event,
|
||||
Future<void> postOfflineOneTimePassword(
|
||||
OfflineOneTimePasswordEvent event,
|
||||
Emitter<VisitorPasswordState> emit) async {
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
await generate7DigitNumber();
|
||||
bool res = await AccessMangApi().postOffLineOneTime(
|
||||
var res = await AccessMangApi().postOffLineOneTime(
|
||||
email: event.email,
|
||||
devicesUuid: selectedDevices,
|
||||
passwordName: event.passwordName);
|
||||
if (res == true) {
|
||||
if(res['statusCode']==201){
|
||||
passwordStatus= PasswordStatus.fromJson(res['data']);
|
||||
emit(SuccessState());
|
||||
}else {
|
||||
throw Exception('Failed to create password');
|
||||
}
|
||||
emit(TableLoaded(data));
|
||||
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
Navigator.pop(event.context!);
|
||||
stateDialog(
|
||||
context: event.context!,
|
||||
message: e.toString(),
|
||||
title: 'Something Wrong');
|
||||
} on DioException catch (e){
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
print('errorMessage==$errorData');
|
||||
emit(FailedState(errorMessage.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,27 +287,24 @@ class VisitorPasswordBloc
|
||||
try {
|
||||
emit(LoadingInitialState());
|
||||
await generate7DigitNumber();
|
||||
bool res = await AccessMangApi().postOffLineMultipleTime(
|
||||
var res = await AccessMangApi().postOffLineMultipleTime(
|
||||
email: event.email,
|
||||
devicesUuid: selectedDevices,
|
||||
passwordName: event.passwordName,
|
||||
invalidTime: expirationTimeTimeStamp.toString(),
|
||||
effectiveTime: effectiveTimeTimeStamp.toString(),
|
||||
);
|
||||
if (res == true) {
|
||||
if(res['statusCode']==201){
|
||||
passwordStatus= PasswordStatus.fromJson(res['data']);
|
||||
emit(SuccessState());
|
||||
}else {
|
||||
throw Exception('Failed to create password');
|
||||
}
|
||||
emit(TableLoaded(data));
|
||||
|
||||
} catch (e) {
|
||||
emit(FailedState(e.toString()));
|
||||
Navigator.pop(event.context!);
|
||||
stateDialog(
|
||||
context: event.context!,
|
||||
message: e.toString(),
|
||||
title: 'Something Wrong'); }
|
||||
} on DioException catch (e){
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
print('errorMessage==$errorData');
|
||||
emit(FailedState(errorMessage.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
void selectDevice(
|
||||
@ -476,13 +466,15 @@ class VisitorPasswordBloc
|
||||
String? message,
|
||||
String? title,
|
||||
dynamic actions,
|
||||
Widget? widgeta,
|
||||
}) {
|
||||
return showCustomDialog(
|
||||
context: context!,
|
||||
message: message!,
|
||||
iconPath: Assets.deviceNoteIcon,
|
||||
title: title,
|
||||
dialogHeight: 150,
|
||||
widget: widgeta,
|
||||
dialogHeight: MediaQuery.of(context).size.height*0.3,
|
||||
actions: actions ??
|
||||
<Widget>[
|
||||
TextButton(
|
||||
@ -494,4 +486,31 @@ class VisitorPasswordBloc
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Future<void> stateAndDeviseDialog({
|
||||
// BuildContext? context,
|
||||
// String? message,
|
||||
// String? title,
|
||||
// dynamic actions,
|
||||
// }) {
|
||||
// return showCustomDialog(
|
||||
// context: context!,
|
||||
// message: message!,
|
||||
// iconPath: Assets.deviceNoteIcon,
|
||||
// title: title,
|
||||
// dialogHeight: 150,
|
||||
// actions: actions ??
|
||||
// <Widget>[
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// child: const Text('OK'),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
124
lib/pages/visitor_password/model/failed_operation.dart
Normal file
124
lib/pages/visitor_password/model/failed_operation.dart
Normal file
@ -0,0 +1,124 @@
|
||||
class FailedOperation {
|
||||
final bool success;
|
||||
final dynamic deviceUuid;
|
||||
final dynamic error;
|
||||
|
||||
FailedOperation({
|
||||
required this.success,
|
||||
required this.deviceUuid,
|
||||
required this.error,
|
||||
});
|
||||
|
||||
factory FailedOperation.fromJson(Map<String, dynamic> json) {
|
||||
return FailedOperation(
|
||||
success: json['success'],
|
||||
deviceUuid: json['deviceUuid'],
|
||||
error: json['error'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'success': success,
|
||||
'deviceUuid': deviceUuid,
|
||||
'error': error,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class SuccessOperation {
|
||||
final bool success;
|
||||
// final Result result;
|
||||
final String deviceUuid;
|
||||
|
||||
SuccessOperation({
|
||||
required this.success,
|
||||
// required this.result,
|
||||
required this.deviceUuid,
|
||||
});
|
||||
|
||||
factory SuccessOperation.fromJson(Map<String, dynamic> json) {
|
||||
return SuccessOperation(
|
||||
success: json['success'],
|
||||
// result: Result.fromJson(json['result']),
|
||||
deviceUuid: json['deviceUuid'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'success': success,
|
||||
// 'result': result.toJson(),
|
||||
'deviceUuid': deviceUuid,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// class Result {
|
||||
// final dynamic effectiveTime;
|
||||
// final dynamic invalidTime;
|
||||
// final dynamic offlineTempPassword;
|
||||
// final dynamic offlineTempPasswordId;
|
||||
// final dynamic offlineTempPasswordName;
|
||||
//
|
||||
// Result({
|
||||
// required this.effectiveTime,
|
||||
// required this.invalidTime,
|
||||
// required this.offlineTempPassword,
|
||||
// required this.offlineTempPasswordId,
|
||||
// required this.offlineTempPasswordName,
|
||||
// });
|
||||
//
|
||||
// factory Result.fromJson(Map<String, dynamic> json) {
|
||||
// return Result(
|
||||
// effectiveTime: json['effective_time'],
|
||||
// invalidTime: json['invalid_time'],
|
||||
// offlineTempPassword: json['offline_temp_password'].toString(),
|
||||
// offlineTempPasswordId: json['offline_temp_password_id'],
|
||||
// offlineTempPasswordName: json['offline_temp_password_name'],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// return {
|
||||
// 'effective_time': effectiveTime,
|
||||
// 'invalid_time': invalidTime,
|
||||
// 'offline_temp_password': offlineTempPassword,
|
||||
// 'offline_temp_password_id': offlineTempPasswordId,
|
||||
// 'offline_temp_password_name': offlineTempPasswordName,
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
class PasswordStatus {
|
||||
final List<SuccessOperation> successOperations;
|
||||
final List<FailedOperation> failedOperations;
|
||||
|
||||
PasswordStatus({
|
||||
required this.successOperations,
|
||||
required this.failedOperations,
|
||||
});
|
||||
|
||||
factory PasswordStatus.fromJson(Map<String, dynamic> json) {
|
||||
return PasswordStatus(
|
||||
successOperations: (json['successOperations'] as List)
|
||||
.map((i) => SuccessOperation.fromJson(i))
|
||||
.toList(),
|
||||
failedOperations: (json['failedOperations'] as List)
|
||||
.map((i) => FailedOperation.fromJson(i))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'successOperations': successOperations.map((e) => e.toJson()).toList(),
|
||||
'failedOperations': failedOperations.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,56 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
context: context,
|
||||
message: 'Password Created Successfully',
|
||||
title: 'Send Success',
|
||||
widgeta:Column(
|
||||
children: [
|
||||
if(visitorBloc.passwordStatus!.failedOperations.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
const Text('Failed Devises'),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
|
||||
shrinkWrap: true,
|
||||
itemCount:visitorBloc.passwordStatus!.failedOperations.length ,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(5),
|
||||
|
||||
decoration: containerDecoration,
|
||||
height: 45,
|
||||
child: Center(child: Text(visitorBloc.passwordStatus!.failedOperations[index].deviceUuid)),
|
||||
);
|
||||
},),
|
||||
),
|
||||
],
|
||||
),
|
||||
if(visitorBloc.passwordStatus!.successOperations.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
const Text('Success Devises'),
|
||||
SizedBox(
|
||||
width: 200,
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
itemCount:visitorBloc.passwordStatus!.successOperations.length ,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
margin: EdgeInsets.all(5),
|
||||
decoration: containerDecoration,
|
||||
height: 45,
|
||||
child: Center(child: Text(visitorBloc.passwordStatus!.successOperations[index].deviceUuid)),
|
||||
);
|
||||
},),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
} else if (state is FailedState) {
|
||||
visitorBloc.stateDialog(
|
||||
@ -110,68 +160,92 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text('Online Password',
|
||||
style: text,
|
||||
),
|
||||
value: 'Online Password',
|
||||
groupValue: (state is PasswordTypeSelected)
|
||||
? state.selectedType
|
||||
: visitorBloc.accessTypeSelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<VisitorPasswordBloc>()
|
||||
.add(SelectPasswordType(value));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
||||
title: Text('Offline Password',
|
||||
style:text ),
|
||||
value: 'Offline Password',
|
||||
groupValue: (state is PasswordTypeSelected)
|
||||
? state.selectedType
|
||||
: visitorBloc.accessTypeSelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<VisitorPasswordBloc>().add(SelectPasswordType(value));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
|
||||
title: Text('Dynamic Password',
|
||||
style: text,),
|
||||
value: 'Dynamic Password',
|
||||
groupValue: (state is PasswordTypeSelected)
|
||||
? state.selectedType
|
||||
: visitorBloc.accessTypeSelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<VisitorPasswordBloc>()
|
||||
.add(SelectPasswordType(value));
|
||||
visitorBloc.usageFrequencySelected = '';
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: size.width*0.12,
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text('Online Password',
|
||||
style: text,
|
||||
),
|
||||
value: 'Online Password',
|
||||
groupValue: (state is PasswordTypeSelected)
|
||||
? state.selectedType
|
||||
: visitorBloc.accessTypeSelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<VisitorPasswordBloc>()
|
||||
.add(SelectPasswordType(value));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: size.width*0.12,
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text('Offline Password',
|
||||
style:text ),
|
||||
value: 'Offline Password',
|
||||
groupValue: (state is PasswordTypeSelected)
|
||||
? state.selectedType
|
||||
: visitorBloc.accessTypeSelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<VisitorPasswordBloc>().add(SelectPasswordType(value));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: size.width*0.12,
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text('Dynamic Password',
|
||||
style: text,),
|
||||
value: 'Dynamic Password',
|
||||
groupValue: (state is PasswordTypeSelected)
|
||||
? state.selectedType
|
||||
: visitorBloc.accessTypeSelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<VisitorPasswordBloc>()
|
||||
.add(SelectPasswordType(value));
|
||||
visitorBloc.usageFrequencySelected = '';
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
const Spacer(flex: 2,),
|
||||
],
|
||||
),
|
||||
if(visitorBloc.accessTypeSelected == 'Online Password')
|
||||
Text(
|
||||
'Only currently online devices can be selected. It is recommended to use when the device network is stable, and the system randomly generates a digital password',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: ColorsManager.grayColor,fontSize: 9),
|
||||
),
|
||||
if(visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
Text(
|
||||
'Unaffected by the online status of the device, you can select online or offline device, and the system randomly generates a digital password',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: ColorsManager.grayColor,fontSize: 9),),
|
||||
|
||||
if(visitorBloc.accessTypeSelected == 'Dynamic Password')
|
||||
Text(
|
||||
'Quick and short-acting password, only valid within 5 minutes after creation, the system randomly generates a digital password.',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
color: ColorsManager.grayColor,fontSize: 9),),
|
||||
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
)
|
||||
@ -179,7 +253,7 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
),
|
||||
visitorBloc.accessTypeSelected == 'Dynamic Password'
|
||||
? const SizedBox()
|
||||
: Column(
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
@ -193,7 +267,8 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
SizedBox(
|
||||
width: size.width*0.12,
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text('One-Time',
|
||||
@ -205,13 +280,13 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
: visitorBloc.usageFrequencySelected,
|
||||
onChanged: (String? value) {
|
||||
if (value != null) {
|
||||
context.read<VisitorPasswordBloc>()
|
||||
.add(SelectUsageFrequency(value));
|
||||
context.read<VisitorPasswordBloc>().add(SelectUsageFrequency(value));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
SizedBox(
|
||||
width: size.width*0.12,
|
||||
child: RadioListTile<String>(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text('Periodic',
|
||||
@ -230,10 +305,35 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
//One-Time
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password')
|
||||
Text('Within the validity period, each device can be unlocked only once.',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,fontSize: 9),
|
||||
)
|
||||
),
|
||||
if (visitorBloc.usageFrequencySelected == 'One-Time' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
Text('Within the validity period, there is no limit to the number of times each device can be unlocked.',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,fontSize: 9),
|
||||
),
|
||||
|
||||
// Periodic
|
||||
if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')
|
||||
Text('Within the validity period, there is no limit to the number of times each device can be unlocked, and it should be used at least once within 24 hours after the entry into force.',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,fontSize: 9),
|
||||
),
|
||||
|
||||
if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Online Password')
|
||||
Text('Within the validity period, there is no limit to the number of times each device can be unlocked.',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,fontSize: 9),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
@ -247,19 +347,37 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
title: 'Access Period',
|
||||
size: size,
|
||||
endTime: () {
|
||||
visitorBloc.add(SelectTimeVisitorPassword(
|
||||
context: context,
|
||||
isStart: false,
|
||||
isRepeat: false));
|
||||
if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password'){
|
||||
visitorBloc.add(SelectTimeEvent(
|
||||
context: context,
|
||||
isEffective: false));
|
||||
}else{
|
||||
visitorBloc.add(SelectTimeVisitorPassword(
|
||||
context: context,
|
||||
isStart: false,
|
||||
isRepeat: false));
|
||||
}
|
||||
},
|
||||
startTime: () {
|
||||
visitorBloc.add(SelectTimeVisitorPassword(
|
||||
context: context,
|
||||
isStart: true,
|
||||
isRepeat: false));
|
||||
if (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password'){
|
||||
visitorBloc.add(SelectTimeEvent(context: context, isEffective: true));
|
||||
}else{
|
||||
visitorBloc.add(SelectTimeVisitorPassword(
|
||||
context: context,
|
||||
isStart: true,
|
||||
isRepeat: false));
|
||||
}
|
||||
},
|
||||
firstString: visitorBloc.startTimeAccess.toString(),
|
||||
secondString: visitorBloc.endTimeAccess.toString(),
|
||||
|
||||
firstString:
|
||||
(visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')?
|
||||
visitorBloc.effectiveTime:visitorBloc.startTimeAccess.toString(),
|
||||
secondString: (visitorBloc.usageFrequencySelected == 'Periodic' &&
|
||||
visitorBloc.accessTypeSelected == 'Offline Password')?
|
||||
visitorBloc.expirationTime:visitorBloc.endTimeAccess.toString(),
|
||||
icon: Assets.calendarIcon
|
||||
),
|
||||
const SizedBox(
|
||||
@ -367,12 +485,26 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
onPressed: () {
|
||||
if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
||||
if(visitorBloc.selectedDevices.isNotEmpty){
|
||||
if(visitorBloc.effectiveTimeTimeStamp!=null&&visitorBloc.expirationTimeTimeStamp!=null) {
|
||||
if(visitorBloc.usageFrequencySelected == 'One-Time' && visitorBloc.accessTypeSelected == 'Offline Password'){
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
}
|
||||
else{
|
||||
visitorBloc.stateDialog(context:
|
||||
context,message: 'Please select Access Period to continue',title: 'Access Period');
|
||||
}else{
|
||||
if(visitorBloc.effectiveTimeTimeStamp!=null&&visitorBloc.expirationTimeTimeStamp!=null) {
|
||||
if(isRepeat==true){
|
||||
if(visitorBloc.expirationTime!='End Time'&&visitorBloc.effectiveTime!='Start Time'&&visitorBloc.selectedDays.isNotEmpty){
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
}
|
||||
else{
|
||||
visitorBloc.stateDialog(context:
|
||||
context,message: 'Please select days and fill start time and end time to continue',title: 'Access Period');
|
||||
}
|
||||
}else{
|
||||
setPasswordFunction(context, size, visitorBloc);
|
||||
}
|
||||
}
|
||||
else{
|
||||
visitorBloc.stateDialog(context:
|
||||
context,message: 'Please select Access Period to continue',title: 'Access Period');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
visitorBloc.stateDialog(context:
|
||||
@ -380,6 +512,57 @@ class VisitorPasswordDialog extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// onPressed: () {
|
||||
// if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
||||
// if (visitorBloc.selectedDevices.isNotEmpty) {
|
||||
// switch (visitorBloc.usageFrequencySelected) {
|
||||
// case 'One-Time':
|
||||
// if (visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||
// setPasswordFunction(context, size, visitorBloc);
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Invalid combination of Access Type and Usage Frequency.',
|
||||
// title: 'Error',
|
||||
// );
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// if (visitorBloc.effectiveTimeTimeStamp != null && visitorBloc.expirationTimeTimeStamp != null) {
|
||||
// if (isRepeat) {
|
||||
// if (visitorBloc.expirationTime != 'End Time' &&
|
||||
// visitorBloc.effectiveTime != 'Start Time' &&
|
||||
// visitorBloc.selectedDays.isNotEmpty) {
|
||||
// setPasswordFunction(context, size, visitorBloc);
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Please select days and fill start time and end time to continue',
|
||||
// title: 'Access Period',
|
||||
// );
|
||||
// }
|
||||
// } else {
|
||||
// setPasswordFunction(context, size, visitorBloc);
|
||||
// }
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Please select Access Period to continue',
|
||||
// title: 'Access Period',
|
||||
// );
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
// visitorBloc.stateDialog(
|
||||
// context: context,
|
||||
// message: 'Please select devices to continue',
|
||||
// title: 'Select Devices',
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
borderRadius: 8,
|
||||
child: Text('Ok', style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
|
Reference in New Issue
Block a user