Skip to content

Commit

Permalink
upgraded dependencies, minor code and performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aldrinzigmundv committed Feb 27, 2024
1 parent a81da57 commit 319994e
Show file tree
Hide file tree
Showing 23 changed files with 332 additions and 527 deletions.
8 changes: 2 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ android {
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 23
targetSdkVersion 33
versionCode 8
versionName "0.8.1"
versionCode 9
versionName "0.8.5"
}

signingConfigs {
Expand All @@ -78,7 +78,3 @@ android {
flutter {
source '../..'
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
13 changes: 0 additions & 13 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
14 changes: 10 additions & 4 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ pluginManagement {

includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

plugins {
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

include ":app"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}

apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
include ":app"
9 changes: 4 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import 'package:flutter/material.dart';

import 'package:thirdbank/pages/loadingpage.dart';

void main() => runApp(
const MaterialApp(
title: "Third Bank",
home: LoadingPage(),
));
void main() => runApp(const MaterialApp(
title: "Third Bank",
home: LoadingPage(),
));
8 changes: 5 additions & 3 deletions lib/pages/homepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ class _HomePageState extends State<HomePage> {
_refreshWallet() async {
try {
await wallet.syncWallet();
await wallet.getBlockchainHeight();
await wallet.getBalance();
await wallet.getTransactions();
await Future.wait([
Future(() => wallet.getBlockchainHeight()),
Future(() => wallet.getBalance()),
Future(() => wallet.getTransactions()),
]);
if (wallet.transactions.isNotEmpty) {
setState(() {
_transactionAreaMessage = 'Tap on a transaction to get more info.';
Expand Down
71 changes: 39 additions & 32 deletions lib/pages/loadingpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ class _LoadingPageState extends State<LoadingPage> {
final StorageProvider storage = StorageProvider();
final AuthenticationProvider auth = AuthenticationProvider();

String _loadingpagetext = "Please wait...";
String _loadingpagetext = "Powered by aldrinzigmund.com";

void _startup() async {
Future.delayed(const Duration(seconds: 1), () async {
await storage.initialize();
await auth.initialize();
await Future.wait([
Future(() => storage.initialize()),
Future(() => auth.initialize()),
]);
if (await storage.read(key: "setupdone") == "true" &&
await storage.read(key: "lock") == "true") {
if (await auth.authenticate()) {
Expand All @@ -34,7 +36,7 @@ class _LoadingPageState extends State<LoadingPage> {
await storage.read(key: "lock") == "false") {
_startWallet();
} else {
if (context.mounted) {
if (mounted) {
goToMnemonicQuestionPage(
context: context, wallet: wallet, storage: storage);
}
Expand All @@ -44,12 +46,18 @@ class _LoadingPageState extends State<LoadingPage> {

void _startWallet() async {
try {
wallet.mnemonic = await storage.read(key: "mnemonic");
wallet.walletAddress = await storage.read(key: "address");
await Future.wait([
Future(() => storage.read(key: "mnemonic")),
Future(() => storage.read(key: "address")),
]).then((values) => {
wallet.mnemonic = values[0],
wallet.walletAddress = values[1],
});

await wallet.createOrRestoreWallet(mnemonic: wallet.mnemonic);
wallet.mnemonic = "";
wallet.getBlockchainHeight();
if (context.mounted) {
await wallet.getBlockchainHeight();
if (mounted) {
goToHomePage(context: context, wallet: wallet, storage: storage);
}
} catch (_) {
Expand All @@ -76,32 +84,31 @@ class _LoadingPageState extends State<LoadingPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.yellowAccent,
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Image.asset("assets/icons/icon.png"),
const Padding(
padding: EdgeInsets.all(9.0),
child: Text(
'Third Bank',
style: TextStyle(
fontSize: 27.0,
backgroundColor: Colors.yellowAccent,
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Image.asset("assets/icons/icon.png"),
const Padding(
padding: EdgeInsets.all(9.0),
child: Text(
'Third Bank',
style: TextStyle(
fontSize: 27.0,
),
textAlign: TextAlign.center,
),
textAlign: TextAlign.center,
),
),
]),
),
bottomNavigationBar: Padding(
padding: const EdgeInsets.fromLTRB(9.0, 9.0, 9.0, 36.0),
child: Text(
_loadingpagetext,
style: const TextStyle(
fontSize: 18.0,
),
textAlign: TextAlign.center,
]),
),
bottomNavigationBar: Padding(
padding: const EdgeInsets.fromLTRB(9.0, 9.0, 9.0, 36.0),
child: Text(
_loadingpagetext,
style: const TextStyle(
fontSize: 15.0,
),
)
);
textAlign: TextAlign.center,
),
));
}
}
16 changes: 10 additions & 6 deletions lib/pages/setup pages/authenticationquestionpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ class _AuthenticationQuestionPageState
final AuthenticationProvider authentication = AuthenticationProvider();

_addLocalAuth() async {
await storage.write(key: "setupdone", value: "true");
await storage.write(key: "lock", value: "true");
if (context.mounted) {
await Future.wait([
Future(() => storage.write(key: "setupdone", value: "true")),
Future(() => storage.write(key: "lock", value: "true")),
]);
if (mounted) {
goToHomePage(context: context, wallet: wallet, storage: storage);
}
}

_noLocalAuth() async {
await storage.write(key: "setupdone", value: "true");
await storage.write(key: "lock", value: "false");
if (context.mounted) {
await Future.wait([
Future(() => storage.write(key: "setupdone", value: "true")),
Future(() => storage.write(key: "lock", value: "false")),
]);
if (mounted) {
goToHomePage(context: context, wallet: wallet, storage: storage);
}
}
Expand Down
16 changes: 10 additions & 6 deletions lib/pages/setup pages/generatemnemonicpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ class _GenerateMnemonicPageState extends State<GenerateMnemonicPage> {
duration: Duration(seconds: 2),
));
try {
await wallet.createOrRestoreWallet(mnemonic: wallet.mnemonic);
await storage.write(key: "mnemonic", value: wallet.mnemonic);
await Future.wait([
Future(() => wallet.createOrRestoreWallet(mnemonic: wallet.mnemonic)),
Future(() => storage.write(key: "mnemonic", value: wallet.mnemonic)),
]);
wallet.mnemonic = "";
await wallet.getNewAddress();
await storage.write(key: "address", value: wallet.walletAddress);
Expand All @@ -52,13 +54,15 @@ class _GenerateMnemonicPageState extends State<GenerateMnemonicPage> {
final localAuthAvailable =
await authentication.checkAuthenticationAvailability();
if (!localAuthAvailable) {
await storage.write(key: "setupdone", value: "true");
await storage.write(key: "lock", value: "false");
if (context.mounted) {
await Future.wait([
Future(() => storage.write(key: "setupdone", value: "true")),
Future(() => storage.write(key: "lock", value: "false")),
]);
if (mounted) {
goToHomePage(context: context, wallet: wallet, storage: storage);
}
} else {
if (context.mounted) {
if (mounted) {
goToAuthenticationQuestionPage(
context: context, wallet: wallet, storage: storage);
}
Expand Down
16 changes: 10 additions & 6 deletions lib/pages/setup pages/restoremnemonicpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ class _RestoreMnemonicPageState extends State<RestoreMnemonicPage> {
duration: Duration(seconds: 2),
));
try {
await wallet.createOrRestoreWallet(mnemonic: _mnemonic.text);
await storage.write(key: "mnemonic", value: _mnemonic.text);
await Future.wait([
Future(() => wallet.createOrRestoreWallet(mnemonic: _mnemonic.text)),
Future(() => storage.write(key: "mnemonic", value: _mnemonic.text)),
]);
wallet.mnemonic = "";
await wallet.getNewAddress();
await storage.write(key: "address", value: wallet.walletAddress);
Expand All @@ -58,13 +60,15 @@ class _RestoreMnemonicPageState extends State<RestoreMnemonicPage> {
final localAuthAvailable =
await authentication.checkAuthenticationAvailability();
if (!localAuthAvailable) {
await storage.write(key: "setupdone", value: "true");
await storage.write(key: "lock", value: "false");
if (context.mounted) {
await Future.wait([
Future(() => storage.write(key: "setupdone", value: "true")),
Future(() => storage.write(key: "lock", value: "false")),
]);
if (mounted) {
goToHomePage(context: context, wallet: wallet, storage: storage);
}
} else {
if (context.mounted) {
if (mounted) {
goToAuthenticationQuestionPage(
context: context, wallet: wallet, storage: storage);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/transactionpages/receivepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class _ReceivePageState extends State<ReceivePage> {

_copyWalletAddressToClipboard() {
Clipboard.setData(ClipboardData(text: wallet.walletAddress));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Wallet address copied to clipboard."),
duration: Duration(seconds: 2),
));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Wallet address copied to clipboard."),
duration: Duration(seconds: 2),
));
}

@override
Expand Down
15 changes: 7 additions & 8 deletions lib/pages/transactionpages/sendpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ class _SendPage extends State<SendBitcoinPage> {
String _scannedQRAddress = "";
String _scanQRButtonText = "Scan Recipient's QR Code";

String _speedDropdownValue =
'Moderate Fee, Moderate Settlement (around 1 hour)';
String _speedDropdownValue = 'Moderate Fee (settles around 1 hour)';
final List<String> _speeds = <String>[
'Highest Fee, Settles Fastest (<10 minutes)',
'Higher Fee, Settles Faster (around 10 minutes)',
'Moderate Fee, Moderate Settlement (around 1 hour)',
'Lower Fee, Settles Slower (around 24 hours)',
'Lowest Fee, Settles Slowest (around 7 days)',
'Highest Fee (settles <10 minutes)',
'Higher Fee (settles around 10 minutes)',
'Moderate Fee (settles around 1 hour)',
'Lower Fee (settles around 24 hours)',
'Lowest Fee (settles around 7 days)',
];

_scanQRCode() async {
Expand Down Expand Up @@ -91,7 +90,7 @@ class _SendPage extends State<SendBitcoinPage> {
chosenAddress = _destinationAddress.text;
}
final cleanedDestinationAddress = _cleanAddress(chosenAddress);
if (context.mounted) {
if (mounted) {
goToTransactionConfirmationPage(
context: context,
wallet: wallet,
Expand Down
44 changes: 36 additions & 8 deletions lib/pages/transactionpages/transactionconfirmationpage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,42 @@ class TransactionConfirmationPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Padding(padding: EdgeInsets.all(9.0), child: Text('Transaction Fee', style: TextStyle(fontSize: 21.0, fontWeight: FontWeight.bold))),
Padding(padding: const EdgeInsets.all(9.0), child: Text(fee, style: const TextStyle(fontSize: 21.0))),
const SizedBox(height: 18.0,),
const Padding(padding: EdgeInsets.all(9.0), child: Text('Amount to Send', style: TextStyle(fontSize: 21.0, fontWeight: FontWeight.bold))),
Padding(padding: const EdgeInsets.all(9.0), child: Text('$amount sats', style: const TextStyle(fontSize: 21.0))),
const SizedBox(height: 18.0,),
const Padding(padding: EdgeInsets.all(9.0), child: Text('Destination Address', style: TextStyle(fontSize: 21.0, fontWeight: FontWeight.bold))),
Padding(padding: const EdgeInsets.all(9.0), child: Text(address, style: const TextStyle(fontSize: 21.0))),
const Padding(
padding: EdgeInsets.all(6.0),
child: Text('Transaction Fee',
style: TextStyle(
fontSize: 21.0,
fontWeight: FontWeight.bold))),
Padding(
padding: const EdgeInsets.all(6.0),
child: Text(fee,
style: const TextStyle(fontSize: 21.0))),
const SizedBox(
height: 18.0,
),
const Padding(
padding: EdgeInsets.all(6.0),
child: Text('Amount to Send',
style: TextStyle(
fontSize: 21.0,
fontWeight: FontWeight.bold))),
Padding(
padding: const EdgeInsets.all(6.0),
child: Text('$amount sats',
style: const TextStyle(fontSize: 21.0))),
const SizedBox(
height: 18.0,
),
const Padding(
padding: EdgeInsets.all(6.0),
child: Text('Destination Address',
style: TextStyle(
fontSize: 21.0,
fontWeight: FontWeight.bold))),
Padding(
padding: const EdgeInsets.all(6.0),
child: Text(address,
style: const TextStyle(fontSize: 21.0))),
]),
),
)
Expand Down
Loading

0 comments on commit 319994e

Please sign in to comment.