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