prasule/lib/views/initialization_screen.dart

48 lines
1.4 KiB
Dart
Raw Normal View History

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;
}
Navigator.of(context)
.pushReplacement(platformRoute((c) => const HomeView()));
});
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Align(
child: CircularProgressIndicator(),
),
);
}
}