Skip to content

Commit

Permalink
Merge pull request #28 from Ishad-M-I-M/main
Browse files Browse the repository at this point in the history
UI improvements
  • Loading branch information
Ishad-M-I-M authored Nov 18, 2022
2 parents bffe954 + 102964f commit 8f70a69
Show file tree
Hide file tree
Showing 49 changed files with 542 additions and 120 deletions.
15 changes: 14 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<application
android:label="iblock"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down Expand Up @@ -33,4 +33,17 @@
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
<!-- Provide required visibility configuration for API level 30 and above -->
<queries>
<!-- If your app checks for SMS support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="sms" />
</intent>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
</queries>
</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@
<string>This app needs camera access to scan QR codes</string>
<key>NSFaceIDUsageDescription</key>
<string>Why is my app authenticating using face id?</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>sms</string>
<string>tel</string>
</array>
</dict>
</plist>
48 changes: 48 additions & 0 deletions lib/bloc/settings/settings_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'package:bloc/bloc.dart';
import 'package:meta/meta.dart';

import '../../services/secure_storage_service.dart';
import '../../services/user_contract_service.dart';

part 'settings_event.dart';

part 'settings_state.dart';

class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
SettingsBloc() : super(Initial()) {
on<LoadEvent>((event, emit) async {
emit(Loading());
var privateKey = await SecureStorageService.get("private-key") as String;
var contractAddress =
await SecureStorageService.get("contract-address") as String;

var service = UserContractService();
var userInfo = await service.getAll(contractAddress, privateKey);
emit(Loaded(
privateKey: privateKey,
contractAddress: contractAddress,
email: userInfo['Email'] as String,
phone: userInfo['Phone'] as String));
});

on<EditEvent>((event, emit) async {
emit(Loading());
try{
var service = UserContractService();
if (event.editedProperty == "email"){
await service.setEmail(event.email, contractAddress: event.contractAddress, privateKey: event.privateKey);
}
else if(event.editedProperty == "phone"){
await service.setMobile(event.phone, contractAddress: event.contractAddress, privateKey: event.privateKey);
}
else{
throw Exception("Unexpected Error");
}
emit(Loaded(privateKey: event.privateKey, contractAddress: event.contractAddress, email: event.email, phone: event.phone));
}
catch(e){
emit(Failed(e.toString()));
}
});
}
}
17 changes: 17 additions & 0 deletions lib/bloc/settings/settings_event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
part of 'settings_bloc.dart';

@immutable
abstract class SettingsEvent {}

class LoadEvent extends SettingsEvent{}

class EditEvent extends SettingsEvent{
final String editedProperty;
final String privateKey;
final String contractAddress;
final String email;
final String phone;
EditEvent(this.editedProperty, {required this.privateKey, required this.contractAddress, required this.email, required this.phone});
}

class VerifyEmail extends SettingsEvent{}
21 changes: 21 additions & 0 deletions lib/bloc/settings/settings_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
part of 'settings_bloc.dart';

@immutable
abstract class SettingsState {}

class Initial extends SettingsState {}

class Loading extends SettingsState{}

class Loaded extends SettingsState{
final String privateKey;
final String contractAddress;
final String email;
final String phone;
Loaded({required this.privateKey, required this.contractAddress, required this.email, required this.phone});
}

class Failed extends SettingsState {
final String message;
Failed(this.message);
}
22 changes: 18 additions & 4 deletions lib/bloc/signup/signup_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,37 @@ class SignupBloc extends Bloc<SignupEvent, SignupState> {
gender: event.gender)
.timeout(const Duration(seconds: 10),
onTimeout: (){
throw Exception("Failed to deploy your contract");
throw Exception("Failed to connect to the backend");
});

var privateKey = result['private-key'] as String;

await SecureStorageService.store("private-key", privateKey);
await SecureStorageService.store("user-email", event.email);

emit(PrivateKeyStored());
emit(PrivateKeyStored(event.email));
}
catch(error){
log(error.toString());
emit(Failed(error.toString()));
}
});

