@@ -20,59 +20,49 @@ import 'package:files/widgets/side_pane.dart';
20
20
import 'package:files/widgets/tab_strip.dart' ;
21
21
import 'package:files/widgets/workspace.dart' ;
22
22
import 'package:flutter/material.dart' ;
23
+ import 'package:yaru/yaru.dart' ;
24
+ import 'package:yaru_widgets/yaru_widgets.dart' ;
23
25
24
26
Future <void > main () async {
25
27
WidgetsFlutterBinding .ensureInitialized ();
28
+ await YaruWindowTitleBar .ensureInitialized ();
29
+ await YaruWindow .ensureInitialized ();
26
30
await initProviders ();
27
31
await driveProvider.init ();
28
32
29
33
runApp (const Files ());
30
34
}
31
35
36
+ ThemeData ? _applyThemeValues (ThemeData ? theme) {
37
+ return theme? .copyWith (
38
+ outlinedButtonTheme: OutlinedButtonThemeData (
39
+ style: theme.outlinedButtonTheme.style? .merge (
40
+ OutlinedButton .styleFrom (
41
+ backgroundColor: theme.colorScheme.surfaceVariant,
42
+ ),
43
+ ),
44
+ ),
45
+ );
46
+ }
47
+
32
48
class Files extends StatelessWidget {
33
49
const Files ({super .key});
34
50
35
51
@override
36
52
Widget build (BuildContext context) {
37
- return MaterialApp (
38
- title: 'Files' ,
39
- theme: ThemeData (
40
- colorScheme: const ColorScheme (
41
- primary: Colors .deepOrange,
42
- secondary: Colors .deepOrange,
43
- background: Color (0xFF161616 ),
44
- surface: Color (0xFF212121 ),
45
- error: Colors .red,
46
- onPrimary: Colors .white,
47
- onSecondary: Colors .white,
48
- onBackground: Colors .white,
49
- onSurface: Colors .white,
50
- onError: Colors .white,
51
- brightness: Brightness .dark,
52
- ),
53
- scrollbarTheme: ScrollbarThemeData (
54
- thumbVisibility: const MaterialStatePropertyAll (true ),
55
- trackVisibility: MaterialStateProperty .resolveWith (
56
- (states) => states.contains (MaterialState .hovered),
53
+ return YaruTheme (
54
+ builder: (context, value, child) {
55
+ return MaterialApp (
56
+ title: 'Files' ,
57
+ theme: _applyThemeValues (value.theme),
58
+ darkTheme: _applyThemeValues (value.darkTheme),
59
+ scrollBehavior: const MaterialScrollBehavior ().copyWith (
60
+ scrollbars: false ,
57
61
),
58
- trackBorderColor: MaterialStateProperty .all (Colors .transparent),
59
- crossAxisMargin: 0 ,
60
- mainAxisMargin: 0 ,
61
- radius: Radius .zero,
62
- ),
63
- menuTheme: const MenuThemeData (
64
- style: MenuStyle (
65
- padding: MaterialStatePropertyAll (
66
- EdgeInsets .symmetric (vertical: 16 ),
67
- ),
68
- ),
69
- ),
70
- ),
71
- scrollBehavior: const MaterialScrollBehavior ().copyWith (
72
- scrollbars: false ,
73
- ),
74
- debugShowCheckedModeBanner: false ,
75
- home: const FilesHome (),
62
+ debugShowCheckedModeBanner: false ,
63
+ home: const FilesHome (),
64
+ );
65
+ },
76
66
);
77
67
}
78
68
}
@@ -94,47 +84,81 @@ class _FilesHomeState extends State<FilesHome> {
94
84
95
85
@override
96
86
Widget build (BuildContext context) {
97
- return Row (
98
- children: [
99
- SidePane (
100
- destinations: folderProvider.destinations,
101
- workspace: workspaces[currentWorkspace],
102
- onNewTab: (String tabPath) {
103
- workspaces.add (WorkspaceController (initialDir: tabPath));
104
- currentWorkspace = workspaces.length - 1 ;
105
- setState (() {});
106
- },
107
- ),
108
- Expanded (
109
- child: Material (
110
- color: Theme .of (context).colorScheme.background,
111
- child: Column (
112
- children: [
113
- SizedBox (
114
- height: 56 ,
115
- child: TabStrip (
116
- tabs: workspaces,
117
- selectedTab: currentWorkspace,
118
- allowClosing: workspaces.length > 1 ,
119
- onTabChanged: (index) =>
120
- setState (() => currentWorkspace = index),
121
- onTabClosed: (index) {
122
- workspaces.removeAt (index);
123
- if (index < workspaces.length) {
124
- currentWorkspace = index;
125
- } else if (index - 1 >= 0 ) {
126
- currentWorkspace = index - 1 ;
127
- }
128
- setState (() {});
129
- },
130
- onNewTab: () {
131
- workspaces
132
- .add (WorkspaceController (initialDir: currentDir));
133
- currentWorkspace = workspaces.length - 1 ;
134
- setState (() {});
87
+ return Material (
88
+ color: Theme .of (context).colorScheme.background,
89
+ child: Column (
90
+ children: [
91
+ GestureDetector (
92
+ onPanStart: (details) => YaruWindow .drag (context),
93
+ child: SizedBox (
94
+ height: 56 ,
95
+ child: TabStrip (
96
+ tabs: workspaces,
97
+ selectedTab: currentWorkspace,
98
+ allowClosing: workspaces.length > 1 ,
99
+ onTabChanged: (index) =>
100
+ setState (() => currentWorkspace = index),
101
+ onTabClosed: (index) {
102
+ workspaces.removeAt (index);
103
+ if (index < workspaces.length) {
104
+ currentWorkspace = index;
105
+ } else if (index - 1 >= 0 ) {
106
+ currentWorkspace = index - 1 ;
107
+ }
108
+ setState (() {});
109
+ },
110
+ onNewTab: () {
111
+ workspaces.add (WorkspaceController (initialDir: currentDir));
112
+ currentWorkspace = workspaces.length - 1 ;
113
+ setState (() {});
114
+ },
115
+ trailing: [
116
+ const SizedBox (width: 16 ),
117
+ YaruWindowControl (
118
+ type: YaruWindowControlType .minimize,
119
+ onTap: () => YaruWindow .minimize (context),
120
+ ),
121
+ const SizedBox (width: 8 ),
122
+ StreamBuilder <YaruWindowState >(
123
+ stream: YaruWindow .states (context),
124
+ builder: (context, snapshot) {
125
+ final bool maximized =
126
+ snapshot.data? .isMaximized ?? false ;
127
+
128
+ return YaruWindowControl (
129
+ type: maximized
130
+ ? YaruWindowControlType .restore
131
+ : YaruWindowControlType .maximize,
132
+ onTap: () => maximized
133
+ ? YaruWindow .restore (context)
134
+ : YaruWindow .maximize (context),
135
+ );
135
136
},
136
137
),
138
+ const SizedBox (width: 8 ),
139
+ YaruWindowControl (
140
+ type: YaruWindowControlType .close,
141
+ onTap: () => YaruWindow .close (context),
142
+ ),
143
+ const SizedBox (width: 16 ),
144
+ ],
145
+ ),
146
+ ),
147
+ ),
148
+ const Divider (thickness: 1 , height: 1 ),
149
+ Expanded (
150
+ child: Row (
151
+ children: [
152
+ SidePane (
153
+ destinations: folderProvider.destinations,
154
+ workspace: workspaces[currentWorkspace],
155
+ onNewTab: (String tabPath) {
156
+ workspaces.add (WorkspaceController (initialDir: tabPath));
157
+ currentWorkspace = workspaces.length - 1 ;
158
+ setState (() {});
159
+ },
137
160
),
161
+ const VerticalDivider (thickness: 1 , width: 1 ),
138
162
Expanded (
139
163
child: FilesWorkspace (
140
164
key: ValueKey (currentWorkspace),
@@ -144,8 +168,8 @@ class _FilesHomeState extends State<FilesHome> {
144
168
],
145
169
),
146
170
),
147
- ) ,
148
- ] ,
171
+ ] ,
172
+ ) ,
149
173
);
150
174
}
151
175
}
0 commit comments