a792b30513
The first show of an app run starts one terminal (the machine's login prompt) unless one is running; later toggles never open another. Drop the tmux field and restart note, and update the Settings copy and the terminal notes.
88 lines
3.1 KiB
Dart
88 lines
3.1 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../terminal/terminal_layout.dart';
|
|
import 'settings_group.dart';
|
|
import 'settings_theme.dart';
|
|
|
|
/// Appearance → Terminal: whether the terminal docks at the bottom of the
|
|
/// window or floats over it (Ctrl+` shows and hides it either way).
|
|
class SettingsTerminalSection extends StatelessWidget {
|
|
const SettingsTerminalSection({super.key, required this.layout});
|
|
|
|
final TerminalLayout layout;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListenableBuilder(
|
|
listenable: layout,
|
|
builder: (context, _) {
|
|
final cupertino = usesCupertinoControls(context);
|
|
final Widget choice = cupertino
|
|
? CupertinoSlidingSegmentedControl<TerminalMode>(
|
|
groupValue: layout.mode,
|
|
children: {
|
|
for (final mode in TerminalMode.values)
|
|
mode: Padding(
|
|
key: ValueKey('settings-terminal-${mode.name}'),
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
child: Text(mode.label),
|
|
),
|
|
},
|
|
onValueChanged: (mode) {
|
|
if (mode != null) layout.setMode(mode);
|
|
},
|
|
)
|
|
: SegmentedButton<TerminalMode>(
|
|
segments: [
|
|
for (final mode in TerminalMode.values)
|
|
ButtonSegment(
|
|
value: mode,
|
|
label: Text(
|
|
mode.label,
|
|
key: ValueKey('settings-terminal-${mode.name}'),
|
|
),
|
|
icon: Icon(
|
|
mode == TerminalMode.panel
|
|
? Icons.call_to_action_outlined
|
|
: Icons.picture_in_picture_alt_outlined,
|
|
),
|
|
),
|
|
],
|
|
selected: {layout.mode},
|
|
onSelectionChanged: (modes) => layout.setMode(modes.first),
|
|
);
|
|
return SettingsGroup(
|
|
title: 'Terminal',
|
|
footer: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Text(
|
|
'Saved on this device. Ctrl+` shows or hides the terminal; on '
|
|
'a narrow window it opens full screen. A terminal starts at '
|
|
'the machine\'s login prompt: type that account\'s password '
|
|
'once, and it stays logged in while hidden. Terminals end '
|
|
'when the server restarts; run tmux inside one to keep work.',
|
|
),
|
|
if (layout.saveFailed)
|
|
Text(
|
|
'Could not save; applies until reload.',
|
|
style: TextStyle(color: settingsErrorColor(context)),
|
|
),
|
|
],
|
|
),
|
|
children: [
|
|
SettingsGroupItem(
|
|
child: Semantics(
|
|
label: 'Terminal placement',
|
|
child: Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: choice,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|