Merge branch 'main' into pipelines/run-20261111-0115-cupertino-out-ui-motion-navigation-input-6491
# Conflicts: # app/test/features/runs/ui/runs_list_widget_test.dart
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Asks for one machine's own password. [signIn] returns null on success,
|
||||
/// otherwise the sentence to show; the dialog stays open for a retry.
|
||||
Future<void> showMachineSignIn(
|
||||
@@ -11,9 +8,7 @@ Future<void> showMachineSignIn(
|
||||
required Future<String?> Function(String password) signIn,
|
||||
}) {
|
||||
final dialog = MachineSignInDialog(name: name, signIn: signIn);
|
||||
return usesCupertinoHost(context)
|
||||
? showCupertinoDialog<void>(context: context, builder: (_) => dialog)
|
||||
: showDialog<void>(context: context, builder: (_) => dialog);
|
||||
return showDialog<void>(context: context, builder: (_) => dialog);
|
||||
}
|
||||
|
||||
class MachineSignInDialog extends StatefulWidget {
|
||||
@@ -68,24 +63,14 @@ class _MachineSignInDialogState extends State<MachineSignInDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final field = cupertino
|
||||
? CupertinoTextField(
|
||||
key: const Key('machine-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
placeholder: 'Password',
|
||||
onSubmitted: busy ? null : (_) => submit(),
|
||||
)
|
||||
: TextField(
|
||||
key: const Key('machine-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => submit(),
|
||||
);
|
||||
final field = TextField(
|
||||
key: const Key('machine-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => submit(),
|
||||
);
|
||||
final content = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -103,36 +88,20 @@ class _MachineSignInDialogState extends State<MachineSignInDialog> {
|
||||
],
|
||||
);
|
||||
final title = Text('Sign in to ${widget.name}');
|
||||
return cupertino
|
||||
? CupertinoAlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: busy ? null : () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('machine-sign-in'),
|
||||
onPressed: busy ? null : submit,
|
||||
child: Text(busy ? 'Signing in…' : 'Sign in'),
|
||||
),
|
||||
],
|
||||
)
|
||||
: AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('machine-sign-in'),
|
||||
onPressed: busy ? null : submit,
|
||||
child: Text(busy ? 'Signing in…' : 'Sign in'),
|
||||
),
|
||||
],
|
||||
);
|
||||
return AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('machine-sign-in'),
|
||||
onPressed: busy ? null : submit,
|
||||
child: Text(busy ? 'Signing in…' : 'Sign in'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'machine_elevation.dart';
|
||||
|
||||
/// The app's elevation prompt: the native password dialog over whatever
|
||||
@@ -21,12 +19,10 @@ Future<bool> showElevationDialog(
|
||||
MachineElevation machine,
|
||||
) async {
|
||||
final dialog = ElevationDialog(name: machine.name, submit: machine.submit);
|
||||
final result = usesCupertinoHost(context)
|
||||
? await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => dialog,
|
||||
)
|
||||
: await showDialog<bool>(context: context, builder: (_) => dialog);
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => dialog,
|
||||
);
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
@@ -74,24 +70,14 @@ class _ElevationDialogState extends State<ElevationDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final field = cupertino
|
||||
? CupertinoTextField(
|
||||
key: const Key('elevation-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
placeholder: 'Password',
|
||||
onSubmitted: busy ? null : (_) => confirm(),
|
||||
)
|
||||
: TextField(
|
||||
key: const Key('elevation-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => confirm(),
|
||||
);
|
||||
final field = TextField(
|
||||
key: const Key('elevation-password'),
|
||||
controller: password,
|
||||
obscureText: true,
|
||||
autofocus: true,
|
||||
decoration: const InputDecoration(labelText: 'Password'),
|
||||
onSubmitted: busy ? null : (_) => confirm(),
|
||||
);
|
||||
final content = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -111,37 +97,20 @@ class _ElevationDialogState extends State<ElevationDialog> {
|
||||
);
|
||||
const title = Text('Confirm password');
|
||||
final confirmLabel = Text(busy ? 'Confirming…' : 'Confirm');
|
||||
return cupertino
|
||||
? CupertinoAlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: busy ? null : () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('elevation-confirm'),
|
||||
isDefaultAction: true,
|
||||
onPressed: busy ? null : confirm,
|
||||
child: confirmLabel,
|
||||
),
|
||||
],
|
||||
)
|
||||
: AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('elevation-confirm'),
|
||||
onPressed: busy ? null : confirm,
|
||||
child: confirmLabel,
|
||||
),
|
||||
],
|
||||
);
|
||||
return AlertDialog(
|
||||
title: title,
|
||||
content: content,
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: busy ? null : () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
key: const Key('elevation-confirm'),
|
||||
onPressed: busy ? null : confirm,
|
||||
child: confirmLabel,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_keys.dart';
|
||||
import 'needs_you_sheet.dart';
|
||||
@@ -43,8 +41,8 @@ class NeedsYouBell extends StatefulWidget {
|
||||
final ValueChanged<AttentionEntry> onDismiss;
|
||||
final ValueChanged<List<AttentionEntry>> onClearAll;
|
||||
|
||||
/// Forces the native host in tests and fixtures; otherwise the ambient
|
||||
/// [usesCupertinoHost] decides.
|
||||
/// Retained for callers that still pass it; the bell is the Material action
|
||||
/// whether this is set or not.
|
||||
final bool? cupertino;
|
||||
|
||||
@override
|
||||
@@ -150,17 +148,14 @@ class _NeedsYouBellState extends State<NeedsYouBell> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final native = widget.cupertino ?? usesCupertinoHost(context);
|
||||
final label = attentionBadgeLabel(widget.entries.length);
|
||||
final action = native ? _cupertino(context) : _material(context, label);
|
||||
final semantics = Semantics(
|
||||
label: label,
|
||||
button: true,
|
||||
onTap: _open,
|
||||
excludeSemantics: true,
|
||||
child: action,
|
||||
child: _material(label),
|
||||
);
|
||||
if (native) return semantics;
|
||||
// The reserved badge room is outside the semantics box, so the focus
|
||||
// rectangle stays the size of the action rather than the empty end room.
|
||||
return Padding(
|
||||
@@ -169,57 +164,18 @@ class _NeedsYouBellState extends State<NeedsYouBell> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _material(BuildContext context, String label) {
|
||||
Widget _material(String label) {
|
||||
return IconButton(
|
||||
key: attentionBellKey,
|
||||
focusNode: _focus,
|
||||
tooltip: label,
|
||||
onPressed: _open,
|
||||
icon: _badged(
|
||||
context,
|
||||
hostCupertino: false,
|
||||
icon: const Icon(Icons.notifications_outlined),
|
||||
),
|
||||
icon: _badged(const Icon(Icons.notifications_outlined)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
// The whole 44pt target and no extra padding, like every bar action.
|
||||
return CupertinoButton(
|
||||
key: attentionBellKey,
|
||||
focusNode: _focus,
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: _open,
|
||||
child: _badged(
|
||||
context,
|
||||
hostCupertino: true,
|
||||
icon: const Icon(CupertinoIcons.bell),
|
||||
textStyle: theme.textTheme.tabLabelTextStyle,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _badged(
|
||||
BuildContext context, {
|
||||
required bool hostCupertino,
|
||||
required Widget icon,
|
||||
TextStyle? textStyle,
|
||||
}) {
|
||||
Widget _badged(Widget icon) {
|
||||
final count = widget.entries.length;
|
||||
// No native Cupertino badge exists; the framework Badge is used with the
|
||||
// host's semantic red and the host's smallest text role.
|
||||
if (hostCupertino && count > 0) {
|
||||
return Badge.count(
|
||||
key: attentionBadgeKey,
|
||||
count: count,
|
||||
textStyle: textStyle,
|
||||
backgroundColor: CupertinoColors.systemRed.resolveFrom(context),
|
||||
textColor: CupertinoColors.white,
|
||||
child: icon,
|
||||
);
|
||||
}
|
||||
if (count > 0) {
|
||||
return Badge.count(key: attentionBadgeKey, count: count, child: icon);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ const attentionBellKey = ValueKey<String>('attention-bell');
|
||||
/// The visible count badge. Absent when nothing needs the operator.
|
||||
const attentionBadgeKey = ValueKey<String>('attention-badge');
|
||||
|
||||
/// The open sheet itself, whichever native host draws it.
|
||||
/// The open sheet itself.
|
||||
const attentionSheetKey = ValueKey<String>('attention-sheet');
|
||||
|
||||
/// The honest empty line shown when the open snapshot has no entries.
|
||||
const attentionEmptyKey = ValueKey<String>('attention-empty');
|
||||
|
||||
/// The header's Done action, which closes the sheet on both hosts.
|
||||
/// The header's Done action, which closes the sheet.
|
||||
const attentionDoneKey = ValueKey<String>('attention-done');
|
||||
|
||||
/// The bulk dismissal action, present only while the snapshot has entries.
|
||||
|
||||
@@ -15,8 +15,7 @@ import 'needs_you_bell.dart';
|
||||
/// It owns the live attention state for this destination: [rows] are the
|
||||
/// already-loaded `list_runs` summaries and [frames] is the shared gateway's
|
||||
/// unsolicited stream, so it never polls or issues an attention request. The
|
||||
/// bell has no built-in host choice; the ambient app host (or [cupertino] in a
|
||||
/// fixture) selects the native Material or Cupertino action and sheet.
|
||||
/// bell is always the Material action and sheet.
|
||||
class NeedsYouRunsHeading extends StatefulWidget {
|
||||
const NeedsYouRunsHeading({
|
||||
super.key,
|
||||
@@ -49,7 +48,8 @@ class NeedsYouRunsHeading extends StatefulWidget {
|
||||
/// Injected clock for deterministic local-day windows.
|
||||
final DateTime Function()? now;
|
||||
|
||||
/// Forces the native host in tests and fixtures.
|
||||
/// Retained for callers that still pass it; the heading is always the
|
||||
/// Material bell whether this is set or not.
|
||||
final bool? cupertino;
|
||||
|
||||
/// The app-level notification capability. Absent in fixtures that only draw
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_sheet_cupertino.dart';
|
||||
import 'needs_you_sheet_material.dart';
|
||||
|
||||
/// Opens the native `Needs you` sheet over the live [entries].
|
||||
@@ -17,8 +14,8 @@ import 'needs_you_sheet_material.dart';
|
||||
///
|
||||
/// The sheet stays open after Dismiss and Clear all, so several rows can be
|
||||
/// dealt with in one visit. Choosing a row closes it; Escape, the barrier and
|
||||
/// system back are native route behaviour. The caller supplies the native host
|
||||
/// explicitly when it already knows it; otherwise the ambient app host decides.
|
||||
/// system back are native route behaviour. The sheet is always the Material
|
||||
/// bottom sheet; [cupertino] is retained for callers that still pass it.
|
||||
Future<void> showNeedsYouSheet({
|
||||
required BuildContext context,
|
||||
required ValueListenable<List<AttentionEntry>> entries,
|
||||
@@ -28,19 +25,6 @@ Future<void> showNeedsYouSheet({
|
||||
bool? cupertino,
|
||||
}) {
|
||||
final snapshot = attentionDismissalSnapshot(entries.value);
|
||||
final native = cupertino ?? usesCupertinoHost(context);
|
||||
if (native) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoNeedsYouSheet(
|
||||
entries: entries,
|
||||
snapshot: snapshot,
|
||||
onOpen: onOpen,
|
||||
onDismiss: onDismiss,
|
||||
onClearAll: onClearAll,
|
||||
),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import 'attention_status_icon.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_copy.dart';
|
||||
import 'needs_you_keys.dart';
|
||||
|
||||
/// The Cupertino popup body of the `Needs you` surface.
|
||||
///
|
||||
/// It reads as a native action-sheet style grouped list: an inset-grouped iOS
|
||||
/// list in a [CupertinoPopupSurface], with a Close action, one grouped row per
|
||||
/// live entry and a separate Clear-all group. Dismissing and Clear all leave the
|
||||
/// sheet open and redraw it, matching the browser; [snapshot] is the set Clear
|
||||
/// all may remove, so a later arrival is shown but never cleared by this visit.
|
||||
/// Rows use host text roles without a line cap so a long label and description
|
||||
/// wrap at a narrow, scaled width.
|
||||
class CupertinoNeedsYouSheet extends StatelessWidget {
|
||||
const CupertinoNeedsYouSheet({
|
||||
super.key,
|
||||
required this.entries,
|
||||
required this.snapshot,
|
||||
required this.onOpen,
|
||||
required this.onDismiss,
|
||||
required this.onClearAll,
|
||||
});
|
||||
|
||||
/// The caller's current rows; a dismissal removed there redraws the sheet.
|
||||
final ValueListenable<List<AttentionEntry>> entries;
|
||||
|
||||
/// The identities captured when the sheet opened, all Clear all may remove.
|
||||
final List<AttentionEntry> snapshot;
|
||||
|
||||
final ValueChanged<AttentionEntry> onOpen;
|
||||
final ValueChanged<AttentionEntry> onDismiss;
|
||||
final ValueChanged<List<AttentionEntry>> onClearAll;
|
||||
|
||||
void _close(BuildContext context) => Navigator.of(context).pop();
|
||||
|
||||
void _open(BuildContext context, AttentionEntry entry) {
|
||||
_close(context);
|
||||
onOpen(entry);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ValueListenableBuilder<List<AttentionEntry>>(
|
||||
valueListenable: entries,
|
||||
builder: (context, rows, _) => _sheet(context, rows),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sheet(BuildContext context, List<AttentionEntry> rows) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final dismissLabels = attentionDismissLabels(rows);
|
||||
return SafeArea(
|
||||
key: attentionSheetKey,
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: CupertinoPopupSurface(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: AppSheetHeader(
|
||||
title: attentionSheetTitle,
|
||||
cupertino: true,
|
||||
doneKey: attentionDoneKey,
|
||||
onDone: () => _close(context),
|
||||
),
|
||||
),
|
||||
if (rows.isEmpty)
|
||||
Padding(
|
||||
key: attentionEmptyKey,
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(20, 8, 20, 24),
|
||||
child: Text(
|
||||
attentionEmptyCopy,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Flexible(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final entry in rows)
|
||||
_AttentionRow(
|
||||
key: attentionRowKey(entry.key),
|
||||
entry: entry,
|
||||
dismissLabel: dismissLabels[entry.key]!,
|
||||
onOpen: () => _open(context, entry),
|
||||
onDismiss: () => onDismiss(entry),
|
||||
),
|
||||
],
|
||||
),
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
CupertinoListTile(
|
||||
key: attentionClearAllKey,
|
||||
title: Center(child: Text(attentionClearAllCopy)),
|
||||
onTap: () => onClearAll(snapshot),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// One native grouped row: an open action over the host's text roles and a
|
||||
/// separate Dismiss control named after the row it removes. It deliberately does
|
||||
/// not use [CupertinoListTile], whose single-line title/subtitle would truncate a
|
||||
/// long scaled label.
|
||||
class _AttentionRow extends StatelessWidget {
|
||||
const _AttentionRow({
|
||||
super.key,
|
||||
required this.entry,
|
||||
required this.dismissLabel,
|
||||
required this.onOpen,
|
||||
required this.onDismiss,
|
||||
});
|
||||
|
||||
final AttentionEntry entry;
|
||||
final String dismissLabel;
|
||||
final VoidCallback onOpen;
|
||||
final VoidCallback onDismiss;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final secondary = theme.textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 10, 8, 10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: attentionStatusIcon(entry),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
onPressed: onOpen,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(entry.label, style: theme.textTheme.textStyle),
|
||||
const SizedBox(height: 4),
|
||||
Text(attentionRowDescription(entry), style: secondary),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
CupertinoButton(
|
||||
key: attentionDismissKey(entry.key),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onDismiss,
|
||||
child: Icon(CupertinoIcons.xmark, semanticLabel: dismissLabel),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../notify/notification_models.dart';
|
||||
|
||||
/// The permission tile's root, so a caller can find it whichever host draws it.
|
||||
/// The permission tile's root, so a caller can find it.
|
||||
const notificationTileKey = ValueKey<String>('notification-permission-tile');
|
||||
|
||||
/// The explicit-gesture Enable action, present only when a request is possible.
|
||||
@@ -44,28 +42,20 @@ class NotificationPermissionTile extends StatelessWidget {
|
||||
/// request would be possible.
|
||||
final VoidCallback? onRequest;
|
||||
|
||||
/// Forces the native host in tests and fixtures; otherwise the ambient
|
||||
/// [usesCupertinoHost] decides.
|
||||
/// Retained for callers that still pass it; the tile is the Material row
|
||||
/// whether this is set or not.
|
||||
final bool? cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final view = notificationPermissionView(state, asked: asked);
|
||||
final native = cupertino ?? usesCupertinoHost(context);
|
||||
final action = view.canRequest && onRequest != null
|
||||
? _action(native, view.actionLabel!, onRequest!)
|
||||
? _action(view.actionLabel!, onRequest!)
|
||||
: null;
|
||||
final titleStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyLarge;
|
||||
final helperStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
final titleStyle = Theme.of(context).textTheme.bodyLarge;
|
||||
final helperStyle = Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
// One compact row: the state, one short helper line and Enable at the
|
||||
// end. The full sentence for the state is what a screen reader hears.
|
||||
// The Settings section supplies the `Notifications` heading.
|
||||
@@ -97,20 +87,13 @@ class NotificationPermissionTile extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// A short `Enable`, named in full for assistive technology.
|
||||
Widget _action(bool native, String label, VoidCallback onRequest) {
|
||||
Widget _action(String label, VoidCallback onRequest) {
|
||||
const text = Text(notificationEnableShortLabel);
|
||||
final Widget button = native
|
||||
? CupertinoButton.tinted(
|
||||
key: notificationEnableKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
);
|
||||
final Widget button = FilledButton.tonal(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
|
||||
@@ -338,9 +338,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
context,
|
||||
chatSessionColor(_rowFor(pane.sessionId)),
|
||||
) ??
|
||||
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary)
|
||||
Theme.of(context).colorScheme.primary
|
||||
: Colors.transparent;
|
||||
return Semantics(
|
||||
selected: active,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/directory_listing.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
|
||||
/// Confirms deleting [entry]. A folder is described as deleted only when
|
||||
/// empty; the server refuses a folder with contents and the panel then asks
|
||||
@@ -38,41 +36,22 @@ Future<bool> _confirm(
|
||||
required String body,
|
||||
required String action,
|
||||
}) async {
|
||||
final confirmed = chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(action),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(action),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(body),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(action),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return confirmed == true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@@ -115,25 +113,17 @@ class _FileDownloadButtonState extends State<FileDownloadButton> {
|
||||
Widget build(BuildContext context) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (usesCupertinoHost(context))
|
||||
CupertinoButton.filled(
|
||||
onPressed: _busy ? null : _download,
|
||||
child: _busy
|
||||
? const CupertinoActivityIndicator()
|
||||
: const Text('Download'),
|
||||
)
|
||||
else
|
||||
FilledButton.icon(
|
||||
onPressed: _busy ? null : _download,
|
||||
icon: _busy
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Icon(Icons.download_outlined),
|
||||
label: const Text('Download'),
|
||||
),
|
||||
FilledButton.icon(
|
||||
onPressed: _busy ? null : _download,
|
||||
icon: _busy
|
||||
? const SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: CircularProgressIndicator(strokeWidth: 2),
|
||||
)
|
||||
: const Icon(Icons.download_outlined),
|
||||
label: const Text('Download'),
|
||||
),
|
||||
if (_status != null)
|
||||
Padding(padding: const EdgeInsets.only(top: 8), child: Text(_status!)),
|
||||
],
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/layout/app_overflow_menu.dart';
|
||||
import '../data/directory_listing.dart';
|
||||
import '../domain/chat_attachment_picker.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'files_controller.dart';
|
||||
import 'files_models.dart';
|
||||
|
||||
@@ -103,42 +101,27 @@ class FilesHeader extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
for (final crumb in folderCrumbs(listing.home, listing.path))
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
onPressed: controller.loading
|
||||
? null
|
||||
: () => controller.open(crumb.path),
|
||||
child: Text(crumb.label),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: controller.loading
|
||||
? null
|
||||
: () => controller.open(crumb.path),
|
||||
child: Text(crumb.label),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: controller.loading
|
||||
? null
|
||||
: () => controller.open(crumb.path),
|
||||
child: Text(crumb.label),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child:
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoSearchTextField(
|
||||
controller: filter,
|
||||
onChanged: controller.setFilter,
|
||||
placeholder: 'Filter files',
|
||||
)
|
||||
: TextField(
|
||||
controller: filter,
|
||||
onChanged: controller.setFilter,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.search),
|
||||
hintText: 'Filter files',
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
controller: filter,
|
||||
onChanged: controller.setFilter,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.search),
|
||||
hintText: 'Filter files',
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Show hidden files',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../core/transport/pipelines_client.dart';
|
||||
import '../data/directory_listing.dart';
|
||||
import '../domain/chat_attachment_picker.dart';
|
||||
@@ -100,73 +98,60 @@ class _FilesPanelState extends State<FilesPanel> {
|
||||
if (controller.missingDirectory) {
|
||||
return const _FilesMessage('This chat has no working directory.');
|
||||
}
|
||||
return Theme(
|
||||
data: usesCupertinoHost(context)
|
||||
? ThemeData(
|
||||
brightness: CupertinoTheme.brightnessOf(context),
|
||||
colorSchemeSeed: CupertinoTheme.of(context).primaryColor,
|
||||
)
|
||||
: Theme.of(context),
|
||||
child: Builder(
|
||||
builder: (context) => Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: FilesDropArea(
|
||||
drop: _drop,
|
||||
folderLabel: listing == null
|
||||
? null
|
||||
: homeRelativeLabel(listing.home, listing.path),
|
||||
onFiles: controller.upload,
|
||||
onError: (error) => controller.reportUploadError(
|
||||
'A dropped item could not be read: $error',
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: FilesDropArea(
|
||||
drop: _drop,
|
||||
folderLabel: listing == null
|
||||
? null
|
||||
: homeRelativeLabel(listing.home, listing.path),
|
||||
onFiles: controller.upload,
|
||||
onError: (error) => controller.reportUploadError(
|
||||
'A dropped item could not be read: $error',
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
FilesHeader(
|
||||
controller: controller,
|
||||
filter: _filter,
|
||||
picker: _picker,
|
||||
onUpload: _pickAndUpload,
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
FilesHeader(
|
||||
controller: controller,
|
||||
filter: _filter,
|
||||
picker: _picker,
|
||||
onUpload: _pickAndUpload,
|
||||
if (controller.error != null)
|
||||
ChatErrorNotice(
|
||||
message: controller.error!,
|
||||
onRetry: controller.retry,
|
||||
),
|
||||
FilesUploadNotice(controller: controller),
|
||||
if (controller.loading && listing == null)
|
||||
const Expanded(child: ChatLoadingIndicator())
|
||||
else if (listing != null && entries.isEmpty && !controller.loading)
|
||||
Expanded(
|
||||
child: _FilesMessage(
|
||||
controller.filter.isEmpty
|
||||
? 'This folder is empty.'
|
||||
: 'No files match your filter.',
|
||||
),
|
||||
if (controller.error != null)
|
||||
ChatErrorNotice(
|
||||
message: controller.error!,
|
||||
onRetry: controller.retry,
|
||||
),
|
||||
FilesUploadNotice(controller: controller),
|
||||
if (controller.loading && listing == null)
|
||||
const Expanded(child: ChatLoadingIndicator())
|
||||
else if (listing != null &&
|
||||
entries.isEmpty &&
|
||||
!controller.loading)
|
||||
Expanded(
|
||||
child: _FilesMessage(
|
||||
controller.filter.isEmpty
|
||||
? 'This folder is empty.'
|
||||
: 'No files match your filter.',
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: FilesEntries(
|
||||
entries: entries,
|
||||
view: controller.view,
|
||||
endpoint: _endpoint,
|
||||
onTap: (entry) => entry.isDir
|
||||
? controller.open(entry.path)
|
||||
: _open(entry),
|
||||
menu: _menu,
|
||||
onDrop: (dragged, folder) =>
|
||||
controller.move(dragged, folder.path),
|
||||
),
|
||||
),
|
||||
if (listing?.truncated == true)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Text('Some entries are not shown.'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: FilesEntries(
|
||||
entries: entries,
|
||||
view: controller.view,
|
||||
endpoint: _endpoint,
|
||||
onTap: (entry) =>
|
||||
entry.isDir ? controller.open(entry.path) : _open(entry),
|
||||
menu: _menu,
|
||||
onDrop: (dragged, folder) =>
|
||||
controller.move(dragged, folder.path),
|
||||
),
|
||||
),
|
||||
if (listing?.truncated == true)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Text('Some entries are not shown.'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../data/directory_listing.dart';
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'files_mutations.dart';
|
||||
|
||||
/// Asks for [entry]'s new name, prefilled and selected. Resolves to the
|
||||
@@ -14,9 +12,7 @@ Future<String?> showRenameEntryDialog(
|
||||
DirectoryEntry entry,
|
||||
) {
|
||||
final dialog = _RenameEntryDialog(entry: entry);
|
||||
return chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? showCupertinoDialog<String>(context: context, builder: (_) => dialog)
|
||||
: showDialog<String>(context: context, builder: (_) => dialog);
|
||||
return showDialog<String>(context: context, builder: (_) => dialog);
|
||||
}
|
||||
|
||||
class _RenameEntryDialog extends StatefulWidget {
|
||||
@@ -62,44 +58,6 @@ class _RenameEntryDialogState extends State<_RenameEntryDialog> {
|
||||
builder: (context, value, _) {
|
||||
final error = renameNameError(value.text);
|
||||
final canSave = error == null && value.text.trim() != widget.entry.name;
|
||||
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(title),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
CupertinoTextField(
|
||||
key: const Key('files-rename-field'),
|
||||
controller: _name,
|
||||
autofocus: true,
|
||||
placeholder: 'Name',
|
||||
onSubmitted: (_) => _save(),
|
||||
),
|
||||
if (error != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
error,
|
||||
style: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: canSave ? _save : null,
|
||||
child: const Text('Save'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(title),
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'files_controller.dart';
|
||||
|
||||
/// The Files panel's operation feedback: a progress strip while files are
|
||||
@@ -15,8 +13,6 @@ class FilesUploadNotice extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final progress = controller.uploading > 0
|
||||
? controller.uploadLabel
|
||||
: controller.mutationLabel;
|
||||
@@ -29,11 +25,7 @@ class FilesUploadNotice extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const LinearProgressIndicator(),
|
||||
),
|
||||
const Expanded(child: LinearProgressIndicator()),
|
||||
const SizedBox(width: 12),
|
||||
Text(progress),
|
||||
],
|
||||
@@ -42,13 +34,11 @@ class FilesUploadNotice extends StatelessWidget {
|
||||
),
|
||||
if (controller.uploadError != null)
|
||||
_Refusal(
|
||||
cupertino: cupertino,
|
||||
message: controller.uploadError!,
|
||||
onDismiss: controller.dismissUploadError,
|
||||
),
|
||||
if (controller.mutationError != null)
|
||||
_Refusal(
|
||||
cupertino: cupertino,
|
||||
message: controller.mutationError!,
|
||||
onDismiss: controller.dismissMutationError,
|
||||
),
|
||||
@@ -58,27 +48,13 @@ class FilesUploadNotice extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _Refusal extends StatelessWidget {
|
||||
const _Refusal({
|
||||
required this.cupertino,
|
||||
required this.message,
|
||||
required this.onDismiss,
|
||||
});
|
||||
final bool cupertino;
|
||||
const _Refusal({required this.message, required this.onDismiss});
|
||||
final String message;
|
||||
final VoidCallback onDismiss;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => cupertino
|
||||
? ChatCupertinoMessage(
|
||||
message: message,
|
||||
icon: CupertinoIcons.exclamationmark_circle,
|
||||
actionLabel: 'Dismiss',
|
||||
onAction: onDismiss,
|
||||
)
|
||||
: MaterialBanner(
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(onPressed: onDismiss, child: const Text('Dismiss')),
|
||||
],
|
||||
);
|
||||
Widget build(BuildContext context) => MaterialBanner(
|
||||
content: Text(message),
|
||||
actions: [TextButton(onPressed: onDismiss, child: const Text('Dismiss'))],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../artifacts/actions/artifact_file_bridge.dart';
|
||||
import '../../artifacts/actions/artifact_transfer.dart';
|
||||
import '../../artifacts/domain/artifact_groups.dart';
|
||||
@@ -100,11 +98,9 @@ class FilesViewer {
|
||||
fileBridge: bridge,
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
Navigator.of(context).push<void>(
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
Navigator.of(
|
||||
context,
|
||||
).push<void>(MaterialPageRoute<void>(builder: (_) => page));
|
||||
}
|
||||
|
||||
/// Downloads [entry] straight from a row or tile menu and reports the
|
||||
@@ -127,7 +123,7 @@ class FilesViewer {
|
||||
messenger.showSnackBar(SnackBar(content: Text(result.message)));
|
||||
return;
|
||||
}
|
||||
// A Cupertino host has no snack bar; a failure still has to be said.
|
||||
// Without a scaffold messenger a failure still has to be said.
|
||||
if (result.state != ArtifactTransferState.failed || !context.mounted) {
|
||||
return;
|
||||
}
|
||||
@@ -137,16 +133,10 @@ class FilesViewer {
|
||||
title: Text(entry.name),
|
||||
content: Text(result.message),
|
||||
actions: [
|
||||
if (usesCupertinoHost(dialog))
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(dialog),
|
||||
child: const Text('OK'),
|
||||
)
|
||||
else
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialog),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialog),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Covers a chat beside the stage too narrow to use: its colour and title,
|
||||
/// running down the column. A press brings that chat to center stage. The
|
||||
/// retained chat underneath keeps its state.
|
||||
@@ -22,20 +19,13 @@ class ChatCenterStageStrip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final accent =
|
||||
color ??
|
||||
(cupertino ? CupertinoTheme.of(context).primaryColor : scheme.primary);
|
||||
final accent = color ?? scheme.primary;
|
||||
final background = Color.alphaBlend(
|
||||
accent.withValues(alpha: .12),
|
||||
cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: scheme.surfaceContainer,
|
||||
scheme.surfaceContainer,
|
||||
);
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
final style = Theme.of(context).textTheme.titleSmall;
|
||||
final label = Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
@@ -62,25 +52,17 @@ class ChatCenterStageStrip extends StatelessWidget {
|
||||
label: 'Show $title on center stage',
|
||||
excludeSemantics: true,
|
||||
onTap: onSelected,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
color: background,
|
||||
borderRadius: BorderRadius.zero,
|
||||
onPressed: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
)
|
||||
: Tooltip(
|
||||
message: title,
|
||||
excludeFromSemantics: true,
|
||||
child: Material(
|
||||
color: background,
|
||||
child: InkWell(
|
||||
onTap: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: title,
|
||||
excludeFromSemantics: true,
|
||||
child: Material(
|
||||
color: background,
|
||||
child: InkWell(
|
||||
onTap: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'chat_workspace_pane_scope.dart';
|
||||
|
||||
/// "Move up/down/left/right" for a tiled pane's actions (More) menu. A move
|
||||
/// swaps the pane with the one across that edge. A direction with no pane is
|
||||
/// disabled in the Material menu (and left out of a Cupertino action sheet).
|
||||
/// Nothing is offered when the panes are not tiled (one pane, or a phone).
|
||||
/// disabled in the menu. Nothing is offered when the panes are not tiled (one
|
||||
/// pane, or a phone).
|
||||
List<Widget> chatPaneMoveActions(
|
||||
ChatWorkspacePaneScope? scope, {
|
||||
required void Function(String targetPaneId) onMove,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// A named, explicit switch action above the inactive transcript. It occupies
|
||||
/// space rather than obscuring the small chat's readable content.
|
||||
@@ -17,20 +15,11 @@ class ChatPeekHeader extends StatelessWidget {
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact = constraints.maxHeight < 44;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final textStyle = cupertino
|
||||
? (compact
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
||||
: CupertinoTheme.of(context).textTheme.textStyle)
|
||||
: (compact
|
||||
? Theme.of(context).textTheme.labelMedium
|
||||
: Theme.of(context).textTheme.labelLarge);
|
||||
final foreground = cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
final background = cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainer;
|
||||
final textStyle = compact
|
||||
? Theme.of(context).textTheme.labelMedium
|
||||
: Theme.of(context).textTheme.labelLarge;
|
||||
final foreground = Theme.of(context).colorScheme.onSurface;
|
||||
final background = Theme.of(context).colorScheme.surfaceContainer;
|
||||
final content = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -44,34 +33,23 @@ class ChatPeekHeader extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Text('Switch', style: textStyle?.copyWith(color: foreground)),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.arrow_up : Icons.arrow_upward,
|
||||
color: foreground,
|
||||
size: 18,
|
||||
),
|
||||
Icon(Icons.arrow_upward, color: foreground, size: 18),
|
||||
],
|
||||
);
|
||||
return ColoredBox(
|
||||
color: background,
|
||||
child: Tooltip(
|
||||
message: 'Switch to $title',
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
minimumSize: const Size(0, 44),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
)
|
||||
: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 44),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
),
|
||||
child: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 44),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/motion/quick_switch_effect.dart';
|
||||
import 'chat_pane_switch_motion.dart';
|
||||
|
||||
@@ -24,12 +22,8 @@ class ChatSwitchCard extends StatelessWidget {
|
||||
motion.isAnimating ? motion.progress : 1,
|
||||
outgoing: outgoing,
|
||||
);
|
||||
final shadow = usesCupertinoHost(context)
|
||||
? CupertinoColors.black
|
||||
: Theme.of(context).shadowColor;
|
||||
final surface = usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface;
|
||||
final shadow = Theme.of(context).shadowColor;
|
||||
final surface = Theme.of(context).colorScheme.surface;
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) => Opacity(
|
||||
opacity: pose.opacity,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'chat_workspace_controller.dart';
|
||||
import '../../../ui/adaptive/resize_grip.dart';
|
||||
import 'chat_workspace_geometry.dart';
|
||||
@@ -50,9 +48,7 @@ class _ChatWorkspaceDividerState extends State<ChatWorkspaceDivider> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final verticalLine = _horizontal;
|
||||
final color = usesCupertinoHost(context)
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).dividerColor;
|
||||
final color = Theme.of(context).dividerColor;
|
||||
return Semantics(
|
||||
identifier: 'chat-divider-${widget.geometry.split.id}',
|
||||
label: 'Resize chat panes ${_horizontal ? 'horizontally' : 'vertically'}',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../ui/motion/motion.dart';
|
||||
import '../../../ui/motion/surface_visibility.dart';
|
||||
@@ -78,23 +78,16 @@ class _ChatWorkspaceEntranceState extends State<ChatWorkspaceEntrance>
|
||||
),
|
||||
),
|
||||
);
|
||||
final transition = widget.cupertino
|
||||
? CupertinoPageTransition(
|
||||
primaryRouteAnimation: _controller,
|
||||
secondaryRouteAnimation: const AlwaysStoppedAnimation(0),
|
||||
linearTransition: false,
|
||||
child: content,
|
||||
)
|
||||
: FadeTransition(
|
||||
opacity: _curve,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.08),
|
||||
end: Offset.zero,
|
||||
).animate(_curve),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
final transition = FadeTransition(
|
||||
opacity: _curve,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.08),
|
||||
end: Offset.zero,
|
||||
).animate(_curve),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
child: transition,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'chat_center_stage_motion.dart';
|
||||
import 'chat_center_stage_strip.dart';
|
||||
import 'chat_mobile_panes.dart';
|
||||
@@ -130,11 +128,7 @@ Widget chatWorkspaceSurface({
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
if (mobile != null)
|
||||
ColoredBox(
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
ColoredBox(color: Theme.of(context).colorScheme.surface),
|
||||
picture,
|
||||
for (final pane in livePanes)
|
||||
if (motion.isTape ||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import 'graph_viewport.dart';
|
||||
import 'graph_viewport_controller.dart';
|
||||
@@ -100,23 +98,6 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
|
||||
Expanded(child: viewport),
|
||||
],
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
automaticallyImplyLeading: false,
|
||||
leading: SegmentedBackButton(cupertino: true, onPressed: _close),
|
||||
title: widget.title,
|
||||
actions: [
|
||||
_GraphFitButton(
|
||||
cupertino: true,
|
||||
onPressed: _controller.fitToViewport,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: BelowTopBar(child: body),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
@@ -124,12 +105,7 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
|
||||
title: widget.title,
|
||||
automaticallyImplyLeading: false,
|
||||
leading: SegmentedBackButton(cupertino: false, onPressed: _close),
|
||||
actions: [
|
||||
_GraphFitButton(
|
||||
cupertino: false,
|
||||
onPressed: _controller.fitToViewport,
|
||||
),
|
||||
],
|
||||
actions: [_GraphFitButton(onPressed: _controller.fitToViewport)],
|
||||
),
|
||||
body: BelowTopBar(child: body),
|
||||
);
|
||||
@@ -137,9 +113,8 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
|
||||
}
|
||||
|
||||
class _GraphFitButton extends StatelessWidget {
|
||||
const _GraphFitButton({required this.cupertino, required this.onPressed});
|
||||
const _GraphFitButton({required this.onPressed});
|
||||
|
||||
final bool cupertino;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
@override
|
||||
@@ -147,22 +122,15 @@ class _GraphFitButton extends StatelessWidget {
|
||||
child: Semantics(
|
||||
button: true,
|
||||
label: graphFitLabel,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
key: const Key('graph-fit'),
|
||||
padding: const EdgeInsets.all(8),
|
||||
onPressed: onPressed,
|
||||
child: const ExcludeSemantics(child: Icon(CupertinoIcons.resize)),
|
||||
)
|
||||
: Tooltip(
|
||||
message: graphFitLabel,
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: const Key('graph-fit'),
|
||||
onPressed: onPressed,
|
||||
icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)),
|
||||
),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: graphFitLabel,
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: const Key('graph-fit'),
|
||||
onPressed: onPressed,
|
||||
icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -190,8 +158,9 @@ Future<void> openGraphExpanded(
|
||||
selectedStage: selectedStage,
|
||||
header: header,
|
||||
);
|
||||
final route = usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(fullscreenDialog: true, builder: (_) => page)
|
||||
: MaterialPageRoute<void>(fullscreenDialog: true, builder: (_) => page);
|
||||
final route = MaterialPageRoute<void>(
|
||||
fullscreenDialog: true,
|
||||
builder: (_) => page,
|
||||
);
|
||||
return Navigator.of(context).push(route);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/glass_pill.dart';
|
||||
import 'graph_viewport_controller.dart';
|
||||
|
||||
@@ -121,20 +119,20 @@ class _GraphViewportState extends State<GraphViewport> {
|
||||
top: 8,
|
||||
end: 8,
|
||||
child: GlassPill(
|
||||
cupertino: usesCupertinoHost(context),
|
||||
cupertino: false,
|
||||
child: Wrap(
|
||||
spacing: 2,
|
||||
children: [
|
||||
_ViewportButton(
|
||||
buttonKey: const Key('graph-fit'),
|
||||
icon: _fitIcon(context),
|
||||
icon: Icons.fit_screen,
|
||||
label: graphFitLabel,
|
||||
onPressed: widget.controller.fitToViewport,
|
||||
),
|
||||
if (widget.onExpand != null)
|
||||
_ViewportButton(
|
||||
buttonKey: const Key('graph-expand'),
|
||||
icon: _expandIcon(context),
|
||||
icon: Icons.fullscreen,
|
||||
label: graphExpandLabel,
|
||||
onPressed: widget.onExpand,
|
||||
),
|
||||
@@ -147,12 +145,6 @@ class _GraphViewportState extends State<GraphViewport> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
IconData _fitIcon(BuildContext context) =>
|
||||
usesCupertinoHost(context) ? CupertinoIcons.resize : Icons.fit_screen;
|
||||
|
||||
IconData _expandIcon(BuildContext context) =>
|
||||
usesCupertinoHost(context) ? CupertinoIcons.fullscreen : Icons.fullscreen;
|
||||
}
|
||||
|
||||
/// One native graph control inside the shared floating glass pill.
|
||||
@@ -160,7 +152,7 @@ class _GraphViewportState extends State<GraphViewport> {
|
||||
/// The label and the button's own tap action must reach the same semantics
|
||||
/// node: the icon is the only excluded child, and [MergeSemantics] folds the
|
||||
/// host button's action into the labelled node, so a screen reader can activate
|
||||
/// Fit and Expand on either host. A hand-written `Semantics` sibling around an
|
||||
/// Fit and Expand. A hand-written `Semantics` sibling around an
|
||||
/// excluded button would announce the control with no action at all.
|
||||
class _ViewportButton extends StatelessWidget {
|
||||
const _ViewportButton({
|
||||
@@ -181,24 +173,17 @@ class _ViewportButton extends StatelessWidget {
|
||||
child: Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
child: usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
key: buttonKey,
|
||||
padding: const EdgeInsets.all(8),
|
||||
onPressed: onPressed,
|
||||
child: ExcludeSemantics(child: Icon(icon)),
|
||||
)
|
||||
: Tooltip(
|
||||
message: label,
|
||||
// The merged node already carries the label; the tooltip is
|
||||
// only the pointer affordance.
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: buttonKey,
|
||||
onPressed: onPressed,
|
||||
icon: ExcludeSemantics(child: Icon(icon)),
|
||||
),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: label,
|
||||
// The merged node already carries the label; the tooltip is
|
||||
// only the pointer affordance.
|
||||
excludeFromSemantics: true,
|
||||
child: IconButton(
|
||||
key: buttonKey,
|
||||
onPressed: onPressed,
|
||||
icon: ExcludeSemantics(child: Icon(icon)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../layout/layout_models.dart';
|
||||
import '../routing/route_models.dart';
|
||||
|
||||
@@ -32,9 +30,9 @@ RoutingConfig graphCanvasRoutingConfig() => RoutingConfig(
|
||||
/// The native theme roles one definition graph canvas needs.
|
||||
///
|
||||
/// No palette, font family or size is defined here: every value comes from the
|
||||
/// ambient Material or Cupertino theme, so light/dark and text scaling follow
|
||||
/// the host exactly. Edge labels and diagnostics are metadata, so they use the
|
||||
/// host's secondary-label role rather than the node's own label style.
|
||||
/// ambient Material theme, so light/dark and text scaling follow the host
|
||||
/// exactly. Edge labels and diagnostics are metadata, so they use the host's
|
||||
/// secondary-label role rather than the node's own label style.
|
||||
class GraphCanvasStyle {
|
||||
const GraphCanvasStyle({
|
||||
required this.labelStyle,
|
||||
@@ -44,20 +42,6 @@ class GraphCanvasStyle {
|
||||
});
|
||||
|
||||
factory GraphCanvasStyle.of(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
return GraphCanvasStyle(
|
||||
labelStyle: theme.textTheme.tabLabelTextStyle.copyWith(
|
||||
color: secondary,
|
||||
),
|
||||
messageStyle: theme.textTheme.textStyle.copyWith(color: secondary),
|
||||
edgeColor: CupertinoColors.separator.resolveFrom(context),
|
||||
// Cupertino has no divider-thickness token; its separators are one
|
||||
// logical pixel hairlines, so the stroke keeps that native default.
|
||||
edgeWidth: 1,
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
final secondary = theme.colorScheme.onSurfaceVariant;
|
||||
return GraphCanvasStyle(
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../domain/graph_definition.dart';
|
||||
|
||||
@@ -37,7 +35,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
/// Reports [node.key] exactly as the definition recorded it.
|
||||
final ValueChanged<String> onSelected;
|
||||
|
||||
/// Content inset shared by both hosts. It is spacing, not a size: the control
|
||||
/// Content inset for a graph node. It is spacing, not a size: the control
|
||||
/// still takes its size from its label, and the inset keeps wrapped glyphs
|
||||
/// clear of a rounded surface's corners.
|
||||
static const EdgeInsets _contentPadding = EdgeInsets.all(16);
|
||||
@@ -61,9 +59,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
button: true,
|
||||
selected: selected,
|
||||
label: _label,
|
||||
child: usesCupertinoHost(context)
|
||||
? _cupertinoButton(onPressed, content)
|
||||
: _materialCard(onPressed, content),
|
||||
child: _materialCard(onPressed, content),
|
||||
),
|
||||
);
|
||||
return active ? StageActivityHalo(child: control) : control;
|
||||
@@ -106,12 +102,6 @@ class GraphStageNode extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Tinted is Cupertino's stock low-emphasis surface, so an unselected node is
|
||||
/// still a visible node body; filled raises the selected one.
|
||||
Widget _cupertinoButton(VoidCallback onPressed, Widget content) => selected
|
||||
? CupertinoButton.filled(onPressed: onPressed, child: content)
|
||||
: CupertinoButton.tinted(onPressed: onPressed, child: content);
|
||||
|
||||
Widget _content(BuildContext context) {
|
||||
final status = _status;
|
||||
// The recorded status reads apart from the name: a coloured dot and
|
||||
@@ -215,10 +205,7 @@ class _StageActivityHaloState extends State<StageActivityHalo>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final color = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final color = Theme.of(context).colorScheme.primary;
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) => CustomPaint(
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart' show listEquals;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/graph_definition.dart';
|
||||
import '../domain/run_graph_state.dart';
|
||||
import '../layout/layout_models.dart';
|
||||
@@ -200,10 +198,7 @@ class RunGraphCanvas extends StatelessWidget {
|
||||
final executedIds = {for (final route in executed) route.id};
|
||||
final size = Size(routing.width, routing.height);
|
||||
final activeStage = state.activeStage;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final executedColor = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final executedColor = Theme.of(context).colorScheme.primary;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/run_graph_state.dart';
|
||||
import 'graph_canvas_style.dart';
|
||||
|
||||
@@ -31,10 +29,7 @@ class RunGraphHeader extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final executedColor = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final executedColor = Theme.of(context).colorScheme.primary;
|
||||
final mutedColor = style.edgeColor;
|
||||
final active = state.activeStage;
|
||||
return Padding(
|
||||
@@ -53,14 +48,12 @@ class RunGraphHeader extends StatelessWidget {
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
_LegendEntry(
|
||||
icon: cupertino
|
||||
? CupertinoIcons.arrow_right
|
||||
: Icons.arrow_forward,
|
||||
icon: Icons.arrow_forward,
|
||||
label: runGraphExecuted,
|
||||
color: executedColor,
|
||||
),
|
||||
_LegendEntry(
|
||||
icon: cupertino ? CupertinoIcons.minus : Icons.remove,
|
||||
icon: Icons.remove,
|
||||
label: runGraphNotExecuted,
|
||||
color: mutedColor,
|
||||
),
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/text/markdown_source_view.dart';
|
||||
import '../../chat/ui/transcript/chat_markdown_view.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/graph_protocol.dart';
|
||||
import '../domain/stage_definition.dart';
|
||||
|
||||
@@ -159,30 +157,14 @@ Future<void> openStageDefinition(
|
||||
// A terminal is a definition target, not its protocol key: the web pane
|
||||
// titles it with `nodeDisplayLabel` (`Failure`/`Success`).
|
||||
final title = '${nodeDisplayLabel(stageKey)} definition';
|
||||
final route = usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(
|
||||
cupertino: true,
|
||||
title: title,
|
||||
subtitle: identity,
|
||||
),
|
||||
child: SafeArea(top: false, bottom: false, child: view),
|
||||
),
|
||||
)
|
||||
: MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: title,
|
||||
subtitle: identity,
|
||||
),
|
||||
body: SafeArea(top: false, bottom: false, child: view),
|
||||
),
|
||||
);
|
||||
final route = MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(cupertino: false, title: title, subtitle: identity),
|
||||
body: SafeArea(top: false, bottom: false, child: view),
|
||||
),
|
||||
);
|
||||
return Navigator.of(context).push(route);
|
||||
}
|
||||
|
||||
@@ -263,22 +245,6 @@ class _StageDefinitionStyle {
|
||||
});
|
||||
|
||||
factory _StageDefinitionStyle.of(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
return _StageDefinitionStyle(
|
||||
label: theme.textTheme.tabLabelTextStyle.copyWith(color: secondary),
|
||||
// SelectableText needs a style it can merge into the default text
|
||||
// style; Cupertino's textStyle is a complete style with `inherit: false`
|
||||
// and no baseline.
|
||||
value: theme.textTheme.textStyle.copyWith(inherit: true),
|
||||
muted: theme.textTheme.textStyle.copyWith(
|
||||
inherit: true,
|
||||
color: secondary,
|
||||
),
|
||||
heading: theme.textTheme.navTitleTextStyle,
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return _StageDefinitionStyle(
|
||||
label: (theme.textTheme.labelMedium ?? const TextStyle()).copyWith(
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_models.dart';
|
||||
import 'health_widgets.dart';
|
||||
|
||||
@@ -46,12 +44,7 @@ class HealthHeader extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Semantics(
|
||||
label: 'Auto-refresh',
|
||||
child: usesCupertinoControls(context)
|
||||
? CupertinoSwitch(
|
||||
value: autoRefresh,
|
||||
onChanged: onAutoRefresh,
|
||||
)
|
||||
: Switch(value: autoRefresh, onChanged: onAutoRefresh),
|
||||
child: Switch(value: autoRefresh, onChanged: onAutoRefresh),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_page_body.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_controller.dart';
|
||||
import 'health_models.dart';
|
||||
import 'health_sections.dart';
|
||||
@@ -142,16 +140,9 @@ class _HealthScreenState extends State<HealthScreen>
|
||||
],
|
||||
],
|
||||
);
|
||||
return usesCupertinoControls(context)
|
||||
? CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
middle: Text('Server health'),
|
||||
),
|
||||
child: SafeArea(child: content),
|
||||
)
|
||||
: Scaffold(
|
||||
appBar: AppBar(title: const Text('Server health')),
|
||||
body: content,
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Server health')),
|
||||
body: content,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_models.dart';
|
||||
@@ -20,22 +19,7 @@ class HealthCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!usesCupertinoControls(context)) return Card(child: content);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
|
||||
context,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: DefaultTextStyle(
|
||||
style: settingsTextStyle(context),
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
);
|
||||
return Card(child: content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,23 +31,13 @@ class HealthMeter extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final percent = value == null ? null : value! * 100;
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final normal = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: scheme.primary;
|
||||
final high = cupertino
|
||||
? CupertinoColors.systemOrange.resolveFrom(context)
|
||||
: scheme.tertiary;
|
||||
final critical = cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: scheme.error;
|
||||
final color = percent == null
|
||||
? scheme.outline
|
||||
: percent >= healthMeterCritical
|
||||
? critical
|
||||
? scheme.error
|
||||
: percent >= healthMeterHigh
|
||||
? high
|
||||
: normal;
|
||||
? scheme.tertiary
|
||||
: scheme.primary;
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -111,7 +85,6 @@ class HealthAction extends StatelessWidget {
|
||||
final String label;
|
||||
final VoidCallback? onPressed;
|
||||
@override
|
||||
Widget build(BuildContext context) => usesCupertinoControls(context)
|
||||
? CupertinoButton(onPressed: onPressed, child: Text(label))
|
||||
: TextButton(onPressed: onPressed, child: Text(label));
|
||||
Widget build(BuildContext context) =>
|
||||
TextButton(onPressed: onPressed, child: Text(label));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_row.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'health_screen.dart';
|
||||
|
||||
class SettingsHealthSection extends StatelessWidget {
|
||||
@@ -10,21 +8,13 @@ class SettingsHealthSection extends StatelessWidget {
|
||||
final ApiGateway gateway;
|
||||
@override
|
||||
Widget build(BuildContext context) => SettingsRow(
|
||||
leading: Icon(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoIcons.heart
|
||||
: Icons.monitor_heart_outlined,
|
||||
),
|
||||
leading: const Icon(Icons.monitor_heart_outlined),
|
||||
title: const Text('Server health'),
|
||||
subtitle: const Text('CPU, memory, GPU, storage and process'),
|
||||
chevron: true,
|
||||
onTap: () {
|
||||
final page = HealthScreen(gateway: gateway);
|
||||
Navigator.of(context).push(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
Navigator.of(context).push(MaterialPageRoute<void>(builder: (_) => page));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/session/server_session.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'session_security_api.dart';
|
||||
|
||||
/// The server's sign-in security: a warning when its password predates the
|
||||
@@ -72,28 +70,6 @@ class _SettingsSecuritySectionState extends State<SettingsSecuritySection> {
|
||||
'Every browser and device signed in to this server, this one '
|
||||
'included, must sign in again. Open connections close now.',
|
||||
);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: title,
|
||||
content: body,
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: const Key('settings-revoke-all-confirm'),
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Sign out everywhere'),
|
||||
),
|
||||
],
|
||||
),
|
||||
) ??
|
||||
false;
|
||||
}
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -148,17 +124,11 @@ class _SettingsSecuritySectionState extends State<SettingsSecuritySection> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final security = _security;
|
||||
final button = usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
key: const Key('settings-revoke-all'),
|
||||
onPressed: _busy ? null : _revokeAll,
|
||||
child: const Text('Sign out everywhere'),
|
||||
)
|
||||
: OutlinedButton(
|
||||
key: const Key('settings-revoke-all'),
|
||||
onPressed: _busy ? null : _revokeAll,
|
||||
child: const Text('Sign out everywhere'),
|
||||
);
|
||||
final button = OutlinedButton(
|
||||
key: const Key('settings-revoke-all'),
|
||||
onPressed: _busy ? null : _revokeAll,
|
||||
child: const Text('Sign out everywhere'),
|
||||
);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_row.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'storage_screen.dart';
|
||||
|
||||
class SettingsStorageSection extends StatelessWidget {
|
||||
@@ -10,21 +8,13 @@ class SettingsStorageSection extends StatelessWidget {
|
||||
final ApiGateway gateway;
|
||||
@override
|
||||
Widget build(BuildContext context) => SettingsRow(
|
||||
leading: Icon(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoIcons.archivebox
|
||||
: Icons.storage_outlined,
|
||||
),
|
||||
leading: const Icon(Icons.storage_outlined),
|
||||
title: const Text('Storage'),
|
||||
subtitle: const Text('Usage, worktrees and retention policy'),
|
||||
chevron: true,
|
||||
onTap: () {
|
||||
final page = StorageScreen(gateway: gateway);
|
||||
Navigator.of(context).push(
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
Navigator.of(context).push(MaterialPageRoute<void>(builder: (_) => page));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../settings_theme.dart';
|
||||
|
||||
class StorageAction extends StatelessWidget {
|
||||
const StorageAction({
|
||||
@@ -13,27 +11,15 @@ class StorageAction extends StatelessWidget {
|
||||
final VoidCallback? onPressed;
|
||||
final bool destructive;
|
||||
@override
|
||||
Widget build(BuildContext context) => usesCupertinoControls(context)
|
||||
? CupertinoButton(
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
label,
|
||||
style: destructive
|
||||
? TextStyle(
|
||||
color: CupertinoColors.destructiveRed.resolveFrom(context),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: onPressed,
|
||||
style: destructive
|
||||
? TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
)
|
||||
: null,
|
||||
child: Text(label),
|
||||
);
|
||||
Widget build(BuildContext context) => TextButton(
|
||||
onPressed: onPressed,
|
||||
style: destructive
|
||||
? TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
)
|
||||
: null,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
|
||||
class StorageSwitch extends StatelessWidget {
|
||||
@@ -52,9 +38,7 @@ class StorageSwitch extends StatelessWidget {
|
||||
Expanded(child: Text(label)),
|
||||
Semantics(
|
||||
label: label,
|
||||
child: usesCupertinoControls(context)
|
||||
? CupertinoSwitch(value: value, onChanged: onChanged)
|
||||
: Switch(value: value, onChanged: onChanged),
|
||||
child: Switch(value: value, onChanged: onChanged),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -77,35 +61,17 @@ class StorageInput extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final keyboard = TextInputType.numberWithOptions(decimal: decimal);
|
||||
return usesCupertinoControls(context)
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(label),
|
||||
const SizedBox(height: 8),
|
||||
Semantics(
|
||||
label: label,
|
||||
child: CupertinoTextField(
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboard,
|
||||
onChanged: onChanged,
|
||||
placeholder: 'No limit',
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: TextField(
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboard,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
hintText: 'No limit',
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
);
|
||||
return TextField(
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboard,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
labelText: label,
|
||||
hintText: 'No limit',
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../settings_page_body.dart';
|
||||
import '../settings_theme.dart';
|
||||
import 'storage_cleanup.dart';
|
||||
import 'storage_controller.dart';
|
||||
import 'storage_controls.dart';
|
||||
@@ -93,45 +91,23 @@ class _StorageScreenState extends State<StorageScreen> {
|
||||
final preview = _controller.preview!;
|
||||
final message =
|
||||
'Permanently remove ${storageInt(preview['candidate_count'])} eligible items and reclaim up to ${storageBytes(storageInt(preview['reclaimable_bytes']))}? This cannot be undone.';
|
||||
final bool? confirmed;
|
||||
if (usesCupertinoControls(context)) {
|
||||
confirmed = await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: const Text('Apply cleanup?'),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Remove items'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Apply cleanup?'),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Remove items'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Apply cleanup?'),
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('Remove items'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (confirmed == true && mounted) await _controller.apply(policy);
|
||||
}
|
||||
|
||||
@@ -145,7 +121,6 @@ class _StorageScreenState extends State<StorageScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoControls(context);
|
||||
final content = SettingsPageBody(
|
||||
children: [
|
||||
if (_controller.busy)
|
||||
@@ -196,16 +171,9 @@ class _StorageScreenState extends State<StorageScreen> {
|
||||
),
|
||||
],
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(
|
||||
middle: Text('Storage'),
|
||||
),
|
||||
child: SafeArea(child: content),
|
||||
)
|
||||
: Scaffold(
|
||||
appBar: AppBar(title: const Text('Storage')),
|
||||
body: content,
|
||||
);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Storage')),
|
||||
body: content,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../settings_group.dart';
|
||||
import 'storage_controls.dart';
|
||||
import 'storage_models.dart';
|
||||
@@ -67,10 +66,7 @@ class StorageUsage extends StatelessWidget {
|
||||
context,
|
||||
MaterialLocalizations,
|
||||
);
|
||||
if (material != null) {
|
||||
return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}';
|
||||
}
|
||||
final local = CupertinoLocalizations.of(context);
|
||||
return '${time.day} ${local.datePickerMonth(time.month)} ${time.year} · ${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}';
|
||||
if (material == null) return null;
|
||||
return '${time.day} ${material.formatMonthYear(time)} · ${material.formatTimeOfDay(TimeOfDay.fromDateTime(time), alwaysUse24HourFormat: true)}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,16 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
final GlobalKey _navigator = GlobalKey();
|
||||
late final LocalKey _rootPage = ValueKey('window-root-${widget.entry.id}');
|
||||
|
||||
/// The page-transition theme handed to the window's navigator, rebuilt only
|
||||
/// when the app's theme itself changes.
|
||||
ThemeData? _themeSource;
|
||||
ThemeData? _pageTheme;
|
||||
|
||||
/// The root page kept across builds: a new page object would rebuild the
|
||||
/// window's content on every move and resize.
|
||||
WindowKind? _pageKind;
|
||||
Page<void>? _page;
|
||||
|
||||
String get _id => widget.entry.id;
|
||||
|
||||
@override
|
||||
@@ -160,6 +170,22 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
widget.manager.raise(_id);
|
||||
}
|
||||
|
||||
ThemeData _pageThemeFor(ThemeData theme) {
|
||||
if (identical(theme, _themeSource)) return _pageTheme!;
|
||||
_themeSource = theme;
|
||||
return _pageTheme = WindowNavigator.themeData(theme);
|
||||
}
|
||||
|
||||
Page<void> _rootPageFor(WindowKind kind) {
|
||||
final page = _page;
|
||||
if (page != null && identical(kind, _pageKind)) return page;
|
||||
_pageKind = kind;
|
||||
return _page = MaterialPage<void>(
|
||||
key: _rootPage,
|
||||
child: _WindowContent(kind: kind),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = widget.manager;
|
||||
@@ -174,6 +200,7 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
frame.bottom,
|
||||
);
|
||||
final title = kind.title(context, entry);
|
||||
final pageTheme = _pageThemeFor(Theme.of(context));
|
||||
final hiding = !widget.visible;
|
||||
final content = Stack(
|
||||
fit: StackFit.expand,
|
||||
@@ -185,17 +212,21 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
explicitChildNodes: true,
|
||||
label: 'Window: $title',
|
||||
identifier: 'window-${entry.kind}',
|
||||
child: WindowFrame(
|
||||
title: title,
|
||||
icon: kind.icon,
|
||||
actions: kind.actions(context, entry),
|
||||
maximized: entry.maximized,
|
||||
onMove: _move,
|
||||
onMoveEnd: _moveEnded,
|
||||
onMinimize: () => manager.setMinimized(_id, true),
|
||||
onToggleMaximized: () =>
|
||||
manager.setMaximized(_id, !entry.maximized),
|
||||
onClose: () => manager.close(_id),
|
||||
// Its own layer: moving the window moves the title bar without
|
||||
// repainting it.
|
||||
child: RepaintBoundary(
|
||||
child: WindowFrame(
|
||||
title: title,
|
||||
icon: kind.icon,
|
||||
actions: kind.actions(context, entry),
|
||||
maximized: entry.maximized,
|
||||
onMove: _move,
|
||||
onMoveEnd: _moveEnded,
|
||||
onMinimize: () => manager.setMinimized(_id, true),
|
||||
onToggleMaximized: () =>
|
||||
manager.setMaximized(_id, !entry.maximized),
|
||||
onClose: () => manager.close(_id),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -210,19 +241,16 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
child: WindowScope(
|
||||
manager: manager,
|
||||
entry: entry,
|
||||
body: body,
|
||||
child: ScaffoldMessenger(
|
||||
child: WindowNavigator.theme(
|
||||
context,
|
||||
child: WindowNavigator(
|
||||
key: _navigator,
|
||||
pages: [
|
||||
MaterialPage<void>(
|
||||
key: _rootPage,
|
||||
child: _WindowContent(kind: kind),
|
||||
),
|
||||
],
|
||||
onDidRemovePage: (_) {},
|
||||
child: WindowBodyScope(
|
||||
body: body,
|
||||
child: ScaffoldMessenger(
|
||||
child: Theme(
|
||||
data: pageTheme,
|
||||
child: WindowNavigator(
|
||||
key: _navigator,
|
||||
pages: [_rootPageFor(kind)],
|
||||
onDidRemovePage: (_) {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -18,23 +18,21 @@ import 'window_scope.dart';
|
||||
class WindowNavigator extends Navigator {
|
||||
const WindowNavigator({super.key, super.pages, super.onDidRemovePage});
|
||||
|
||||
/// [child] with page transitions that keep every `MaterialPageRoute` of a
|
||||
/// window navigator below it inside the window's content area.
|
||||
static Widget theme(BuildContext context, {required Widget child}) {
|
||||
final theme = Theme.of(context);
|
||||
/// [theme] with page transitions that keep every `MaterialPageRoute` of a
|
||||
/// window navigator inside the window's content area. The caller keeps the
|
||||
/// result, so rebuilding a window layer does not hand its contents a new
|
||||
/// theme.
|
||||
static ThemeData themeData(ThemeData theme) {
|
||||
final builders = theme.pageTransitionsTheme.builders;
|
||||
return Theme(
|
||||
data: theme.copyWith(
|
||||
pageTransitionsTheme: PageTransitionsTheme(
|
||||
builders: {
|
||||
for (final platform in TargetPlatform.values)
|
||||
platform: _WindowPageTransitions(
|
||||
builders[platform] ?? const ZoomPageTransitionsBuilder(),
|
||||
),
|
||||
},
|
||||
),
|
||||
return theme.copyWith(
|
||||
pageTransitionsTheme: PageTransitionsTheme(
|
||||
builders: {
|
||||
for (final platform in TargetPlatform.values)
|
||||
platform: _WindowPageTransitions(
|
||||
builders[platform] ?? const ZoomPageTransitionsBuilder(),
|
||||
),
|
||||
},
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,9 +115,8 @@ class WindowPageBox extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scope = WindowScope.maybeOf(context);
|
||||
if (scope == null) return child;
|
||||
final body = scope.body;
|
||||
final body = WindowBodyScope.maybeOf(context);
|
||||
if (body == null) return child;
|
||||
const radius = Radius.circular(windowCornerRadius);
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -140,7 +137,9 @@ class WindowPageBox extends StatelessWidget {
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
primary: false,
|
||||
body: child,
|
||||
// Its own layer: moving or resizing the window repositions the
|
||||
// page without repainting it.
|
||||
body: RepaintBoundary(child: child),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'window_entry.dart';
|
||||
import 'window_manager.dart';
|
||||
|
||||
/// The floating window some content is in: its entry, the manager, and where
|
||||
/// the content area is drawn in the window host. Absent outside a window, so
|
||||
/// shared content can tell the tiled app from a window.
|
||||
/// The floating window some content is in: its entry and the manager. Absent
|
||||
/// outside a window, so shared content can tell the tiled app from a window.
|
||||
///
|
||||
/// Content depends on what it can read of the entry, not on where the window
|
||||
/// is drawn: moving, resizing, minimising or maximising a window keeps its
|
||||
/// content as it is.
|
||||
class WindowScope extends InheritedWidget {
|
||||
const WindowScope({
|
||||
super.key,
|
||||
required this.manager,
|
||||
required this.entry,
|
||||
required this.body,
|
||||
required super.child,
|
||||
});
|
||||
|
||||
final WindowManager manager;
|
||||
final WindowEntry entry;
|
||||
|
||||
/// The content area (the window less its title bar), in the host's
|
||||
/// coordinates.
|
||||
final Rect body;
|
||||
|
||||
static WindowScope? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<WindowScope>();
|
||||
|
||||
@@ -30,6 +29,26 @@ class WindowScope extends InheritedWidget {
|
||||
@override
|
||||
bool updateShouldNotify(WindowScope oldWidget) =>
|
||||
oldWidget.manager != manager ||
|
||||
oldWidget.entry != entry ||
|
||||
oldWidget.body != body;
|
||||
oldWidget.entry.id != entry.id ||
|
||||
oldWidget.entry.kind != entry.kind ||
|
||||
oldWidget.entry.contentId != entry.contentId ||
|
||||
oldWidget.entry.serverKey != entry.serverKey ||
|
||||
!mapEquals(oldWidget.entry.data, entry.data);
|
||||
}
|
||||
|
||||
/// Where a window's content area is drawn in the window host. Kept apart from
|
||||
/// [WindowScope] so a move or a resize repositions the page without rebuilding
|
||||
/// what the page shows.
|
||||
class WindowBodyScope extends InheritedWidget {
|
||||
const WindowBodyScope({super.key, required this.body, required super.child});
|
||||
|
||||
/// The content area (the window less its title bar), in the host's
|
||||
/// coordinates.
|
||||
final Rect body;
|
||||
|
||||
static Rect? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<WindowBodyScope>()?.body;
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(WindowBodyScope oldWidget) => oldWidget.body != body;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user