mirror of
https://github.com/Myzel394/quid_faciam_hodie.git
synced 2025-06-19 07:35:26 +02:00
improvements & bugfixes
This commit is contained in:
parent
ae1a5c8b07
commit
40d2ffe25b
@ -1,15 +1,21 @@
|
||||
import 'package:camera/camera.dart';
|
||||
|
||||
class GlobalValuesManager {
|
||||
static bool _hasBeenInitialized = false;
|
||||
static List<CameraDescription> _cameras = [];
|
||||
|
||||
static List<CameraDescription> get cameras => [..._cameras];
|
||||
static bool get hasBeenInitialized => _hasBeenInitialized;
|
||||
|
||||
static void setCameras(List<CameraDescription> cameras) {
|
||||
if (_cameras.isNotEmpty) {
|
||||
throw Exception('Cameras already set');
|
||||
return;
|
||||
}
|
||||
|
||||
_cameras = cameras;
|
||||
}
|
||||
|
||||
static void setHasBeenInitialized(bool hasBeenInitialized) {
|
||||
_hasBeenInitialized = hasBeenInitialized;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:quid_faciam_hodie/constants/storage_keys.dart';
|
||||
import 'package:quid_faciam_hodie/screens/welcome_screen.dart';
|
||||
|
||||
const storage = FlutterSecureStorage();
|
||||
|
||||
class StartupPageManager {
|
||||
static Future<String> getPage() async =>
|
||||
(await storage.read(key: STARTUP_PAGE_KEY)) ?? WelcomeScreen.ID;
|
||||
|
||||
static Future<void> navigateToNewPage(
|
||||
BuildContext context,
|
||||
String newPageID,
|
||||
) async {
|
||||
await storage.write(key: STARTUP_PAGE_KEY, value: newPageID);
|
||||
await Navigator.pushReplacementNamed(context, newPageID);
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:quid_faciam_hodie/constants/spacing.dart';
|
||||
import 'package:quid_faciam_hodie/extensions/snackbar.dart';
|
||||
import 'package:quid_faciam_hodie/managers/authentication_manager.dart';
|
||||
import 'package:quid_faciam_hodie/screens/main_screen.dart';
|
||||
import 'package:quid_faciam_hodie/screens/server_loading_screen.dart';
|
||||
import 'package:quid_faciam_hodie/utils/loadable.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
|
||||
@ -73,7 +73,7 @@ class _LoginScreenState extends AuthState<LoginScreen> with Loadable {
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
Navigator.pushReplacementNamed(context, MainScreen.ID);
|
||||
Navigator.pushReplacementNamed(context, ServerLoadingScreen.ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,18 +25,21 @@ class _ServerLoadingScreenState extends State<ServerLoadingScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
Future<void> load() async {
|
||||
if (!GlobalValuesManager.hasBeenInitialized) {
|
||||
GlobalValuesManager.setCameras(await availableCameras());
|
||||
|
||||
await Supabase.initialize(
|
||||
url: SUPABASE_API_URL,
|
||||
anonKey: SUPABASE_API_KEY,
|
||||
debug: kDebugMode,
|
||||
);
|
||||
|
||||
GlobalValuesManager.setHasBeenInitialized(true);
|
||||
}
|
||||
|
||||
final memories = context.read<Memories>();
|
||||
final session = Supabase.instance.client.auth.session();
|
||||
|
||||
@ -64,21 +67,21 @@ class _ServerLoadingScreenState extends State<ServerLoadingScreen> {
|
||||
initialFadeInDelay: Duration.zero,
|
||||
fadeInDuration: Duration(seconds: 1),
|
||||
fadeOutDuration: Duration(seconds: 1),
|
||||
fadeInDelay: Duration(seconds: 6),
|
||||
fadeInDelay: Duration(seconds: 4),
|
||||
fadeOutDelay: Duration.zero,
|
||||
),
|
||||
DotAnimation(
|
||||
initialFadeInDelay: Duration(seconds: 2),
|
||||
fadeInDuration: Duration(seconds: 1),
|
||||
fadeOutDuration: Duration(seconds: 1),
|
||||
fadeInDelay: Duration(seconds: 6),
|
||||
fadeInDelay: Duration(seconds: 4),
|
||||
fadeOutDelay: Duration.zero,
|
||||
),
|
||||
DotAnimation(
|
||||
initialFadeInDelay: Duration(seconds: 4),
|
||||
fadeInDuration: Duration(seconds: 1),
|
||||
fadeOutDuration: Duration(seconds: 1),
|
||||
fadeInDelay: Duration(seconds: 6),
|
||||
fadeInDelay: Duration(seconds: 4),
|
||||
fadeOutDelay: Duration.zero,
|
||||
),
|
||||
SizedBox(height: SMALL_SPACE),
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:quid_faciam_hodie/constants/spacing.dart';
|
||||
import 'package:quid_faciam_hodie/managers/startup_page_manager.dart';
|
||||
import 'package:quid_faciam_hodie/widgets/logo.dart';
|
||||
|
||||
import 'grant_permission_screen.dart';
|
||||
@ -44,7 +43,7 @@ class WelcomeScreen extends StatelessWidget {
|
||||
icon: const Icon(Icons.arrow_right),
|
||||
label: const Text('Start'),
|
||||
onPressed: () {
|
||||
StartupPageManager.navigateToNewPage(
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
GrantPermissionScreen.ID,
|
||||
);
|
||||
|
@ -59,7 +59,7 @@ class _DotAnimationState extends State<DotAnimation> {
|
||||
if (animateIn) {
|
||||
// Animate out
|
||||
_timer = Timer(widget.fadeOutDelay, () {
|
||||
if (mounted) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ class _DotAnimationState extends State<DotAnimation> {
|
||||
} else {
|
||||
// Animate in
|
||||
_timer = Timer(widget.fadeInDelay, () {
|
||||
if (mounted) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user