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.
This commit is contained in:
@@ -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'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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<T> {
|
||||
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<T> extends StatelessWidget {
|
||||
const TerminalMenuButton({
|
||||
super.key,
|
||||
@@ -38,66 +36,33 @@ class TerminalMenuButton<T> extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!cupertino) {
|
||||
return PopupMenuButton<T>(
|
||||
tooltip: label,
|
||||
icon: Icon(icon),
|
||||
onSelected: onSelected,
|
||||
itemBuilder: (_) => [
|
||||
for (final choice in choices)
|
||||
choice.checked == null
|
||||
? PopupMenuItem<T>(
|
||||
key: choice.key,
|
||||
value: choice.value,
|
||||
child: Text(choice.label),
|
||||
)
|
||||
: CheckedPopupMenuItem<T>(
|
||||
key: choice.key,
|
||||
value: choice.value,
|
||||
checked: choice.checked!,
|
||||
child: Text(choice.label),
|
||||
),
|
||||
if (info case final info?) ...[
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<T>(
|
||||
key: const ValueKey('terminal-menu-info'),
|
||||
enabled: false,
|
||||
child: Text(info),
|
||||
),
|
||||
],
|
||||
return PopupMenuButton<T>(
|
||||
tooltip: label,
|
||||
icon: Icon(icon),
|
||||
onSelected: onSelected,
|
||||
itemBuilder: (_) => [
|
||||
for (final choice in choices)
|
||||
choice.checked == null
|
||||
? PopupMenuItem<T>(
|
||||
key: choice.key,
|
||||
value: choice.value,
|
||||
child: Text(choice.label),
|
||||
)
|
||||
: CheckedPopupMenuItem<T>(
|
||||
key: choice.key,
|
||||
value: choice.value,
|
||||
checked: choice.checked!,
|
||||
child: Text(choice.label),
|
||||
),
|
||||
if (info case final info?) ...[
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem<T>(
|
||||
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<void> _sheet(BuildContext context) async {
|
||||
final picked = await showCupertinoModalPopup<T>(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'terminal_body.dart';
|
||||
@@ -17,9 +16,7 @@ PageRoute<void> terminalPageRoute({
|
||||
}) {
|
||||
Widget page(BuildContext _) =>
|
||||
TerminalPage(hub: hub, layout: layout, cupertino: cupertino);
|
||||
return cupertino
|
||||
? CupertinoPageRoute<void>(builder: page)
|
||||
: MaterialPageRoute<void>(builder: page);
|
||||
return MaterialPageRoute<void>(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,
|
||||
|
||||
@@ -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<TerminalPanel> {
|
||||
),
|
||||
),
|
||||
);
|
||||
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',
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<String>(
|
||||
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user