Merge commit '42cb6a6f2d0de09a5851b31ef1b866c876a32337' into pipelines/run-20261111-0141-perf-window-moves-do-not-rebuild-content-b294
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,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,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,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)}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user