mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
history page, comic menu
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
part of "components.dart";
|
||||
|
||||
void showDesktopMenu(
|
||||
BuildContext context, Offset location, List<DesktopMenuEntry> entries) {
|
||||
Navigator.of(context).push(DesktopMenuRoute(entries, location));
|
||||
void showMenuX(BuildContext context, Offset location, List<MenuEntry> entries) {
|
||||
Navigator.of(context).push(_MenuRoute(entries, location));
|
||||
}
|
||||
|
||||
class DesktopMenuRoute<T> extends PopupRoute<T> {
|
||||
final List<DesktopMenuEntry> entries;
|
||||
class _MenuRoute<T> extends PopupRoute<T> {
|
||||
final List<MenuEntry> entries;
|
||||
|
||||
final Offset location;
|
||||
|
||||
DesktopMenuRoute(this.entries, this.location);
|
||||
_MenuRoute(this.entries, this.location);
|
||||
|
||||
@override
|
||||
Color? get barrierColor => Colors.transparent;
|
||||
@@ -24,7 +23,7 @@ class DesktopMenuRoute<T> extends PopupRoute<T> {
|
||||
@override
|
||||
Widget buildPage(BuildContext context, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
const width = 196.0;
|
||||
var width = entries.first.icon == null ? 216.0 : 242.0;
|
||||
final size = MediaQuery.of(context).size;
|
||||
var left = location.dx;
|
||||
if (left + width > size.width - 10) {
|
||||
@@ -41,22 +40,33 @@ class DesktopMenuRoute<T> extends PopupRoute<T> {
|
||||
left: left,
|
||||
top: top,
|
||||
child: Container(
|
||||
width: width,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: context.colorScheme.surface,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.colorScheme.shadow.withOpacity(0.2),
|
||||
blurRadius: 8,
|
||||
blurStyle: BlurStyle.outer,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: BlurEffect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Material(
|
||||
color: context.brightness == Brightness.light
|
||||
? const Color(0xFFFAFAFA).withOpacity(0.72)
|
||||
: const Color(0xFF090909).withOpacity(0.72),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.2),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
child: Container(
|
||||
width: width,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 12, horizontal: 6),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children:
|
||||
entries.map((e) => buildEntry(e, context)).toList(),
|
||||
),
|
||||
]),
|
||||
child: Material(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: entries.map((e) => buildEntry(e, context)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -65,7 +75,7 @@ class DesktopMenuRoute<T> extends PopupRoute<T> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildEntry(DesktopMenuEntry entry, BuildContext context) {
|
||||
Widget buildEntry(MenuEntry entry, BuildContext context) {
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
onTap: () {
|
||||
@@ -73,22 +83,20 @@ class DesktopMenuRoute<T> extends PopupRoute<T> {
|
||||
entry.onClick();
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 32,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
if (entry.icon != null)
|
||||
Icon(
|
||||
entry.icon,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Text(entry.text),
|
||||
],
|
||||
height: App.isMobile ? 42 : 36,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
if (entry.icon != null)
|
||||
Icon(
|
||||
entry.icon,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(entry.text),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -108,10 +116,10 @@ class DesktopMenuRoute<T> extends PopupRoute<T> {
|
||||
}
|
||||
}
|
||||
|
||||
class DesktopMenuEntry {
|
||||
class MenuEntry {
|
||||
final String text;
|
||||
final IconData? icon;
|
||||
final void Function() onClick;
|
||||
|
||||
DesktopMenuEntry({required this.text, this.icon, required this.onClick});
|
||||
MenuEntry({required this.text, this.icon, required this.onClick});
|
||||
}
|
||||
|
Reference in New Issue
Block a user