feat: add prev and next buttons to the address bar on pointer platforms
This commit is contained in:
parent
28ff7ca327
commit
ac9118a453
3 changed files with 90 additions and 9 deletions
|
|
@ -1,12 +1,14 @@
|
|||
import 'package:flutter/foundation.dart' show defaultTargetPlatform, TargetPlatform;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:signals/signals_flutter.dart' show SignalBuilder;
|
||||
|
||||
import '../../application/internal_pages.dart';
|
||||
import '../app.dart';
|
||||
|
||||
/// The single-field address bar. The left icon opens the settings page; the
|
||||
/// right icons reload, subscribe (only when the page offers something to
|
||||
/// subscribe to) and bookmark the current page.
|
||||
/// The single-field address bar. The left icon opens the settings page and,
|
||||
/// on pointer platforms, carries the back and forward buttons; the right
|
||||
/// icons reload, subscribe (only when the page offers something to subscribe
|
||||
/// to) and bookmark the current page.
|
||||
class AddressBar extends StatefulWidget {
|
||||
const AddressBar({super.key});
|
||||
|
||||
|
|
@ -52,6 +54,14 @@ class _AddressBarState extends State<AddressBar> {
|
|||
_controller.text = url;
|
||||
}
|
||||
|
||||
// Touch devices navigate with swipes; desktops get buttons.
|
||||
final hasButtons = switch (defaultTargetPlatform) {
|
||||
TargetPlatform.linux ||
|
||||
TargetPlatform.windows ||
|
||||
TargetPlatform.macOS => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
// Only pages with dated entry links or an Atom feed can be subscribed
|
||||
// to (mews spec, section 6).
|
||||
final canSubscribe = page != null &&
|
||||
|
|
@ -79,12 +89,41 @@ class _AddressBarState extends State<AddressBar> {
|
|||
labelText: strings.t('reader-address-label'),
|
||||
isDense: true,
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: IconButton(
|
||||
icon: const Icon(Icons.tune),
|
||||
tooltip: strings.t('reader-open-settings'),
|
||||
onPressed: () =>
|
||||
deps.browser.open(InternalPages.settingsUrl),
|
||||
),
|
||||
prefixIcon: hasButtons
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.tune),
|
||||
tooltip: strings.t('reader-open-settings'),
|
||||
onPressed: () =>
|
||||
deps.browser.open(InternalPages.settingsUrl),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
tooltip: strings.t('reader-back'),
|
||||
onPressed: deps.browser.canGoBack
|
||||
? deps.browser.back
|
||||
: null,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
tooltip: strings.t('reader-forward'),
|
||||
onPressed: deps.browser.canGoForward
|
||||
? deps.browser.forward
|
||||
: null,
|
||||
),
|
||||
],
|
||||
)
|
||||
: IconButton(
|
||||
icon: const Icon(Icons.tune),
|
||||
tooltip: strings.t('reader-open-settings'),
|
||||
onPressed: () =>
|
||||
deps.browser.open(InternalPages.settingsUrl),
|
||||
),
|
||||
prefixIconConstraints: hasButtons
|
||||
? const BoxConstraints(minWidth: 138, minHeight: 48)
|
||||
: null,
|
||||
suffixIcon: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue