Skip to content

Commit

Permalink
Merge pull request #5 from Ishad-M-I-M/main
Browse files Browse the repository at this point in the history
Changes in signup and qr result
  • Loading branch information
Ishad-M-I-M authored Sep 25, 2022
2 parents 6a74ab8 + 68889d8 commit 41b1a5c
Show file tree
Hide file tree
Showing 20 changed files with 646 additions and 85 deletions.
21 changes: 21 additions & 0 deletions lib/bloc/initialize/initialize_bloc.dart
Original file line number Diff line number Diff line change
@@ -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<InitializeEvent, InitializeState> {
InitializeBloc() : super(Initial()) {
on<InitializeAppEvent>((event, emit) async{
emit(Initial());

//simulate the initializing tests
// ex:- check registration status
await Future.delayed(const Duration(seconds: 3));

emit(NotRegistered());
});
}
}
6 changes: 6 additions & 0 deletions lib/bloc/initialize/initialize_event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
part of 'initialize_bloc.dart';

@immutable
abstract class InitializeEvent {}

class InitializeAppEvent extends InitializeEvent {}
10 changes: 10 additions & 0 deletions lib/bloc/initialize/initialize_state.dart
Original file line number Diff line number Diff line change
@@ -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 {}
21 changes: 21 additions & 0 deletions lib/bloc/signup/signup_bloc.dart
Original file line number Diff line number Diff line change
@@ -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<SignupEvent, SignupState> {
SignupBloc() : super(Initial()) {
on<SubmitSignupEvent>((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());
});
}
}
22 changes: 22 additions & 0 deletions lib/bloc/signup/signup_event.dart
Original file line number Diff line number Diff line change
@@ -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
});
}
12 changes: 12 additions & 0 deletions lib/bloc/signup/signup_state.dart
Original file line number Diff line number Diff line change
@@ -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 {}
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
53 changes: 1 addition & 52 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>;
return Scaffold(
body: SafeArea(
child: SizedBox(
Expand Down Expand Up @@ -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"))
// ]),
// ],
)
],
),
Expand Down
37 changes: 31 additions & 6 deletions lib/pages/opening_screen.dart
Original file line number Diff line number Diff line change
@@ -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<OpeningScreen> createState() => _OpeningScreenState();
}

class _OpeningScreenState extends State<OpeningScreen> {
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(
Expand All @@ -34,7 +45,21 @@ class OpeningScreen extends StatelessWidget {
const SizedBox(
height: 20,
),
const Text('Loading...'),

BlocProvider(
create: (context) => _initializeBloc,
child: BlocListener<InitializeBloc, InitializeState>(
listener: (context, state) {
if (state is NotRegistered) {
Navigator.popAndPushNamed(context, '/welcome1');
}
else if (state is Registered) {
Navigator.popAndPushNamed(context, '/home');
}
},
child: const Text('Initializing...'),
),
),
],
),
),
Expand Down
78 changes: 70 additions & 8 deletions lib/pages/qr_result_page.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -8,13 +9,74 @@ class QRResultPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
print((jsonDecode(result.code!) as Map<String, dynamic>)['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<String, dynamic>)['information']
as List<dynamic>)
.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'),
// ),
);
}
}
Loading

0 comments on commit 41b1a5c

Please sign in to comment.