1
1
import 'dart:ui' ;
2
2
3
3
import 'package:flutter/material.dart' ;
4
- import 'package:gtk/gtk.dart' ;
5
4
import 'package:ubuntu_service/ubuntu_service.dart' ;
6
5
import 'package:yaru/yaru.dart' ;
7
6
8
7
import '../../app.dart' ;
9
- import '../../common.dart' ;
10
8
import '../../library.dart' ;
11
9
import '../../theme.dart' ;
12
10
import '../l10n/l10n.dart' ;
13
11
import 'app.dart' ;
14
12
15
- class MusicPod extends StatelessWidget {
16
- const MusicPod ({super .key});
13
+ class YaruMusicPodApp extends StatelessWidget {
14
+ const YaruMusicPodApp ({
15
+ super .key,
16
+ });
17
17
18
18
@override
19
19
Widget build (BuildContext context) {
20
- if (yaruStyled) {
21
- return YaruTheme (
22
- builder: (context, yaruThemeData, child) {
23
- return GtkApplication (
24
- child: MusicPodApp (
25
- lightTheme: yaruThemeData.theme,
26
- darkTheme: yaruThemeData.darkTheme? .copyWith (
27
- scaffoldBackgroundColor: const Color (0xFF1e1e1e ),
28
- ),
20
+ return YaruTheme (
21
+ builder: (context, yaru, child) {
22
+ return MusicPodApp (
23
+ lightTheme: yaru.theme,
24
+ darkTheme: yaru.darkTheme? .copyWith (
25
+ scaffoldBackgroundColor: const Color (0xFF1e1e1e ),
26
+ dividerColor: darkDividerColor,
27
+ dividerTheme: const DividerThemeData (
28
+ color: darkDividerColor,
29
+ space: 1.0 ,
30
+ thickness: 0.0 ,
29
31
),
30
- );
31
- },
32
- );
33
- } else {
34
- return MusicPodApp (
35
- lightTheme: m3Theme (),
36
- darkTheme: m3Theme (brightness: Brightness .dark),
37
- );
38
- }
32
+ ),
33
+ );
34
+ },
35
+ child: const MusicPodApp (),
36
+ );
39
37
}
40
38
}
41
39
42
- class MusicPodApp extends StatelessWidget {
40
+ class MusicPodApp extends StatefulWidget {
43
41
const MusicPodApp ({
44
42
super .key,
45
43
this .lightTheme,
@@ -48,32 +46,35 @@ class MusicPodApp extends StatelessWidget {
48
46
49
47
final ThemeData ? lightTheme, darkTheme;
50
48
49
+ @override
50
+ State <MusicPodApp > createState () => _MusicPodAppState ();
51
+ }
52
+
53
+ class _MusicPodAppState extends State <MusicPodApp > {
54
+ bool initialized = false ;
55
+
56
+ @override
57
+ void initState () {
58
+ super .initState ();
59
+ getService <LibraryService >().init ().then (
60
+ (value) {
61
+ if (! initialized) {
62
+ setState (() => initialized = value);
63
+ }
64
+ },
65
+ );
66
+ }
67
+
51
68
@override
52
69
Widget build (BuildContext context) {
53
- const dividerColor = Color .fromARGB (19 , 255 , 255 , 255 );
54
70
return MaterialApp (
55
71
debugShowCheckedModeBanner: false ,
56
- theme: lightTheme,
57
- darkTheme: darkTheme? .copyWith (
58
- dividerColor: dividerColor,
59
- dividerTheme: const DividerThemeData (
60
- color: dividerColor,
61
- space: 1.0 ,
62
- thickness: 0.0 ,
63
- ),
64
- ),
72
+ theme: widget.lightTheme ?? m3Theme (),
73
+ darkTheme: widget.darkTheme ?? m3Theme (brightness: Brightness .dark),
65
74
localizationsDelegates: AppLocalizations .localizationsDelegates,
66
75
supportedLocales: supportedLocales,
67
76
onGenerateTitle: (context) => 'MusicPod' ,
68
- home: FutureBuilder (
69
- future: getService <LibraryService >().init (),
70
- builder: (context, snapshot) {
71
- if (snapshot.connectionState == ConnectionState .done) {
72
- return App .create ();
73
- }
74
- return const Scaffold (appBar: HeaderBar (), body: SplashScreen ());
75
- },
76
- ),
77
+ home: initialized ? App .create () : const SplashScreen (),
77
78
scrollBehavior: const MaterialScrollBehavior ().copyWith (
78
79
dragDevices: {
79
80
PointerDeviceKind .mouse,
0 commit comments