mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 08:14:55 +00:00
Merge branch 'dev' of https://github.com/SyncrowIOT/syncrow-app into release-to-stores
This commit is contained in:
@ -149,7 +149,6 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
|||||||
_streamSubscription = null;
|
_streamSubscription = null;
|
||||||
return super.close();
|
return super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_doorLockUpdated(DoorLockUpdated event, Emitter<SmartDoorState> emit) {
|
_doorLockUpdated(DoorLockUpdated event, Emitter<SmartDoorState> emit) {
|
||||||
unlockRequest = deviceStatus.unlockRequest;
|
unlockRequest = deviceStatus.unlockRequest;
|
||||||
@ -254,18 +253,42 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _updateLock(UpdateLockEvent event, Emitter<SmartDoorState> emit) async {
|
void _updateLock(UpdateLockEvent event, Emitter<SmartDoorState> emit) async {
|
||||||
emit(LoadingNewSate(smartDoorModel: deviceStatus));
|
final oldValue = deviceStatus.normalOpenSwitch;
|
||||||
|
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: !oldValue);
|
||||||
|
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||||
try {
|
try {
|
||||||
// final response = await DevicesAPI.controlDevice(
|
|
||||||
// DeviceControlModel(deviceId: deviceId, code: 'normal_open_switch', value: !event.value),
|
|
||||||
// deviceId);
|
|
||||||
|
|
||||||
final response = await DevicesAPI.openDoorLock(deviceId);
|
final response = await DevicesAPI.openDoorLock(deviceId);
|
||||||
|
|
||||||
if (response) {
|
if (!response) {
|
||||||
deviceStatus.normalOpenSwitch = !event.value;
|
_revertValueAndEmit(deviceId, 'normal_open_switch', oldValue, emit);
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {
|
||||||
|
_revertValueAndEmit(deviceId, 'normal_open_switch', oldValue, emit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _revertValueAndEmit(String deviceId, String code, dynamic oldValue,
|
||||||
|
Emitter<SmartDoorState> emit) {
|
||||||
|
_updateLocalValue(code, oldValue);
|
||||||
|
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||||
|
emit(const FailedState(errorMessage: 'Failed to control the device.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _updateLocalValue(String code, dynamic value) {
|
||||||
|
switch (code) {
|
||||||
|
case 'normal_open_switch':
|
||||||
|
if (value is bool) {
|
||||||
|
deviceStatus = deviceStatus.copyWith(normalOpenSwitch: value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'reverse_lock':
|
||||||
|
if (value is bool) {
|
||||||
|
deviceStatus = deviceStatus.copyWith(reverseLock: value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
emit(UpdateState(smartDoorModel: deviceStatus));
|
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +354,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
|||||||
|
|
||||||
Future<void> selectTimeOnlinePassword(
|
Future<void> selectTimeOnlinePassword(
|
||||||
SelectTimeOnlinePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
SelectTimeOnlinePasswordEvent event, Emitter<SmartDoorState> emit) async {
|
||||||
|
effectiveTimeTimeStamp ??= DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||||
emit(ChangeTimeState());
|
emit(ChangeTimeState());
|
||||||
final DateTime? picked = await showDatePicker(
|
final DateTime? picked = await showDatePicker(
|
||||||
context: event.context,
|
context: event.context,
|
||||||
@ -375,7 +399,13 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
|||||||
selectedDateTime.minute,
|
selectedDateTime.minute,
|
||||||
).millisecondsSinceEpoch ~/
|
).millisecondsSinceEpoch ~/
|
||||||
1000; // Divide by 1000 to remove milliseconds
|
1000; // Divide by 1000 to remove milliseconds
|
||||||
|
final currentTimestamp = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||||
if (event.isEffective) {
|
if (event.isEffective) {
|
||||||
|
if (selectedTimestamp < currentTimestamp) {
|
||||||
|
CustomSnackBar.displaySnackBar(
|
||||||
|
'Effective Time cannot be later than Expiration Time.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (expirationTimeTimeStamp != null &&
|
if (expirationTimeTimeStamp != null &&
|
||||||
selectedTimestamp > expirationTimeTimeStamp!) {
|
selectedTimestamp > expirationTimeTimeStamp!) {
|
||||||
CustomSnackBar.displaySnackBar(
|
CustomSnackBar.displaySnackBar(
|
||||||
|
|||||||
@ -113,4 +113,44 @@ class SmartDoorModel {
|
|||||||
remoteNoDpKey: _remoteNoDpKey,
|
remoteNoDpKey: _remoteNoDpKey,
|
||||||
normalOpenSwitch: _normalOpenSwitch);
|
normalOpenSwitch: _normalOpenSwitch);
|
||||||
}
|
}
|
||||||
|
SmartDoorModel copyWith({
|
||||||
|
String? uuid,
|
||||||
|
int? unlockFingerprint,
|
||||||
|
int? unlockPassword,
|
||||||
|
int? unlockTemporary,
|
||||||
|
int? unlockCard,
|
||||||
|
String? alarmLock,
|
||||||
|
int? unlockRequest,
|
||||||
|
int? residualElectricity,
|
||||||
|
bool? reverseLock,
|
||||||
|
int? unlockApp,
|
||||||
|
bool? hijack,
|
||||||
|
bool? doorbell,
|
||||||
|
String? unlockOfflinePd,
|
||||||
|
String? unlockOfflineClear,
|
||||||
|
String? unlockDoubleKit,
|
||||||
|
String? remoteNoPdSetkey,
|
||||||
|
String? remoteNoDpKey,
|
||||||
|
bool? normalOpenSwitch,
|
||||||
|
}) {
|
||||||
|
return SmartDoorModel(
|
||||||
|
unlockAlarm: alarmLock ?? unlockAlarm,
|
||||||
|
unlockFingerprint: unlockFingerprint ?? this.unlockFingerprint,
|
||||||
|
unlockPassword: unlockPassword ?? this.unlockPassword,
|
||||||
|
unlockTemporary: unlockTemporary ?? this.unlockTemporary,
|
||||||
|
unlockCard: unlockCard ?? this.unlockCard,
|
||||||
|
unlockRequest: unlockRequest ?? this.unlockRequest,
|
||||||
|
residualElectricity: residualElectricity ?? this.residualElectricity,
|
||||||
|
reverseLock: reverseLock ?? this.reverseLock,
|
||||||
|
unlockApp: unlockApp ?? this.unlockApp,
|
||||||
|
hijack: hijack ?? this.hijack,
|
||||||
|
doorbell: doorbell ?? this.doorbell,
|
||||||
|
unlockOfflinePd: unlockOfflinePd ?? this.unlockOfflinePd,
|
||||||
|
unlockOfflineClear: unlockOfflineClear ?? this.unlockOfflineClear,
|
||||||
|
unlockDoubleKit: unlockDoubleKit ?? this.unlockDoubleKit,
|
||||||
|
remoteNoPdSetkey: remoteNoPdSetkey ?? this.remoteNoPdSetkey,
|
||||||
|
remoteNoDpKey: remoteNoDpKey ?? this.remoteNoDpKey,
|
||||||
|
normalOpenSwitch: normalOpenSwitch ?? this.normalOpenSwitch,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,9 @@ class NameTimeWidget extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
DateTime cleaned =
|
||||||
|
DateTime(now.year, now.month, now.day, now.hour, now.minute);
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -59,19 +62,22 @@ class NameTimeWidget extends StatelessWidget {
|
|||||||
width: MediaQuery.of(context).size.width / 3.5,
|
width: MediaQuery.of(context).size.width / 3.5,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
BlocProvider.of<SmartDoorBloc>(context).add(
|
||||||
BlocProvider.of<SmartDoorBloc>(context).add(SelectTimeOnlinePasswordEvent(context: context, isEffective: true));
|
SelectTimeOnlinePasswordEvent(
|
||||||
|
context: context, isEffective: true));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
BlocProvider.of<SmartDoorBloc>(context).effectiveTime,
|
BlocProvider.of<SmartDoorBloc>(context)
|
||||||
style: TextStyle(fontSize: 14,
|
.effectiveTime ==
|
||||||
color: BlocProvider.of<SmartDoorBloc>(context).effectiveTime ==
|
|
||||||
'Select Time'
|
'Select Time'
|
||||||
? ColorsManager.textGray
|
? cleaned.toString()
|
||||||
: null),
|
: BlocProvider.of<SmartDoorBloc>(context)
|
||||||
|
.effectiveTime,
|
||||||
|
style: TextStyle(fontSize: 14),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
],),
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(
|
||||||
color: ColorsManager.graysColor,
|
color: ColorsManager.graysColor,
|
||||||
@ -96,10 +102,13 @@ class NameTimeWidget extends StatelessWidget {
|
|||||||
context: context, isEffective: false));
|
context: context, isEffective: false));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
BlocProvider.of<SmartDoorBloc>(context).expirationTime,
|
BlocProvider.of<SmartDoorBloc>(context)
|
||||||
|
.expirationTime,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: BlocProvider.of<SmartDoorBloc>(context).expirationTime == 'Select Time'
|
color: BlocProvider.of<SmartDoorBloc>(context)
|
||||||
|
.expirationTime ==
|
||||||
|
'Select Time'
|
||||||
? ColorsManager.textGray
|
? ColorsManager.textGray
|
||||||
: null),
|
: null),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -6,10 +6,9 @@ import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_eve
|
|||||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/smart_door_model.dart';
|
import 'package:syncrow_app/features/devices/model/smart_door_model.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.dart';
|
|
||||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class DoorLockButton extends StatefulWidget {
|
class DoorLockButton extends StatelessWidget {
|
||||||
const DoorLockButton({
|
const DoorLockButton({
|
||||||
super.key,
|
super.key,
|
||||||
required this.doorLock,
|
required this.doorLock,
|
||||||
@ -18,157 +17,79 @@ class DoorLockButton extends StatefulWidget {
|
|||||||
|
|
||||||
final DeviceModel doorLock;
|
final DeviceModel doorLock;
|
||||||
final SmartDoorModel smartDoorModel;
|
final SmartDoorModel smartDoorModel;
|
||||||
@override
|
|
||||||
State<DoorLockButton> createState() => _DoorLockButtonState(smartDoorModel: smartDoorModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DoorLockButtonState extends State<DoorLockButton> with SingleTickerProviderStateMixin {
|
double _calculateProgress() {
|
||||||
late AnimationController _animationController;
|
final value = smartDoorModel.unlockRequest;
|
||||||
late Animation<double> _animation;
|
if (value <= 0 || value > 30) return 0;
|
||||||
SmartDoorModel smartDoorModel;
|
return value / 30.0;
|
||||||
_DoorLockButtonState({required this.smartDoorModel});
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
_animationController = AnimationController(
|
|
||||||
vsync: this,
|
|
||||||
value: context.read<SmartDoorBloc>().unlockRequest > 0 ? 1 : 0,
|
|
||||||
duration: Duration(seconds: context.read<SmartDoorBloc>().unlockRequest),
|
|
||||||
);
|
|
||||||
if (context.read<SmartDoorBloc>().unlockRequest > 0) {
|
|
||||||
_animationController.reverse();
|
|
||||||
}
|
|
||||||
|
|
||||||
_animation = Tween<double>(begin: 0, end: 1).animate(_animationController)
|
|
||||||
..addListener(() {
|
|
||||||
setState(() {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(DoorLockButton oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
|
|
||||||
if (_animationController.status == AnimationStatus.dismissed) {
|
|
||||||
if (context.read<SmartDoorBloc>().unlockRequest > 0) {
|
|
||||||
_animationController.value = 1;
|
|
||||||
_animationController.duration =
|
|
||||||
Duration(seconds: context.read<SmartDoorBloc>().unlockRequest);
|
|
||||||
_animationController.reverse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_animationController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
final progress = _calculateProgress();
|
||||||
padding: EdgeInsets.only(
|
final isEnabled = smartDoorModel.unlockRequest > 0;
|
||||||
right: context.width * 0.25 / 2,
|
|
||||||
left: context.width * 0.25 / 2,
|
return SizedBox(
|
||||||
bottom: context.width * 0.2 / 2,
|
width: 255,
|
||||||
),
|
height: 255,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
overlayColor:
|
onTap: isEnabled
|
||||||
WidgetStateProperty.all(ColorsManager.primaryColorWithOpacity.withOpacity(0.1)),
|
? () {
|
||||||
borderRadius: BorderRadius.circular(999),
|
BlocProvider.of<SmartDoorBloc>(context).add(
|
||||||
onTapDown: (details) {
|
UpdateLockEvent(value: !smartDoorModel.normalOpenSwitch),
|
||||||
// if (_animationController.status == AnimationStatus.dismissed) {
|
);
|
||||||
// _animationController.forward();
|
}
|
||||||
// } else if (_animationController.status == AnimationStatus.completed) {
|
: null,
|
||||||
// _animationController.reverse();
|
|
||||||
// } else if (_animationController.status == AnimationStatus.forward) {
|
|
||||||
// _animationController.reverse();
|
|
||||||
// } else if (_animationController.status == AnimationStatus.reverse) {
|
|
||||||
// _animationController.forward();
|
|
||||||
// }
|
|
||||||
if (context.read<SmartDoorBloc>().unlockRequest > 0) {
|
|
||||||
BlocProvider.of<SmartDoorBloc>(context)
|
|
||||||
.add(UpdateLockEvent(value: smartDoorModel.normalOpenSwitch));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTapUp: (details) {
|
|
||||||
// if (_animationController.status == AnimationStatus.forward) {
|
|
||||||
// _animationController.reverse();
|
|
||||||
// } else if (_animationController.status == AnimationStatus.reverse) {
|
|
||||||
// _animationController.forward();
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
child: Container(
|
child: Container(
|
||||||
width: context.width * 06,
|
width: 255,
|
||||||
height: context.width * 0.6,
|
height: 255,
|
||||||
margin: const EdgeInsets.all(10),
|
decoration: BoxDecoration(
|
||||||
decoration: const BoxDecoration(
|
color: const Color(0xFFEBECED),
|
||||||
|
shape: BoxShape.circle,
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.grey,
|
color: Colors.grey.withOpacity(0.5),
|
||||||
blurRadius: 18,
|
blurRadius: 18,
|
||||||
// offset: Offset(6, 7),
|
|
||||||
blurStyle: BlurStyle.outer,
|
blurStyle: BlurStyle.outer,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
color: Color(0xFFEBECED),
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(999)),
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Stack(
|
||||||
padding: const EdgeInsets.all(25),
|
alignment: Alignment.center,
|
||||||
child: Stack(
|
children: [
|
||||||
alignment: Alignment.center,
|
Container(
|
||||||
children: [
|
margin: const EdgeInsets.all(30),
|
||||||
Container(
|
decoration: const BoxDecoration(
|
||||||
margin: const EdgeInsets.all(8),
|
color: Color(0xFFF9F9F9),
|
||||||
decoration: BoxDecoration(
|
shape: BoxShape.circle,
|
||||||
color: Colors.white,
|
),
|
||||||
borderRadius: BorderRadius.circular(999),
|
child: Center(
|
||||||
boxShadow: [
|
child: SvgPicture.asset(
|
||||||
BoxShadow(
|
smartDoorModel.normalOpenSwitch
|
||||||
color: Colors.white.withOpacity(0.5),
|
? Assets.doorUnlockIcon
|
||||||
blurRadius: 30,
|
: Assets.assetsIconsDoorlockAssetsLockIcon,
|
||||||
offset: const Offset(-5, -5),
|
width: 60,
|
||||||
blurStyle: BlurStyle.outer,
|
height: 60,
|
||||||
),
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.14),
|
|
||||||
blurRadius: 25,
|
|
||||||
offset: const Offset(5, 5),
|
|
||||||
blurStyle: BlurStyle.outer,
|
|
||||||
),
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.14),
|
|
||||||
blurRadius: 30,
|
|
||||||
offset: const Offset(5, 5),
|
|
||||||
blurStyle: BlurStyle.inner,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
smartDoorModel.normalOpenSwitch
|
|
||||||
? Assets.doorUnlockIcon
|
|
||||||
: Assets.assetsIconsDoorlockAssetsLockIcon,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox.expand(
|
),
|
||||||
|
if (progress > 0)
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(shape: BoxShape.circle),
|
||||||
|
height: 250,
|
||||||
|
width: 250,
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
value: _animation.value,
|
value: progress,
|
||||||
strokeWidth: 15,
|
strokeWidth: 8,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
valueColor: const AlwaysStoppedAnimation<Color>(ColorsManager.primaryColor),
|
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||||
|
ColorsManager.primaryColor),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,7 +18,8 @@ import 'package:syncrow_app/utils/resource_manager/font_manager.dart';
|
|||||||
class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
||||||
final String? deviceId;
|
final String? deviceId;
|
||||||
final String? type;
|
final String? type;
|
||||||
const CreateOfflineTimeLimitPasswordPage({super.key, this.deviceId, this.type});
|
const CreateOfflineTimeLimitPasswordPage(
|
||||||
|
{super.key, this.deviceId, this.type});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
bool isRepeat = false;
|
bool isRepeat = false;
|
||||||
@ -28,9 +29,7 @@ class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
|||||||
child: BlocConsumer<SmartDoorBloc, SmartDoorState>(
|
child: BlocConsumer<SmartDoorBloc, SmartDoorState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is FailedState) {
|
if (state is FailedState) {
|
||||||
CustomSnackBar.displaySnackBar(
|
CustomSnackBar.displaySnackBar(state.errorMessage);
|
||||||
state.errorMessage
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (state is IsRepeatState) {
|
if (state is IsRepeatState) {
|
||||||
isRepeat = state.repeat;
|
isRepeat = state.repeat;
|
||||||
@ -39,6 +38,10 @@ class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
|||||||
generated = state.generated;
|
generated = state.generated;
|
||||||
}
|
}
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
DateTime cleaned =
|
||||||
|
DateTime(now.year, now.month, now.day, now.hour, now.minute);
|
||||||
|
|
||||||
final smartDoorBloc = BlocProvider.of<SmartDoorBloc>(context);
|
final smartDoorBloc = BlocProvider.of<SmartDoorBloc>(context);
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
@ -85,46 +88,56 @@ class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: smartDoorBloc.passwordController.text.isEmpty ?
|
children: smartDoorBloc
|
||||||
List.generate(10, (index) {
|
.passwordController.text.isEmpty
|
||||||
return const Padding(
|
? List.generate(10, (index) {
|
||||||
padding: EdgeInsets.symmetric(
|
return const Padding(
|
||||||
horizontal: 4.0,
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: 15),
|
horizontal: 4.0,
|
||||||
child: Icon(
|
vertical: 15),
|
||||||
Icons.circle,
|
child: Icon(
|
||||||
size: 20.0,
|
Icons.circle,
|
||||||
color: Colors.black,
|
size: 20.0,
|
||||||
),
|
color: Colors.black,
|
||||||
);
|
),
|
||||||
}) : [
|
);
|
||||||
Expanded(
|
})
|
||||||
child: Row(
|
: [
|
||||||
children: [
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: BodyLarge(
|
child: Row(
|
||||||
style: const TextStyle(
|
children: [
|
||||||
color: ColorsManager.primaryColor,
|
Expanded(
|
||||||
fontWeight: FontWeight.bold,
|
child: BodyLarge(
|
||||||
letterSpacing: 8.0,
|
style: const TextStyle(
|
||||||
fontSize: 25,
|
color: ColorsManager
|
||||||
wordSpacing: 2),
|
.primaryColor,
|
||||||
textAlign: TextAlign.center,
|
fontWeight:
|
||||||
text: smartDoorBloc.passwordController.text,
|
FontWeight.bold,
|
||||||
fontSize: 25,
|
letterSpacing: 8.0,
|
||||||
|
fontSize: 25,
|
||||||
|
wordSpacing: 2),
|
||||||
|
textAlign:
|
||||||
|
TextAlign.center,
|
||||||
|
text: smartDoorBloc
|
||||||
|
.passwordController
|
||||||
|
.text,
|
||||||
|
fontSize: 25,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await Clipboard.setData(
|
||||||
|
ClipboardData(
|
||||||
|
text: smartDoorBloc
|
||||||
|
.passwordController
|
||||||
|
.text));
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.copy)),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await Clipboard.setData(
|
|
||||||
ClipboardData(text: smartDoorBloc.passwordController.text)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.copy)),
|
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)),
|
)),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 10,
|
width: 10,
|
||||||
@ -135,91 +148,142 @@ class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment:
|
||||||
children: [
|
MainAxisAlignment.spaceBetween,
|
||||||
Expanded(
|
children: [
|
||||||
child: Container(
|
Expanded(
|
||||||
padding: const EdgeInsets.all(10.0),
|
child: Container(
|
||||||
child: const BodyMedium(
|
padding:
|
||||||
text: 'Password Name',
|
const EdgeInsets.all(10.0),
|
||||||
fontWeight: FontWeight.normal,
|
child: const BodyMedium(
|
||||||
),
|
text: 'Password Name',
|
||||||
),
|
fontWeight: FontWeight.normal,
|
||||||
),
|
),
|
||||||
SizedBox(
|
),
|
||||||
width: MediaQuery.of(context).size.width / 2.6,
|
|
||||||
child: TextFormField(
|
|
||||||
controller: BlocProvider.of<SmartDoorBloc>(context).passwordNameController,
|
|
||||||
decoration:
|
|
||||||
const InputDecoration(
|
|
||||||
hintText: 'Enter The Name',
|
|
||||||
hintStyle: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: ColorsManager.textGray)
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
const Divider(color: ColorsManager.graysColor,),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
const Expanded(
|
|
||||||
child: BodyMedium(
|
|
||||||
text: 'Effective Time',
|
|
||||||
fontWeight: FontWeight.normal,
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
SizedBox(
|
width: MediaQuery.of(context)
|
||||||
width: MediaQuery.of(context).size.width / 3.5,
|
.size
|
||||||
child: InkWell(
|
.width /
|
||||||
onTap: () {
|
2.6,
|
||||||
BlocProvider.of<SmartDoorBloc>(context).add(SelectTimeEvent(context: context, isEffective: true));
|
child: TextFormField(
|
||||||
},
|
controller: BlocProvider.of<
|
||||||
child: Text(
|
SmartDoorBloc>(context)
|
||||||
BlocProvider.of<SmartDoorBloc>(context).effectiveTime,
|
.passwordNameController,
|
||||||
style: TextStyle(
|
decoration:
|
||||||
fontSize: 14,
|
const InputDecoration(
|
||||||
color: BlocProvider.of<SmartDoorBloc>(context).effectiveTime ==
|
hintText:
|
||||||
'Select Time' ? ColorsManager.textGray : null),
|
'Enter The Name',
|
||||||
),
|
hintStyle: TextStyle(
|
||||||
)),],
|
fontSize: 14,
|
||||||
),
|
color: ColorsManager
|
||||||
),
|
.textGray)),
|
||||||
const Divider(
|
)),
|
||||||
color: ColorsManager.graysColor,
|
],
|
||||||
),
|
),
|
||||||
Padding(
|
Column(
|
||||||
padding: const EdgeInsets.all(10.0),
|
children: [
|
||||||
child: Row(mainAxisAlignment:
|
const Divider(
|
||||||
MainAxisAlignment.spaceBetween,
|
color: ColorsManager.graysColor,
|
||||||
children: [
|
),
|
||||||
const Expanded(
|
Padding(
|
||||||
child: BodyMedium(
|
padding: const EdgeInsets.all(10.0),
|
||||||
text: 'Expiration Time',
|
child: Row(
|
||||||
fontWeight: FontWeight.normal,
|
mainAxisAlignment:
|
||||||
),
|
MainAxisAlignment
|
||||||
),
|
.spaceBetween,
|
||||||
SizedBox(
|
children: [
|
||||||
width: MediaQuery.of(context).size.width / 3.5,
|
const Expanded(
|
||||||
child: InkWell(
|
child: BodyMedium(
|
||||||
onTap: () {
|
text: 'Effective Time',
|
||||||
BlocProvider.of<SmartDoorBloc>(context).add(SelectTimeEvent(
|
fontWeight:
|
||||||
context: context,
|
FontWeight.normal,
|
||||||
isEffective: false));
|
),
|
||||||
},
|
),
|
||||||
child: Text(
|
SizedBox(
|
||||||
BlocProvider.of<SmartDoorBloc>(context).expirationTime,
|
width:
|
||||||
style: TextStyle(
|
MediaQuery.of(context)
|
||||||
fontSize: 14,
|
.size
|
||||||
color: BlocProvider.of<SmartDoorBloc>(context)
|
.width /
|
||||||
.expirationTime == 'Select Time' ? ColorsManager
|
3.5,
|
||||||
.textGray : null),
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<
|
||||||
|
SmartDoorBloc>(
|
||||||
|
context)
|
||||||
|
.add(
|
||||||
|
SelectTimeEvent(
|
||||||
|
context:
|
||||||
|
context,
|
||||||
|
isEffective:
|
||||||
|
true));
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
BlocProvider.of<SmartDoorBloc>(
|
||||||
|
context)
|
||||||
|
.effectiveTime ==
|
||||||
|
'Select Time'
|
||||||
|
? cleaned.toString()
|
||||||
|
: BlocProvider.of<
|
||||||
|
SmartDoorBloc>(
|
||||||
|
context)
|
||||||
|
.effectiveTime,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
color: ColorsManager.graysColor,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment
|
||||||
|
.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Expanded(
|
||||||
|
child: BodyMedium(
|
||||||
|
text: 'Expiration Time',
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: MediaQuery.of(context)
|
||||||
|
.size
|
||||||
|
.width /
|
||||||
|
3.5,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<
|
||||||
|
SmartDoorBloc>(
|
||||||
|
context)
|
||||||
|
.add(SelectTimeEvent(
|
||||||
|
context: context,
|
||||||
|
isEffective:
|
||||||
|
false));
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
BlocProvider.of<
|
||||||
|
SmartDoorBloc>(
|
||||||
|
context)
|
||||||
|
.expirationTime,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: BlocProvider.of<
|
||||||
|
SmartDoorBloc>(
|
||||||
|
context)
|
||||||
|
.expirationTime ==
|
||||||
|
'Select Time'
|
||||||
|
? ColorsManager
|
||||||
|
.textGray
|
||||||
|
: null),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -238,7 +302,8 @@ class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const BodyMedium(
|
const BodyMedium(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
text: 'Use the time-limited password at least once within 24 hours after the password takes effect. Otherwise, the password becomes invalid.',
|
text:
|
||||||
|
'Use the time-limited password at least once within 24 hours after the password takes effect. Otherwise, the password becomes invalid.',
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
fontColor: ColorsManager.grayColor,
|
fontColor: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
@ -256,10 +321,13 @@ class CreateOfflineTimeLimitPasswordPage extends StatelessWidget {
|
|||||||
backgroundColor: ColorsManager.primaryColor,
|
backgroundColor: ColorsManager.primaryColor,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (generated == false) {
|
if (generated == false) {
|
||||||
smartDoorBloc.add(GenerateAndSavePasswordTimeLimitEvent(context: context));
|
smartDoorBloc.add(
|
||||||
|
GenerateAndSavePasswordTimeLimitEvent(
|
||||||
|
context: context));
|
||||||
} else {
|
} else {
|
||||||
if(smartDoorBloc.passwordNameController.text.isNotEmpty){
|
if (smartDoorBloc
|
||||||
smartDoorBloc.add(RenamePasswordEvent());
|
.passwordNameController.text.isNotEmpty) {
|
||||||
|
smartDoorBloc.add(RenamePasswordEvent());
|
||||||
}
|
}
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user