mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
feat(app): mouse back/forward buttons walk the tab history
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
141e1a20d0
commit
a8559fd467
3 files changed
+104
-67
No files matched your search
@@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/gestures.dart'
|
||||||
|
show kBackMouseButton, kForwardMouseButton;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../state/app_state.dart';
|
import '../state/app_state.dart';
|
||||||
@@ -65,73 +67,84 @@ class _ShellState extends State<Shell> {
|
|||||||
for (final e in actions.entries)
|
for (final e in actions.entries)
|
||||||
...Map.fromEntries(activators(app.keymap.of(e.key), e.value)),
|
...Map.fromEntries(activators(app.keymap.of(e.key), e.value)),
|
||||||
},
|
},
|
||||||
child: Focus(
|
// The mouse's back/forward side buttons work like the arrows, as in a browser.
|
||||||
autofocus: true,
|
child: Listener(
|
||||||
child: LayoutBuilder(
|
onPointerDown: (e) {
|
||||||
builder: (context, box) {
|
if (e.buttons & kBackMouseButton != 0) app.back();
|
||||||
final narrow = box.maxWidth < 760;
|
if (e.buttons & kForwardMouseButton != 0) app.forward();
|
||||||
final sidebar = _Sidebar(
|
},
|
||||||
onNavigate: () {
|
child: Focus(
|
||||||
if (narrow) _scaffold.currentState?.closeDrawer();
|
autofocus: true,
|
||||||
},
|
child: LayoutBuilder(
|
||||||
);
|
builder: (context, box) {
|
||||||
return Scaffold(
|
final narrow = box.maxWidth < 760;
|
||||||
key: _scaffold,
|
final sidebar = _Sidebar(
|
||||||
drawer: narrow
|
onNavigate: () {
|
||||||
? Drawer(backgroundColor: colors.surface, child: sidebar)
|
if (narrow) _scaffold.currentState?.closeDrawer();
|
||||||
: null,
|
},
|
||||||
body: Row(
|
);
|
||||||
children: [
|
return Scaffold(
|
||||||
if (!narrow)
|
key: _scaffold,
|
||||||
AnimatedContainer(
|
drawer: narrow
|
||||||
duration: const Duration(milliseconds: 180),
|
? Drawer(backgroundColor: colors.surface, child: sidebar)
|
||||||
curve: Curves.easeOutCubic,
|
: null,
|
||||||
width: _sidebar ? 248 : 0,
|
body: Row(
|
||||||
child: ClipRect(
|
children: [
|
||||||
child: OverflowBox(
|
if (!narrow)
|
||||||
alignment: Alignment.topLeft,
|
AnimatedContainer(
|
||||||
minWidth: 248,
|
duration: const Duration(milliseconds: 180),
|
||||||
maxWidth: 248,
|
curve: Curves.easeOutCubic,
|
||||||
child: sidebar,
|
width: _sidebar ? 248 : 0,
|
||||||
),
|
child: ClipRect(
|
||||||
),
|
child: OverflowBox(
|
||||||
),
|
alignment: Alignment.topLeft,
|
||||||
Expanded(
|
minWidth: 248,
|
||||||
child: Column(
|
maxWidth: 248,
|
||||||
children: [
|
child: sidebar,
|
||||||
_TopBar(
|
|
||||||
narrow: narrow,
|
|
||||||
onMenu: () => narrow
|
|
||||||
? _scaffold.currentState?.openDrawer()
|
|
||||||
: setState(() => _sidebar = !_sidebar),
|
|
||||||
),
|
|
||||||
if (!narrow) const TabStrip(),
|
|
||||||
Expanded(
|
|
||||||
child: KeyedSubtree(
|
|
||||||
key: ValueKey((app.tab.uid, route, app.generation)),
|
|
||||||
child: switch (route) {
|
|
||||||
JournalsRoute() => const JournalsView(),
|
|
||||||
TimelineRoute() => const GraphView(
|
|
||||||
mode: GraphMode.timeline,
|
|
||||||
),
|
|
||||||
GraphRoute() => GraphView(
|
|
||||||
mode: route.mode,
|
|
||||||
focusId: route.focusId,
|
|
||||||
),
|
|
||||||
AllPagesRoute() => const AllPagesView(),
|
|
||||||
SettingsRoute() => const SettingsView(),
|
|
||||||
TagRoute() => TagView(name: route.name),
|
|
||||||
PageTarget() => PageScreen(target: route),
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_TopBar(
|
||||||
|
narrow: narrow,
|
||||||
|
onMenu: () => narrow
|
||||||
|
? _scaffold.currentState?.openDrawer()
|
||||||
|
: setState(() => _sidebar = !_sidebar),
|
||||||
|
),
|
||||||
|
if (!narrow) const TabStrip(),
|
||||||
|
Expanded(
|
||||||
|
child: KeyedSubtree(
|
||||||
|
key: ValueKey((
|
||||||
|
app.tab.uid,
|
||||||
|
route,
|
||||||
|
app.generation,
|
||||||
|
)),
|
||||||
|
child: switch (route) {
|
||||||
|
JournalsRoute() => const JournalsView(),
|
||||||
|
TimelineRoute() => const GraphView(
|
||||||
|
mode: GraphMode.timeline,
|
||||||
|
),
|
||||||
|
GraphRoute() => GraphView(
|
||||||
|
mode: route.mode,
|
||||||
|
focusId: route.focusId,
|
||||||
|
),
|
||||||
|
AllPagesRoute() => const AllPagesView(),
|
||||||
|
SettingsRoute() => const SettingsView(),
|
||||||
|
TagRoute() => TagView(name: route.name),
|
||||||
|
PageTarget() => PageScreen(target: route),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -177,6 +177,26 @@ void main() {
|
|||||||
expect(app.route, isA<JournalsRoute>());
|
expect(app.route, isA<JournalsRoute>());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('mouse back/forward buttons walk the history', (tester) async {
|
||||||
|
final app = await pump(tester, demo());
|
||||||
|
app.go(const AllPagesRoute());
|
||||||
|
await settle(tester);
|
||||||
|
Future<void> press(int button) async {
|
||||||
|
final mouse = await tester.createGesture(
|
||||||
|
kind: PointerDeviceKind.mouse,
|
||||||
|
buttons: button,
|
||||||
|
);
|
||||||
|
await mouse.down(const Offset(800, 500));
|
||||||
|
await mouse.up();
|
||||||
|
await settle(tester);
|
||||||
|
}
|
||||||
|
|
||||||
|
await press(kBackMouseButton);
|
||||||
|
expect(app.route, isA<JournalsRoute>());
|
||||||
|
await press(kForwardMouseButton);
|
||||||
|
expect(app.route, isA<AllPagesRoute>());
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('strip shows titles; middle-click closes, plus opens', (
|
testWidgets('strip shows titles; middle-click closes, plus opens', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
+7
-3
@@ -149,6 +149,9 @@ Both are plain names with no page, shown as one row of pills under the title.
|
|||||||
same-name type or tag; "Rename" there never renames the hub itself.
|
same-name type or tag; "Rename" there never renames the hub itself.
|
||||||
- In the graph every tag is a virtual node drawn as a hollow accent ring and linked to its
|
- In the graph every tag is a virtual node drawn as a hollow accent ring and linked to its
|
||||||
pages with a separate edge kind (TAGGED); tapping one opens its tag view.
|
pages with a separate edge kind (TAGGED); tapping one opens its tag view.
|
||||||
|
A hub's implicit tag (or a tag named like a hub) has no ring of its own: the hub node
|
||||||
|
stands for it.
|
||||||
|
- The mouse's back/forward side buttons move through the tab's history, like the arrows.
|
||||||
|
|
||||||
## Hubs, namespaces and cleanup
|
## Hubs, namespaces and cleanup
|
||||||
- **Hub** (folder icon): a page kind, not a note: no outline, a title, a short description
|
- **Hub** (folder icon): a page kind, not a note: no outline, a title, a short description
|
||||||
@@ -170,9 +173,10 @@ Both are plain names with no page, shown as one row of pills under the title.
|
|||||||
note that keeps the original outline; title clashes are shown inline) and "Add to hub…".
|
note that keeps the original outline; title clashes are shown inline) and "Add to hub…".
|
||||||
- Every page's `⋯` menu (notes and hubs) ends with "Delete page…": the same confirmation as
|
- Every page's `⋯` menu (notes and hubs) ends with "Delete page…": the same confirmation as
|
||||||
All pages; tabs showing it step back (or fall back to Journals) and recents drop it.
|
All pages; tabs showing it step back (or fall back to Journals) and recents drop it.
|
||||||
- All pages ▸ "Clean up": dialog listing legacy Logseq pages (`contents`, `hls__...`, pages
|
- All pages ▸ "Clean up": dialog listing empty pages (no text in any block, not a hub, no
|
||||||
with `type:: system`, ...) with checkboxes; "Delete (n)" removes only the checked ones
|
type, tags or description; all preselected) and legacy Logseq pages (`contents`,
|
||||||
and their blocks.
|
`hls__...`, pages with `type:: system`, ...) with checkboxes and "Select all/none";
|
||||||
|
"Delete (n)" removes only the checked ones and their blocks.
|
||||||
|
|
||||||
## Page sidebar and All pages
|
## Page sidebar and All pages
|
||||||
- The sidebar icon next to a note's `⋯` menu toggles a right sidebar (collapsed by default,
|
- The sidebar icon next to a note's `⋯` menu toggles a right sidebar (collapsed by default,
|
||||||
|
|||||||
Reference in new issue
Block a user