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 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../chat/shell/chat_shell_terminal_keys.dart';
|
import '../chat/shell/chat_shell_terminal_keys.dart';
|
||||||
@@ -78,13 +77,10 @@ class TerminalBody extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextStyle? _noteStyle(BuildContext context) => cupertino
|
TextStyle? _noteStyle(BuildContext context) =>
|
||||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
)
|
);
|
||||||
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _closeEnded(TerminalTab tab) {
|
Widget _closeEnded(TerminalTab tab) {
|
||||||
void close() => unawaited(hub.close(tab));
|
void close() => unawaited(hub.close(tab));
|
||||||
@@ -92,9 +88,7 @@ class TerminalBody extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
|
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: cupertino
|
child: TextButton(onPressed: close, child: const Text('Close tab')),
|
||||||
? CupertinoButton(onPressed: close, child: const Text('Close tab'))
|
|
||||||
: TextButton(onPressed: close, child: const Text('Close tab')),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -116,15 +110,10 @@ class TerminalBody extends StatelessWidget {
|
|||||||
child: Text(error, style: _noteStyle(context)),
|
child: Text(error, style: _noteStyle(context)),
|
||||||
),
|
),
|
||||||
if (machines.isNotEmpty)
|
if (machines.isNotEmpty)
|
||||||
cupertino
|
FilledButton.tonal(
|
||||||
? CupertinoButton(
|
onPressed: open,
|
||||||
onPressed: open,
|
child: const Text('New terminal'),
|
||||||
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';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// One choice of a [TerminalMenuButton].
|
/// One choice of a [TerminalMenuButton].
|
||||||
@@ -12,8 +11,7 @@ class TerminalChoice<T> {
|
|||||||
final Key? key;
|
final Key? key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An icon button opening the host's menu: a Material popup menu, or a
|
/// An icon button opening the host's menu.
|
||||||
/// Cupertino action sheet with Cancel.
|
|
||||||
class TerminalMenuButton<T> extends StatelessWidget {
|
class TerminalMenuButton<T> extends StatelessWidget {
|
||||||
const TerminalMenuButton({
|
const TerminalMenuButton({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -38,66 +36,33 @@ class TerminalMenuButton<T> extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (!cupertino) {
|
return PopupMenuButton<T>(
|
||||||
return PopupMenuButton<T>(
|
tooltip: label,
|
||||||
tooltip: label,
|
icon: Icon(icon),
|
||||||
icon: Icon(icon),
|
onSelected: onSelected,
|
||||||
onSelected: onSelected,
|
itemBuilder: (_) => [
|
||||||
itemBuilder: (_) => [
|
for (final choice in choices)
|
||||||
for (final choice in choices)
|
choice.checked == null
|
||||||
choice.checked == null
|
? PopupMenuItem<T>(
|
||||||
? PopupMenuItem<T>(
|
key: choice.key,
|
||||||
key: choice.key,
|
value: choice.value,
|
||||||
value: choice.value,
|
child: Text(choice.label),
|
||||||
child: Text(choice.label),
|
)
|
||||||
)
|
: CheckedPopupMenuItem<T>(
|
||||||
: CheckedPopupMenuItem<T>(
|
key: choice.key,
|
||||||
key: choice.key,
|
value: choice.value,
|
||||||
value: choice.value,
|
checked: choice.checked!,
|
||||||
checked: choice.checked!,
|
child: Text(choice.label),
|
||||||
child: Text(choice.label),
|
),
|
||||||
),
|
if (info case final info?) ...[
|
||||||
if (info case final info?) ...[
|
const PopupMenuDivider(),
|
||||||
const PopupMenuDivider(),
|
PopupMenuItem<T>(
|
||||||
PopupMenuItem<T>(
|
key: const ValueKey('terminal-menu-info'),
|
||||||
key: const ValueKey('terminal-menu-info'),
|
enabled: false,
|
||||||
enabled: false,
|
child: Text(info),
|
||||||
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 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'terminal_body.dart';
|
import 'terminal_body.dart';
|
||||||
@@ -17,9 +16,7 @@ PageRoute<void> terminalPageRoute({
|
|||||||
}) {
|
}) {
|
||||||
Widget page(BuildContext _) =>
|
Widget page(BuildContext _) =>
|
||||||
TerminalPage(hub: hub, layout: layout, cupertino: cupertino);
|
TerminalPage(hub: hub, layout: layout, cupertino: cupertino);
|
||||||
return cupertino
|
return MaterialPageRoute<void>(builder: page);
|
||||||
? CupertinoPageRoute<void>(builder: page)
|
|
||||||
: MaterialPageRoute<void>(builder: page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The full-screen terminal page of a narrow window, opened and closed by
|
/// 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(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text('Terminal')),
|
appBar: AppBar(title: const Text('Terminal')),
|
||||||
body: body,
|
body: body,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@@ -123,12 +122,8 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final surface = widget.cupertino
|
final surface = Theme.of(context).colorScheme.surfaceContainerLow;
|
||||||
? CupertinoColors.systemBackground.resolveFrom(context)
|
final divider = Theme.of(context).colorScheme.outlineVariant;
|
||||||
: Theme.of(context).colorScheme.surfaceContainerLow;
|
|
||||||
final divider = widget.cupertino
|
|
||||||
? CupertinoColors.separator.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.outlineVariant;
|
|
||||||
return Semantics(
|
return Semantics(
|
||||||
container: true,
|
container: true,
|
||||||
label: 'Terminal panel',
|
label: 'Terminal panel',
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../ui/adaptive/segmented_bar_pieces.dart';
|
import '../../ui/adaptive/segmented_bar_pieces.dart';
|
||||||
@@ -31,31 +30,17 @@ class TerminalShortcutBubble extends StatelessWidget {
|
|||||||
final label = running > 1
|
final label = running > 1
|
||||||
? 'Open terminal, $running running'
|
? 'Open terminal, $running running'
|
||||||
: 'Open terminal';
|
: 'Open terminal';
|
||||||
final icon = Icon(
|
final icon = Icon(Icons.terminal, size: 20);
|
||||||
cupertino
|
|
||||||
? CupertinoIcons.chevron_left_slash_chevron_right
|
|
||||||
: Icons.terminal,
|
|
||||||
size: 20,
|
|
||||||
);
|
|
||||||
final content = running > 1
|
final content = running > 1
|
||||||
? Badge.count(count: running, child: icon)
|
? Badge.count(count: running, child: icon)
|
||||||
: icon;
|
: icon;
|
||||||
final button = cupertino
|
final button = FloatingActionButton.small(
|
||||||
? CupertinoButton.tinted(
|
key: const Key('terminal-shortcut-bubble'),
|
||||||
key: const Key('terminal-shortcut-bubble'),
|
heroTag: null,
|
||||||
sizeStyle: CupertinoButtonSize.small,
|
tooltip: label,
|
||||||
padding: const EdgeInsets.all(10),
|
onPressed: onOpen,
|
||||||
borderRadius: BorderRadius.circular(22),
|
child: content,
|
||||||
onPressed: onOpen,
|
);
|
||||||
child: content,
|
|
||||||
)
|
|
||||||
: FloatingActionButton.small(
|
|
||||||
key: const Key('terminal-shortcut-bubble'),
|
|
||||||
heroTag: null,
|
|
||||||
tooltip: label,
|
|
||||||
onPressed: onOpen,
|
|
||||||
child: content,
|
|
||||||
);
|
|
||||||
return Semantics(
|
return Semantics(
|
||||||
button: true,
|
button: true,
|
||||||
label: label,
|
label: label,
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ class TerminalTabStrip extends StatelessWidget {
|
|||||||
padding: const EdgeInsetsDirectional.only(end: 4),
|
padding: const EdgeInsetsDirectional.only(end: 4),
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
identifier: 'terminal-tab-$index',
|
identifier: 'terminal-tab-$index',
|
||||||
child: _tab(context, tab, tab == selected),
|
child: _tab(tab, tab == selected),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_newTerminal(context),
|
_newTerminal(),
|
||||||
if (showModes)
|
if (showModes)
|
||||||
TerminalMenuButton<_Option>(
|
TerminalMenuButton<_Option>(
|
||||||
cupertino: cupertino,
|
cupertino: cupertino,
|
||||||
@@ -88,7 +88,7 @@ class TerminalTabStrip extends StatelessWidget {
|
|||||||
String _label(TerminalTab tab) =>
|
String _label(TerminalTab tab) =>
|
||||||
hub.multiMachine ? '${tab.title} · ${tab.machineName}' : tab.title;
|
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(
|
final label = Text(
|
||||||
_label(tab),
|
_label(tab),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
@@ -98,35 +98,6 @@ class TerminalTabStrip extends StatelessWidget {
|
|||||||
: const TextStyle(fontStyle: FontStyle.italic),
|
: const TextStyle(fontStyle: FontStyle.italic),
|
||||||
);
|
);
|
||||||
void close() => unawaited(hub.close(tab));
|
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(
|
return InputChip(
|
||||||
label: label,
|
label: label,
|
||||||
selected: selected,
|
selected: selected,
|
||||||
@@ -138,7 +109,7 @@ class TerminalTabStrip extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _newTerminal(BuildContext context) {
|
Widget _newTerminal() {
|
||||||
final machines = hub.connected;
|
final machines = hub.connected;
|
||||||
if (machines.length > 1) {
|
if (machines.length > 1) {
|
||||||
return TerminalMenuButton<String>(
|
return TerminalMenuButton<String>(
|
||||||
@@ -159,20 +130,11 @@ class TerminalTabStrip extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
final enabled = machines.isNotEmpty;
|
final enabled = machines.isNotEmpty;
|
||||||
void open() => unawaited(hub.open());
|
void open() => unawaited(hub.open());
|
||||||
return cupertino
|
return IconButton(
|
||||||
? CupertinoButton(
|
tooltip: 'New terminal',
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
onPressed: enabled ? open : null,
|
||||||
onPressed: enabled ? open : null,
|
icon: const Icon(Icons.add),
|
||||||
child: const Icon(
|
);
|
||||||
CupertinoIcons.add,
|
|
||||||
semanticLabel: 'New terminal',
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: 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 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'terminal_layout.dart';
|
import 'terminal_layout.dart';
|
||||||
@@ -28,17 +27,6 @@ class TerminalToggleButton extends StatelessWidget {
|
|||||||
listenable: layout,
|
listenable: layout,
|
||||||
builder: (context, _) {
|
builder: (context, _) {
|
||||||
final shown = layout.visible;
|
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(
|
return IconButton(
|
||||||
key: const ValueKey('shell.terminal'),
|
key: const ValueKey('shell.terminal'),
|
||||||
tooltip: label,
|
tooltip: label,
|
||||||
|
|||||||
Reference in New Issue
Block a user