CreateTemporaryPassword

This commit is contained in:
mohammad
2024-06-27 16:59:05 +03:00
parent 4b09259a47
commit 3e7b6839d9
16 changed files with 623 additions and 7 deletions
+1 -4
View File
@@ -275,10 +275,7 @@ class AuthCubit extends Cubit<AuthState> {
getTokenAndValidate() async {
emit(AuthTokenLoading());
const storage = FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
));
const storage = FlutterSecureStorage();
final firstLaunch =
await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true;
@@ -1,3 +1,5 @@
import 'dart:math';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_event.dart';
import 'package:syncrow_app/features/devices/bloc/smart_door_bloc/smart_door_state.dart';
@@ -44,4 +46,14 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
} catch (_) {}
emit(UpdateState(smartDoorModel: deviceStatus));
}
int generate7DigitNumber() {
Random random = Random();
int min = 1000000; // Minimum 7-digit number
int max = 9999999; // Maximum 7-digit number
return min + random.nextInt(max - min + 1);
}
}
@@ -15,3 +15,5 @@ class UpdateLockEvent extends SmartDoorEvent {
@override
List<Object> get props => [value];
}
@@ -0,0 +1,266 @@
import 'package:day_picker/day_picker.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
import 'package:time_picker_spinner/time_picker_spinner.dart';
class CreateTemporaryPassword extends StatefulWidget {
const CreateTemporaryPassword({super.key});
@override
State<CreateTemporaryPassword> createState() =>
_CreateTemporaryPasswordState();
}
class _CreateTemporaryPasswordState extends State<CreateTemporaryPassword> {
List<DayInWeek> _days = [
DayInWeek(
"Sun",
dayKey: '',
),
DayInWeek(
"Mon",
dayKey: '',
),
DayInWeek("Tue", isSelected: true, dayKey: ''),
DayInWeek(
"Wed",
dayKey: '',
),
DayInWeek(
"Thu",
dayKey: '',
),
DayInWeek(
"Fri",
dayKey: '',
),
DayInWeek(
"Sat",
dayKey: '',
),
];
DateTime dateTime = DateTime.now();
@override
Widget build(BuildContext context) {
TextEditingController? controller = TextEditingController();
return DefaultScaffold(
title: 'Create Password',
actions: [TextButton(onPressed: () {}, child: const Text('Save'))],
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BodyMedium(
text:
'Save the password immediately. The password is not displayed in the app.',
fontWeight: FontWeight.normal,
fontColor: ColorsManager.grayColor,
),
SizedBox(
height: 20,
),
const BodyMedium(
text: '7-Digit Password',
fontWeight: FontWeight.normal,
fontColor: ColorsManager.grayColor,
),
DefaultContainer(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
child: Row(
children: [
Expanded(
child: PinCodeTextField(
keyboardType: TextInputType.phone,
length: 7,
enabled: true,
obscureText: false,
animationType: AnimationType.fade,
pinTheme: PinTheme(
shape: PinCodeFieldShape.underline,
fieldHeight: 45,
fieldWidth: 20,
activeFillColor: Colors.white,
disabledColor: Colors.grey,
activeColor: Colors.grey,
errorBorderColor: Colors.grey,
inactiveColor: Colors.grey,
inactiveFillColor: Colors.grey,
selectedColor: Colors.grey),
animationDuration: Duration(milliseconds: 300),
backgroundColor: Colors.white,
enableActiveFill: false,
controller: controller,
onCompleted: (v) {
print("Completed");
},
onChanged: (value) {
print(value);
},
appContext: context,
)),
const SizedBox(
width: 10,
),
InkWell(
onTap: () {},
child: const BodyMedium(
text: 'Generate Randomly',
fontWeight: FontWeight.bold,
fontColor: ColorsManager.primaryColor,
))
],
),
),
const SizedBox(
height: 20,
),
DefaultContainer(
padding: const EdgeInsets.all(10),
child: Column(
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: const BodyMedium(
text: 'Password Name',
fontWeight: FontWeight.normal,
),
trailing: Container(
width: MediaQuery.of(context).size.width / 2,
child: TextFormField(
decoration:
InputDecoration(labelText: 'Enter The Name'),
)),
),
Divider(),
ListTile(
contentPadding: EdgeInsets.zero,
leading: const BodyMedium(
text: 'Effective Time',
fontWeight: FontWeight.normal,
),
trailing: Container(
width: MediaQuery.of(context).size.width / 2,
child: TextFormField(
enabled: false,
decoration: InputDecoration(
border: InputBorder.none,
labelText: 'Select Time'),
)),
),
Divider(),
ListTile(
contentPadding: EdgeInsets.zero,
leading: const BodyMedium(
text: 'Select Time',
fontWeight: FontWeight.normal,
),
trailing: Container(
width: MediaQuery.of(context).size.width / 2,
child: TextFormField(
enabled: false,
decoration: InputDecoration(
border: InputBorder.none,
labelText: 'Select Time'),
)),
),
],
)),
SizedBox(
height: 20,
),
DefaultContainer(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: const BodyMedium(
text: 'Repeat',
fontWeight: FontWeight.normal,
),
trailing: Transform.scale(
scale: .8,
child: CupertinoSwitch(
value: true,
onChanged: (value) {},
applyTheme: true,
)),
),
),
const SizedBox(
height: 20,
),
DefaultContainer(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
onPressed: () {},
child: const Text('Start'),
),
TextButton(
onPressed: () {},
child: const Text('End'),
)
],
),
Divider(),
SizedBox(
height: 80,
child: TimePickerSpinner(
spacing: 10,
locale: const Locale('en', ''),
time: dateTime,
is24HourMode: false,
itemHeight: 40,
normalTextStyle: const TextStyle(
fontSize: 24,
),
highlightedTextStyle:
const TextStyle(fontSize: 24, color: Colors.blue),
onTimeChange: (time) {
setState(() {
dateTime = time;
});
},
),
),
Divider(),
SizedBox(height: 20),
SelectWeekDays(
width: MediaQuery.of(context).size.width/1,
fontSize: 10,
fontWeight: FontWeight.w600,
days: _days,
border: false,
selectedDayTextColor: Colors.black,
unSelectedDayTextColor: Colors.grey,
boxDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(30.0),
color: Colors.white),
onSelect: (values) {
print(values);
},
),
],
)),
SizedBox(height: 40,)
],
),
),
);
}
}
@@ -3,6 +3,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/members_management_view.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/smart_linkage_view.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/temporary_password_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/unlocking_records_view.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
@@ -79,7 +80,7 @@ List<Map<String, dynamic>> doorLockButtons = [
{
'title': 'Temporary Password',
'image': Assets.assetsIconsDoorlockAssetsTemporaryPassword,
'page': null,
'page':const TemporaryPasswordPage() ,
},
{
'title': 'Smart Linkage',
@@ -36,7 +36,6 @@ class DoorInterface extends StatelessWidget {
),
);
}
}, builder: (context, state) {
SmartDoorModel smartDoorModel = SmartDoorModel(
unlockFingerprint: 0,
@@ -113,6 +112,7 @@ class DoorInterface extends StatelessWidget {
smartDoorModel: smartDoorModel,
),
const DoorLockGrid(),
],
)
],
@@ -0,0 +1,225 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/view_temporary_password.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class TemporaryPasswordPage extends StatefulWidget {
const TemporaryPasswordPage({super.key});
@override
State<TemporaryPasswordPage> createState() => _TemporaryPasswordPageState();
}
class _TemporaryPasswordPageState extends State<TemporaryPasswordPage> {
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Temporary Password',
child: Column(
children: [
const SizedBox(height: 10),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const BodyLarge(
text: 'Online Password',
fontWeight: FontWeight.normal,
fontColor: Color(0xfff999999),
),
const BodyMedium(
text: 'We recommend that you use the online password when the Wi-Fi network is stable.',
fontWeight: FontWeight.normal,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 10),
DefaultContainer(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
child:ListTile(
contentPadding: EdgeInsets.zero,
leading: SvgPicture.asset(
Assets.timeLimitedPasswordIcon),
title: const BodyMedium(
text: 'Time-Limited Password',
fontWeight: FontWeight.normal,
),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => const ViewTemporaryPassword(),));
},
trailing: const Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
),
),
// Row(
// children: [
// Expanded(
// child: Row(
// children: [
// SizedBox(
// width: 45,
// height: 40,
// child: SvgPicture.asset(
// Assets.timeLimitedPasswordIcon),
// ),
// const SizedBox(width: 15),
// const Expanded(
// child:
// BodyMedium(
// text: 'Time-Limited Password',
// fontWeight: FontWeight.normal,
// ),
// ),
// ],
// ),
// ),
// const Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// Icon(
// Icons.arrow_forward_ios,
// color: ColorsManager.greyColor,
// size: 15,
// ),
// ],
// ),
// ],
// ),
),
],
),
const SizedBox(height: 10),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const BodyLarge(
text: 'Offline Password',
fontWeight: FontWeight.normal,
fontColor: Color(0xfff999999),
),
const BodyMedium(
text: 'WWe recommend that you use the offline password when the Wi-Fi is disconnected or in an unstable Wi-Fi environment.',
fontWeight: FontWeight.normal,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 10),
DefaultContainer(
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 20),
child: Column(children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: SvgPicture.asset(Assets.oneTimePassword),
title:
const BodyMedium(
text: 'One-Time Password',
fontWeight: FontWeight.normal,
),
onTap: () {},
trailing: const Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
),
),
// Row(
// children: [
// Expanded(
// child: Row(
// children: [
// SizedBox(
// width: 45,
// height: 40,
// child: SvgPicture.asset(
// Assets.oneTimePassword),
// ),
// const SizedBox(width: 15),
// const Expanded(
// child: BodyMedium(
// text: 'One-Time Password',
// fontWeight: FontWeight.normal,
// ),
// ),
// ],
// ),
// ),
// const Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// Icon(
// Icons.arrow_forward_ios,
// color: ColorsManager.greyColor,
// size: 15,
// ),
// ],
// ),
// ],
// ),
const Divider( ),
ListTile(
contentPadding: EdgeInsets.zero,
leading: SvgPicture.asset(
Assets.timeLimitedPassword),
title: BodyMedium(
text: 'Time-Limited Password',
fontWeight: FontWeight.normal,
),
onTap: () {},
trailing: const Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
),
),
// Row(
// children: [
// Expanded(
// child: Row(
// children: [
// SizedBox(
// width: 45,
// height: 40,
// child: SvgPicture.asset(
// Assets.timeLimitedPassword),
//
// ),
// const SizedBox(width: 15),
// const Expanded(
// child: BodyMedium(
// text: 'Time-Limited Password',
// fontWeight: FontWeight.normal,
// ),
// ),
// ],
// ),
// ),
// const Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// Icon(
// Icons.arrow_forward_ios,
// color: ColorsManager.greyColor,
// size: 15,
// ),
// ],
// ),
// ],
// ),
],)
),
],
),
const Spacer(),
],
),
);
}
}
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'create_temporary_password.dart';
class ViewTemporaryPassword extends StatelessWidget {
const ViewTemporaryPassword({super.key});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Passwords',
actions: [
IconButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => const CreateTemporaryPassword(),));
},
icon: const Icon(Icons.add)
)
],
child: Container(
child: Center(
child:Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.noValidPasswords
),
const SizedBox(height: 10,),
const BodyMedium(text: 'No Valid Passwords')
],
),
),
)
);;
}
}