From 49551cea42bc869c6ccf2b527a7efecaef4e0307 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Thu, 22 Sep 2022 21:17:00 +0530 Subject: [PATCH 01/10] included signup page in dummy routine --- lib/main.dart | 3 +++ lib/pages/signup_page.dart | 6 +++++- lib/pages/welcome_pages/welcome_screen1.dart | 2 +- lib/pages/welcome_pages/welcome_screen3.dart | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 3bd6d2a..29ff4ed 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -88,6 +88,9 @@ class MyApp extends StatelessWidget { case '/settings': builder = (context) => const SettingsPage(); break; + case '/signup': + builder = (context) => const SignUpPage(); + break; default: builder = (context) => HomePage(); } diff --git a/lib/pages/signup_page.dart b/lib/pages/signup_page.dart index fabc39a..0ff0d6f 100644 --- a/lib/pages/signup_page.dart +++ b/lib/pages/signup_page.dart @@ -35,9 +35,13 @@ class SignUpPage extends StatelessWidget { TextInputField('Mobile Number'), TextInputField('Gender'), const SizedBox(height: 30,), - Button('Sign up', onPressed: (){}), + Button('Sign up', onPressed: (){ + print('Sign up'); + Navigator.popAndPushNamed(context, '/home'); + }), const SizedBox(height: 20,), Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('Already had an account?'), TextButton(onPressed: () => _openRecoverAccountDialog(context), child: const Text('Recover it here')) diff --git a/lib/pages/welcome_pages/welcome_screen1.dart b/lib/pages/welcome_pages/welcome_screen1.dart index aafb27a..39d9013 100644 --- a/lib/pages/welcome_pages/welcome_screen1.dart +++ b/lib/pages/welcome_pages/welcome_screen1.dart @@ -51,7 +51,7 @@ class WelcomeScreen1 extends StatelessWidget { } void _navigateToHomeScreen(BuildContext context) { - Navigator.popAndPushNamed(context, '/home'); + Navigator.popAndPushNamed(context, '/signup'); } void _navigateToWelcomeScreen2(BuildContext context) { diff --git a/lib/pages/welcome_pages/welcome_screen3.dart b/lib/pages/welcome_pages/welcome_screen3.dart index b697783..ba8730d 100644 --- a/lib/pages/welcome_pages/welcome_screen3.dart +++ b/lib/pages/welcome_pages/welcome_screen3.dart @@ -47,7 +47,7 @@ class WelcomeScreen3 extends StatelessWidget { } void _navigateToHomeScreen(BuildContext context) { - Navigator.popAndPushNamed(context, '/home'); + Navigator.popAndPushNamed(context, '/signup'); } void _navigateToWelcomeScreen2(BuildContext context) { From 73515eba318d34649552bf4db96132186493e3fc Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Thu, 22 Sep 2022 22:03:17 +0530 Subject: [PATCH 02/10] used bloc library to simulate initializing process. --- lib/bloc/initialize/initialize_bloc.dart | 21 +++++++++++++ lib/bloc/initialize/initialize_event.dart | 6 ++++ lib/bloc/initialize/initialize_state.dart | 10 ++++++ lib/pages/opening_screen.dart | 37 +++++++++++++++++++---- 4 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 lib/bloc/initialize/initialize_bloc.dart create mode 100644 lib/bloc/initialize/initialize_event.dart create mode 100644 lib/bloc/initialize/initialize_state.dart diff --git a/lib/bloc/initialize/initialize_bloc.dart b/lib/bloc/initialize/initialize_bloc.dart new file mode 100644 index 0000000..bc52627 --- /dev/null +++ b/lib/bloc/initialize/initialize_bloc.dart @@ -0,0 +1,21 @@ +import 'dart:async'; + +import 'package:bloc/bloc.dart'; +import 'package:meta/meta.dart'; + +part 'initialize_event.dart'; +part 'initialize_state.dart'; + +class InitializeBloc extends Bloc { + InitializeBloc() : super(Initial()) { + on((event, emit) async{ + emit(Initial()); + + //simulate the initializing tests + // ex:- check registration status + await Future.delayed(const Duration(seconds: 3)); + + emit(NotRegistered()); + }); + } +} diff --git a/lib/bloc/initialize/initialize_event.dart b/lib/bloc/initialize/initialize_event.dart new file mode 100644 index 0000000..f74162c --- /dev/null +++ b/lib/bloc/initialize/initialize_event.dart @@ -0,0 +1,6 @@ +part of 'initialize_bloc.dart'; + +@immutable +abstract class InitializeEvent {} + +class InitializeAppEvent extends InitializeEvent {} \ No newline at end of file diff --git a/lib/bloc/initialize/initialize_state.dart b/lib/bloc/initialize/initialize_state.dart new file mode 100644 index 0000000..9a75ca8 --- /dev/null +++ b/lib/bloc/initialize/initialize_state.dart @@ -0,0 +1,10 @@ +part of 'initialize_bloc.dart'; + +@immutable +abstract class InitializeState {} + +class Initial extends InitializeState {} + +class Registered extends InitializeState {} + +class NotRegistered extends InitializeState {} diff --git a/lib/pages/opening_screen.dart b/lib/pages/opening_screen.dart index 0276c88..7600665 100644 --- a/lib/pages/opening_screen.dart +++ b/lib/pages/opening_screen.dart @@ -1,16 +1,27 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import '../../bloc/initialize/initialize_bloc.dart'; -class OpeningScreen extends StatelessWidget { +class OpeningScreen extends StatefulWidget { const OpeningScreen({Key? key}) : super(key: key); @override - Widget build(BuildContext context) { + State createState() => _OpeningScreenState(); +} + +class _OpeningScreenState extends State { + final InitializeBloc _initializeBloc = InitializeBloc(); + + @override + void initState() { + super.initState(); + _initializeBloc.add(InitializeAppEvent()); + } - Timer(const Duration(seconds: 3), () { - _navigateToWelcomeScreen1(context); - }); + @override + Widget build(BuildContext context) { return Scaffold( body: SizedBox( @@ -34,7 +45,21 @@ class OpeningScreen extends StatelessWidget { const SizedBox( height: 20, ), - const Text('Loading...'), + + BlocProvider( + create: (context) => _initializeBloc, + child: BlocListener( + listener: (context, state) { + if (state is NotRegistered) { + Navigator.popAndPushNamed(context, '/welcome1'); + } + else if (state is Registered) { + Navigator.popAndPushNamed(context, '/home'); + } + }, + child: const Text('Initializing...'), + ), + ), ], ), ), From 38b0bbba9b0ccf458fb328984ba8f5f98b152202 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Thu, 22 Sep 2022 22:16:21 +0530 Subject: [PATCH 03/10] included TextEditor controller for custom TextInputField widget --- lib/widgets/forms/text_input_field.dart | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/widgets/forms/text_input_field.dart b/lib/widgets/forms/text_input_field.dart index b29457c..c2e373d 100644 --- a/lib/widgets/forms/text_input_field.dart +++ b/lib/widgets/forms/text_input_field.dart @@ -1,18 +1,29 @@ import 'package:flutter/material.dart'; -class TextInputField extends StatelessWidget { +class TextInputField extends StatefulWidget { final String label; + TextEditingController controller = TextEditingController(); EdgeInsets padding ; - TextInputField(this.label, {Key? key, this.padding = const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30)}) : super(key: key); + TextInputField(this.label, { + Key? key, + TextEditingController? controller, + this.padding = const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30) + }) : super(key: key); + @override + State createState() => _TextInputFieldState(); +} + +class _TextInputFieldState extends State { @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30), child: TextFormField( + controller: widget.controller, decoration: InputDecoration( - labelText: label, + labelText: widget.label, labelStyle: const TextStyle( color: Colors.black, fontSize: 16, From 55c45850bf87682502b0ee13e5a4e833fbe07a26 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Thu, 22 Sep 2022 22:49:48 +0530 Subject: [PATCH 04/10] created bloc classes for sign up --- lib/bloc/signup/signup_bloc.dart | 21 +++++++++++++++++++++ lib/bloc/signup/signup_event.dart | 22 ++++++++++++++++++++++ lib/bloc/signup/signup_state.dart | 12 ++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 lib/bloc/signup/signup_bloc.dart create mode 100644 lib/bloc/signup/signup_event.dart create mode 100644 lib/bloc/signup/signup_state.dart diff --git a/lib/bloc/signup/signup_bloc.dart b/lib/bloc/signup/signup_bloc.dart new file mode 100644 index 0000000..f5405b7 --- /dev/null +++ b/lib/bloc/signup/signup_bloc.dart @@ -0,0 +1,21 @@ +import 'dart:async'; + +import 'package:bloc/bloc.dart'; +import 'package:meta/meta.dart'; + +part 'signup_event.dart'; +part 'signup_state.dart'; + +class SignupBloc extends Bloc { + SignupBloc() : super(Initial()) { + on((event, emit) async{ + emit(Submitted()); + + //simulate the signup process + // creating a wallet, storing the data in wallet + await Future.delayed(const Duration(seconds: 3)); + + emit(Success()); + }); + } +} diff --git a/lib/bloc/signup/signup_event.dart b/lib/bloc/signup/signup_event.dart new file mode 100644 index 0000000..7f33051 --- /dev/null +++ b/lib/bloc/signup/signup_event.dart @@ -0,0 +1,22 @@ +part of 'signup_bloc.dart'; + +@immutable +abstract class SignupEvent {} + +class SubmitSignupEvent extends SignupEvent { + final String name; + final String email; + final String dob; + final String country; + final String phone; + final String gender; + + SubmitSignupEvent({ + required this.name, + required this.email, + required this.dob, + required this.country, + required this.phone, + required this.gender + }); +} \ No newline at end of file diff --git a/lib/bloc/signup/signup_state.dart b/lib/bloc/signup/signup_state.dart new file mode 100644 index 0000000..34529ce --- /dev/null +++ b/lib/bloc/signup/signup_state.dart @@ -0,0 +1,12 @@ +part of 'signup_bloc.dart'; + +@immutable +abstract class SignupState {} + +class Initial extends SignupState {} + +class Submitted extends SignupState {} + +class Success extends SignupState {} + +class Failed extends SignupState {} \ No newline at end of file From e4f47056d68b8c9f2da069e60666c4b524d3df49 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Thu, 22 Sep 2022 22:50:39 +0530 Subject: [PATCH 05/10] use bloc to outline the signup --- lib/pages/signup_page.dart | 64 +++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/lib/pages/signup_page.dart b/lib/pages/signup_page.dart index 0ff0d6f..34e66ad 100644 --- a/lib/pages/signup_page.dart +++ b/lib/pages/signup_page.dart @@ -1,11 +1,28 @@ import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../bloc/signup/signup_bloc.dart'; import '../widgets/forms/text_input_field.dart'; import '../widgets/forms/button.dart'; -class SignUpPage extends StatelessWidget { +class SignUpPage extends StatefulWidget { const SignUpPage({Key? key}) : super(key: key); + @override + State createState() => _SignUpPageState(); +} + +class _SignUpPageState extends State { + final SignupBloc _signupBloc = SignupBloc(); + + final TextEditingController _nameController = TextEditingController(); + final TextEditingController _emailController = TextEditingController(); + final TextEditingController _dobController = TextEditingController(); + final TextEditingController _countryController = TextEditingController(); + final TextEditingController _mobileNumberController = TextEditingController(); + final TextEditingController _genderController = TextEditingController(); + @override Widget build(BuildContext context) { return Scaffold( @@ -28,17 +45,42 @@ class SignUpPage extends StatelessWidget { 'Sign Up', style: Theme.of(context).textTheme.titleLarge, )), - TextInputField('Full Name'), - TextInputField('Email'), - TextInputField('Date of Birth'), - TextInputField('Country'), - TextInputField('Mobile Number'), - TextInputField('Gender'), + TextInputField('Full Name', controller: _nameController), + TextInputField('Email', controller: _emailController), + TextInputField('Date of Birth', controller: _dobController), + TextInputField('Country', controller: _countryController), + TextInputField('Mobile Number', controller: _mobileNumberController), + TextInputField('Gender', controller: _genderController), const SizedBox(height: 30,), - Button('Sign up', onPressed: (){ - print('Sign up'); - Navigator.popAndPushNamed(context, '/home'); - }), + + BlocProvider( + create: (context) => _signupBloc, + child: BlocListener( + listener: (context, state) { + if (state is Submitted){ + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Submitting...'), + ), + ); + } + else if (state is Success) { + Navigator.popAndPushNamed(context, '/home'); + } + }, + child: Button('Sign Up', onPressed: () { + _signupBloc.add(SubmitSignupEvent( + name: _nameController.text, + email: _emailController.text, + dob: _dobController.text, + country: _countryController.text, + phone: _mobileNumberController.text, + gender: _genderController.text + )); + }), + ), + + ), const SizedBox(height: 20,), Row( mainAxisAlignment: MainAxisAlignment.center, From 901c4f9a7580e1e3c9d93c1f77c2134cbaf0268f Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Fri, 23 Sep 2022 11:33:09 +0530 Subject: [PATCH 06/10] designed date input field --- lib/pages/signup_page.dart | 25 +++++++---- lib/widgets/forms/date_input_field.dart | 55 +++++++++++++++++++++++++ lib/widgets/forms/text_input_field.dart | 2 +- pubspec.lock | 14 +++++++ pubspec.yaml | 1 + 5 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 lib/widgets/forms/date_input_field.dart diff --git a/lib/pages/signup_page.dart b/lib/pages/signup_page.dart index 34e66ad..19a8be7 100644 --- a/lib/pages/signup_page.dart +++ b/lib/pages/signup_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../bloc/signup/signup_bloc.dart'; +import '../widgets/forms/date_input_field.dart'; import '../widgets/forms/text_input_field.dart'; import '../widgets/forms/button.dart'; @@ -47,7 +48,7 @@ class _SignUpPageState extends State { )), TextInputField('Full Name', controller: _nameController), TextInputField('Email', controller: _emailController), - TextInputField('Date of Birth', controller: _dobController), + DateInputField('Date of Birth', controller: _dobController), TextInputField('Country', controller: _countryController), TextInputField('Mobile Number', controller: _mobileNumberController), TextInputField('Gender', controller: _genderController), @@ -69,14 +70,16 @@ class _SignUpPageState extends State { } }, child: Button('Sign Up', onPressed: () { - _signupBloc.add(SubmitSignupEvent( - name: _nameController.text, - email: _emailController.text, - dob: _dobController.text, - country: _countryController.text, - phone: _mobileNumberController.text, - gender: _genderController.text - )); + if (_validateInputs()){ + _signupBloc.add(SubmitSignupEvent( + name: _nameController.text, + email: _emailController.text, + dob: _dobController.text, + country: _countryController.text, + phone: _mobileNumberController.text, + gender: _genderController.text + )); + } }), ), @@ -110,4 +113,8 @@ class _SignUpPageState extends State { ); }); } + + bool _validateInputs(){ + return true; + } } diff --git a/lib/widgets/forms/date_input_field.dart b/lib/widgets/forms/date_input_field.dart new file mode 100644 index 0000000..24a516a --- /dev/null +++ b/lib/widgets/forms/date_input_field.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; + +import 'package:date_field/date_field.dart'; + +class DateInputField extends StatefulWidget { + final String label; + TextEditingController controller = TextEditingController(); + EdgeInsets padding ; + + DateInputField(this.label, { + Key? key, + TextEditingController? controller, + this.padding = const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30) + }) : super(key: key); + + @override + State createState() => _DateInputFieldState(); +} + +class _DateInputFieldState extends State { + + @override + Widget build(BuildContext context) { + return Padding( + padding: widget.padding, + child: DateTimeFormField( + decoration: InputDecoration( + labelText: widget.label, + labelStyle: const TextStyle( + color: Colors.black, + fontSize: 16, + ), + enabledBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.black, + width: 1, + ), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 1, + ), + ), + suffixIcon: const Icon(Icons.event_note), + ), + mode: DateTimeFieldPickerMode.date, + autovalidateMode: AutovalidateMode.always, + onDateSelected: (DateTime value) { + widget.controller.text = value.toString(); + }, + ), + ); + } +} \ No newline at end of file diff --git a/lib/widgets/forms/text_input_field.dart b/lib/widgets/forms/text_input_field.dart index c2e373d..efc838b 100644 --- a/lib/widgets/forms/text_input_field.dart +++ b/lib/widgets/forms/text_input_field.dart @@ -19,7 +19,7 @@ class _TextInputFieldState extends State { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30), + padding: widget.padding, child: TextFormField( controller: widget.controller, decoration: InputDecoration( diff --git a/pubspec.lock b/pubspec.lock index 2520fe1..9492ee4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + date_field: + dependency: "direct main" + description: + name: date_field + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" equatable: dependency: "direct main" description: @@ -100,6 +107,13 @@ packages: description: flutter source: sdk version: "0.0.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" js: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c588565..0d04ac4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: flutter_bloc: ^8.0.1 equatable: ^2.0.3 qr_code_scanner: ^1.0.0 + date_field: ^3.0.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. From f2d69d05a7d472a42c43a96433ecd5887a689f70 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Fri, 23 Sep 2022 11:56:10 +0530 Subject: [PATCH 07/10] designed select input field --- lib/pages/signup_page.dart | 3 +- lib/widgets/forms/select_input_field.dart | 61 +++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 lib/widgets/forms/select_input_field.dart diff --git a/lib/pages/signup_page.dart b/lib/pages/signup_page.dart index 19a8be7..1524a4a 100644 --- a/lib/pages/signup_page.dart +++ b/lib/pages/signup_page.dart @@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../bloc/signup/signup_bloc.dart'; import '../widgets/forms/date_input_field.dart'; +import '../widgets/forms/select_input_field.dart'; import '../widgets/forms/text_input_field.dart'; import '../widgets/forms/button.dart'; @@ -51,7 +52,7 @@ class _SignUpPageState extends State { DateInputField('Date of Birth', controller: _dobController), TextInputField('Country', controller: _countryController), TextInputField('Mobile Number', controller: _mobileNumberController), - TextInputField('Gender', controller: _genderController), + SelectInputField('Gender', const ['Male', 'Female', 'Other'], controller: _genderController), const SizedBox(height: 30,), BlocProvider( diff --git a/lib/widgets/forms/select_input_field.dart b/lib/widgets/forms/select_input_field.dart new file mode 100644 index 0000000..3a31b4d --- /dev/null +++ b/lib/widgets/forms/select_input_field.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; + +class SelectInputField extends StatefulWidget { + final String label; + final List options; + final TextEditingController controller = TextEditingController(); + EdgeInsets padding; + + SelectInputField(this.label, this.options, + { Key? key, + TextEditingController? controller, + this.padding = + const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30)}) + : super(key: key); + + @override + State createState() => _SelectInputFieldState(); +} + +class _SelectInputFieldState extends State { + @override + Widget build(BuildContext context) { + return Padding( + padding: widget.padding, + child: DropdownButtonFormField( + decoration: InputDecoration( + labelText: widget.label, + labelStyle: const TextStyle( + color: Colors.black, + fontSize: 16, + ), + enabledBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.black, + width: 1, + ), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blue, + width: 1, + ), + ), + ), + style: const TextStyle( + color: Colors.black, + fontSize: 16, + ), + items: widget.options.map((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + onChanged: (String? value) { + widget.controller.text = value!; + }, + ), + ); + } +} From cd1a7d6db565625d5b2611e423e7fde317da1211 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Fri, 23 Sep 2022 14:14:52 +0530 Subject: [PATCH 08/10] bugfix: TextEditor controller didn't contain the input value --- lib/pages/signup_page.dart | 10 +++++++++- lib/widgets/add_new_dialog.dart | 4 ++-- lib/widgets/forms/date_input_field.dart | 4 ++-- lib/widgets/forms/select_input_field.dart | 4 ++-- lib/widgets/forms/text_input_field.dart | 4 ++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/pages/signup_page.dart b/lib/pages/signup_page.dart index 1524a4a..a117f8e 100644 --- a/lib/pages/signup_page.dart +++ b/lib/pages/signup_page.dart @@ -71,6 +71,14 @@ class _SignUpPageState extends State { } }, child: Button('Sign Up', onPressed: () { + print({ + 'name': _nameController.text, + 'email': _emailController.text, + 'dob': _dobController.text, + 'country': _countryController.text, + 'phone': _mobileNumberController.text, + 'gender': _genderController.text + }); if (_validateInputs()){ _signupBloc.add(SubmitSignupEvent( name: _nameController.text, @@ -106,7 +114,7 @@ class _SignUpPageState extends State { builder: (context) { return AlertDialog( title: const Text('Recover Account'), - content: TextInputField('Enter recovery phrase'), + content: TextInputField('Enter recovery phrase', controller: TextEditingController(),), actions: [ TextButton(onPressed: () => Navigator.pop(context), child: const Text('Cancel')), ElevatedButton(onPressed: () => Navigator.pop(context), child: const Text('Submit')) diff --git a/lib/widgets/add_new_dialog.dart b/lib/widgets/add_new_dialog.dart index 7765bfc..6ac3df2 100644 --- a/lib/widgets/add_new_dialog.dart +++ b/lib/widgets/add_new_dialog.dart @@ -11,8 +11,8 @@ class AddNewDialog extends StatelessWidget { content: Column( mainAxisSize: MainAxisSize.min, children: [ - TextInputField("Property Name", padding: const EdgeInsets.all(8),), - TextInputField("Property Value", padding: const EdgeInsets.all(8),), + TextInputField("Property Name", padding: const EdgeInsets.all(8), controller: TextEditingController(),), + TextInputField("Property Value", padding: const EdgeInsets.all(8), controller: TextEditingController(),), ], ), actions: [ diff --git a/lib/widgets/forms/date_input_field.dart b/lib/widgets/forms/date_input_field.dart index 24a516a..763dee1 100644 --- a/lib/widgets/forms/date_input_field.dart +++ b/lib/widgets/forms/date_input_field.dart @@ -4,12 +4,12 @@ import 'package:date_field/date_field.dart'; class DateInputField extends StatefulWidget { final String label; - TextEditingController controller = TextEditingController(); + final TextEditingController controller; EdgeInsets padding ; DateInputField(this.label, { Key? key, - TextEditingController? controller, + required this.controller, this.padding = const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30) }) : super(key: key); diff --git a/lib/widgets/forms/select_input_field.dart b/lib/widgets/forms/select_input_field.dart index 3a31b4d..f39a125 100644 --- a/lib/widgets/forms/select_input_field.dart +++ b/lib/widgets/forms/select_input_field.dart @@ -3,12 +3,12 @@ import 'package:flutter/material.dart'; class SelectInputField extends StatefulWidget { final String label; final List options; - final TextEditingController controller = TextEditingController(); + final TextEditingController controller; EdgeInsets padding; SelectInputField(this.label, this.options, { Key? key, - TextEditingController? controller, + required this.controller, this.padding = const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30)}) : super(key: key); diff --git a/lib/widgets/forms/text_input_field.dart b/lib/widgets/forms/text_input_field.dart index efc838b..d69f9dd 100644 --- a/lib/widgets/forms/text_input_field.dart +++ b/lib/widgets/forms/text_input_field.dart @@ -2,12 +2,12 @@ import 'package:flutter/material.dart'; class TextInputField extends StatefulWidget { final String label; - TextEditingController controller = TextEditingController(); + final TextEditingController controller; EdgeInsets padding ; TextInputField(this.label, { Key? key, - TextEditingController? controller, + required this.controller, this.padding = const EdgeInsets.only(top: 8, bottom: 8, left: 30, right: 30) }) : super(key: key); From a7f0cb817661f7aa702ab4f6ed473412d028f0f4 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Sat, 24 Sep 2022 11:28:34 +0530 Subject: [PATCH 09/10] get the data from signup page to home page --- lib/pages/home_page.dart | 53 +------------------------------------- lib/pages/signup_page.dart | 18 ++++++------- 2 files changed, 10 insertions(+), 61 deletions(-) diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index dc5d626..8238c17 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -5,16 +5,9 @@ import '../widgets/add_new_dialog.dart'; class HomePage extends StatelessWidget { HomePage({Key? key}) : super(key: key); - final data = {"Name": "Test User", - "Email Address": "test@iblock.com", - "Date of Birth" : "01/01/2000", - "Country" : "United States", - "Mobile Number" : "+1 123 456 7890", - "Gender" : "Male" - }; - @override Widget build(BuildContext context) { + final data = ModalRoute.of(context)!.settings.arguments as Map; return Scaffold( body: SafeArea( child: SizedBox( @@ -43,50 +36,6 @@ class HomePage extends StatelessWidget { Padding( padding: const EdgeInsets.all(10), child: Text(e.value)) ])).toList() - // const [ - // TableRow(children: [ - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("Email Address", - // style: TextStyle(fontWeight: FontWeight.bold))), - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("test@iblock.com")) - // ]), - // TableRow(children: [ - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("Date of Birth", - // style: TextStyle(fontWeight: FontWeight.bold))), - // Padding( - // padding: EdgeInsets.all(10), child: Text("01/01/2000")) - // ]), - // TableRow(children: [ - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("Country", - // style: TextStyle(fontWeight: FontWeight.bold))), - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("United States")) - // ]), - // TableRow(children: [ - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("Mobile Number", - // style: TextStyle(fontWeight: FontWeight.bold))), - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("+1 123 456 7890")) - // ]), - // TableRow(children: [ - // Padding( - // padding: EdgeInsets.all(10), - // child: Text("Gender", - // style: TextStyle(fontWeight: FontWeight.bold))), - // Padding(padding: EdgeInsets.all(10), child: Text("Male")) - // ]), - // ], ) ], ), diff --git a/lib/pages/signup_page.dart b/lib/pages/signup_page.dart index a117f8e..aa75ed3 100644 --- a/lib/pages/signup_page.dart +++ b/lib/pages/signup_page.dart @@ -67,18 +67,18 @@ class _SignUpPageState extends State { ); } else if (state is Success) { - Navigator.popAndPushNamed(context, '/home'); + Navigator.popAndPushNamed(context, '/home', + arguments: { + 'Name': _nameController.text, + 'Email': _emailController.text, + 'Date of Birth': _dobController.text, + 'Country': _countryController.text, + 'Phone': _mobileNumberController.text, + 'Gender': _genderController.text + }); } }, child: Button('Sign Up', onPressed: () { - print({ - 'name': _nameController.text, - 'email': _emailController.text, - 'dob': _dobController.text, - 'country': _countryController.text, - 'phone': _mobileNumberController.text, - 'gender': _genderController.text - }); if (_validateInputs()){ _signupBloc.add(SubmitSignupEvent( name: _nameController.text, From 68889d8336e904842ca1cbf914d24283e55c3931 Mon Sep 17 00:00:00 2001 From: Mohamed Ishad Date: Sun, 25 Sep 2022 21:05:04 +0530 Subject: [PATCH 10/10] extract the information from qr code --- lib/pages/qr_result_page.dart | 78 ++++++++++-- lib/widgets/qr_scanner.dart | 3 +- pubspec.lock | 224 ++++++++++++++++++++++++++++++++++ pubspec.yaml | 3 + 4 files changed, 298 insertions(+), 10 deletions(-) diff --git a/lib/pages/qr_result_page.dart b/lib/pages/qr_result_page.dart index 4088fd1..7d4f411 100644 --- a/lib/pages/qr_result_page.dart +++ b/lib/pages/qr_result_page.dart @@ -1,4 +1,5 @@ -import 'package:flutter/foundation.dart'; +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:qr_code_scanner/qr_code_scanner.dart'; @@ -8,13 +9,74 @@ class QRResultPage extends StatelessWidget { @override Widget build(BuildContext context) { + print((jsonDecode(result.code!) as Map)['information'] + as List); return Scaffold( - appBar: AppBar( - title: const Text('QR Result'), - ), - body: Center( - child: Text(result.code != null ? 'Barcode Type: ${describeEnum(result.format)} Data: ${result.code}': 'No result'), - ), - ); + appBar: AppBar( + title: const Text('Requesting Information'), + ), + body: (result.code == null) + ? const Center( + child: Text('Error'), + ) + : SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + flex: 9, + child: Column( + children: ((jsonDecode(result.code!) + as Map)['information'] + as List) + .map((e) => Padding( + padding: const EdgeInsets.all(4.0), + child: Text( + e, + style: const TextStyle(fontSize: 14), + ), + )) + .toList(), + )), + Expanded( + flex: 1, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () {}, + style: + ElevatedButton.styleFrom(primary: Colors.blue) + .copyWith( + elevation: + ButtonStyleButton.allOrNull(0.0)), + child: const Text("Approve"), + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: ElevatedButton( + onPressed: () {}, + style: + ElevatedButton.styleFrom(primary: Colors.red) + .copyWith( + elevation: + ButtonStyleButton.allOrNull(0.0)), + child: const Text("Decline"), + ), + ), + ], + ), + ) + ], + ), + ) + // Center( + // child: Text(result.code != null ? 'Barcode Type: ${describeEnum(result.format)} Data: ${result.code}': 'No result'), + // ), + ); } } diff --git a/lib/widgets/qr_scanner.dart b/lib/widgets/qr_scanner.dart index 4106018..48e2136 100644 --- a/lib/widgets/qr_scanner.dart +++ b/lib/widgets/qr_scanner.dart @@ -1,5 +1,4 @@ import 'dart:developer' as developer; -import 'dart:io'; import 'dart:math'; import 'package:flutter/foundation.dart'; @@ -95,8 +94,8 @@ class _QRScannerState extends State { setState(() { result = scanData; }); - Navigator.pushNamed(context, '/qrcode-result', arguments: scanData); controller.pauseCamera(); + Navigator.pushNamed(context, '/qrcode-result', arguments: scanData); }); } diff --git a/pubspec.lock b/pubspec.lock index 9492ee4..da45bef 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,34 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + url: "https://pub.dartlang.org" + source: hosted + version: "48.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.0" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + asn1lib: + dependency: transitive + description: + name: asn1lib + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.1" async: dependency: transitive description: @@ -22,6 +50,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + build: + dependency: transitive + description: + name: build + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.1" + build_config: + dependency: transitive + description: + name: build_config + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + built_collection: + dependency: transitive + description: + name: built_collection + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + url: "https://pub.dartlang.org" + source: hosted + version: "8.4.1" characters: dependency: transitive description: @@ -36,6 +92,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.1" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" clock: dependency: transitive description: @@ -43,6 +106,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + code_builder: + dependency: transitive + description: + name: code_builder + url: "https://pub.dartlang.org" + source: hosted + version: "4.3.0" collection: dependency: transitive description: @@ -50,6 +120,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.16.0" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" cupertino_icons: dependency: "direct main" description: @@ -57,6 +141,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + dart_style: + dependency: transitive + description: + name: dart_style + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.4" date_field: dependency: "direct main" description: @@ -78,6 +169,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" flutter: dependency: "direct main" description: flutter @@ -107,6 +212,27 @@ packages: description: flutter source: sdk version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + http: + dependency: "direct main" + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.5" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.1" intl: dependency: transitive description: @@ -121,6 +247,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.4" + json_annotation: + dependency: transitive + description: + name: json_annotation + url: "https://pub.dartlang.org" + source: hosted + version: "4.7.0" + json_rpc_2: + dependency: transitive + description: + name: json_rpc_2 + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.2" lints: dependency: transitive description: @@ -128,6 +268,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + logging: + dependency: transitive + description: + name: logging + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" matcher: dependency: transitive description: @@ -156,6 +303,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -163,6 +317,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" + pointycastle: + dependency: transitive + description: + name: pointycastle + url: "https://pub.dartlang.org" + source: hosted + version: "3.6.2" provider: dependency: transitive description: @@ -170,6 +331,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.0.3" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.1" qr_code_scanner: dependency: "direct main" description: @@ -177,6 +352,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" + rsa_encrypt: + dependency: "direct main" + description: + name: rsa_encrypt + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" sky_engine: dependency: transitive description: flutter @@ -203,6 +385,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" string_scanner: dependency: transitive description: @@ -224,6 +413,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.9" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + uuid: + dependency: transitive + description: + name: uuid + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.6" vector_math: dependency: transitive description: @@ -231,6 +434,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + watcher: + dependency: transitive + description: + name: watcher + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + web3dart: + dependency: "direct main" + description: + name: web3dart + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.5" + yaml: + dependency: transitive + description: + name: yaml + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.1" sdks: dart: ">=2.17.5 <3.0.0" flutter: ">=1.16.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0d04ac4..2702678 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,6 +37,9 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + web3dart: ^2.3.5 + rsa_encrypt: ^2.0.0 + http: ^0.13.5 dev_dependencies: flutter_test: