mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
padding and text them
This commit is contained in:
@ -59,7 +59,7 @@ class MyApp extends StatelessWidget {
|
|||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), // Set up color scheme
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), // Set up color scheme
|
||||||
useMaterial3: true, // Enable Material 3
|
useMaterial3: true, // Enable Material 3
|
||||||
),
|
),
|
||||||
// home: AddDeviceDialog()
|
// home: VisitorPasswordDialog()
|
||||||
home:isLoggedIn == 'Success' ? const HomePage() : const LoginPage(),
|
home:isLoggedIn == 'Success' ? const HomePage() : const LoginPage(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,15 @@ class CustomWebTextField extends StatelessWidget {
|
|||||||
.bodyMedium!
|
.bodyMedium!
|
||||||
.copyWith(color: Colors.red),
|
.copyWith(color: Colors.red),
|
||||||
),
|
),
|
||||||
Text(textFieldName),
|
Text(textFieldName,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10,),
|
const SizedBox(width: 10,),
|
||||||
Text(
|
Expanded(
|
||||||
description??'', // ' The password will be sent to the visitor’s email address.',
|
child: Text(
|
||||||
|
description??'',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
@ -51,6 +54,7 @@ class CustomWebTextField extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
color: ColorsManager.textGray),
|
color: ColorsManager.textGray),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 7,),
|
const SizedBox(height: 7,),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
@ -39,7 +40,8 @@ class DateTimeWebWidget extends StatelessWidget {
|
|||||||
.bodyMedium!
|
.bodyMedium!
|
||||||
.copyWith(color: Colors.red),
|
.copyWith(color: Colors.red),
|
||||||
),
|
),
|
||||||
Text(title??''),
|
Text(title??'' , style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 8,),
|
SizedBox(height: 8,),
|
||||||
@ -55,12 +57,14 @@ class DateTimeWebWidget extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: startTime,
|
onTap: startTime,
|
||||||
child: Text(firstString)
|
child: Text(firstString, style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: ColorsManager.grayColor,fontSize: 12,fontWeight: FontWeight.w400),)
|
||||||
),
|
),
|
||||||
const Icon(Icons.arrow_right_alt),
|
const Icon(Icons.arrow_right_alt),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap:endTime,
|
onTap:endTime,
|
||||||
child: Text(secondString)),
|
child: Text(secondString, style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: ColorsManager.grayColor,fontSize: 12,fontWeight: FontWeight.w400),)),
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
Assets.calendarIcon,
|
Assets.calendarIcon,
|
||||||
),
|
),
|
||||||
|
92
lib/pages/common/hour_picker_dialog.dart
Normal file
92
lib/pages/common/hour_picker_dialog.dart
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class HourPickerDialog extends StatefulWidget {
|
||||||
|
final TimeOfDay initialTime;
|
||||||
|
HourPickerDialog({required this.initialTime});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_HourPickerDialogState createState() => _HourPickerDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HourPickerDialogState extends State<HourPickerDialog> {
|
||||||
|
late int _selectedHour;
|
||||||
|
bool _isPm = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_selectedHour = widget.initialTime.hour > 12 ? widget.initialTime.hour - 12 : widget.initialTime.hour;
|
||||||
|
_isPm = widget.initialTime.period == DayPeriod.pm;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text('Select Hour'),
|
||||||
|
content: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
DropdownButton<int>(
|
||||||
|
value: _selectedHour,
|
||||||
|
items: List.generate(12, (index) {
|
||||||
|
int displayHour = index + 1;
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: displayHour,
|
||||||
|
child: Text(displayHour.toString()),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
_selectedHour = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(width: 16.0),
|
||||||
|
DropdownButton<bool>(
|
||||||
|
value: _isPm,
|
||||||
|
items: [
|
||||||
|
DropdownMenuItem(
|
||||||
|
value: false,
|
||||||
|
child: Text('AM'),
|
||||||
|
),
|
||||||
|
DropdownMenuItem(
|
||||||
|
value: true,
|
||||||
|
child: Text('PM'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
_isPm = value!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(null),
|
||||||
|
child: Text('Cancel'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
int hour = _isPm ? _selectedHour + 12 : _selectedHour;
|
||||||
|
Navigator.of(context).pop(TimeOfDay(hour: hour, minute: 0));
|
||||||
|
},
|
||||||
|
child: Text('OK'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<TimeOfDay?> showHourPicker({
|
||||||
|
required BuildContext context,
|
||||||
|
required TimeOfDay initialTime,
|
||||||
|
}) {
|
||||||
|
return showDialog<TimeOfDay>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => HourPickerDialog(initialTime: initialTime),
|
||||||
|
);
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
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_event.dart';
|
||||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_state.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/device_model.dart';
|
||||||
@ -10,6 +10,7 @@ import 'package:syncrow_web/pages/visitor_password/model/schedule_model.dart';
|
|||||||
import 'package:syncrow_web/services/access_mang_api.dart';
|
import 'package:syncrow_web/services/access_mang_api.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||||
|
|
||||||
List<String> selectedDevices = [];
|
List<String> selectedDevices = [];
|
||||||
|
|
||||||
// Define the BLoC
|
// Define the BLoC
|
||||||
@ -30,7 +31,8 @@ class VisitorPasswordBloc
|
|||||||
|
|
||||||
on<OfflineMultipleTimePasswordEvent>(postOfflineMultipleTimePassword);
|
on<OfflineMultipleTimePasswordEvent>(postOfflineMultipleTimePassword);
|
||||||
on<OfflineOneTimePasswordEvent>(postOfflineOneTimePassword);
|
on<OfflineOneTimePasswordEvent>(postOfflineOneTimePassword);
|
||||||
|
on<SelectTimeEvent>(selectTimeOfLinePassword);
|
||||||
|
on<ChangeTimeEvent>(changeTime);
|
||||||
}
|
}
|
||||||
final TextEditingController userNameController = TextEditingController();
|
final TextEditingController userNameController = TextEditingController();
|
||||||
final TextEditingController emailController = TextEditingController();
|
final TextEditingController emailController = TextEditingController();
|
||||||
@ -38,14 +40,14 @@ class VisitorPasswordBloc
|
|||||||
final TextEditingController deviceNameController = TextEditingController();
|
final TextEditingController deviceNameController = TextEditingController();
|
||||||
final TextEditingController deviceIdController = TextEditingController();
|
final TextEditingController deviceIdController = TextEditingController();
|
||||||
final TextEditingController unitNameController = TextEditingController();
|
final TextEditingController unitNameController = TextEditingController();
|
||||||
final TextEditingController virtualAddressController = TextEditingController();
|
final TextEditingController virtualAddressController =
|
||||||
|
TextEditingController();
|
||||||
|
|
||||||
|
|
||||||
List<DeviceModel> data = [];
|
List<DeviceModel> data = [];
|
||||||
List<String> selectedDeviceIds = [];
|
List<String> selectedDeviceIds = [];
|
||||||
|
String effectiveTime = 'Select Time';
|
||||||
|
|
||||||
|
String expirationTime = 'Select Time';
|
||||||
|
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
@ -61,12 +63,11 @@ class VisitorPasswordBloc
|
|||||||
int? repeatEffectiveTimeTimeStamp;
|
int? repeatEffectiveTimeTimeStamp;
|
||||||
int? repeatExpirationTimeTimeStamp;
|
int? repeatExpirationTimeTimeStamp;
|
||||||
|
|
||||||
String startTime = 'Start Time';
|
DateTime? startTime = DateTime.now();
|
||||||
String endTime = 'End Time';
|
DateTime? endTime;
|
||||||
|
|
||||||
|
String startTimeAccess = 'Start Time';
|
||||||
String repeatStartTime = 'Start Time';
|
String endTimeAccess = 'End Time';
|
||||||
String repeatEndTime = 'End Time';
|
|
||||||
|
|
||||||
// DateTime? repeatStartTime=DateTime.now();
|
// DateTime? repeatStartTime=DateTime.now();
|
||||||
// DateTime? repeatEndTime;
|
// DateTime? repeatEndTime;
|
||||||
@ -85,13 +86,15 @@ class VisitorPasswordBloc
|
|||||||
|
|
||||||
Future<void> selectTimeVisitorPassword(
|
Future<void> selectTimeVisitorPassword(
|
||||||
SelectTimeVisitorPassword event,
|
SelectTimeVisitorPassword event,
|
||||||
Emitter<VisitorPasswordState> emit) async {
|
Emitter<VisitorPasswordState> emit,
|
||||||
|
) async {
|
||||||
final DateTime? picked = await showDatePicker(
|
final DateTime? picked = await showDatePicker(
|
||||||
context: event.context,
|
context: event.context,
|
||||||
initialDate: DateTime.now(),
|
initialDate: DateTime.now(),
|
||||||
firstDate: DateTime(2015, 8),
|
firstDate: DateTime(2015, 8),
|
||||||
lastDate: DateTime(3101),
|
lastDate: DateTime(3101),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
final TimeOfDay? timePicked = await showTimePicker(
|
final TimeOfDay? timePicked = await showTimePicker(
|
||||||
context: event.context,
|
context: event.context,
|
||||||
@ -113,6 +116,7 @@ class VisitorPasswordBloc
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (timePicked != null) {
|
if (timePicked != null) {
|
||||||
final selectedDateTime = DateTime(
|
final selectedDateTime = DateTime(
|
||||||
picked.year,
|
picked.year,
|
||||||
@ -121,51 +125,41 @@ class VisitorPasswordBloc
|
|||||||
timePicked.hour,
|
timePicked.hour,
|
||||||
timePicked.minute,
|
timePicked.minute,
|
||||||
);
|
);
|
||||||
final selectedTimestamp = DateTime(
|
|
||||||
selectedDateTime.year,
|
|
||||||
selectedDateTime.month,
|
|
||||||
selectedDateTime.day,
|
|
||||||
selectedDateTime.hour,
|
|
||||||
selectedDateTime.minute,
|
|
||||||
).millisecondsSinceEpoch ~/
|
|
||||||
1000; // Divide by 1000 to remove milliseconds
|
|
||||||
if (event.isStart) {
|
|
||||||
if (expirationTimeTimeStamp != null && selectedTimestamp >expirationTimeTimeStamp!) {
|
|
||||||
CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
|
|
||||||
} else {
|
|
||||||
if(event.isRepeat==true)
|
|
||||||
{repeatStartTime = selectedDateTime.toString().split('.').first;}
|
|
||||||
|
|
||||||
else // Remove seconds and milliseconds
|
final selectedTimestamp = selectedDateTime.millisecondsSinceEpoch ~/ 1000;
|
||||||
{startTime = selectedDateTime.toString().split('.').first;}
|
|
||||||
effectiveTimeTimeStamp = selectedTimestamp;
|
if (event.isStart) {
|
||||||
emit(ChangeTimeState());
|
if (expirationTimeTimeStamp != null &&
|
||||||
|
selectedTimestamp > expirationTimeTimeStamp!) {
|
||||||
|
CustomSnackBar.displaySnackBar(
|
||||||
|
'Effective Time cannot be later than Expiration Time.',
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
emit(ChangeTimeState());
|
effectiveTimeTimeStamp = selectedTimestamp;
|
||||||
|
|
||||||
|
startTimeAccess = selectedDateTime.toString().split('.').first;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (effectiveTimeTimeStamp != null &&
|
if (effectiveTimeTimeStamp != null &&
|
||||||
selectedTimestamp < effectiveTimeTimeStamp!) {
|
selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||||
CustomSnackBar.displaySnackBar('Expiration Time cannot be earlier than Effective Time.');
|
CustomSnackBar.displaySnackBar(
|
||||||
} else {
|
'Expiration Time cannot be earlier than Effective Time.',
|
||||||
if(event.isRepeat==true)
|
);
|
||||||
{repeatEndTime = selectedDateTime.toString().split('.').first;}
|
return;
|
||||||
else
|
}
|
||||||
{endTime = selectedDateTime.toString().split('.').first;}
|
|
||||||
expirationTimeTimeStamp = selectedTimestamp;
|
expirationTimeTimeStamp = selectedTimestamp;
|
||||||
emit(ChangeTimeState());
|
|
||||||
|
endTimeAccess = selectedDateTime.toString().split('.').first;
|
||||||
|
|
||||||
}
|
}
|
||||||
emit(ChangeTimeState());
|
|
||||||
|
|
||||||
|
emit(ChangeTimeState());
|
||||||
emit(VisitorPasswordInitial());
|
emit(VisitorPasswordInitial());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit(AccessInitial());
|
|
||||||
// emit(TableLoaded(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool toggleRepeat(
|
bool toggleRepeat(
|
||||||
ToggleRepeatEvent event, Emitter<VisitorPasswordState> emit) {
|
ToggleRepeatEvent event, Emitter<VisitorPasswordState> emit) {
|
||||||
emit(LoadingInitialState());
|
emit(LoadingInitialState());
|
||||||
@ -212,17 +206,24 @@ class VisitorPasswordBloc
|
|||||||
|
|
||||||
//online password
|
//online password
|
||||||
|
|
||||||
Future<void> postOnlineOneTimePassword(
|
Future<void> postOnlineOneTimePassword(OnlineOneTimePasswordEvent event,
|
||||||
OnlineOneTimePasswordEvent event,
|
|
||||||
Emitter<VisitorPasswordState> emit) async {
|
Emitter<VisitorPasswordState> emit) async {
|
||||||
try {
|
try {
|
||||||
|
generate7DigitNumber();
|
||||||
|
|
||||||
print('selectedDevices$selectedDevices');
|
print('selectedDevices$selectedDevices');
|
||||||
// emit(DeviceLoaded());
|
// emit(DeviceLoaded());
|
||||||
await AccessMangApi().postOnlineOneTime(
|
bool res = await AccessMangApi().postOnlineOneTime(
|
||||||
email: event.email,
|
email: event.email,
|
||||||
|
password: passwordController,
|
||||||
devicesUuid: selectedDevices,
|
devicesUuid: selectedDevices,
|
||||||
passwordName: event.passwordName);
|
passwordName: event.passwordName,
|
||||||
// emit(TableLoaded(data));
|
effectiveTime: effectiveTimeTimeStamp.toString(),
|
||||||
|
invalidTime: expirationTimeTimeStamp.toString());
|
||||||
|
if (res = true) {
|
||||||
|
Navigator.pop(event.context!);
|
||||||
|
}
|
||||||
|
emit(TableLoaded(data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(e.toString()));
|
emit(FailedState(e.toString()));
|
||||||
}
|
}
|
||||||
@ -233,33 +234,31 @@ class VisitorPasswordBloc
|
|||||||
Emitter<VisitorPasswordState> emit) async {
|
Emitter<VisitorPasswordState> emit) async {
|
||||||
try {
|
try {
|
||||||
generate7DigitNumber();
|
generate7DigitNumber();
|
||||||
// emit(DeviceLoaded());
|
bool res = await AccessMangApi().postOnlineMultipleTime(
|
||||||
await AccessMangApi().postOnlineMultipleTime(
|
|
||||||
scheduleList: [
|
scheduleList: [
|
||||||
// if (repeat)
|
if (repeat)
|
||||||
// Schedule(
|
Schedule(
|
||||||
// effectiveTime: getTimeOnly(repeatStartTime),
|
effectiveTime: getTimeFromDateTimeString(expirationTime),
|
||||||
// invalidTime: getTimeOnly(repeatEndTime).toString(),
|
invalidTime: getTimeFromDateTimeString(effectiveTime).toString(),
|
||||||
// workingDay: selectedDays,
|
workingDay: selectedDays,
|
||||||
// ),
|
),
|
||||||
],
|
],
|
||||||
password: passwordController,
|
password: passwordController,
|
||||||
invalidTime:event.invalidTime ,
|
invalidTime: expirationTimeTimeStamp.toString(),
|
||||||
effectiveTime:event.effectiveTime ,
|
effectiveTime: effectiveTimeTimeStamp.toString(),
|
||||||
email: event.email,
|
email: event.email,
|
||||||
devicesUuid: selectedDevices,
|
devicesUuid: selectedDevices,
|
||||||
passwordName: event.passwordName
|
passwordName: event.passwordName);
|
||||||
);
|
if(res==true){
|
||||||
// emit(TableLoaded(data));
|
Navigator.pop(event.context!);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(e.toString()));
|
emit(FailedState(e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//offline password
|
//offline password
|
||||||
Future<void> postOfflineOneTimePassword(
|
Future<void> postOfflineOneTimePassword(OfflineOneTimePasswordEvent event,
|
||||||
OfflineOneTimePasswordEvent event,
|
|
||||||
Emitter<VisitorPasswordState> emit) async {
|
Emitter<VisitorPasswordState> emit) async {
|
||||||
try {
|
try {
|
||||||
generate7DigitNumber();
|
generate7DigitNumber();
|
||||||
@ -267,8 +266,7 @@ class VisitorPasswordBloc
|
|||||||
await AccessMangApi().postOffLineOneTime(
|
await AccessMangApi().postOffLineOneTime(
|
||||||
email: event.email,
|
email: event.email,
|
||||||
devicesUuid: selectedDevices,
|
devicesUuid: selectedDevices,
|
||||||
passwordName: event.passwordName
|
passwordName: event.passwordName);
|
||||||
);
|
|
||||||
// emit(TableLoaded(data));
|
// emit(TableLoaded(data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(e.toString()));
|
emit(FailedState(e.toString()));
|
||||||
@ -286,15 +284,13 @@ class VisitorPasswordBloc
|
|||||||
devicesUuid: selectedDevices,
|
devicesUuid: selectedDevices,
|
||||||
passwordName: event.passwordName,
|
passwordName: event.passwordName,
|
||||||
invalidTime: event.invalidTime,
|
invalidTime: event.invalidTime,
|
||||||
effectiveTime:event.effectiveTime
|
effectiveTime: event.effectiveTime);
|
||||||
);
|
|
||||||
// emit(TableLoaded(data));
|
// emit(TableLoaded(data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(e.toString()));
|
emit(FailedState(e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void selectDevice(
|
void selectDevice(
|
||||||
SelectDeviceEvent event, Emitter<VisitorPasswordState> emit) {
|
SelectDeviceEvent event, Emitter<VisitorPasswordState> emit) {
|
||||||
if (selectedDeviceIds.contains(event.deviceId)) {
|
if (selectedDeviceIds.contains(event.deviceId)) {
|
||||||
@ -302,8 +298,6 @@ class VisitorPasswordBloc
|
|||||||
} else {
|
} else {
|
||||||
selectedDeviceIds.add(event.deviceId);
|
selectedDeviceIds.add(event.deviceId);
|
||||||
}
|
}
|
||||||
selectedDevices=selectedDeviceIds;
|
|
||||||
print(selectedDevices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String? validate(String? value) {
|
String? validate(String? value) {
|
||||||
@ -313,7 +307,6 @@ class VisitorPasswordBloc
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future generate7DigitNumber() async {
|
Future generate7DigitNumber() async {
|
||||||
emit(LoadingInitialState());
|
emit(LoadingInitialState());
|
||||||
passwordController = '';
|
passwordController = '';
|
||||||
@ -324,12 +317,12 @@ class VisitorPasswordBloc
|
|||||||
emit(GeneratePasswordState());
|
emit(GeneratePasswordState());
|
||||||
return passwordController;
|
return passwordController;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getTimeOnly(DateTime? dateTime) {
|
String getTimeOnly(DateTime? dateTime) {
|
||||||
if (dateTime == null) return '';
|
if (dateTime == null) return '';
|
||||||
return DateFormat('HH:mm').format(dateTime);
|
return DateFormat('HH:mm').format(dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void filterDevices() {
|
void filterDevices() {
|
||||||
final deviceName = deviceNameController.text.toLowerCase();
|
final deviceName = deviceNameController.text.toLowerCase();
|
||||||
final deviceId = deviceIdController.text.toLowerCase();
|
final deviceId = deviceIdController.text.toLowerCase();
|
||||||
@ -346,8 +339,10 @@ class VisitorPasswordBloc
|
|||||||
|
|
||||||
add(UpdateFilteredDevicesEvent(filteredData));
|
add(UpdateFilteredDevicesEvent(filteredData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<VisitorPasswordState> mapEventToState(VisitorPasswordEvent event) async* {
|
Stream<VisitorPasswordState> mapEventToState(
|
||||||
|
VisitorPasswordEvent event) async* {
|
||||||
if (event is FetchDevice) {
|
if (event is FetchDevice) {
|
||||||
// Fetching logic...
|
// Fetching logic...
|
||||||
} else if (event is UpdateFilteredDevicesEvent) {
|
} else if (event is UpdateFilteredDevicesEvent) {
|
||||||
@ -355,7 +350,113 @@ class VisitorPasswordBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onUpdateFilteredDevices(UpdateFilteredDevicesEvent event, Emitter<VisitorPasswordState> emit) {
|
void _onUpdateFilteredDevices(
|
||||||
|
UpdateFilteredDevicesEvent event, Emitter<VisitorPasswordState> emit) {
|
||||||
emit(TableLoaded(event.filteredData));
|
emit(TableLoaded(event.filteredData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDeviceToList() {
|
||||||
|
selectedDevices = selectedDeviceIds;
|
||||||
|
print(selectedDevices);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> selectTimeOfLinePassword(SelectTimeEvent event, Emitter<VisitorPasswordState> emit) async {
|
||||||
|
emit(ChangeTimeState());
|
||||||
|
final DateTime? picked = await showDatePicker(
|
||||||
|
context: event.context,
|
||||||
|
initialDate: DateTime.now(),
|
||||||
|
firstDate: DateTime.now(),
|
||||||
|
lastDate: DateTime(3101),
|
||||||
|
);
|
||||||
|
if (picked != null) {
|
||||||
|
final TimeOfDay? timePicked = await showHourPicker(
|
||||||
|
context: event.context,
|
||||||
|
initialTime: TimeOfDay.now(),
|
||||||
|
);
|
||||||
|
if (timePicked != null) {
|
||||||
|
final selectedDateTime = DateTime(
|
||||||
|
picked.year,
|
||||||
|
picked.month,
|
||||||
|
picked.day,
|
||||||
|
timePicked.hour,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
final selectedTimestamp = DateTime(
|
||||||
|
selectedDateTime.year,
|
||||||
|
selectedDateTime.month,
|
||||||
|
selectedDateTime.day,
|
||||||
|
selectedDateTime.hour,
|
||||||
|
selectedDateTime.minute,
|
||||||
|
).millisecondsSinceEpoch ~/
|
||||||
|
1000; // Divide by 1000 to remove milliseconds
|
||||||
|
if (event.isEffective) {
|
||||||
|
if (expirationTimeTimeStamp != null &&
|
||||||
|
selectedTimestamp > expirationTimeTimeStamp!) {
|
||||||
|
CustomSnackBar.displaySnackBar(
|
||||||
|
'Effective Time cannot be later than Expiration Time.');
|
||||||
|
} else {
|
||||||
|
effectiveTime = selectedDateTime
|
||||||
|
.toString()
|
||||||
|
.split('.')
|
||||||
|
.first; // Remove seconds and milliseconds
|
||||||
|
effectiveTimeTimeStamp = selectedTimestamp;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (effectiveTimeTimeStamp != null &&
|
||||||
|
selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||||
|
CustomSnackBar.displaySnackBar(
|
||||||
|
'Expiration Time cannot be earlier than Effective Time.');
|
||||||
|
} else {
|
||||||
|
expirationTime = selectedDateTime
|
||||||
|
.toString()
|
||||||
|
.split('.')
|
||||||
|
.first; // Remove seconds and milliseconds
|
||||||
|
expirationTimeTimeStamp = selectedTimestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print('effectiveTime=$effectiveTime');
|
||||||
|
print('expirationTime=$expirationTime');
|
||||||
|
|
||||||
|
print('expirationTimeTimeStamp=$expirationTimeTimeStamp');
|
||||||
|
print('effectiveTimeTimeStamp=$effectiveTimeTimeStamp');
|
||||||
|
emit(TimeSelectedState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeTime(ChangeTimeEvent event, Emitter<VisitorPasswordState> emit) {
|
||||||
|
if (event.isStartEndTime == true) {
|
||||||
|
startTime = event.val;
|
||||||
|
} else {
|
||||||
|
endTime = event.val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DateTime? convertStringToDateTime(String dateTimeString) {
|
||||||
|
try {
|
||||||
|
// Define the input format. Adjust this pattern based on your input string format.
|
||||||
|
final DateFormat inputFormat = DateFormat('yyyy-MM-dd HH:mm:ss');
|
||||||
|
// Convert the string to a DateTime object.
|
||||||
|
DateTime dateTime = inputFormat.parse(dateTimeString);
|
||||||
|
return dateTime;
|
||||||
|
} catch (e) {
|
||||||
|
print("Error parsing date: $e");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getTimeFromDateTimeString(String dateTimeString) {
|
||||||
|
DateTime? dateTime = convertStringToDateTime(dateTimeString);
|
||||||
|
if (dateTime == null) return '';
|
||||||
|
|
||||||
|
// Extract the time component from the DateTime object.
|
||||||
|
return DateFormat('HH:mm').format(dateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
String? validateEmail(String? value) {
|
||||||
|
if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value!)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,9 @@ class FetchDevice extends VisitorPasswordEvent {}
|
|||||||
class OnlineOneTimePasswordEvent extends VisitorPasswordEvent {
|
class OnlineOneTimePasswordEvent extends VisitorPasswordEvent {
|
||||||
final String? email;
|
final String? email;
|
||||||
final String? passwordName;
|
final String? passwordName;
|
||||||
|
final BuildContext? context;
|
||||||
|
|
||||||
const OnlineOneTimePasswordEvent({this.email,this.passwordName});
|
const OnlineOneTimePasswordEvent({this.email,this.passwordName,this.context});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [email!,passwordName!,];
|
List<Object> get props => [email!,passwordName!,];
|
||||||
@ -68,9 +69,10 @@ class OnlineMultipleTimePasswordEvent extends VisitorPasswordEvent {
|
|||||||
final String? passwordName;
|
final String? passwordName;
|
||||||
final String? invalidTime;
|
final String? invalidTime;
|
||||||
final String? effectiveTime;
|
final String? effectiveTime;
|
||||||
const OnlineMultipleTimePasswordEvent({this.email,this.passwordName,this.invalidTime,this.effectiveTime});
|
final BuildContext? context;
|
||||||
|
const OnlineMultipleTimePasswordEvent({this.email,this.passwordName,this.invalidTime,this.effectiveTime,this.context});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [email!,passwordName!,invalidTime!,effectiveTime!];
|
List<Object> get props => [email!,passwordName!,invalidTime!,effectiveTime!,context!];
|
||||||
}
|
}
|
||||||
|
|
||||||
//offline password
|
//offline password
|
||||||
@ -115,4 +117,18 @@ class UpdateFilteredDevicesEvent extends VisitorPasswordEvent {
|
|||||||
final List<DeviceModel> filteredData;
|
final List<DeviceModel> filteredData;
|
||||||
|
|
||||||
UpdateFilteredDevicesEvent(this.filteredData);
|
UpdateFilteredDevicesEvent(this.filteredData);
|
||||||
|
}class SelectTimeEvent extends VisitorPasswordEvent {
|
||||||
|
final BuildContext context;
|
||||||
|
final bool isEffective;
|
||||||
|
const SelectTimeEvent({required this.context,required this.isEffective});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [context,isEffective];
|
||||||
|
}
|
||||||
|
class ChangeTimeEvent extends VisitorPasswordEvent {
|
||||||
|
final dynamic val;
|
||||||
|
final bool isStartEndTime;
|
||||||
|
|
||||||
|
const ChangeTimeEvent({required this.val,required this.isStartEndTime});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [val,isStartEndTime];
|
||||||
}
|
}
|
@ -41,6 +41,7 @@ class IsRepeatState extends VisitorPasswordState {
|
|||||||
|
|
||||||
class LoadingInitialState extends VisitorPasswordState {}
|
class LoadingInitialState extends VisitorPasswordState {}
|
||||||
class ChangeTimeState extends VisitorPasswordState {}
|
class ChangeTimeState extends VisitorPasswordState {}
|
||||||
|
class TimeSelectedState extends VisitorPasswordState {}
|
||||||
class DeviceLoaded extends VisitorPasswordState {}
|
class DeviceLoaded extends VisitorPasswordState {}
|
||||||
class GeneratePasswordState extends VisitorPasswordState {}
|
class GeneratePasswordState extends VisitorPasswordState {}
|
||||||
|
|
||||||
|
@ -207,6 +207,7 @@ class AddDeviceDialog extends StatelessWidget {
|
|||||||
width: size.width * 0.2,
|
width: size.width * 0.2,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
visitorBloc.addDeviceToList();
|
||||||
Navigator.of(context).pop(); // Close the dialog
|
Navigator.of(context).pop(); // Close the dialog
|
||||||
},
|
},
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
|
@ -56,19 +56,26 @@ class RepeatWidget extends StatelessWidget {
|
|||||||
title: '',
|
title: '',
|
||||||
size: size,
|
size: size,
|
||||||
endTime: () {
|
endTime: () {
|
||||||
visitorBloc.add(SelectTimeVisitorPassword(
|
print('sadasd');
|
||||||
isRepeat: true,
|
visitorBloc.add(SelectTimeEvent(
|
||||||
context: context, isStart: false
|
context: context,
|
||||||
));
|
isEffective: false));
|
||||||
|
new Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
|
visitorBloc.add(ChangeTimeEvent(val: visitorBloc.endTime, isStartEndTime: true));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
startTime: () {
|
startTime: () {
|
||||||
visitorBloc.add(SelectTimeVisitorPassword(
|
new Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
isRepeat: true,
|
visitorBloc.add(ChangeTimeEvent(val: visitorBloc.endTime, isStartEndTime: true));
|
||||||
context: context, isStart: true
|
});
|
||||||
));
|
visitorBloc.add(SelectTimeEvent(context: context, isEffective: true));
|
||||||
|
|
||||||
},
|
},
|
||||||
firstString: visitorBloc.repeatStartTime.toString(),
|
firstString:visitorBloc.effectiveTime ,
|
||||||
secondString: visitorBloc.repeatEndTime.toString(),
|
secondString: visitorBloc.expirationTime ,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/common/custom_web_textfield.dart';
|
import 'package:syncrow_web/pages/common/custom_web_textfield.dart';
|
||||||
import 'package:syncrow_web/pages/common/date_time_widget.dart';
|
import 'package:syncrow_web/pages/common/date_time_widget.dart';
|
||||||
import 'package:syncrow_web/pages/common/default_button.dart';
|
import 'package:syncrow_web/pages/common/default_button.dart';
|
||||||
@ -10,6 +11,8 @@ import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_event.d
|
|||||||
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_state.dart';
|
import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_state.dart';
|
||||||
import 'package:syncrow_web/pages/visitor_password/view/add_device_dialog.dart';
|
import 'package:syncrow_web/pages/visitor_password/view/add_device_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/visitor_password/view/repeat_widget.dart';
|
import 'package:syncrow_web/pages/visitor_password/view/repeat_widget.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class VisitorPasswordDialog extends StatelessWidget {
|
class VisitorPasswordDialog extends StatelessWidget {
|
||||||
@ -23,19 +26,22 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
child: BlocBuilder<VisitorPasswordBloc, VisitorPasswordState>(
|
child: BlocBuilder<VisitorPasswordBloc, VisitorPasswordState>(
|
||||||
builder: (BuildContext context, VisitorPasswordState state) {
|
builder: (BuildContext context, VisitorPasswordState state) {
|
||||||
final visitorBloc = BlocProvider.of<VisitorPasswordBloc>(context);
|
final visitorBloc = BlocProvider.of<VisitorPasswordBloc>(context);
|
||||||
bool isRepeat = state is IsRepeatState ? state.repeat : visitorBloc.repeat;
|
bool isRepeat =
|
||||||
|
state is IsRepeatState ? state.repeat : visitorBloc.repeat;
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
title: Text('Create visitor password',
|
title: Text(
|
||||||
|
'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,
|
fontSize: 24,
|
||||||
color: Colors.black),),
|
color: Colors.black),
|
||||||
|
),
|
||||||
content: SingleChildScrollView(
|
content: SingleChildScrollView(
|
||||||
child: Form(
|
child: Form(
|
||||||
key: visitorBloc.forgetFormKey,
|
key: visitorBloc.forgetFormKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(5.0),
|
||||||
child: ListBody(
|
child: ListBody(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
@ -55,18 +61,21 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: CustomWebTextField(
|
child: CustomWebTextField(
|
||||||
validator: visitorBloc.validate,
|
validator: visitorBloc.validateEmail,
|
||||||
controller: visitorBloc.emailController,
|
controller: visitorBloc.emailController,
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
textFieldName: 'Email Address',
|
textFieldName: 'Email Address',
|
||||||
description: 'The password will be sent to the visitor’s email address.',
|
description:
|
||||||
|
'The password will be sent to the visitor’s email address.',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 20,),
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -79,7 +88,9 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
.bodyMedium!
|
.bodyMedium!
|
||||||
.copyWith(color: Colors.red),
|
.copyWith(color: Colors.red),
|
||||||
),
|
),
|
||||||
const Text('Access Type'),
|
Text('Access Type',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@ -87,7 +98,10 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: size.width * 0.15,
|
width: size.width * 0.15,
|
||||||
child: RadioListTile<String>(
|
child: RadioListTile<String>(
|
||||||
title: const Text('Online Password'),
|
title: Text('Online Password',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),
|
||||||
|
),
|
||||||
value: 'Online Password',
|
value: 'Online Password',
|
||||||
groupValue: (state is PasswordTypeSelected)
|
groupValue: (state is PasswordTypeSelected)
|
||||||
? state.selectedType
|
? state.selectedType
|
||||||
@ -95,16 +109,19 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
print(value);
|
print(value);
|
||||||
context.read<VisitorPasswordBloc>().add(SelectPasswordType(value));
|
context
|
||||||
|
.read<VisitorPasswordBloc>()
|
||||||
|
.add(SelectPasswordType(value));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: size.width * 0.15,
|
width: size.width * 0.15,
|
||||||
child: RadioListTile<String>(
|
child: RadioListTile<String>(
|
||||||
title: const Text('Offline Password'),
|
title: Text('Offline Password',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
value: 'Offline Password',
|
value: 'Offline Password',
|
||||||
groupValue: (state is PasswordTypeSelected)
|
groupValue: (state is PasswordTypeSelected)
|
||||||
? state.selectedType
|
? state.selectedType
|
||||||
@ -113,23 +130,28 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
if (value != null) {
|
if (value != null) {
|
||||||
print(value);
|
print(value);
|
||||||
|
|
||||||
context.read<VisitorPasswordBloc>().add(SelectPasswordType(value));
|
context
|
||||||
|
.read<VisitorPasswordBloc>()
|
||||||
|
.add(SelectPasswordType(value));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: size.width * 0.15,
|
width: size.width * 0.15,
|
||||||
child: RadioListTile<String>(
|
child: RadioListTile<String>(
|
||||||
title: const Text('Dynamic Password'),
|
title: Text('Dynamic Password',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
value: 'Dynamic Password',
|
value: 'Dynamic Password',
|
||||||
groupValue: (state is PasswordTypeSelected)
|
groupValue: (state is PasswordTypeSelected)
|
||||||
? state.selectedType
|
? state.selectedType
|
||||||
: visitorBloc.accessTypeSelected,
|
: visitorBloc.accessTypeSelected,
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
context.read<VisitorPasswordBloc>().add(SelectPasswordType(value));
|
context
|
||||||
|
.read<VisitorPasswordBloc>()
|
||||||
|
.add(SelectPasswordType(value));
|
||||||
visitorBloc.usageFrequencySelected = '';
|
visitorBloc.usageFrequencySelected = '';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -137,13 +159,19 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const 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'),
|
Text(
|
||||||
const SizedBox(height: 20,)
|
'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),),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
visitorBloc.accessTypeSelected=='Dynamic Password' ?
|
visitorBloc.accessTypeSelected == 'Dynamic Password'
|
||||||
SizedBox():
|
? SizedBox()
|
||||||
Column(
|
: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@ -155,7 +183,8 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
.bodyMedium!
|
.bodyMedium!
|
||||||
.copyWith(color: Colors.red),
|
.copyWith(color: Colors.red),
|
||||||
),
|
),
|
||||||
const Text('Usage Frequency'),
|
Text('Usage Frequency',style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
@ -163,16 +192,22 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 200,
|
width: 200,
|
||||||
child: RadioListTile<String>(
|
child: RadioListTile<String>(
|
||||||
title: const Text('One-Time'),
|
title: Text('One-Time',style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
value: 'One-Time',
|
value: 'One-Time',
|
||||||
groupValue: (state is UsageFrequencySelected)
|
groupValue:
|
||||||
|
(state is UsageFrequencySelected)
|
||||||
? state.selectedFrequency
|
? state.selectedFrequency
|
||||||
: visitorBloc.usageFrequencySelected,
|
: visitorBloc
|
||||||
|
.usageFrequencySelected,
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
print(value);
|
print(value);
|
||||||
|
|
||||||
context.read<VisitorPasswordBloc>().add(SelectUsageFrequency(value));
|
context
|
||||||
|
.read<VisitorPasswordBloc>()
|
||||||
|
.add(SelectUsageFrequency(
|
||||||
|
value));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -180,45 +215,61 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 200,
|
width: 200,
|
||||||
child: RadioListTile<String>(
|
child: RadioListTile<String>(
|
||||||
title: const Text('Periodic'),
|
title: Text('Periodic',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
value: 'Periodic',
|
value: 'Periodic',
|
||||||
groupValue: (state is UsageFrequencySelected)
|
groupValue:
|
||||||
|
(state is UsageFrequencySelected)
|
||||||
? state.selectedFrequency
|
? state.selectedFrequency
|
||||||
: visitorBloc.usageFrequencySelected,
|
: visitorBloc
|
||||||
|
.usageFrequencySelected,
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
context.read<VisitorPasswordBloc>().add(SelectUsageFrequency(value));
|
context
|
||||||
|
.read<VisitorPasswordBloc>()
|
||||||
|
.add(SelectUsageFrequency(
|
||||||
|
value));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Text('Within the validity period, each device can be unlocked only once.',
|
||||||
const Text('Within the validity period, each device can be unlocked only once.')
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: ColorsManager.grayColor,fontSize: 9),)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20,),
|
const SizedBox(
|
||||||
if((visitorBloc.usageFrequencySelected!='One-Time'||visitorBloc.accessTypeSelected!='Offline Password')&&(visitorBloc.usageFrequencySelected!=''))
|
height: 20,
|
||||||
|
),
|
||||||
|
if ((visitorBloc.usageFrequencySelected != 'One-Time' ||
|
||||||
|
visitorBloc.accessTypeSelected !=
|
||||||
|
'Offline Password') &&
|
||||||
|
(visitorBloc.usageFrequencySelected != ''))
|
||||||
DateTimeWebWidget(
|
DateTimeWebWidget(
|
||||||
|
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
title: 'Access Period',
|
title: 'Access Period',
|
||||||
size: size,
|
size: size,
|
||||||
endTime: () {
|
endTime: () {
|
||||||
visitorBloc.add(SelectTimeVisitorPassword(
|
visitorBloc.add(SelectTimeVisitorPassword(
|
||||||
context: context, isStart: false,isRepeat:false));
|
context: context,
|
||||||
|
isStart: false,
|
||||||
|
isRepeat: false));
|
||||||
},
|
},
|
||||||
startTime: () {
|
startTime: () {
|
||||||
visitorBloc.add(SelectTimeVisitorPassword(
|
visitorBloc.add(SelectTimeVisitorPassword(
|
||||||
context: context, isStart: true,isRepeat:false));
|
context: context,
|
||||||
|
isStart: true,
|
||||||
|
isRepeat: false));
|
||||||
},
|
},
|
||||||
firstString: visitorBloc.startTime,
|
firstString: visitorBloc.startTimeAccess.toString(),
|
||||||
secondString: visitorBloc.endTime,
|
secondString: visitorBloc.endTimeAccess.toString(),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 20,),
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -231,12 +282,21 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
.bodyMedium!
|
.bodyMedium!
|
||||||
.copyWith(color: Colors.red),
|
.copyWith(color: Colors.red),
|
||||||
),
|
),
|
||||||
const Text('Access Devices'),
|
Text('Access Devices', style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
color: Colors.black,fontSize: 13),),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Text('Within the validity period, each device can be unlocked only once.'),
|
Text(
|
||||||
const SizedBox(height: 20,),
|
'Within the validity period, each device can be unlocked only once.',style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
if(visitorBloc.usageFrequencySelected=='Periodic'&&visitorBloc.accessTypeSelected=='Online Password')
|
fontWeight: FontWeight.w400,
|
||||||
|
color: ColorsManager.grayColor,fontSize: 9),),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
if (visitorBloc.usageFrequencySelected ==
|
||||||
|
'Periodic' &&
|
||||||
|
visitorBloc.accessTypeSelected ==
|
||||||
|
'Online Password')
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 100,
|
width: 100,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
@ -254,11 +314,14 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if(visitorBloc.usageFrequencySelected=='Periodic'&&visitorBloc.accessTypeSelected=='Online Password')
|
if (visitorBloc.usageFrequencySelected ==
|
||||||
|
'Periodic' &&
|
||||||
|
visitorBloc.accessTypeSelected ==
|
||||||
|
'Online Password')
|
||||||
isRepeat ? const RepeatWidget() : const SizedBox(),
|
isRepeat ? const RepeatWidget() : const SizedBox(),
|
||||||
Container(
|
Container(
|
||||||
decoration: containerDecoration,
|
decoration: containerDecoration,
|
||||||
width: size.width * 0.1,
|
width: size.width * 0.08,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(
|
||||||
@ -270,12 +333,13 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
child: Text('+ Add Device'),
|
child: Text('+ Add Device',style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: ColorsManager.whiteColors,fontSize: 12),),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -294,7 +358,9 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Cancel',
|
'Cancel',
|
||||||
style: Theme.of(context).textTheme.bodyMedium!,
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: ColorsManager.blackColor,fontSize: 16),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -303,7 +369,9 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
width: size.width * 0.2,
|
width: size.width * 0.2,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
print(selectedDevices);
|
||||||
if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
if (visitorBloc.forgetFormKey.currentState!.validate()) {
|
||||||
|
if (selectedDevices.toString() != '[]') {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@ -311,8 +379,8 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
return InfoDialog(
|
return InfoDialog(
|
||||||
size: size,
|
size: size,
|
||||||
title: 'Set Password',
|
title: 'Set Password',
|
||||||
content: 'This action will update all of the selected\n door locks passwords in the property.\n\nAre you sure you want to continue?',
|
content:
|
||||||
|
'This action will update all of the selected\n door locks passwords in the property.\n\nAre you sure you want to continue?',
|
||||||
actions: [
|
actions: [
|
||||||
Container(
|
Container(
|
||||||
decoration: containerDecoration,
|
decoration: containerDecoration,
|
||||||
@ -320,12 +388,15 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop(); // Close the dialog
|
Navigator.of(context)
|
||||||
|
.pop(); // Close the dialog
|
||||||
},
|
},
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Cancel',
|
'Cancel',
|
||||||
style: Theme.of(context).textTheme.bodyMedium!,
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: ColorsManager.blackColor,fontSize: 16),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -335,37 +406,66 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if(visitorBloc.usageFrequencySelected=='One-Time'&&visitorBloc.accessTypeSelected=='Online Password'){
|
if (visitorBloc.usageFrequencySelected ==
|
||||||
visitorBloc.add(OnlineOneTimePasswordEvent(
|
'One-Time' &&
|
||||||
passwordName:visitorBloc.userNameController.text ,
|
visitorBloc.accessTypeSelected ==
|
||||||
email: visitorBloc.emailController.text
|
'Online Password') {
|
||||||
)
|
visitorBloc.add(
|
||||||
);
|
OnlineOneTimePasswordEvent(
|
||||||
}
|
context: context,
|
||||||
else if(visitorBloc.usageFrequencySelected=='Periodic'&&visitorBloc.accessTypeSelected=='Online Password') {
|
passwordName: visitorBloc
|
||||||
visitorBloc.add(OnlineMultipleTimePasswordEvent(
|
.userNameController.text,
|
||||||
passwordName:visitorBloc.userNameController.text ,
|
email: visitorBloc
|
||||||
email: visitorBloc.emailController.text,
|
.emailController.text));
|
||||||
effectiveTime:visitorBloc.effectiveTimeTimeStamp.toString() ,
|
} else if (visitorBloc
|
||||||
invalidTime:visitorBloc.expirationTimeTimeStamp.toString()
|
.usageFrequencySelected ==
|
||||||
)
|
'Periodic' &&
|
||||||
);
|
visitorBloc.accessTypeSelected ==
|
||||||
}
|
'Online Password') {
|
||||||
else if(visitorBloc.usageFrequencySelected=='One-Time'&&visitorBloc.accessTypeSelected=='Offline Password') {
|
visitorBloc.add(
|
||||||
visitorBloc.add(OfflineOneTimePasswordEvent(
|
OnlineMultipleTimePasswordEvent(
|
||||||
passwordName:visitorBloc.userNameController.text ,
|
passwordName:
|
||||||
email: visitorBloc.emailController.text,
|
visitorBloc
|
||||||
)
|
.userNameController
|
||||||
);
|
.text,
|
||||||
}
|
email:
|
||||||
else if(visitorBloc.usageFrequencySelected=='Periodic'&&visitorBloc.accessTypeSelected=='Offline Password') {
|
visitorBloc
|
||||||
visitorBloc.add(OfflineMultipleTimePasswordEvent(
|
.emailController.text,
|
||||||
passwordName:visitorBloc.userNameController.text ,
|
effectiveTime: visitorBloc
|
||||||
email: visitorBloc.emailController.text,
|
.effectiveTimeTimeStamp
|
||||||
effectiveTime:visitorBloc.effectiveTimeTimeStamp.toString() ,
|
.toString(),
|
||||||
invalidTime:visitorBloc.expirationTimeTimeStamp.toString()
|
invalidTime: visitorBloc
|
||||||
)
|
.expirationTimeTimeStamp
|
||||||
);
|
.toString()));
|
||||||
|
} else if (visitorBloc
|
||||||
|
.usageFrequencySelected ==
|
||||||
|
'One-Time' &&
|
||||||
|
visitorBloc.accessTypeSelected ==
|
||||||
|
'Offline Password') {
|
||||||
|
visitorBloc
|
||||||
|
.add(OfflineOneTimePasswordEvent(
|
||||||
|
passwordName: visitorBloc
|
||||||
|
.userNameController.text,
|
||||||
|
email:
|
||||||
|
visitorBloc.emailController.text,
|
||||||
|
));
|
||||||
|
} else if (visitorBloc
|
||||||
|
.usageFrequencySelected ==
|
||||||
|
'Periodic' &&
|
||||||
|
visitorBloc.accessTypeSelected ==
|
||||||
|
'Offline Password') {
|
||||||
|
visitorBloc.add(
|
||||||
|
OfflineMultipleTimePasswordEvent(
|
||||||
|
passwordName: visitorBloc
|
||||||
|
.userNameController.text,
|
||||||
|
email: visitorBloc
|
||||||
|
.emailController.text,
|
||||||
|
effectiveTime: visitorBloc
|
||||||
|
.effectiveTimeTimeStamp
|
||||||
|
.toString(),
|
||||||
|
invalidTime: visitorBloc
|
||||||
|
.expirationTimeTimeStamp
|
||||||
|
.toString()));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text(
|
child: const Text(
|
||||||
@ -373,9 +473,61 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],);
|
],
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
content: SizedBox(
|
||||||
|
height: size!.height * 0.15,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
Assets.deviceNoteIcon,
|
||||||
|
height: 35,
|
||||||
|
width: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Please select devices to continue',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.headlineLarge!
|
||||||
|
.copyWith(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: Colors.black),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
actionsAlignment: MainAxisAlignment.center,
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text('OK',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
color: ColorsManager.whiteColors,fontSize: 16),),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/model/password_model.dart';
|
import 'package:syncrow_web/pages/access_management/model/password_model.dart';
|
||||||
import 'package:syncrow_web/pages/visitor_password/model/schedule_model.dart';
|
import 'package:syncrow_web/pages/visitor_password/model/schedule_model.dart';
|
||||||
@ -51,15 +52,24 @@ class AccessMangApi{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future postOnlineOneTime({String? email,String? passwordName,List<String>? devicesUuid}) async {
|
Future<bool> postOnlineOneTime({
|
||||||
|
String? email,
|
||||||
|
String? passwordName,
|
||||||
|
String? password,
|
||||||
|
String? effectiveTime,
|
||||||
|
String? invalidTime,
|
||||||
|
List<String>? devicesUuid}) async {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
print('postOfflineOneTime List: ${
|
print('postOfflineOneTime List: ${
|
||||||
{
|
jsonEncode({
|
||||||
"email": email,
|
"email": email,
|
||||||
"passwordName": passwordName,
|
"passwordName": passwordName,
|
||||||
"devicesUuid": devicesUuid
|
"password": password,
|
||||||
}
|
"devicesUuid": devicesUuid,
|
||||||
|
"effectiveTime":effectiveTime ,
|
||||||
|
"invalidTime": invalidTime
|
||||||
|
})
|
||||||
}');
|
}');
|
||||||
|
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
@ -67,18 +77,27 @@ class AccessMangApi{
|
|||||||
body: jsonEncode({
|
body: jsonEncode({
|
||||||
"email": email,
|
"email": email,
|
||||||
"passwordName": passwordName,
|
"passwordName": passwordName,
|
||||||
"devicesUuid": devicesUuid
|
"password": password,
|
||||||
|
"devicesUuid": devicesUuid,
|
||||||
|
"effectiveTime":effectiveTime ,
|
||||||
|
"invalidTime": invalidTime
|
||||||
}),
|
}),
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<dynamic> jsonData = json;
|
|
||||||
print('postOfflineOneTime List: $json');
|
print('postOfflineOneTime List: $json');
|
||||||
|
if(json['statusCode'].toString()=='201'){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
} catch (e) {
|
} on DioException catch (e) {
|
||||||
debugPrint('Error fetching $e');
|
debugPrint('Error: ${e.message}');
|
||||||
return [];
|
|
||||||
|
debugPrint('Error fetching ${e.response!.statusMessage}');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,25 +118,30 @@ class AccessMangApi{
|
|||||||
"effectiveTime": effectiveTime,
|
"effectiveTime": effectiveTime,
|
||||||
"invalidTime": invalidTime,
|
"invalidTime": invalidTime,
|
||||||
};
|
};
|
||||||
print('createPassword =${scheduleList![0].workingDay}');
|
|
||||||
if (scheduleList != null) {
|
if (scheduleList != null) {
|
||||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||||
}
|
}
|
||||||
print('createPassword =$body');
|
print('createPassword =${jsonEncode(body)}');
|
||||||
|
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.sendOnlineMultipleTime,
|
path: ApiEndpoints.sendOnlineMultipleTime,
|
||||||
body: jsonEncode(body),
|
body: jsonEncode(body),
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<dynamic> jsonData = json;
|
print('createPassword =${json}');
|
||||||
print('postOfflineOneTime List: $json');
|
|
||||||
|
if(json['data']['successOperations'][0]['success'].toString()=='true'){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
} catch (e) {
|
} on DioException catch (e){
|
||||||
debugPrint('Error fetching $e');
|
debugPrint('Error fetching ${e.type.name}');
|
||||||
return [];
|
debugPrint('Error fetching ${e.response!.statusMessage}');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user