Skip to content

Commit

Permalink
Merge pull request #679 from frg2089/feat/hotkey
Browse files Browse the repository at this point in the history
Windows桌面UI添加用 Alt + ← 后退的快捷键
  • Loading branch information
Notsfsssf authored Feb 16, 2024
2 parents 106637c + 9802ce4 commit 7b49bd4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
17 changes: 16 additions & 1 deletion lib/fluent/component/illust_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,33 @@ class _IllustCardState extends State<IllustCard> {
child: _build(context),
items: [
MenuFlyoutItem(
text: Text('Like'),
leading: Observer(builder: (context) {
switch (store.state) {
case 0:
return Icon(FluentIcons.heart);
case 1:
return Icon(FluentIcons.heart_fill);
default:
return Icon(
FluentIcons.heart_fill,
color: Colors.red,
);
}
}),
text: Text(I18n.of(context).bookmark),
onPressed: () async {
await _onStar();
},
),
MenuFlyoutItem(
leading: Icon(FluentIcons.save),
text: Text(I18n.of(context).save),
onPressed: () async {
await _onSave();
},
),
MenuFlyoutItem(
leading: Icon(FluentIcons.favorite_list),
text: Text(I18n.of(context).favorited_tag),
onPressed: () async {
final result = await showDialog<dynamic>(
Expand Down
31 changes: 22 additions & 9 deletions lib/fluent/page/hello/fluent_hello_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:pixez/fluent/component/pixiv_image.dart';
import 'package:pixez/fluent/component/search_box.dart';
Expand Down Expand Up @@ -192,16 +193,28 @@ class FluentHelloPageState extends State<FluentHelloPage> with WindowListener {

@override
Widget build(BuildContext context) {
return Listener(
child: NavigationView(
appBar: _buildAppBar(context),
pane: _buildPane(context),
paneBodyBuilder: (item, widget) => _nav,
return RawKeyboardListener(
focusNode: FocusNode(),
autofocus: true,
child: Listener(
child: NavigationView(
appBar: _buildAppBar(context),
pane: _buildPane(context),
paneBodyBuilder: (item, widget) => _nav,
),
onPointerDown: (event) {
if (event.buttons == kBackMouseButton &&
event.kind == PointerDeviceKind.mouse) {
_navobs.navigator?.maybePop(null);
}
},
),
onPointerDown: (event) {
if (event.buttons == kBackMouseButton &&
event.kind == PointerDeviceKind.mouse) {
_navobs.navigator?.maybePop(null);
onKey: (value) {
if (value is RawKeyUpEvent) {
if (value.isAltPressed &&
value.logicalKey == LogicalKeyboardKey.arrowLeft) {
_navobs.navigator?.maybePop(null);
}
}
},
);
Expand Down

0 comments on commit 7b49bd4

Please sign in to comment.