on<AcceptingContractAddressEvent>((event, emit){
emit(PrivateKeyStored());
on<AcceptingContractAddressEvent>((event, emit) async{
var email = await SecureStorageService.get("user-email");
if (email != null) {
emit(PrivateKeyStored(email));
}
else {
emit(Failed("Email not found"));
}
});

on<StartOverEvent>((event, emit) async{
emit(Loading());
await SecureStorageService.delete("private-key");
await SecureStorageService.delete("user-email");
emit(Initial());
});

on<ContractAddressSubmitEvent>((event, emit) async{
Expand Down
2 changes: 2 additions & 0 deletions lib/bloc/signup/signup_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ContractAddressSubmitEvent extends SignupEvent{
ContractAddressSubmitEvent({required this.contractAddress});
}

class StartOverEvent extends SignupEvent{}

class RecoverySubmitEvent extends SignupEvent{
final String privateKey;
final String contractAddress;
Expand Down
5 changes: 4 additions & 1 deletion lib/bloc/signup/signup_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class Submitted extends SignupState {}

class RecoverySubmitted extends SignupState{}

class PrivateKeyStored extends SignupState{}
class PrivateKeyStored extends SignupState{
final String email;
PrivateKeyStored(this.email);
}

class Success extends SignupState {
final Map<String, String> userInfo;
Expand Down
1 change: 1 addition & 0 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Config{
static const String rpcUrl = "https://goerli.infura.io/v3/8b9d3fdeaccc4be4aeea708c77476676";
static const String wsUrl = "wss://goerli.infura.io/v3/8b9d3fdeaccc4be4aeea708c77476676";
static const String VERSION = 'v1.0.0';
static const int chainId = 5;


Expand Down
52 changes: 44 additions & 8 deletions lib/pages/enter_address_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:iblock/widgets/covered_loading.dart';
import 'package:url_launcher/url_launcher.dart';

import '../bloc/signup/signup_bloc.dart';
import '../widgets/forms/button.dart';
import '../widgets/forms/text_input_field.dart';
import '../widgets/covered_loading.dart';

class EnterAddressPage extends StatefulWidget {
const EnterAddressPage({Key? key}) : super(key: key);
Expand All @@ -30,7 +31,7 @@ class _EnterAddressPageState extends State<EnterAddressPage> {
body: BlocProvider(
create: (context) => _signupBloc,
child: BlocConsumer<SignupBloc, SignupState>(
listenWhen: (previous, current)=> previous != current && current is Success || current is Failed,
listenWhen: (previous, current)=> previous != current && current is Success || current is Failed || current is Initial,
listener: (context, state) {
if (state is Success) {
Navigator.pushNamedAndRemoveUntil(
Expand All @@ -39,12 +40,14 @@ class _EnterAddressPageState extends State<EnterAddressPage> {
} else if (state is Failed) {
Navigator.pushNamed(context, '/error',
arguments: {"message": state.message});
} else if (state is Initial){
Navigator.popAndPushNamed(context, '/signup');
}
else{
Navigator.popAndPushNamed(context, "/error", arguments: {"message": "unexpected Error"});
}
},
buildWhen: (previous, current)=> previous != current && current is PrivateKeyStored || current is Loading || current is Initial,
buildWhen: (previous, current)=> previous != current && current is PrivateKeyStored || current is Loading,
builder: (context, state){
if (state is PrivateKeyStored){
return SafeArea(
Expand All @@ -61,6 +64,10 @@ class _EnterAddressPageState extends State<EnterAddressPage> {
height: 100,
child: Image.asset('assets/images/icon.png'),
),
const Padding(
padding: EdgeInsets.all(16.0),
child: Text("iBlock", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24),),
),
Padding(
padding: const EdgeInsets.only(top: 50),
child: TextInputField("Enter Contract Address:",
Expand All @@ -81,14 +88,43 @@ class _EnterAddressPageState extends State<EnterAddressPage> {
padding: const EdgeInsets.all(8.0),
margin:
const EdgeInsets.only(left: 36, right: 36, top: 40),
child: const Text(
"Your contract address will be sent to your email. Check your email",
child: Column(
children: [
const Text(
"Your contract address will be sent to your email. Check your email",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
),
),
InkWell(
onTap: ()=>launchUrl(Uri.parse('mailto:${state.email}')),
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(state.email, style: const TextStyle(
decoration: TextDecoration.underline
),),
),
)
],
),
),
Padding(padding: const EdgeInsets.only(top: 24.0),
child: Column(
children: [
const Text("Did you receive email as deployment is failed / Provided email address is wrong",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 12,
fontSize: 12
),),
TextButton(
onPressed: (){
_signupBloc.add(StartOverEvent());
},
child: const Text("Click here"),
),
),
),
],
),)
],
),
),
Expand Down
2 changes: 0 additions & 2 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';

import '../widgets/add_new_dialog.dart';

class HomePage extends StatefulWidget {
HomePage({Key? key}) : super(key: key);

Expand Down
Loading

0 comments on commit 8f70a69

Please sign in to comment.