2024-06-30 20:25:36 +02:00
|
|
|
// SPDX-FileCopyrightText: (C) 2024 Matyáš Caras
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-06-30 11:30:07 +02:00
|
|
|
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';
|
|
|
|
|
2024-06-30 20:25:36 +02:00
|
|
|
/// Intermediate screen used to initialize variables relying on context
|
2024-06-30 11:30:07 +02:00
|
|
|
class InitializationScreen extends StatefulWidget {
|
2024-06-30 20:25:36 +02:00
|
|
|
/// Intermediate screen used to initialize variables relying on context
|
2024-06-30 11:30:07 +02:00
|
|
|
const InitializationScreen({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<InitializationScreen> createState() => _InitializationScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _InitializationScreenState extends State<InitializationScreen> {
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
getApplicationDocumentsDirectory().then((v) {
|
2024-07-17 20:11:44 +02:00
|
|
|
WalletManager.walletPath = "${v.path}/wallets";
|
2024-06-30 11:30:07 +02:00
|
|
|
if (!mounted) return;
|
|
|
|
final wallets = WalletManager.listWallets();
|
|
|
|
if (wallets.isEmpty && mounted) {
|
|
|
|
Navigator.of(context)
|
|
|
|
.pushReplacement(platformRoute((c) => const SetupView()));
|
|
|
|
return;
|
|
|
|
}
|
2024-07-19 17:34:45 +02:00
|
|
|
WalletManager.selectedWallet = wallets.first;
|
2024-06-30 11:30:07 +02:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushReplacement(platformRoute((c) => const HomeView()));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return const Scaffold(
|
|
|
|
body: Align(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|