-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5def25
commit 3efa695
Showing
12 changed files
with
193 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/cosmos_ui_components/lib/components/cosmos_error_view.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:cosmos_ui_components/cosmos_ui_components.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class CosmosErrorView extends StatelessWidget { | ||
const CosmosErrorView({ | ||
Key? key, | ||
required this.title, | ||
required this.message, | ||
}) : super(key: key); | ||
|
||
final String title; | ||
final String message; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Icon( | ||
Icons.error, | ||
color: Theme.of(context).colorScheme.error, | ||
), | ||
const SizedBox(height: CosmosAppTheme.spacingM), | ||
Text(title), | ||
const SizedBox(height: CosmosAppTheme.spacingM), | ||
Text(message), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ dependencies: | |
path: packages/cosmos_utils | ||
ref: main | ||
|
||
|
||
dev_dependencies: | ||
flutter_test: | ||
sdk: flutter | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:starport_template/starport_app.dart'; | ||
import 'package:starport_template/stores/wallets_store.dart'; | ||
import 'package:transaction_signing_gateway/alan/alan_credentials_serializer.dart'; | ||
import 'package:transaction_signing_gateway/alan/alan_transaction_broadcaster.dart'; | ||
import 'package:transaction_signing_gateway/alan/alan_transaction_signer.dart'; | ||
import 'package:transaction_signing_gateway/gateway/transaction_signing_gateway.dart'; | ||
import 'package:transaction_signing_gateway/mobile/mobile_key_info_storage.dart'; | ||
import 'package:transaction_signing_gateway/mobile/no_op_transaction_summary_ui.dart'; | ||
|
||
void main() { | ||
_buildDependencies(); | ||
runApp(StarportApp()); | ||
} | ||
|
||
void _buildDependencies() { | ||
StarportApp.signingGateway = TransactionSigningGateway( | ||
transactionSummaryUI: NoOpTransactionSummaryUI(), | ||
signers: [ | ||
AlanTransactionSigner(), | ||
], | ||
broadcasters: [ | ||
AlanTransactionBroadcaster(), | ||
], | ||
infoStorage: MobileKeyInfoStorage( | ||
serializers: [AlanCredentialsSerializer()], | ||
), | ||
); | ||
StarportApp.walletsStore = WalletsStore(StarportApp.signingGateway); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:cosmos_ui_components/cosmos_ui_components.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:starport_template/pages/mnemonic_onboarding_page.dart'; | ||
import 'package:starport_template/pages/wallets_list_page.dart'; | ||
import 'package:starport_template/starport_app.dart'; | ||
|
||
class RoutingPage extends StatefulWidget { | ||
const RoutingPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
_RoutingPageState createState() => _RoutingPageState(); | ||
} | ||
|
||
class _RoutingPageState extends State<RoutingPage> { | ||
@override | ||
void initState() { | ||
super.initState(); | ||
_loadWallets(); | ||
} | ||
|
||
Future<void> _loadWallets() async { | ||
final store = StarportApp.walletsStore; | ||
await store.loadWallets(); | ||
if (store.loadWalletsFailure.value == null) { | ||
if (store.wallets.value.isEmpty) { | ||
Navigator.of(context).push(MaterialPageRoute(builder: (_) => const MnemonicOnboardingPage())); | ||
} else { | ||
Navigator.of(context).push(MaterialPageRoute(builder: (_) => const WalletsListPage())); | ||
} | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: ContentStateSwitcher( | ||
isLoading: StarportApp.walletsStore.areWalletsLoading.value, | ||
isError: StarportApp.walletsStore.loadWalletsFailure.value != null, | ||
errorChild: const CosmosErrorView( | ||
title: "Something went wrong", | ||
message: "We had problems retrieving wallets from secure storage.", | ||
), | ||
contentChild: const SizedBox(), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class WalletsListPage extends StatelessWidget { | ||
const WalletsListPage({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Scaffold( | ||
body: Center( | ||
child: Text("Wallets List Page"), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import 'package:cosmos_ui_components/cosmos_ui_components.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:starport_template/pages/mnemonic_onboarding_page.dart'; | ||
import 'package:starport_template/pages/routing_page.dart'; | ||
import 'package:starport_template/stores/wallets_store.dart'; | ||
import 'package:transaction_signing_gateway/gateway/transaction_signing_gateway.dart'; | ||
|
||
class StarportApp extends StatelessWidget { | ||
static late TransactionSigningGateway signingGateway; | ||
static late WalletsStore walletsStore; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Starport template', | ||
theme: CosmosAppTheme.buildAppTheme(), | ||
home: const MnemonicOnboardingPage(), | ||
home: const RoutingPage(), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:mobx/mobx.dart'; | ||
import 'package:transaction_signing_gateway/gateway/transaction_signing_gateway.dart'; | ||
import 'package:transaction_signing_gateway/model/credentials_storage_failure.dart'; | ||
import 'package:transaction_signing_gateway/model/wallet_public_info.dart'; | ||
|
||
class WalletsStore { | ||
final TransactionSigningGateway _transactionSigningGateway; | ||
|
||
WalletsStore(this._transactionSigningGateway); | ||
|
||
final Observable<bool> areWalletsLoading = Observable(false); | ||
|
||
final Observable<CredentialsStorageFailure?> loadWalletsFailure = Observable(null); | ||
|
||
Observable<List<WalletPublicInfo>> wallets = Observable([]); | ||
|
||
Future<void> loadWallets() async { | ||
areWalletsLoading.value = true; | ||
(await _transactionSigningGateway.getWalletsList()).fold( | ||
(fail) => loadWalletsFailure.value = fail, | ||
(newWallets) => wallets.value = newWallets, | ||
); | ||
areWalletsLoading.value = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters