From 3be07064f93fcd0e46b6d49d90561e39e6b6d283 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 03:58:24 +0000 Subject: [PATCH] Remove Cupertino terminal branches Keep the Material-only terminal implementation while preserving public Cupertino parameters for callers. This removes unreachable Cupertino widgets and imports without changing the Material path. --- app/lib/features/terminal/terminal_body.dart | 29 ++---- app/lib/features/terminal/terminal_menu.dart | 89 ++++++------------- app/lib/features/terminal/terminal_page.dart | 11 +-- app/lib/features/terminal/terminal_panel.dart | 9 +- .../terminal/terminal_shortcut_bubble.dart | 31 ++----- .../features/terminal/terminal_tab_strip.dart | 56 ++---------- .../terminal/terminal_toggle_button.dart | 12 --- 7 files changed, 56 insertions(+), 181 deletions(-) diff --git a/app/lib/features/terminal/terminal_body.dart b/app/lib/features/terminal/terminal_body.dart index 063b64f9..6dbe0f7c 100644 --- a/app/lib/features/terminal/terminal_body.dart +++ b/app/lib/features/terminal/terminal_body.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../chat/shell/chat_shell_terminal_keys.dart'; @@ -78,13 +77,10 @@ class TerminalBody extends StatelessWidget { ); } - TextStyle? _noteStyle(BuildContext context) => cupertino - ? CupertinoTheme.of(context).textTheme.textStyle.copyWith( - color: CupertinoColors.secondaryLabel.resolveFrom(context), - ) - : Theme.of(context).textTheme.bodySmall?.copyWith( - color: Theme.of(context).colorScheme.onSurfaceVariant, - ); + TextStyle? _noteStyle(BuildContext context) => + Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ); Widget _closeEnded(TerminalTab tab) { void close() => unawaited(hub.close(tab)); @@ -92,9 +88,7 @@ class TerminalBody extends StatelessWidget { padding: const EdgeInsets.fromLTRB(8, 0, 8, 8), child: Align( alignment: AlignmentDirectional.centerStart, - child: cupertino - ? CupertinoButton(onPressed: close, child: const Text('Close tab')) - : TextButton(onPressed: close, child: const Text('Close tab')), + child: TextButton(onPressed: close, child: const Text('Close tab')), ), ); } @@ -116,15 +110,10 @@ class TerminalBody extends StatelessWidget { child: Text(error, style: _noteStyle(context)), ), if (machines.isNotEmpty) - cupertino - ? CupertinoButton( - onPressed: open, - child: const Text('New terminal'), - ) - : FilledButton.tonal( - onPressed: open, - child: const Text('New terminal'), - ), + FilledButton.tonal( + onPressed: open, + child: const Text('New terminal'), + ), ], ), ); diff --git a/app/lib/features/terminal/terminal_menu.dart b/app/lib/features/terminal/terminal_menu.dart index 20612969..1a914f63 100644 --- a/app/lib/features/terminal/terminal_menu.dart +++ b/app/lib/features/terminal/terminal_menu.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; /// One choice of a [TerminalMenuButton]. @@ -12,8 +11,7 @@ class TerminalChoice { final Key? key; } -/// An icon button opening the host's menu: a Material popup menu, or a -/// Cupertino action sheet with Cancel. +/// An icon button opening the host's menu. class TerminalMenuButton extends StatelessWidget { const TerminalMenuButton({ super.key, @@ -38,66 +36,33 @@ class TerminalMenuButton extends StatelessWidget { @override Widget build(BuildContext context) { - if (!cupertino) { - return PopupMenuButton( - tooltip: label, - icon: Icon(icon), - onSelected: onSelected, - itemBuilder: (_) => [ - for (final choice in choices) - choice.checked == null - ? PopupMenuItem( - key: choice.key, - value: choice.value, - child: Text(choice.label), - ) - : CheckedPopupMenuItem( - key: choice.key, - value: choice.value, - checked: choice.checked!, - child: Text(choice.label), - ), - if (info case final info?) ...[ - const PopupMenuDivider(), - PopupMenuItem( - key: const ValueKey('terminal-menu-info'), - enabled: false, - child: Text(info), - ), - ], + return PopupMenuButton( + tooltip: label, + icon: Icon(icon), + onSelected: onSelected, + itemBuilder: (_) => [ + for (final choice in choices) + choice.checked == null + ? PopupMenuItem( + key: choice.key, + value: choice.value, + child: Text(choice.label), + ) + : CheckedPopupMenuItem( + key: choice.key, + value: choice.value, + checked: choice.checked!, + child: Text(choice.label), + ), + if (info case final info?) ...[ + const PopupMenuDivider(), + PopupMenuItem( + key: const ValueKey('terminal-menu-info'), + enabled: false, + child: Text(info), + ), ], - ); - } - return CupertinoButton( - padding: const EdgeInsets.symmetric(horizontal: 8), - onPressed: () => _sheet(context), - child: Icon(cupertinoIcon, semanticLabel: label), + ], ); } - - Future _sheet(BuildContext context) async { - final picked = await showCupertinoModalPopup( - context: context, - builder: (sheet) => CupertinoActionSheet( - title: Text(label), - message: info == null ? null : Text(info!), - actions: [ - for (final choice in choices) - CupertinoActionSheetAction( - key: choice.key, - isDefaultAction: choice.checked ?? false, - onPressed: () => Navigator.of(sheet).pop(choice.value), - child: Text( - choice.checked ?? false ? '${choice.label} ✓' : choice.label, - ), - ), - ], - cancelButton: CupertinoActionSheetAction( - onPressed: () => Navigator.of(sheet).pop(), - child: const Text('Cancel'), - ), - ), - ); - if (picked != null) onSelected(picked); - } } diff --git a/app/lib/features/terminal/terminal_page.dart b/app/lib/features/terminal/terminal_page.dart index fe77a8eb..56ac5485 100644 --- a/app/lib/features/terminal/terminal_page.dart +++ b/app/lib/features/terminal/terminal_page.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'terminal_body.dart'; @@ -17,9 +16,7 @@ PageRoute terminalPageRoute({ }) { Widget page(BuildContext _) => TerminalPage(hub: hub, layout: layout, cupertino: cupertino); - return cupertino - ? CupertinoPageRoute(builder: page) - : MaterialPageRoute(builder: page); + return MaterialPageRoute(builder: page); } /// The full-screen terminal page of a narrow window, opened and closed by @@ -94,12 +91,6 @@ class TerminalPage extends StatelessWidget { ), ), ); - if (cupertino) { - return CupertinoPageScaffold( - navigationBar: const CupertinoNavigationBar(middle: Text('Terminal')), - child: Material(type: MaterialType.transparency, child: body), - ); - } return Scaffold( appBar: AppBar(title: const Text('Terminal')), body: body, diff --git a/app/lib/features/terminal/terminal_panel.dart b/app/lib/features/terminal/terminal_panel.dart index 42caf512..2021463c 100644 --- a/app/lib/features/terminal/terminal_panel.dart +++ b/app/lib/features/terminal/terminal_panel.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -123,12 +122,8 @@ class _TerminalPanelState extends State { ), ), ); - final surface = widget.cupertino - ? CupertinoColors.systemBackground.resolveFrom(context) - : Theme.of(context).colorScheme.surfaceContainerLow; - final divider = widget.cupertino - ? CupertinoColors.separator.resolveFrom(context) - : Theme.of(context).colorScheme.outlineVariant; + final surface = Theme.of(context).colorScheme.surfaceContainerLow; + final divider = Theme.of(context).colorScheme.outlineVariant; return Semantics( container: true, label: 'Terminal panel', diff --git a/app/lib/features/terminal/terminal_shortcut_bubble.dart b/app/lib/features/terminal/terminal_shortcut_bubble.dart index 88f07b5c..d408302c 100644 --- a/app/lib/features/terminal/terminal_shortcut_bubble.dart +++ b/app/lib/features/terminal/terminal_shortcut_bubble.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../ui/adaptive/segmented_bar_pieces.dart'; @@ -31,31 +30,17 @@ class TerminalShortcutBubble extends StatelessWidget { final label = running > 1 ? 'Open terminal, $running running' : 'Open terminal'; - final icon = Icon( - cupertino - ? CupertinoIcons.chevron_left_slash_chevron_right - : Icons.terminal, - size: 20, - ); + final icon = Icon(Icons.terminal, size: 20); final content = running > 1 ? Badge.count(count: running, child: icon) : icon; - final button = cupertino - ? CupertinoButton.tinted( - key: const Key('terminal-shortcut-bubble'), - sizeStyle: CupertinoButtonSize.small, - padding: const EdgeInsets.all(10), - borderRadius: BorderRadius.circular(22), - onPressed: onOpen, - child: content, - ) - : FloatingActionButton.small( - key: const Key('terminal-shortcut-bubble'), - heroTag: null, - tooltip: label, - onPressed: onOpen, - child: content, - ); + final button = FloatingActionButton.small( + key: const Key('terminal-shortcut-bubble'), + heroTag: null, + tooltip: label, + onPressed: onOpen, + child: content, + ); return Semantics( button: true, label: label, diff --git a/app/lib/features/terminal/terminal_tab_strip.dart b/app/lib/features/terminal/terminal_tab_strip.dart index 1781d283..364920b5 100644 --- a/app/lib/features/terminal/terminal_tab_strip.dart +++ b/app/lib/features/terminal/terminal_tab_strip.dart @@ -47,14 +47,14 @@ class TerminalTabStrip extends StatelessWidget { padding: const EdgeInsetsDirectional.only(end: 4), child: Semantics( identifier: 'terminal-tab-$index', - child: _tab(context, tab, tab == selected), + child: _tab(tab, tab == selected), ), ), ], ), ), ), - _newTerminal(context), + _newTerminal(), if (showModes) TerminalMenuButton<_Option>( cupertino: cupertino, @@ -88,7 +88,7 @@ class TerminalTabStrip extends StatelessWidget { String _label(TerminalTab tab) => hub.multiMachine ? '${tab.title} · ${tab.machineName}' : tab.title; - Widget _tab(BuildContext context, TerminalTab tab, bool selected) { + Widget _tab(TerminalTab tab, bool selected) { final label = Text( _label(tab), maxLines: 1, @@ -98,35 +98,6 @@ class TerminalTabStrip extends StatelessWidget { : const TextStyle(fontStyle: FontStyle.italic), ); void close() => unawaited(hub.close(tab)); - if (cupertino) { - final color = selected - ? CupertinoTheme.of(context).primaryColor - : CupertinoColors.label.resolveFrom(context); - return Row( - mainAxisSize: MainAxisSize.min, - children: [ - CupertinoButton( - padding: const EdgeInsets.symmetric(horizontal: 8), - onPressed: () => hub.select(tab), - child: DefaultTextStyle.merge( - style: TextStyle( - color: color, - fontWeight: selected ? FontWeight.w600 : null, - ), - child: label, - ), - ), - CupertinoButton( - padding: EdgeInsets.zero, - onPressed: close, - child: const Icon( - CupertinoIcons.xmark_circle_fill, - semanticLabel: 'Close terminal', - ), - ), - ], - ); - } return InputChip( label: label, selected: selected, @@ -138,7 +109,7 @@ class TerminalTabStrip extends StatelessWidget { ); } - Widget _newTerminal(BuildContext context) { + Widget _newTerminal() { final machines = hub.connected; if (machines.length > 1) { return TerminalMenuButton( @@ -159,20 +130,11 @@ class TerminalTabStrip extends StatelessWidget { } final enabled = machines.isNotEmpty; void open() => unawaited(hub.open()); - return cupertino - ? CupertinoButton( - padding: const EdgeInsets.symmetric(horizontal: 8), - onPressed: enabled ? open : null, - child: const Icon( - CupertinoIcons.add, - semanticLabel: 'New terminal', - ), - ) - : IconButton( - tooltip: 'New terminal', - onPressed: enabled ? open : null, - icon: const Icon(Icons.add), - ); + return IconButton( + tooltip: 'New terminal', + onPressed: enabled ? open : null, + icon: const Icon(Icons.add), + ); } } diff --git a/app/lib/features/terminal/terminal_toggle_button.dart b/app/lib/features/terminal/terminal_toggle_button.dart index dd9bcd0e..9fb3b320 100644 --- a/app/lib/features/terminal/terminal_toggle_button.dart +++ b/app/lib/features/terminal/terminal_toggle_button.dart @@ -1,4 +1,3 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'terminal_layout.dart'; @@ -28,17 +27,6 @@ class TerminalToggleButton extends StatelessWidget { listenable: layout, builder: (context, _) { final shown = layout.visible; - if (cupertino) { - return CupertinoButton( - key: const ValueKey('shell.terminal'), - padding: EdgeInsets.zero, - onPressed: actions.toggle, - child: Icon( - CupertinoIcons.chevron_left_slash_chevron_right, - semanticLabel: label, - ), - ); - } return IconButton( key: const ValueKey('shell.terminal'), tooltip: label,