mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +00:00
fix bugs on create password
This commit is contained in:
@ -147,6 +147,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
final TimeOfDay? timePicked = await showTimePicker(
|
||||
context: event.context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
|
||||
);
|
||||
if (timePicked != null) {
|
||||
final selectedDateTime = DateTime(
|
||||
@ -156,23 +157,28 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
timePicked.hour,
|
||||
timePicked.minute,
|
||||
);
|
||||
// Convert selectedDateTime to a timestamp without seconds and milliseconds
|
||||
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 &&
|
||||
selectedDateTime.millisecondsSinceEpoch >
|
||||
expirationTimeTimeStamp!) {
|
||||
selectedTimestamp > expirationTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar('Effective Time cannot be later than Expiration Time.');
|
||||
} else {
|
||||
effectiveTime = selectedDateTime.toString();
|
||||
effectiveTimeTimeStamp = selectedDateTime.millisecondsSinceEpoch;
|
||||
effectiveTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
||||
effectiveTimeTimeStamp = selectedTimestamp;
|
||||
}
|
||||
} else {
|
||||
if (effectiveTimeTimeStamp != null &&
|
||||
selectedDateTime.millisecondsSinceEpoch <
|
||||
effectiveTimeTimeStamp!) {
|
||||
if (effectiveTimeTimeStamp != null && selectedTimestamp < effectiveTimeTimeStamp!) {
|
||||
CustomSnackBar.displaySnackBar('Expiration Time cannot be earlier than Effective Time.');
|
||||
} else {
|
||||
expirationTime = selectedDateTime.toString();
|
||||
expirationTimeTimeStamp = selectedDateTime.millisecondsSinceEpoch;
|
||||
expirationTime = selectedDateTime.toString().split('.').first; // Remove seconds and milliseconds
|
||||
expirationTimeTimeStamp = selectedTimestamp;
|
||||
}
|
||||
}
|
||||
emit(TimeSelectedState());
|
||||
|
@ -146,11 +146,10 @@ class CreateTemporaryPassword extends StatelessWidget {
|
||||
child: TextFormField(
|
||||
controller:
|
||||
BlocProvider.of<SmartDoorBloc>(context).passwordNameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Enter The Name'),
|
||||
decoration: const InputDecoration(hintText: 'Enter The Name'),
|
||||
)),
|
||||
),
|
||||
const Divider(color:Color(0xffEBEBEB),),
|
||||
const Divider(color:ColorsManager.graysColor,),
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyMedium(
|
||||
@ -169,7 +168,7 @@ class CreateTemporaryPassword extends StatelessWidget {
|
||||
),
|
||||
)),
|
||||
),
|
||||
const Divider(color:Color(0xffEBEBEB),),
|
||||
const Divider(color:ColorsManager.graysColor,),
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: const BodyMedium(
|
||||
@ -183,9 +182,6 @@ class CreateTemporaryPassword extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
BlocProvider.of<SmartDoorBloc>(context)..add(SelectTimeEvent(context: context, isEffective: false));
|
||||
// BlocProvider.of<SmartDoorBloc>(context)
|
||||
// .selectTime(context,
|
||||
// isEffective: false);
|
||||
},
|
||||
child: Text(
|
||||
BlocProvider.of<SmartDoorBloc>(context)
|
||||
@ -239,60 +235,56 @@ class CreateTemporaryPassword extends StatelessWidget {
|
||||
onTap: () {
|
||||
BlocProvider.of<SmartDoorBloc>(context).add(const SetStartEndTimeEvent(val: true));
|
||||
},
|
||||
child: BodyMedium(text: 'Start',fontColor:BlocProvider.of<SmartDoorBloc>(context).isStartEndTime==false? Colors.black:Colors.blue,fontSize: 18,),
|
||||
child: BodyMedium(text: 'Start',
|
||||
fontColor: BlocProvider.of<SmartDoorBloc>(context).isStartEndTime==false?
|
||||
Colors.black:Colors.blue,fontSize: 18,),
|
||||
),
|
||||
|
||||
InkWell(
|
||||
onTap: () {
|
||||
BlocProvider.of<SmartDoorBloc>(context).add(const SetStartEndTimeEvent(val: false));
|
||||
|
||||
},
|
||||
child: BodyMedium(text: 'End',fontColor:BlocProvider.of<SmartDoorBloc>(context).isStartEndTime? Colors.black:Colors.blue,fontSize: 18,),
|
||||
},
|
||||
child:BodyMedium(text: 'End',
|
||||
fontColor:BlocProvider.of<SmartDoorBloc>(context).isStartEndTime?
|
||||
Colors.black:Colors.blue,fontSize: 18,),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(color:Color(0xffEBEBEB),),
|
||||
const Divider(color:ColorsManager.graysColor,),
|
||||
Container(
|
||||
height: 80,
|
||||
child:
|
||||
Container(
|
||||
height: 90,
|
||||
child:BlocProvider.of<SmartDoorBloc>(context).isStartEndTime? TimePickerSpinner(
|
||||
time:
|
||||
BlocProvider.of<SmartDoorBloc>(context).startTime,
|
||||
height: 110,
|
||||
child:BlocProvider.of<SmartDoorBloc>(context).isStartEndTime?
|
||||
TimePickerSpinner(
|
||||
time: BlocProvider.of<SmartDoorBloc>(context).startTime,
|
||||
is24HourMode: false,
|
||||
itemHeight: 40,
|
||||
normalTextStyle: const TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 24,
|
||||
),
|
||||
highlightedTextStyle: const TextStyle(
|
||||
fontSize: 30, color: Colors.blue),
|
||||
onTimeChange: (time) {
|
||||
BlocProvider.of<SmartDoorBloc>(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of<SmartDoorBloc>(context).isStartEndTime));
|
||||
},
|
||||
): Container(
|
||||
child: TimePickerSpinner(
|
||||
time: BlocProvider.of<SmartDoorBloc>(context).endTime,
|
||||
is24HourMode: false,
|
||||
itemHeight: 40,
|
||||
normalTextStyle: const TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 24,
|
||||
),
|
||||
highlightedTextStyle: const TextStyle(
|
||||
fontSize: 30, color: Colors.blue),
|
||||
onTimeChange: (time) {
|
||||
|
||||
// BlocProvider.of<SmartDoorBloc>(context).changeTime(time, BlocProvider.of<SmartDoorBloc>(context).isStartEndTime);
|
||||
BlocProvider.of<SmartDoorBloc>(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of<SmartDoorBloc>(context).isStartEndTime));
|
||||
},
|
||||
): Container(
|
||||
child: TimePickerSpinner(
|
||||
time: BlocProvider.of<SmartDoorBloc>(context).endTime,
|
||||
is24HourMode: false,
|
||||
itemHeight: 40,
|
||||
normalTextStyle: const TextStyle(
|
||||
fontSize: 24,
|
||||
),
|
||||
highlightedTextStyle: const TextStyle(
|
||||
fontSize: 30, color: Colors.blue),
|
||||
onTimeChange: (time) {
|
||||
BlocProvider.of<SmartDoorBloc>(context).add(ChangeTimeEvent(val: time, isStartEndTime: BlocProvider.of<SmartDoorBloc>(context).isStartEndTime));
|
||||
|
||||
// BlocProvider.of<SmartDoorBloc>(context).changeTime(time, BlocProvider.of<SmartDoorBloc>(context).isStartEndTime);
|
||||
},
|
||||
),
|
||||
},
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
const Divider(color:Color(0xffEBEBEB),),
|
||||
const Divider(color:ColorsManager.graysColor,),
|
||||
const SizedBox(height: 20),
|
||||
SelectWeekDays(
|
||||
width: MediaQuery.of(context).size.width / 1,
|
||||
|
@ -96,7 +96,7 @@ class TemporaryPasswordPage extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
|
||||
const Divider( ),
|
||||
const Divider(color:ColorsManager.graysColor,),
|
||||
ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: SvgPicture.asset(
|
||||
|
@ -22,4 +22,5 @@ abstract class ColorsManager {
|
||||
static const Color blackColor = Color(0xFF000000);
|
||||
static const Color lightGreen = Color(0xFF00FF0A);
|
||||
static const Color grayColor = Color(0xFF999999);
|
||||
static const Color graysColor = Color(0xffEBEBEB);
|
||||
}
|
||||
|
Reference in New Issue
Block a user