prasule/lib/views/initialization_screen.dart
Matyáš Caras ef52caa836
feat: creating debt scenarios
also changed way of loading selected wallet
2024-07-19 17:34:45 +02:00

48 lines
1.5 KiB
Dart

// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
//
// SPDX-License-Identifier: AGPL-3.0-only
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:prasule/api/wallet_manager.dart';
import 'package:prasule/pw/platformroute.dart';
import 'package:prasule/views/home.dart';
import 'package:prasule/views/setup.dart';
/// Intermediate screen used to initialize variables relying on context
class InitializationScreen extends StatefulWidget {
/// Intermediate screen used to initialize variables relying on context
const InitializationScreen({super.key});
@override
State<InitializationScreen> createState() => _InitializationScreenState();
}
class _InitializationScreenState extends State<InitializationScreen> {
@override
void initState() {
super.initState();
getApplicationDocumentsDirectory().then((v) {
WalletManager.walletPath = "${v.path}/wallets";
if (!mounted) return;
final wallets = WalletManager.listWallets();
if (wallets.isEmpty && mounted) {
Navigator.of(context)
.pushReplacement(platformRoute((c) => const SetupView()));
return;
}
WalletManager.selectedWallet = wallets.first;
Navigator.of(context)
.pushReplacement(platformRoute((c) => const HomeView()));
});
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Align(
child: CircularProgressIndicator(),
),
);
}
}