mirror of
https://github.com/SyncrowIOT/web.git
synced 2026-03-11 06:41:45 +00:00
Compare commits
6 Commits
web_change
...
fix_hour_p
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ac3e79c30 | |||
| dbb3450c32 | |||
| 8c3df39cf4 | |||
| 7f862fac2a | |||
| 770db5383b | |||
| eddd4828bb |
@ -139,9 +139,11 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
Form(
|
||||||
child: _buildDropdownField(
|
key: forgetBloc.forgetRegionKey,
|
||||||
context, forgetBloc, size))
|
child: SizedBox(
|
||||||
|
child: _buildDropdownField(
|
||||||
|
context, forgetBloc, size)))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
@ -226,12 +228,10 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
1
|
1
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
if (forgetBloc
|
if (forgetBloc.forgetEmailKey.currentState!.validate()||forgetBloc.forgetRegionKey.currentState!.validate()) {
|
||||||
.forgetEmailKey
|
if(forgetBloc.forgetRegionKey.currentState!.validate()){
|
||||||
.currentState!
|
forgetBloc.add(StartTimerEvent());
|
||||||
.validate()) {
|
}
|
||||||
forgetBloc.add(
|
|
||||||
StartTimerEvent());
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -428,7 +428,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Container(
|
SizedBox(
|
||||||
width: size.width * 0.9,
|
width: size.width * 0.9,
|
||||||
child: FormField<String>(
|
child: FormField<String>(
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
@ -493,7 +493,10 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: region.id,
|
value: region.id,
|
||||||
child: Text(
|
child: Text(
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
region.name,
|
region.name,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
@ -568,4 +571,5 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class HourPickerDialog extends StatefulWidget {
|
class HourPickerDialog extends StatefulWidget {
|
||||||
final TimeOfDay initialTime;
|
final TimeOfDay initialTime;
|
||||||
|
|
||||||
const HourPickerDialog({super.key, required this.initialTime});
|
const HourPickerDialog({super.key, required this.initialTime});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -9,70 +12,50 @@ class HourPickerDialog extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HourPickerDialogState extends State<HourPickerDialog> {
|
class _HourPickerDialogState extends State<HourPickerDialog> {
|
||||||
late int _selectedHour;
|
late String selectedHour;
|
||||||
bool _isPm = true;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_selectedHour = widget.initialTime.hour > 12
|
// Initialize the selectedHour with the initial time passed to the dialog
|
||||||
? widget.initialTime.hour - 12
|
selectedHour = widget.initialTime.hour.toString().padLeft(2, '0') + ':00';
|
||||||
: widget.initialTime.hour;
|
|
||||||
_isPm = widget.initialTime.period == DayPeriod.am;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('Select Hour'),
|
title: const Text('Select Hour'),
|
||||||
content: Row(
|
content: DropdownButton<String>(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
value: selectedHour, // Show the currently selected hour
|
||||||
children: [
|
items: List.generate(24, (index) {
|
||||||
DropdownButton<int>(
|
String hour = index.toString().padLeft(2, '0');
|
||||||
value: _selectedHour,
|
return DropdownMenuItem<String>(
|
||||||
items: List.generate(12, (index) {
|
value: '$hour:00',
|
||||||
int displayHour = index + 1;
|
child: Text('$hour:00'),
|
||||||
return DropdownMenuItem(
|
);
|
||||||
value: displayHour,
|
}),
|
||||||
child: Text(displayHour.toString()),
|
onChanged: (String? newValue) {
|
||||||
);
|
if (newValue != null) {
|
||||||
}),
|
setState(() {
|
||||||
onChanged: (value) {
|
selectedHour = newValue; // Update the selected hour without closing the dialog
|
||||||
setState(() {
|
});
|
||||||
_selectedHour = value!;
|
}
|
||||||
});
|
},
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(width: 16.0),
|
|
||||||
DropdownButton<bool>(
|
|
||||||
value: _isPm,
|
|
||||||
items: const [
|
|
||||||
DropdownMenuItem(
|
|
||||||
value: true,
|
|
||||||
child: Text('AM'),
|
|
||||||
),
|
|
||||||
DropdownMenuItem(
|
|
||||||
value:false ,
|
|
||||||
child: Text('PM'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_isPm = value!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(null),
|
onPressed: () => Navigator.of(context).pop(null), // Close the dialog without selection
|
||||||
child: const Text('Cancel'),
|
child: const Text('Cancel'),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
int hour = _isPm ? _selectedHour + 12 : _selectedHour;
|
// Close the dialog and return the selected time
|
||||||
Navigator.of(context).pop(TimeOfDay(hour: hour, minute: 0));
|
Navigator.of(context).pop(
|
||||||
|
TimeOfDay(
|
||||||
|
hour: int.parse(selectedHour.split(':')[0]),
|
||||||
|
minute: 0,
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
),
|
),
|
||||||
@ -86,6 +69,7 @@ Future<TimeOfDay?> showHourPicker({
|
|||||||
required TimeOfDay initialTime,
|
required TimeOfDay initialTime,
|
||||||
}) {
|
}) {
|
||||||
return showDialog<TimeOfDay>(
|
return showDialog<TimeOfDay>(
|
||||||
|
barrierDismissible: false,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => HourPickerDialog(initialTime: initialTime),
|
builder: (context) => HourPickerDialog(initialTime: initialTime),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -116,7 +116,7 @@ class DeviceManagementBody extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
? const EdgeInsets.all(30)
|
? const EdgeInsets.all(30)
|
||||||
: const EdgeInsets.all(15),
|
: const EdgeInsets.all(15),
|
||||||
child: DynamicTable(
|
child: DynamicTable(
|
||||||
withSelectAll: true,
|
withSelectAll: false,
|
||||||
cellDecoration: containerDecoration,
|
cellDecoration: containerDecoration,
|
||||||
onRowSelected: (index, isSelected, row) {
|
onRowSelected: (index, isSelected, row) {
|
||||||
final selectedDevice = devicesToShow[index];
|
final selectedDevice = devicesToShow[index];
|
||||||
|
|||||||
@ -14,6 +14,7 @@ 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/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||||
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordState> {
|
class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordState> {
|
||||||
VisitorPasswordBloc() : super(VisitorPasswordInitial()) {
|
VisitorPasswordBloc() : super(VisitorPasswordInitial()) {
|
||||||
@ -32,9 +33,9 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
on<SelectTimeEvent>(selectTimeOfLinePassword);
|
on<SelectTimeEvent>(selectTimeOfLinePassword);
|
||||||
on<ChangeTimeEvent>(changeTime);
|
on<ChangeTimeEvent>(changeTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
final TextEditingController userNameController = TextEditingController();
|
final TextEditingController userNameController = TextEditingController();
|
||||||
final TextEditingController emailController = TextEditingController();
|
final TextEditingController emailController = TextEditingController();
|
||||||
|
|
||||||
final TextEditingController deviceNameController = TextEditingController();
|
final TextEditingController deviceNameController = TextEditingController();
|
||||||
final TextEditingController deviceIdController = TextEditingController();
|
final TextEditingController deviceIdController = TextEditingController();
|
||||||
final TextEditingController unitNameController = TextEditingController();
|
final TextEditingController unitNameController = TextEditingController();
|
||||||
@ -51,6 +52,7 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
String accessTypeSelected = 'Online Password';
|
String accessTypeSelected = 'Online Password';
|
||||||
String usageFrequencySelected = 'One-Time';
|
String usageFrequencySelected = 'One-Time';
|
||||||
String passwordController = '';
|
String passwordController = '';
|
||||||
|
String accessPeriodValidate = '';
|
||||||
|
|
||||||
bool repeat = false;
|
bool repeat = false;
|
||||||
|
|
||||||
@ -377,19 +379,18 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
1000; // Divide by 1000 to remove milliseconds
|
1000; // Divide by 1000 to remove milliseconds
|
||||||
if (event.isEffective) {
|
if (event.isEffective) {
|
||||||
if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) {
|
if (expirationTimeTimeStamp != null && selectedTimestamp > expirationTimeTimeStamp!) {
|
||||||
CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
|
accessPeriodValidate="Effective Time cannot be later than Expiration Time.";
|
||||||
} else {
|
} else {
|
||||||
effectiveTime =
|
accessPeriodValidate='';
|
||||||
selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
effectiveTime = selectedDateTime.toString().split('.').first;
|
||||||
effectiveTimeTimeStamp = selectedTimestamp;
|
effectiveTimeTimeStamp = selectedTimestamp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
|
if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||||
CustomSnackBar.displaySnackBar(
|
accessPeriodValidate= 'Expiration Time cannot be earlier than Effective Time.';
|
||||||
'Expiration Time cannot be earlier than Effective Time.');
|
|
||||||
} else {
|
} else {
|
||||||
expirationTime =
|
accessPeriodValidate='';
|
||||||
selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
expirationTime = selectedDateTime.toString().split('.').first;
|
||||||
expirationTimeTimeStamp = selectedTimestamp;
|
expirationTimeTimeStamp = selectedTimestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -404,6 +404,9 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
? visitorBloc.expirationTime
|
? visitorBloc.expirationTime
|
||||||
: visitorBloc.endTimeAccess.toString(),
|
: visitorBloc.endTimeAccess.toString(),
|
||||||
icon: Assets.calendarIcon),
|
icon: Assets.calendarIcon),
|
||||||
|
const SizedBox(height: 10,),
|
||||||
|
Text(visitorBloc.accessPeriodValidate,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(color: ColorsManager.red),),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -41,3 +41,4 @@ BoxDecoration containerDecoration = BoxDecoration(
|
|||||||
],
|
],
|
||||||
color: ColorsManager.boxColor,
|
color: ColorsManager.boxColor,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)));
|
borderRadius: const BorderRadius.all(Radius.circular(10)));
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,6 @@ dependencies:
|
|||||||
dropdown_search: ^5.0.6
|
dropdown_search: ^5.0.6
|
||||||
flutter_dotenv: ^5.1.0
|
flutter_dotenv: ^5.1.0
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|||||||
Reference in New Issue
Block a user