Remove yaru dep
This commit is contained in:
parent
a15fae89eb
commit
26a2bd3f5e
21 changed files with 291 additions and 311 deletions
|
@ -10,7 +10,6 @@ import "package:flutter/material.dart";
|
|||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:yaru/yaru.dart';
|
||||
import 'package:brook/providers/button_layout_provider.dart';
|
||||
import 'package:brook/providers/warmup_provider.dart';
|
||||
|
||||
|
@ -30,30 +29,28 @@ class App extends HookConsumerWidget {
|
|||
ytmusicProvider,
|
||||
])))
|
||||
.betterWhen(
|
||||
data: (_) => YaruDetailPage(
|
||||
appBar: const Appbar(title: "Brook"),
|
||||
body: tabs[selected.value],
|
||||
data: (_) => Scaffold(
|
||||
appBar: Appbar(title: "Brook"),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
destinations: tabs
|
||||
.map(
|
||||
(tab) => NavigationDestination(
|
||||
icon: Icon(tab.icon),
|
||||
icon: Icon(
|
||||
tab.icon,
|
||||
),
|
||||
label: tab.title,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
selectedIndex: selected.value,
|
||||
onDestinationSelected: (index) => selected.value = index,
|
||||
selectedIndex: selected.value,
|
||||
),
|
||||
body: tabs[selected.value],
|
||||
),
|
||||
),
|
||||
),
|
||||
theme: AdwaitaThemeData.light().copyWith(
|
||||
textTheme: const YaruThemeData().theme?.textTheme,
|
||||
),
|
||||
darkTheme: AdwaitaThemeData.dark().copyWith(
|
||||
textTheme: const YaruThemeData().darkTheme?.textTheme,
|
||||
),
|
||||
theme: AdwaitaThemeData.light().tweaked(),
|
||||
darkTheme: AdwaitaThemeData.dark(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:adwaita_icons/adwaita_icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:brook/providers/decorations_provider.dart';
|
||||
import 'package:yaru/yaru.dart';
|
||||
import 'package:brook/models/decoration_type.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class Appbar extends ConsumerWidget implements PreferredSizeWidget {
|
||||
final String title;
|
||||
|
@ -11,42 +13,61 @@ class Appbar extends ConsumerWidget implements PreferredSizeWidget {
|
|||
});
|
||||
|
||||
@override
|
||||
Size get preferredSize => const YaruWindowTitleBar().preferredSize;
|
||||
Size get preferredSize => AppBar().preferredSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final window = YaruWindow.of(context);
|
||||
|
||||
List<Widget> getControl(List<YaruWindowControlType> types) => [
|
||||
const SizedBox(width: 6),
|
||||
List<Widget> getControl(List<DecorationType> types) => [
|
||||
SizedBox(width: 6),
|
||||
...types.map(
|
||||
(type) => Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: YaruWindowControl(
|
||||
type: type,
|
||||
onTap: switch (type) {
|
||||
YaruWindowControlType.close => window.close,
|
||||
YaruWindowControlType.maximize => () => window.state().then(
|
||||
(state) => state.isMaximized!
|
||||
? window.restore()
|
||||
: window.maximize(),
|
||||
(type) {
|
||||
final decoration = switch (type) {
|
||||
DecorationType.close => (
|
||||
onClick: windowManager.close,
|
||||
icon: AdwaitaIcons.window_close,
|
||||
),
|
||||
DecorationType.maximize => (
|
||||
onClick: windowManager.maximize,
|
||||
icon: AdwaitaIcons.window_maximize,
|
||||
),
|
||||
DecorationType.minimize => (
|
||||
onClick: windowManager.minimize,
|
||||
icon: AdwaitaIcons.window_minimize,
|
||||
),
|
||||
DecorationType.restore => (
|
||||
onClick: windowManager.restore,
|
||||
icon: AdwaitaIcons.window_restore,
|
||||
),
|
||||
};
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.all(4),
|
||||
onPressed: decoration.onClick,
|
||||
style: ButtonStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(
|
||||
Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
YaruWindowControlType.minimize => window.minimize,
|
||||
YaruWindowControlType.restore => window.restore,
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
icon: AdwaitaIcon(decoration.icon),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
SizedBox(width: 6),
|
||||
];
|
||||
|
||||
final decorations = ref.watch(decorationsProvider);
|
||||
|
||||
return YaruWindowTitleBar(
|
||||
return AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
title: Text(title),
|
||||
leading: Row(children: [
|
||||
SizedBox(width: 12),
|
||||
...getControl(decorations.leading),
|
||||
if (Navigator.of(context).canPop())
|
||||
BackButton(
|
||||
style: ButtonStyle(
|
||||
|
@ -55,12 +76,9 @@ class Appbar extends ConsumerWidget implements PreferredSizeWidget {
|
|||
padding: WidgetStatePropertyAll(EdgeInsets.zero),
|
||||
),
|
||||
),
|
||||
...getControl(decorations.leading)
|
||||
]),
|
||||
buttonPadding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
actions: getControl(decorations.trailing),
|
||||
border: BorderSide.none,
|
||||
style: YaruTitleBarStyle.undecorated,
|
||||
centerTitle: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
35
lib/widgets/result.dart
Normal file
35
lib/widgets/result.dart
Normal file
|
@ -0,0 +1,35 @@
|
|||
import 'package:brook/widgets/thumbnail.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Result extends StatelessWidget {
|
||||
final String thumb;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final VoidCallback onClick;
|
||||
const Result({
|
||||
required this.thumb,
|
||||
required this.onClick,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => SizedBox(
|
||||
height: 64,
|
||||
child: ListTile(
|
||||
leading: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Thumbnail(
|
||||
url: thumb,
|
||||
onClick: onClick,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: subtitle == null ? null : Text(subtitle!),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -17,6 +17,10 @@ class SelectButton<T extends Enum> extends HookWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final oldValue = useState(<T>{});
|
||||
return SegmentedButton(
|
||||
style: SegmentedButton.styleFrom(
|
||||
side: BorderSide.none,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
segments: values
|
||||
.map((value) => ButtonSegment(
|
||||
value: value,
|
||||
|
|
|
@ -4,21 +4,29 @@ class Thumbnail extends StatelessWidget {
|
|||
final String url;
|
||||
final VoidCallback onClick;
|
||||
final double radius;
|
||||
final ShapeBorder? border;
|
||||
final Widget? child;
|
||||
const Thumbnail({
|
||||
super.key,
|
||||
required this.url,
|
||||
required this.onClick,
|
||||
this.radius = 16,
|
||||
this.border,
|
||||
this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(radius)),
|
||||
child: InkWell(
|
||||
onTap: onClick,
|
||||
child: Image.network(
|
||||
url,
|
||||
fit: BoxFit.fill,
|
||||
)),
|
||||
child: Material(
|
||||
child: Ink.image(
|
||||
image: NetworkImage(url),
|
||||
fit: BoxFit.fill,
|
||||
child: InkWell(
|
||||
onTap: onClick,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Reference in a new issue