Restyle Settings as flat grouped list sections (F9) and scroll it behind the bar (F1)
Servers become rows with a selection mark, addresses as subtitles and a Use/Edit/Remove menu plus an Add server row; the connection is a status row with address and Reconnect/Disconnect rows; Templates and Schedules are chevron rows in a Library group. Material groups are flat surfaceContainer surfaces with primary titleSmall headers (no Cards); Cupertino uses inset-grouped sections on the grouped background, switches for the ntfy choices. The trust warning is a footer, helper copy is shortened, Save workspace is a legible tonal/plain button, and the column starts at the bar's inset (max 720) instead of being centred. The page pads by the top media padding instead of a top SafeArea.
This commit is contained in:
@@ -3,16 +3,20 @@ import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/transport/pipelines_client.dart' as transport;
|
||||
import 'settings_controller.dart';
|
||||
import 'settings_controls.dart';
|
||||
import 'settings_copy.dart';
|
||||
import 'settings_group.dart';
|
||||
import 'settings_keys.dart';
|
||||
import 'settings_trust_warning.dart';
|
||||
import 'settings_layout.dart';
|
||||
import 'settings_status_row.dart';
|
||||
import 'settings_trust_warning.dart';
|
||||
|
||||
/// Connection controls: the editable endpoint, the truthful connection card and
|
||||
/// the trusted-network warning. Every action goes through the shared client the
|
||||
export 'settings_status_row.dart';
|
||||
|
||||
/// Connection controls for a single endpoint: the editable URL with Connect /
|
||||
/// Disconnect, the connection's status row and the trusted-network warning as
|
||||
/// the group's footer. Every action goes through the shared client the
|
||||
/// controller was given; nothing here opens a second connection.
|
||||
class SettingsConnectionSection extends StatelessWidget {
|
||||
const SettingsConnectionSection({
|
||||
@@ -26,133 +30,89 @@ class SettingsConnectionSection extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
final errors = <String>[
|
||||
if (controller.endpointSaveError.isNotEmpty) controller.endpointSaveError,
|
||||
if (controller.actionError.isNotEmpty) controller.actionError,
|
||||
];
|
||||
return SettingsGroup(
|
||||
title: 'Connection',
|
||||
footer: settingsConnectionFooter(controller),
|
||||
children: <Widget>[
|
||||
SettingsTextField(
|
||||
controller: serverUrlField,
|
||||
key: SettingsKeys.serverUrl,
|
||||
label: 'Server URL',
|
||||
placeholder: serverUrlPlaceholder,
|
||||
helper: serverUrlHelper,
|
||||
error: controller.urlError,
|
||||
onChanged: controller.updateServerUrl,
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
SettingsActions(
|
||||
primaryLabel: controller.primaryActionLabel,
|
||||
secondaryLabel: controller.secondaryActionLabel,
|
||||
primaryKey: controller.connectionActive
|
||||
? SettingsKeys.disconnect
|
||||
: SettingsKeys.connect,
|
||||
secondaryKey: controller.connectionActive
|
||||
? SettingsKeys.connect
|
||||
: SettingsKeys.reconnect,
|
||||
onPrimary: () => unawaited(
|
||||
controller.connectionActive
|
||||
? controller.disconnect()
|
||||
: controller.connect(),
|
||||
),
|
||||
onSecondary: () => unawaited(
|
||||
controller.connectionActive
|
||||
? controller.connect()
|
||||
: controller.reconnect(),
|
||||
SettingsGroupItem(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
SettingsTextField(
|
||||
controller: serverUrlField,
|
||||
key: SettingsKeys.serverUrl,
|
||||
label: 'Server URL',
|
||||
placeholder: serverUrlPlaceholder,
|
||||
helper: serverUrlHelper,
|
||||
error: controller.urlError,
|
||||
onChanged: controller.updateServerUrl,
|
||||
maxLines: 2,
|
||||
),
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
SettingsActions(
|
||||
primaryLabel: controller.primaryActionLabel,
|
||||
secondaryLabel: controller.secondaryActionLabel,
|
||||
primaryKey: controller.connectionActive
|
||||
? SettingsKeys.disconnect
|
||||
: SettingsKeys.connect,
|
||||
secondaryKey: controller.connectionActive
|
||||
? SettingsKeys.connect
|
||||
: SettingsKeys.reconnect,
|
||||
onPrimary: () => unawaited(
|
||||
controller.connectionActive
|
||||
? controller.disconnect()
|
||||
: controller.connect(),
|
||||
),
|
||||
onSecondary: () => unawaited(
|
||||
controller.connectionActive
|
||||
? controller.connect()
|
||||
: controller.reconnect(),
|
||||
),
|
||||
),
|
||||
for (final error in errors) ...<Widget>[
|
||||
const SizedBox(height: settingsFieldGap),
|
||||
Text(error, style: settingsTextStyle(context, error: true)),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (controller.endpointSaveError.isNotEmpty) ...<Widget>[
|
||||
const SizedBox(height: settingsFieldGap),
|
||||
Text(
|
||||
controller.endpointSaveError,
|
||||
style: settingsTextStyle(context, error: true),
|
||||
),
|
||||
],
|
||||
if (controller.actionError.isNotEmpty) ...<Widget>[
|
||||
const SizedBox(height: settingsFieldGap),
|
||||
Text(
|
||||
controller.actionError,
|
||||
style: settingsTextStyle(context, error: true),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
SettingsStatusCard(controller: controller),
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
const SettingsTrustWarning(),
|
||||
if (controller.protocolWarning case final warning?) ...<Widget>[
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
// The web page appends the same alert after the trust card. A live
|
||||
// region announces a mismatch the operator did not ask to reveal.
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
warning,
|
||||
style: settingsTextStyle(context, error: true),
|
||||
),
|
||||
),
|
||||
],
|
||||
SettingsStatusRow(controller: controller),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The status card's first line is the state; the remaining lines are the
|
||||
/// build/time/reason/backoff facts. Missing ping values stay explicit.
|
||||
class SettingsStatusCard extends StatelessWidget {
|
||||
const SettingsStatusCard({super.key, required this.controller});
|
||||
|
||||
final SettingsController controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final state = controller.connection;
|
||||
final lines = controller.connectionLines;
|
||||
final title = lines.isEmpty ? '' : lines.first;
|
||||
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
||||
final titleColor = switch (state.kind) {
|
||||
transport.ConnectionKind.connected =>
|
||||
usesCupertinoControls(context)
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: theme.colorScheme.primary,
|
||||
transport.ConnectionKind.disconnected => settingsErrorColor(context),
|
||||
_ => settingsTextStyle(context).color,
|
||||
};
|
||||
final titleWidget = Text(
|
||||
title,
|
||||
style: settingsTextStyle(
|
||||
context,
|
||||
title: true,
|
||||
).copyWith(color: titleColor),
|
||||
);
|
||||
return SettingsCard(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
if (state.kind == transport.ConnectionKind.connecting)
|
||||
Row(
|
||||
children: <Widget>[
|
||||
if (usesCupertinoControls(context))
|
||||
const CupertinoActivityIndicator()
|
||||
else
|
||||
const CircularProgressIndicator(strokeWidth: 2),
|
||||
const SizedBox(width: settingsControlGap),
|
||||
Expanded(child: titleWidget),
|
||||
],
|
||||
)
|
||||
else
|
||||
titleWidget,
|
||||
for (final line in details) ...<Widget>[
|
||||
const SizedBox(height: settingsFieldGap),
|
||||
Text(line, style: settingsTextStyle(context, secondary: true)),
|
||||
],
|
||||
],
|
||||
/// The Connection group's footer: the trust warning, then a protocol
|
||||
/// mismatch when the server reports one.
|
||||
Widget settingsConnectionFooter(SettingsController controller) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
const SettingsTrustWarning(),
|
||||
if (controller.protocolWarning case final warning?)
|
||||
Builder(
|
||||
// A live region announces a mismatch the operator did not ask to
|
||||
// reveal.
|
||||
builder: (context) => Padding(
|
||||
padding: const EdgeInsets.only(top: settingsTitleGap),
|
||||
child: Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
warning,
|
||||
style: TextStyle(color: settingsErrorColor(context)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
],
|
||||
);
|
||||
|
||||
/// Workspace controls. The path is resolved by the execution server, and the
|
||||
/// helper says so explicitly; an empty saved value is named "(none)".
|
||||
/// helper says so explicitly; an empty saved value is named "(none)". Save
|
||||
/// stays a legible tonal (Cupertino: plain) button while it is unavailable.
|
||||
class SettingsWorkspaceSection extends StatelessWidget {
|
||||
const SettingsWorkspaceSection({
|
||||
super.key,
|
||||
@@ -167,46 +127,55 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final saveError = controller.workspaceSaveError;
|
||||
final canSave = canSaveWorkspace(controller.workspaceDraft);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
final save = canSave ? () => unawaited(controller.saveWorkspace()) : null;
|
||||
return SettingsGroup(
|
||||
title: 'Workspace',
|
||||
children: <Widget>[
|
||||
SettingsTextField(
|
||||
controller: workspaceField,
|
||||
key: SettingsKeys.workspace,
|
||||
label: 'Workspace path (on the server)',
|
||||
placeholder: workspacePlaceholder,
|
||||
helper: workspaceHelper,
|
||||
error: controller.workspaceError,
|
||||
onChanged: controller.updateWorkspace,
|
||||
SettingsGroupItem(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
SettingsTextField(
|
||||
controller: workspaceField,
|
||||
key: SettingsKeys.workspace,
|
||||
label: 'Workspace path (on the server)',
|
||||
placeholder: workspacePlaceholder,
|
||||
helper: workspaceHelper,
|
||||
error: controller.workspaceError,
|
||||
onChanged: controller.updateWorkspace,
|
||||
),
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
Wrap(
|
||||
spacing: settingsControlGap,
|
||||
runSpacing: settingsFieldGap,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: <Widget>[
|
||||
if (usesCupertinoControls(context))
|
||||
CupertinoButton(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
)
|
||||
else
|
||||
FilledButton.tonal(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
),
|
||||
Text(
|
||||
savedWorkspaceLine(controller.savedWorkspace),
|
||||
style: settingsTextStyle(context, secondary: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (saveError.isNotEmpty) ...<Widget>[
|
||||
const SizedBox(height: settingsFieldGap),
|
||||
Text(saveError, style: settingsTextStyle(context, error: true)),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: settingsTitleGap),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: usesCupertinoControls(context)
|
||||
? CupertinoButton.filled(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
onPressed: canSave
|
||||
? () => unawaited(controller.saveWorkspace())
|
||||
: null,
|
||||
child: const Text('Save workspace'),
|
||||
)
|
||||
: FilledButton(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
onPressed: canSave
|
||||
? () => unawaited(controller.saveWorkspace())
|
||||
: null,
|
||||
child: const Text('Save workspace'),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: settingsFieldGap),
|
||||
Text(
|
||||
savedWorkspaceLine(controller.savedWorkspace),
|
||||
style: settingsTextStyle(context),
|
||||
),
|
||||
if (saveError.isNotEmpty) ...<Widget>[
|
||||
const SizedBox(height: settingsFieldGap),
|
||||
Text(saveError, style: settingsTextStyle(context, error: true)),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user