@@ -20,59 +20,49 @@ import 'package:files/widgets/side_pane.dart';
2020import 'package:files/widgets/tab_strip.dart' ;
2121import 'package:files/widgets/workspace.dart' ;
2222import 'package:flutter/material.dart' ;
23+ import 'package:yaru/yaru.dart' ;
24+ import 'package:yaru_widgets/yaru_widgets.dart' ;
2325
2426Future <void > main () async {
2527 WidgetsFlutterBinding .ensureInitialized ();
28+ await YaruWindowTitleBar .ensureInitialized ();
29+ await YaruWindow .ensureInitialized ();
2630 await initProviders ();
2731 await driveProvider.init ();
2832
2933 runApp (const Files ());
3034}
3135
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+
3248class Files extends StatelessWidget {
3349 const Files ({super .key});
3450
3551 @override
3652 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 ,
5761 ),
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+ },
7666 );
7767 }
7868}
@@ -94,47 +84,81 @@ class _FilesHomeState extends State<FilesHome> {
9484
9585 @override
9686 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+ );
135136 },
136137 ),
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+ },
137160 ),
161+ const VerticalDivider (thickness: 1 , width: 1 ),
138162 Expanded (
139163 child: FilesWorkspace (
140164 key: ValueKey (currentWorkspace),
@@ -144,8 +168,8 @@ class _FilesHomeState extends State<FilesHome> {
144168 ],
145169 ),
146170 ),
147- ) ,
148- ] ,
171+ ] ,
172+ ) ,
149173 );
150174 }
151175}
0 commit comments