From 695d6c109bbaf2920fff8a32be52ba36ccd24fcb Mon Sep 17 00:00:00 2001 From: mohammad Date: Sun, 30 Jun 2024 12:49:05 +0300 Subject: [PATCH] CreateTemporaryPassword --- .../bloc/smart_door_bloc/smart_door_bloc.dart | 12 ++++++++---- .../smart_door/create_temporary_password.dart | 9 ++++++++- .../widgets/smart_door/temporary_password_page.dart | 1 - .../widgets/smart_door/view_temporary_password.dart | 6 ++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart index b384ad4..2cae2e9 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart @@ -219,20 +219,24 @@ class SmartDoorBloc extends Bloc { } bool _validateInputs(BuildContext context) { + if (passwordController.text.length<7) { + CustomSnackBar.displaySnackBar('Password less than 7'); + return true; + } if (passwordController.text.isEmpty) { - _showSnackBar(context, 'Password required'); + CustomSnackBar.displaySnackBar('Password required'); return true; } if (passwordNameController.text.isEmpty) { - _showSnackBar(context, 'Password name required'); + CustomSnackBar.displaySnackBar('Password name required'); return true; } if (effectiveTime == 'Select Time' || effectiveTimeTimeStamp == null) { - _showSnackBar(context, 'Select effective time'); + CustomSnackBar.displaySnackBar('Select effective time'); return true; } if (expirationTime == 'Select Time' || expirationTimeTimeStamp == null) { - _showSnackBar(context, 'Select expiration time'); + CustomSnackBar.displaySnackBar('Select expiration time'); return true; } if (repeat == true && diff --git a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart index c804f7a..6fd500c 100644 --- a/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart +++ b/lib/features/devices/view/widgets/smart_door/create_temporary_password.dart @@ -1,6 +1,7 @@ import 'package:day_picker/day_picker.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart'; @@ -46,7 +47,7 @@ class CreateTemporaryPassword extends StatelessWidget { ), leading: IconButton(onPressed: () { Navigator.of(context).pop('UpdatePage'); - }, icon: Icon(Icons.arrow_back)), + }, icon: const Icon(Icons.arrow_back)), actions: [ TextButton( onPressed: () { @@ -123,6 +124,11 @@ class CreateTemporaryPassword extends StatelessWidget { ], ), ), + BlocProvider.of(context).passwordController.text.isNotEmpty? + TextButton(onPressed: () async { + await Clipboard.setData(ClipboardData(text: BlocProvider.of(context).passwordController.text)); + }, + child: const Text('Copy')):SizedBox(), const SizedBox( height: 20, ), @@ -192,6 +198,7 @@ class CreateTemporaryPassword extends StatelessWidget { const SizedBox( height: 20, ), + if(type=='Online Password') DefaultContainer( padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5), diff --git a/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart b/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart index 7efadb7..ae9ad6b 100644 --- a/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart +++ b/lib/features/devices/view/widgets/smart_door/temporary_password_page.dart @@ -49,7 +49,6 @@ class TemporaryPasswordPage extends StatelessWidget { Navigator.of(context).push(MaterialPageRoute(builder: (context) => ViewTemporaryPassword(deviceId:deviceId,type:'Online Password'),)); }, trailing: const Icon( - Icons.arrow_forward_ios, color: ColorsManager.greyColor, size: 15, diff --git a/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart b/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart index 1675e56..f778931 100644 --- a/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart +++ b/lib/features/devices/view/widgets/smart_door/view_temporary_password.dart @@ -24,7 +24,6 @@ class ViewTemporaryPassword extends StatelessWidget { SmartDoorBloc(deviceId: deviceId!)..add(InitialPasswordsPage(type:type )), child: BlocConsumer( listener: (context, state) { - print('=======4${state}'); if (state is FailedState) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -35,7 +34,6 @@ class ViewTemporaryPassword extends StatelessWidget { } }, builder: (context, state) { final smartDoorBloc = BlocProvider.of(context); - return DefaultScaffold( title: 'Passwords', actions: [ @@ -45,9 +43,9 @@ class ViewTemporaryPassword extends StatelessWidget { builder: (context) => CreateTemporaryPassword(deviceId: deviceId, type: type), )).then((result) { if (result != null) { - smartDoorBloc.add(InitialPasswordsPage(type:type )); } + smartDoorBloc.add(InitialPasswordsPage(type:type )); + } }); - }, icon: const Icon(Icons.add)) ],