WIP: feat(ui): Migrate to new UI implementation
This commit is contained in:
+62
-50
@@ -1,25 +1,68 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:moonwell_launcher/app/design_system/mw_shells.dart';
|
||||
import 'package:moonwell_launcher/app/home_screen/home_screen.dart';
|
||||
import 'package:moonwell_launcher/app/login_screen/login_screen.dart';
|
||||
import 'package:moonwell_launcher/app/theme/mw_theme.dart';
|
||||
import 'package:moonwell_launcher/app/theme/moonwell_design_system.dart';
|
||||
import 'package:moonwell_launcher/features/launcher/application/restore_launcher_session_use_case.dart';
|
||||
import 'package:moonwell_launcher/features/launcher/data/launcher_api_client.dart';
|
||||
import 'package:moonwell_launcher/features/preferences/domain/repositories/preferences_repository.dart';
|
||||
import 'package:moonwell_launcher/service_container.dart';
|
||||
|
||||
class MoonWellApp extends StatelessWidget {
|
||||
class MoonWellApp extends StatefulWidget {
|
||||
const MoonWellApp({super.key});
|
||||
|
||||
@override
|
||||
State<MoonWellApp> createState() => _MoonWellAppState();
|
||||
}
|
||||
|
||||
class _MoonWellAppState extends State<MoonWellApp> {
|
||||
late final LauncherThemeController _themeController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_themeController = LauncherThemeController(getIt<PreferencesRepository>());
|
||||
_themeController.load();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_themeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'MoonWell',
|
||||
home: const _LauncherBootstrapScreen(),
|
||||
theme: moonWellTheme(),
|
||||
return AnimatedBuilder(
|
||||
animation: _themeController,
|
||||
builder: (context, _) => LauncherThemeScope(
|
||||
controller: _themeController,
|
||||
child: MaterialApp(
|
||||
title: 'MoonWell',
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: const _LauncherBootstrapScreen(),
|
||||
theme: MoonWellTheme.create(_themeController.variant),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LauncherThemeScope extends InheritedNotifier<LauncherThemeController> {
|
||||
const LauncherThemeScope({
|
||||
super.key,
|
||||
required LauncherThemeController controller,
|
||||
required super.child,
|
||||
}) : super(notifier: controller);
|
||||
|
||||
static LauncherThemeController of(BuildContext context) {
|
||||
final scope = context
|
||||
.dependOnInheritedWidgetOfExactType<LauncherThemeScope>();
|
||||
assert(scope != null, 'LauncherThemeScope is missing');
|
||||
return scope!.notifier!;
|
||||
}
|
||||
}
|
||||
|
||||
class _LauncherBootstrapScreen extends StatefulWidget {
|
||||
const _LauncherBootstrapScreen();
|
||||
|
||||
@@ -48,7 +91,6 @@ class _LauncherBootstrapScreenState extends State<_LauncherBootstrapScreen> {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const _LauncherBootstrapLoadingScreen();
|
||||
}
|
||||
|
||||
final result =
|
||||
snapshot.data ??
|
||||
const RestoreLauncherSessionResult.unauthenticated();
|
||||
@@ -58,7 +100,6 @@ class _LauncherBootstrapScreenState extends State<_LauncherBootstrapScreen> {
|
||||
manifest: result.manifest!,
|
||||
);
|
||||
}
|
||||
|
||||
return const LoginScreen();
|
||||
},
|
||||
);
|
||||
@@ -70,50 +111,21 @@ class _LauncherBootstrapLoadingScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset('assets/background.png', fit: BoxFit.cover),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: RadialGradient(
|
||||
center: Alignment.center,
|
||||
radius: 1.0,
|
||||
colors: [
|
||||
MWColors.abyss.withAlpha(200),
|
||||
MWColors.abyss.withAlpha(240),
|
||||
],
|
||||
),
|
||||
return const Scaffold(
|
||||
body: MwArtworkBackground(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
MwBrandMark(width: 220),
|
||||
SizedBox(height: 24),
|
||||
SizedBox.square(
|
||||
dimension: 28,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/logo.png',
|
||||
height: 160,
|
||||
filterQuality: FilterQuality.high,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: 28,
|
||||
height: 28,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2.5,
|
||||
color: cs.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user