Skip to content

Commit 01ec113

Browse files
committed
files: Yarufy the app
1 parent 210b473 commit 01ec113

20 files changed

+512
-268
lines changed

lib/backend/folder_provider.dart

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import 'package:files/backend/utils.dart';
2121
import 'package:flutter/material.dart';
2222
import 'package:windows_path_provider/windows_path_provider.dart';
2323
import 'package:xdg_directories/xdg_directories.dart';
24+
import 'package:yaru_icons/yaru_icons.dart';
2425

2526
class FolderProvider {
2627
final List<BuiltinFolder> _folders;
@@ -129,15 +130,15 @@ class SideDestination {
129130
}
130131

131132
const Map<FolderType, IconData> _icons = {
132-
FolderType.home: Icons.home_filled,
133-
FolderType.desktop: Icons.desktop_windows,
134-
FolderType.documents: Icons.note_outlined,
135-
FolderType.pictures: Icons.photo_library_outlined,
136-
FolderType.download: Icons.file_download,
137-
FolderType.videos: Icons.videocam_outlined,
138-
FolderType.music: Icons.music_note_outlined,
139-
FolderType.publicShare: Icons.public_outlined,
140-
FolderType.templates: Icons.file_copy_outlined,
133+
FolderType.home: YaruIcons.home,
134+
FolderType.desktop: YaruIcons.desktop,
135+
FolderType.documents: YaruIcons.document,
136+
FolderType.pictures: YaruIcons.image,
137+
FolderType.download: YaruIcons.download,
138+
FolderType.videos: YaruIcons.video,
139+
FolderType.music: YaruIcons.music_note,
140+
FolderType.publicShare: YaruIcons.globe,
141+
FolderType.templates: YaruIcons.document_new,
141142
};
142143

143144
String windowsFolderToString(WindowsFolder folder) {

lib/backend/utils.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:files/backend/providers.dart';
66
import 'package:flutter/material.dart';
77
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
88
import 'package:mime/mime.dart';
9+
import 'package:yaru_icons/yaru_icons.dart';
910

1011
class Utils {
1112
Utils._();
@@ -52,10 +53,10 @@ class Utils {
5253
final String? mime = lookupMimeType(path);
5354

5455
if (mime != null) {
55-
return iconsPerMime[mime] ?? Icons.insert_drive_file_outlined;
56+
return iconsPerMime[mime] ?? YaruIcons.document_filled;
5657
}
5758

58-
return Icons.insert_drive_file_outlined;
59+
return YaruIcons.document_filled;
5960
}
6061

6162
static IconData iconForFolder(String path) {
@@ -64,7 +65,7 @@ class Utils {
6465
? folderProvider.getIconForType(builtinFolder.type)
6566
: null;
6667

67-
return builtinFolderIcon ?? Icons.folder;
68+
return builtinFolderIcon ?? YaruIcons.folder_filled;
6869
}
6970

7071
static String getEntityName(String path) {

lib/main.dart

Lines changed: 102 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -20,59 +20,49 @@ import 'package:files/widgets/side_pane.dart';
2020
import 'package:files/widgets/tab_strip.dart';
2121
import 'package:files/widgets/workspace.dart';
2222
import 'package:flutter/material.dart';
23+
import 'package:yaru/yaru.dart';
24+
import 'package:yaru_widgets/yaru_widgets.dart';
2325

2426
Future<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+
3248
class 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

Comments
 (0)