Load server configuration
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2025-07-07 21:36:35 +02:00
parent 0a87ac572b
commit 74bb31ecc1
8 changed files with 219 additions and 29 deletions

View File

@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:moneymgr_mobile/providers/auth_state.dart';
import 'package:moneymgr_mobile/services/api/server_api.dart';
import 'package:moneymgr_mobile/widgets/full_screen_error.dart';
class LoadServerConfig extends HookConsumerWidget {
final Widget child;
const LoadServerConfig({super.key, required this.child});
@override
Widget build(BuildContext context, WidgetRef ref) {
final serverConfig = ref.watch(serverConfigOrCacheProvider);
handleSignOut() {
ref.watch(currentAuthStateProvider.notifier).logout();
}
return switch (serverConfig) {
AsyncData() => child,
AsyncError(:final error) => FullScreenError(
message: "Failed to load server configuration!",
error: error.toString(),
actions: [
MaterialButton(
onPressed: handleSignOut,
child: Text("Sign out".toUpperCase()),
),
],
),
_ => const Scaffold(body: Center(child: CircularProgressIndicator())),
};
}
}