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:
@@ -5,12 +5,23 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/transport/pipelines_client.dart';
|
import '../../core/transport/pipelines_client.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
|
||||||
import 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
|
import 'settings_group.dart';
|
||||||
|
import 'settings_row.dart';
|
||||||
import 'settings_sections.dart';
|
import 'settings_sections.dart';
|
||||||
import 'settings_trust_warning.dart';
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
/// Status follows the actual attempted address, not just the preferred URL.
|
/// The short line under the managed connection's rows.
|
||||||
|
const String managedConnectionHelp =
|
||||||
|
'Reconnect tries the preferred address first, then the backups.';
|
||||||
|
|
||||||
|
/// The browser-only addition to [managedConnectionHelp].
|
||||||
|
const String managedConnectionWebHelp =
|
||||||
|
'In a browser the connection stays on this page’s origin.';
|
||||||
|
|
||||||
|
/// The saved-server connection: its state, the address actually attempted and
|
||||||
|
/// Reconnect / Disconnect rows. Status follows the actual attempted address,
|
||||||
|
/// not just the preferred URL.
|
||||||
class ManagedConnectionSection extends StatelessWidget {
|
class ManagedConnectionSection extends StatelessWidget {
|
||||||
const ManagedConnectionSection({
|
const ManagedConnectionSection({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -20,43 +31,49 @@ class ManagedConnectionSection extends StatelessWidget {
|
|||||||
final PipelinesClient client;
|
final PipelinesClient client;
|
||||||
final SettingsController controller;
|
final SettingsController controller;
|
||||||
|
|
||||||
Widget _action(BuildContext context, String text, VoidCallback? press) =>
|
|
||||||
usesCupertinoHost(context)
|
|
||||||
? CupertinoButton(onPressed: press, child: Text(text))
|
|
||||||
: TextButton(onPressed: press, child: Text(text));
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Column(
|
Widget build(BuildContext context) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
final cupertino = usesCupertinoControls(context);
|
||||||
children: [
|
return SettingsGroup(
|
||||||
SelectableText('Current address: ${client.endpoint ?? 'Not connected'}'),
|
title: 'Connection',
|
||||||
const SizedBox(height: 8),
|
leadingRows: true,
|
||||||
const Text(
|
footer: Column(
|
||||||
'Reconnect tries the preferred address first. A dropped or '
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
'unreachable connection tries this server’s backup addresses automatically.',
|
children: <Widget>[
|
||||||
),
|
Text(
|
||||||
if (kIsWeb)
|
kIsWeb
|
||||||
const Text(
|
? '$managedConnectionHelp $managedConnectionWebHelp'
|
||||||
'In a browser, the connection stays on this page’s '
|
: managedConnectionHelp,
|
||||||
'origin. Use a saved server to open its page; native apps use automatic address fallback.',
|
|
||||||
),
|
|
||||||
Wrap(
|
|
||||||
spacing: 8,
|
|
||||||
children: [
|
|
||||||
_action(
|
|
||||||
context,
|
|
||||||
'Reconnect',
|
|
||||||
client.endpoints.isEmpty
|
|
||||||
? null
|
|
||||||
: () => unawaited(client.connectAny(client.endpoints)),
|
|
||||||
),
|
),
|
||||||
_action(context, 'Disconnect', () => unawaited(client.disconnect())),
|
const SizedBox(height: 12),
|
||||||
|
settingsConnectionFooter(controller),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SettingsStatusCard(controller: controller),
|
children: <Widget>[
|
||||||
const SizedBox(height: 12),
|
SettingsStatusRow(controller: controller),
|
||||||
const SettingsTrustWarning(),
|
SettingsRow(
|
||||||
if (controller.protocolWarning case final warning?) Text(warning),
|
leading: Icon(cupertino ? CupertinoIcons.link : Icons.link),
|
||||||
],
|
title: const Text('Current address'),
|
||||||
);
|
subtitle: SelectableText('${client.endpoint ?? 'Not connected'}'),
|
||||||
|
),
|
||||||
|
SettingsRow(
|
||||||
|
action: true,
|
||||||
|
enabled: client.endpoints.isNotEmpty,
|
||||||
|
leading: Icon(
|
||||||
|
cupertino ? CupertinoIcons.arrow_clockwise : Icons.refresh,
|
||||||
|
),
|
||||||
|
title: const Text('Reconnect'),
|
||||||
|
onTap: () => unawaited(client.connectAny(client.endpoints)),
|
||||||
|
),
|
||||||
|
SettingsRow(
|
||||||
|
action: true,
|
||||||
|
leading: Icon(
|
||||||
|
cupertino ? CupertinoIcons.stop_circle : Icons.link_off,
|
||||||
|
),
|
||||||
|
title: const Text('Disconnect'),
|
||||||
|
onTap: () => unawaited(client.disconnect()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../core/servers/server_catalog.dart';
|
||||||
|
import 'settings_row.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
|
/// What a saved server's menu can do.
|
||||||
|
enum SavedServerAction { use, edit, remove }
|
||||||
|
|
||||||
|
/// The key of a saved server's actions menu button.
|
||||||
|
ValueKey<String> savedServerMenuKey(String id) =>
|
||||||
|
ValueKey<String>('settings.server.$id.menu');
|
||||||
|
|
||||||
|
/// One saved server: a selection mark, the name, "Selected server" on the
|
||||||
|
/// active one and each address (preferred, then backups) as subtitle lines.
|
||||||
|
/// Tapping another server uses it; the trailing menu offers Use, Edit and
|
||||||
|
/// Remove.
|
||||||
|
class SavedServerRow extends StatelessWidget {
|
||||||
|
const SavedServerRow({
|
||||||
|
super.key,
|
||||||
|
required this.server,
|
||||||
|
required this.selected,
|
||||||
|
required this.busy,
|
||||||
|
required this.onAction,
|
||||||
|
});
|
||||||
|
|
||||||
|
final SavedServer server;
|
||||||
|
final bool selected;
|
||||||
|
final bool busy;
|
||||||
|
final ValueChanged<SavedServerAction> onAction;
|
||||||
|
|
||||||
|
String _label(SavedServerAction action) => switch (action) {
|
||||||
|
SavedServerAction.use => 'Use ${server.name}',
|
||||||
|
SavedServerAction.edit => 'Edit ${server.name}',
|
||||||
|
SavedServerAction.remove => 'Remove ${server.name}',
|
||||||
|
};
|
||||||
|
|
||||||
|
List<SavedServerAction> get _actions => <SavedServerAction>[
|
||||||
|
if (!selected) SavedServerAction.use,
|
||||||
|
SavedServerAction.edit,
|
||||||
|
SavedServerAction.remove,
|
||||||
|
];
|
||||||
|
|
||||||
|
Future<void> _cupertinoMenu(BuildContext context) async {
|
||||||
|
final action = await showCupertinoModalPopup<SavedServerAction>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => CupertinoActionSheet(
|
||||||
|
title: Text(server.name),
|
||||||
|
actions: <Widget>[
|
||||||
|
for (final action in _actions)
|
||||||
|
CupertinoActionSheetAction(
|
||||||
|
isDestructiveAction: action == SavedServerAction.remove,
|
||||||
|
onPressed: () => Navigator.pop(context, action),
|
||||||
|
child: Text(_label(action)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
cancelButton: CupertinoActionSheetAction(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (action != null) onAction(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino = usesCupertinoControls(context);
|
||||||
|
final Widget menu = cupertino
|
||||||
|
? CupertinoButton(
|
||||||
|
key: savedServerMenuKey(server.id),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
onPressed: busy ? null : () => _cupertinoMenu(context),
|
||||||
|
child: Icon(
|
||||||
|
CupertinoIcons.ellipsis_circle,
|
||||||
|
semanticLabel: '${server.name} actions',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: PopupMenuButton<SavedServerAction>(
|
||||||
|
key: savedServerMenuKey(server.id),
|
||||||
|
enabled: !busy,
|
||||||
|
tooltip: '${server.name} actions',
|
||||||
|
onSelected: onAction,
|
||||||
|
itemBuilder: (context) => <PopupMenuEntry<SavedServerAction>>[
|
||||||
|
for (final action in _actions)
|
||||||
|
PopupMenuItem(value: action, child: Text(_label(action))),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
final Widget mark = selected
|
||||||
|
? Icon(
|
||||||
|
cupertino
|
||||||
|
? CupertinoIcons.checkmark_circle_fill
|
||||||
|
: Icons.check_circle,
|
||||||
|
semanticLabel: 'Selected',
|
||||||
|
color: cupertino
|
||||||
|
? CupertinoTheme.of(context).primaryColor
|
||||||
|
: Theme.of(context).colorScheme.primary,
|
||||||
|
)
|
||||||
|
: Icon(
|
||||||
|
cupertino ? CupertinoIcons.circle : Icons.radio_button_unchecked,
|
||||||
|
color: cupertino
|
||||||
|
? CupertinoColors.tertiaryLabel.resolveFrom(context)
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
return SettingsRow(
|
||||||
|
leading: mark,
|
||||||
|
title: Text(server.name),
|
||||||
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
if (selected) const Text('Selected server'),
|
||||||
|
for (final (index, address) in server.endpoints.indexed)
|
||||||
|
Text('${index == 0 ? 'Preferred' : 'Backup $index'}: $address'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
trailing: menu,
|
||||||
|
onTap: selected || busy ? null : () => onAction(SavedServerAction.use),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,11 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../core/servers/server_catalog.dart';
|
import '../../core/servers/server_catalog.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
import '../../ui/adaptive/host.dart';
|
||||||
import 'saved_server_editor.dart';
|
import 'saved_server_editor.dart';
|
||||||
|
import 'saved_server_row.dart';
|
||||||
import 'server_connections.dart';
|
import 'server_connections.dart';
|
||||||
|
import 'settings_group.dart';
|
||||||
|
import 'settings_row.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
class _ServerSaveFailure implements Exception {
|
class _ServerSaveFailure implements Exception {
|
||||||
const _ServerSaveFailure(this.message);
|
const _ServerSaveFailure(this.message);
|
||||||
@@ -79,73 +83,46 @@ class SavedServersSection extends StatelessWidget {
|
|||||||
if (confirmed == true) await connections.remove(server.id);
|
if (confirmed == true) await connections.remove(server.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _button(BuildContext context, String label, VoidCallback? press) =>
|
void _act(BuildContext context, SavedServer server, SavedServerAction act) {
|
||||||
usesCupertinoHost(context)
|
switch (act) {
|
||||||
? CupertinoButton(onPressed: press, child: Text(label))
|
case SavedServerAction.use:
|
||||||
: TextButton(onPressed: press, child: Text(label));
|
unawaited(connections.select(server.id));
|
||||||
|
case SavedServerAction.edit:
|
||||||
|
unawaited(_edit(context, server));
|
||||||
|
case SavedServerAction.remove:
|
||||||
|
unawaited(_remove(context, server));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => ListenableBuilder(
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
listenable: connections,
|
listenable: connections,
|
||||||
builder: (context, _) => Column(
|
builder: (context, _) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
final cupertino = usesCupertinoHost(context);
|
||||||
children: [
|
final error = connections.error;
|
||||||
for (final server in connections.catalog.servers) ...[
|
return SettingsGroup(
|
||||||
Text(
|
title: 'Servers',
|
||||||
server.name,
|
leadingRows: true,
|
||||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
footer: error == null
|
||||||
),
|
? null
|
||||||
if (server.id == connections.catalog.active?.id)
|
: Text(error, style: TextStyle(color: settingsErrorColor(context))),
|
||||||
const Text('Selected server'),
|
children: [
|
||||||
for (final (index, address) in server.endpoints.indexed)
|
for (final server in connections.catalog.servers)
|
||||||
Text('${index == 0 ? 'Preferred' : 'Backup $index'}: $address'),
|
SavedServerRow(
|
||||||
Wrap(
|
server: server,
|
||||||
spacing: 8,
|
selected: server.id == connections.catalog.active?.id,
|
||||||
children: [
|
busy: connections.busy,
|
||||||
if (server.id != connections.catalog.active?.id)
|
onAction: (act) => _act(context, server, act),
|
||||||
_button(
|
|
||||||
context,
|
|
||||||
'Use ${server.name}',
|
|
||||||
connections.busy
|
|
||||||
? null
|
|
||||||
: () => unawaited(connections.select(server.id)),
|
|
||||||
),
|
|
||||||
_button(
|
|
||||||
context,
|
|
||||||
'Edit ${server.name}',
|
|
||||||
connections.busy
|
|
||||||
? null
|
|
||||||
: () => unawaited(_edit(context, server)),
|
|
||||||
),
|
|
||||||
_button(
|
|
||||||
context,
|
|
||||||
'Remove ${server.name}',
|
|
||||||
connections.busy
|
|
||||||
? null
|
|
||||||
: () => unawaited(_remove(context, server)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
],
|
|
||||||
Align(
|
|
||||||
alignment: AlignmentDirectional.centerStart,
|
|
||||||
child: _button(
|
|
||||||
context,
|
|
||||||
'Add server',
|
|
||||||
connections.busy ? null : () => unawaited(_edit(context)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (connections.error != null)
|
|
||||||
Text(
|
|
||||||
connections.error!,
|
|
||||||
style: TextStyle(
|
|
||||||
color: usesCupertinoHost(context)
|
|
||||||
? CupertinoColors.systemRed.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.error,
|
|
||||||
),
|
),
|
||||||
|
SettingsRow(
|
||||||
|
action: true,
|
||||||
|
enabled: !connections.busy,
|
||||||
|
leading: Icon(cupertino ? CupertinoIcons.add : Icons.add),
|
||||||
|
title: const Text('Add server'),
|
||||||
|
onTap: () => unawaited(_edit(context)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class _SettingsAndroidDownloadSectionState
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
final cupertino = usesCupertinoHost(context);
|
||||||
final muted = cupertino
|
final muted = cupertino
|
||||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||||
)
|
)
|
||||||
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
@@ -81,18 +81,12 @@ class _SettingsAndroidDownloadSectionState
|
|||||||
);
|
);
|
||||||
final update = _update;
|
final update = _update;
|
||||||
if (_loading) {
|
if (_loading) {
|
||||||
return Padding(
|
return Text('Checking for the Android app…', style: muted);
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Text('Checking for the Android app…', style: muted),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (update == null) {
|
if (update == null) {
|
||||||
return Padding(
|
return Text(
|
||||||
padding: const EdgeInsets.all(16),
|
'This server offers no Android app yet. Build one with ./install --apk.',
|
||||||
child: Text(
|
style: muted,
|
||||||
'This server offers no Android app yet. Build one with ./install --apk.',
|
|
||||||
style: muted,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final button = cupertino
|
final button = cupertino
|
||||||
@@ -107,30 +101,27 @@ class _SettingsAndroidDownloadSectionState
|
|||||||
icon: const Icon(Icons.download),
|
icon: const Icon(Icons.download),
|
||||||
label: const Text('Download APK'),
|
label: const Text('Download APK'),
|
||||||
);
|
);
|
||||||
return Padding(
|
return Column(
|
||||||
padding: const EdgeInsets.all(16),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Text('Pipelines for Android · build ${update.versionCode}'),
|
||||||
children: [
|
if (update.notes.isNotEmpty) ...[
|
||||||
Text('Pipelines for Android · build ${update.versionCode}'),
|
const SizedBox(height: 4),
|
||||||
if (update.notes.isNotEmpty) ...[
|
Text(update.notes, style: muted),
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(update.notes, style: muted),
|
|
||||||
],
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
button,
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
'Open it on the phone, allow installs from this browser, then sign '
|
|
||||||
'in under Settings. Later builds arrive through Check for updates.',
|
|
||||||
style: muted,
|
|
||||||
),
|
|
||||||
if (_message case final message?) ...[
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(message, style: muted),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
),
|
const SizedBox(height: 12),
|
||||||
|
button,
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Open it on the phone and allow installs from this browser; later '
|
||||||
|
'builds arrive through Check for updates.',
|
||||||
|
style: muted,
|
||||||
|
),
|
||||||
|
if (_message case final message?) ...[
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(message, style: muted),
|
||||||
|
],
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import '../../ui/theme/app_theme.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@@ -189,37 +188,3 @@ class SettingsActions extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One standard settings card: a Material [Card] or an inset-grouped Cupertino
|
|
||||||
/// section, both using theme surfaces and native corner/padding defaults.
|
|
||||||
class SettingsCard extends StatelessWidget {
|
|
||||||
const SettingsCard({super.key, required this.child});
|
|
||||||
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (usesCupertinoControls(context)) {
|
|
||||||
return CupertinoListSection.insetGrouped(
|
|
||||||
backgroundColor: AppColors.groupedBackground,
|
|
||||||
margin: EdgeInsets.zero,
|
|
||||||
children: <Widget>[
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(settingsCardPadding),
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Card(
|
|
||||||
margin: EdgeInsets.zero,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(settingsCardPadding),
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,15 +5,14 @@ import '../../core/transport/pipelines_client.dart' as transport;
|
|||||||
const String serverUrlPlaceholder = 'ws://192.168.1.20:8081/connect';
|
const String serverUrlPlaceholder = 'ws://192.168.1.20:8081/connect';
|
||||||
|
|
||||||
const String serverUrlHelper =
|
const String serverUrlHelper =
|
||||||
'ws:// only on a trusted LAN/VPN, or wss:// for TLS. '
|
'ws:// only on a trusted LAN/VPN, otherwise wss://. Use the web '
|
||||||
'Use the authenticated web proxy’s /connect address when sign-in is required.';
|
'proxy’s /connect address when sign-in is required.';
|
||||||
|
|
||||||
const String workspacePlaceholder = '/Users/you/repos/pipelines';
|
const String workspacePlaceholder = '/Users/you/repos/pipelines';
|
||||||
|
|
||||||
const String workspaceHelper =
|
const String workspaceHelper =
|
||||||
'An absolute directory that already exists on the execution server. For '
|
'An existing absolute directory on the execution server, not the '
|
||||||
'Docker, mount the host directory at the same absolute path with its '
|
"phone's storage. With Docker, mount it at the same path and owner.";
|
||||||
"owner's UID/GID. This is not the phone's storage.";
|
|
||||||
|
|
||||||
const String workspacePathError =
|
const String workspacePathError =
|
||||||
'The workspace must be an absolute path that exists on the execution '
|
'The workspace must be an absolute path that exists on the execution '
|
||||||
@@ -22,9 +21,9 @@ const String workspacePathError =
|
|||||||
const String trustTitle = 'Trusted LAN/VPN only';
|
const String trustTitle = 'Trusted LAN/VPN only';
|
||||||
|
|
||||||
const String trustBody =
|
const String trustBody =
|
||||||
'Use the authenticated web address for remote access. Direct API access '
|
'Direct API access has no authentication: keep ws:// on a trusted '
|
||||||
'has no authentication and must stay on a trusted LAN/VPN. ws:// traffic '
|
'LAN/VPN, prefer wss://, and use the authenticated web address remotely. '
|
||||||
'is unencrypted; prefer wss://. Never enter provider credentials here.';
|
'Never enter provider credentials here.';
|
||||||
|
|
||||||
/// The workspace draft is valid when it is untouched (empty) or absolute. A
|
/// The workspace draft is valid when it is untouched (empty) or absolute. A
|
||||||
/// relative path is the one rejected value; the execution server resolves the
|
/// relative path is the one rejected value; the execution server resolves the
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../ui/theme/app_theme.dart';
|
||||||
|
import 'settings_layout.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
|
/// One grouped Settings section: a short header, a flat rounded group of rows
|
||||||
|
/// and an optional one-line footer.
|
||||||
|
///
|
||||||
|
/// Material draws the header in the theme's primary `titleSmall` and the rows
|
||||||
|
/// on a flat `surfaceContainer` with hairline dividers (no elevation).
|
||||||
|
/// Cupertino uses the stock inset-grouped [CupertinoListSection], whose rows
|
||||||
|
/// sit on `secondarySystemGroupedBackground` over the page's
|
||||||
|
/// `systemGroupedBackground`.
|
||||||
|
class SettingsGroup extends StatelessWidget {
|
||||||
|
const SettingsGroup({
|
||||||
|
super.key,
|
||||||
|
required this.children,
|
||||||
|
this.title,
|
||||||
|
this.footer,
|
||||||
|
this.leadingRows = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String? title;
|
||||||
|
final List<Widget> children;
|
||||||
|
|
||||||
|
/// A short line (or two) under the group: helper copy, a warning.
|
||||||
|
final Widget? footer;
|
||||||
|
|
||||||
|
/// Whether the rows carry leading icons: Cupertino then starts its
|
||||||
|
/// dividers at the titles (the stock inset), otherwise at the row text.
|
||||||
|
final bool leadingRows;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final title = this.title;
|
||||||
|
final footer = this.footer;
|
||||||
|
if (usesCupertinoControls(context)) {
|
||||||
|
return CupertinoListSection.insetGrouped(
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
|
backgroundColor: AppColors.groupedBackground,
|
||||||
|
header: title == null
|
||||||
|
? null
|
||||||
|
: Text(title, style: settingsHeaderStyle(context)),
|
||||||
|
footer: footer == null ? null : _footer(context, footer),
|
||||||
|
additionalDividerMargin: leadingRows ? null : 6,
|
||||||
|
children: children.isEmpty ? null : children,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
if (title != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
settingsRowInset,
|
||||||
|
0,
|
||||||
|
settingsRowInset,
|
||||||
|
settingsTitleGap,
|
||||||
|
),
|
||||||
|
child: Semantics(
|
||||||
|
header: true,
|
||||||
|
child: Text(title, style: settingsHeaderStyle(context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (children.isNotEmpty)
|
||||||
|
Material(
|
||||||
|
type: MaterialType.card,
|
||||||
|
color: theme.colorScheme.surfaceContainer,
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(settingsGroupRadius),
|
||||||
|
),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
for (final (index, child) in children.indexed) ...<Widget>[
|
||||||
|
if (index > 0)
|
||||||
|
Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: 1,
|
||||||
|
indent: settingsRowInset,
|
||||||
|
color: theme.colorScheme.outlineVariant,
|
||||||
|
),
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (footer != null) _footer(context, footer),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _footer(BuildContext context, Widget footer) {
|
||||||
|
final cupertino = usesCupertinoControls(context);
|
||||||
|
// Cupertino: the footnote size the stock plain list section uses for
|
||||||
|
// its own header and footer.
|
||||||
|
final style = cupertino
|
||||||
|
? settingsTextStyle(context, secondary: true).copyWith(fontSize: 13)
|
||||||
|
: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
);
|
||||||
|
final text = DefaultTextStyle.merge(style: style, child: footer);
|
||||||
|
// The Cupertino section pads its own footer.
|
||||||
|
if (cupertino) return text;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
settingsRowInset,
|
||||||
|
settingsFieldGap + 2,
|
||||||
|
settingsRowInset,
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
child: text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A group header's text style.
|
||||||
|
TextStyle settingsHeaderStyle(BuildContext context) {
|
||||||
|
if (usesCupertinoControls(context)) {
|
||||||
|
return settingsTextStyle(context).copyWith(fontWeight: FontWeight.w600);
|
||||||
|
}
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return (theme.textTheme.titleSmall ?? const TextStyle()).copyWith(
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Free-form content inside a group (a text field, a status block), padded
|
||||||
|
/// like a row so its edges line up with the rows' text.
|
||||||
|
class SettingsGroupItem extends StatelessWidget {
|
||||||
|
const SettingsGroupItem({super.key, required this.child});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsetsDirectional.symmetric(
|
||||||
|
horizontal: usesCupertinoControls(context) ? 20 : settingsRowInset,
|
||||||
|
vertical: 12,
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,34 +4,38 @@
|
|||||||
/// from the active Material or Cupertino theme, so text scaling and platform
|
/// from the active Material or Cupertino theme, so text scaling and platform
|
||||||
/// defaults are never overridden here.
|
/// defaults are never overridden here.
|
||||||
///
|
///
|
||||||
/// The rhythm follows the web Settings page: one centred column, an 8px gap
|
/// The page is a column of grouped sections. It starts at the top bar's own
|
||||||
/// between a section's compact title and its grouped body, and 16px between
|
/// side inset, so on a wide window the groups line up under the title pill
|
||||||
/// sections. The web's 12px field label and helper lines are secondary type in
|
/// instead of floating in the middle, and stops growing at a reading width.
|
||||||
/// [settingsTextStyle]/[SettingsTextField], not fixed sizes.
|
|
||||||
library;
|
library;
|
||||||
|
|
||||||
/// A comfortable reading width on wide windows; the body is centred inside it.
|
/// The widest the column of groups grows on a wide window.
|
||||||
const double settingsContentMaxWidth = 720;
|
const double settingsContentMaxWidth = 720;
|
||||||
|
|
||||||
/// Space between the Settings sections (web `.settings` grid gap).
|
/// Space between the Settings groups.
|
||||||
const double settingsSectionGap = 16;
|
const double settingsSectionGap = 24;
|
||||||
|
|
||||||
/// Space between a compact section title and its grouped body, and between the
|
/// Space between a group's header and its rows, and between stacked blocks
|
||||||
/// blocks inside a section (web `.settings-section` grid gap).
|
/// inside a row.
|
||||||
const double settingsTitleGap = 8;
|
const double settingsTitleGap = 8;
|
||||||
|
|
||||||
/// Space between a field label and its field, and between stacked secondary
|
/// Space between a field label and its field, and between stacked secondary
|
||||||
/// lines (web `.settings-field` gap).
|
/// lines.
|
||||||
const double settingsFieldGap = 4;
|
const double settingsFieldGap = 4;
|
||||||
|
|
||||||
/// Space between wrapped action buttons.
|
/// Space between wrapped action buttons.
|
||||||
const double settingsControlGap = 8;
|
const double settingsControlGap = 8;
|
||||||
|
|
||||||
/// Page insets on narrow windows: a little more room above the first title,
|
/// The page's side inset: the segmented bar's own, so the groups' edge lines
|
||||||
/// and a clear run-out below the last section (web `.settings` padding).
|
/// up with the title pill.
|
||||||
const double settingsPageTopPadding = 20;
|
const double settingsPageSidePadding = 12;
|
||||||
const double settingsPageSidePadding = 16;
|
|
||||||
|
/// Space below the top bar (added to its height) and below the last group.
|
||||||
|
const double settingsPageTopPadding = 8;
|
||||||
const double settingsPageBottomPadding = 32;
|
const double settingsPageBottomPadding = 32;
|
||||||
|
|
||||||
/// Padding inside a standard Material card / Cupertino inset row.
|
/// The inset of a row's text inside a Material group (the [ListTile] default).
|
||||||
const double settingsCardPadding = 16;
|
const double settingsRowInset = 16;
|
||||||
|
|
||||||
|
/// The corner radius of a Material group.
|
||||||
|
const double settingsGroupRadius = 16;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import '../attention/notify/notification_controller.dart';
|
import '../attention/notify/notification_controller.dart';
|
||||||
|
import '../attention/notify/notification_models.dart';
|
||||||
import '../attention/ui/notification_permission_tile.dart';
|
import '../attention/ui/notification_permission_tile.dart';
|
||||||
|
import 'settings_group.dart';
|
||||||
|
|
||||||
/// The Settings entry for the browser notification permission.
|
/// The Settings entry for the browser notification permission.
|
||||||
///
|
///
|
||||||
@@ -10,24 +12,28 @@ import '../attention/ui/notification_permission_tile.dart';
|
|||||||
/// Enable action. The controller is shared with the Runs attention surface, so
|
/// Enable action. The controller is shared with the Runs attention surface, so
|
||||||
/// the permission shown here is the one that gates the live notices.
|
/// the permission shown here is the one that gates the live notices.
|
||||||
class SettingsNotificationsSection extends StatelessWidget {
|
class SettingsNotificationsSection extends StatelessWidget {
|
||||||
const SettingsNotificationsSection({
|
const SettingsNotificationsSection({super.key, required this.controller});
|
||||||
super.key,
|
|
||||||
required this.controller,
|
|
||||||
});
|
|
||||||
|
|
||||||
final NotificationController controller;
|
final NotificationController controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => AnimatedBuilder(
|
Widget build(BuildContext context) => AnimatedBuilder(
|
||||||
animation: controller,
|
animation: controller,
|
||||||
builder: (context, _) => NotificationPermissionTile(
|
builder: (context, _) => SettingsGroup(
|
||||||
state: controller.permission,
|
title: notificationSectionTitle,
|
||||||
asked: controller.asked,
|
children: <Widget>[
|
||||||
onRequest: () {
|
SettingsGroupItem(
|
||||||
// The platform answer updates the controller; the AnimationBuilder above
|
child: NotificationPermissionTile(
|
||||||
// redraws the tile with its own words.
|
state: controller.permission,
|
||||||
controller.requestPermission();
|
asked: controller.asked,
|
||||||
},
|
onRequest: () {
|
||||||
|
// The platform answer updates the controller; the
|
||||||
|
// AnimationBuilder above redraws the tile with its own words.
|
||||||
|
controller.requestPermission();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../core/api_gateway.dart';
|
import '../../core/api_gateway.dart';
|
||||||
import 'ntfy_settings_controller.dart';
|
import 'ntfy_settings_controller.dart';
|
||||||
import 'settings_layout.dart';
|
import 'settings_group.dart';
|
||||||
import 'settings_theme.dart';
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
/// The section title for the server's ntfy notification choices.
|
/// The section title for the server's ntfy notification choices.
|
||||||
@@ -93,36 +93,24 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
|
|||||||
enabled ? (value) => _controller.toggle(setting.key, value) : null,
|
enabled ? (value) => _controller.toggle(setting.key, value) : null,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
return Column(
|
final retry = values == null && widget.connected && !_controller.loading;
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
return SettingsGroup(
|
||||||
children: <Widget>[
|
title: ntfySectionTitle,
|
||||||
Text(
|
footer: Column(
|
||||||
ntfySectionSubtitle,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
style: settingsTextStyle(context, secondary: true),
|
children: <Widget>[
|
||||||
),
|
const Text(ntfySectionSubtitle),
|
||||||
if (status.isNotEmpty) ...<Widget>[
|
if (status.isNotEmpty) Text(status),
|
||||||
const SizedBox(height: settingsFieldGap),
|
if (_controller.error.isNotEmpty)
|
||||||
Text(status, style: settingsTextStyle(context, secondary: true)),
|
Semantics(
|
||||||
],
|
liveRegion: true,
|
||||||
const SizedBox(height: settingsFieldGap),
|
child: Text(
|
||||||
if (cupertino)
|
_controller.error,
|
||||||
CupertinoListSection.insetGrouped(
|
key: ntfyErrorKey,
|
||||||
margin: EdgeInsets.zero,
|
style: TextStyle(color: settingsErrorColor(context)),
|
||||||
children: tiles,
|
),
|
||||||
)
|
|
||||||
else
|
|
||||||
...tiles,
|
|
||||||
if (_controller.error.isNotEmpty) ...<Widget>[
|
|
||||||
const SizedBox(height: settingsFieldGap),
|
|
||||||
Semantics(
|
|
||||||
liveRegion: true,
|
|
||||||
child: Text(
|
|
||||||
_controller.error,
|
|
||||||
key: ntfyErrorKey,
|
|
||||||
style: settingsTextStyle(context, error: true),
|
|
||||||
),
|
),
|
||||||
),
|
if (_controller.error.isNotEmpty && retry)
|
||||||
if (values == null && widget.connected && !_controller.loading)
|
|
||||||
Align(
|
Align(
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: cupertino
|
child: cupertino
|
||||||
@@ -137,7 +125,8 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
|
children: tiles,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,16 +140,14 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
|
|||||||
return CupertinoListTile(
|
return CupertinoListTile(
|
||||||
key: ntfySettingKey(setting.key),
|
key: ntfySettingKey(setting.key),
|
||||||
title: Text(setting.label),
|
title: Text(setting.label),
|
||||||
trailing: CupertinoCheckbox(
|
// iOS settings rows toggle with a switch; an unchecked checkbox is
|
||||||
value: value,
|
// nearly invisible on the grouped row.
|
||||||
onChanged: onChanged == null ? null : (next) => onChanged(next!),
|
trailing: CupertinoSwitch(value: value, onChanged: onChanged),
|
||||||
),
|
|
||||||
onTap: onChanged == null ? null : () => onChanged(!value),
|
onTap: onChanged == null ? null : () => onChanged(!value),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
key: ntfySettingKey(setting.key),
|
key: ntfySettingKey(setting.key),
|
||||||
contentPadding: EdgeInsets.zero,
|
|
||||||
title: Text(setting.label),
|
title: Text(setting.label),
|
||||||
value: value,
|
value: value,
|
||||||
onChanged: onChanged == null ? null : (next) => onChanged(next!),
|
onChanged: onChanged == null ? null : (next) => onChanged(next!),
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
import '../../ui/theme/app_theme.dart';
|
||||||
|
import 'settings_layout.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
|
/// The Settings page's scrolling column of groups.
|
||||||
|
///
|
||||||
|
/// It scrolls behind the floating top bar: instead of a top [SafeArea] it pads
|
||||||
|
/// its start by the bar's height (the top media padding), and its end by the
|
||||||
|
/// floating tab bar's (the bottom media padding), so at rest nothing is hidden
|
||||||
|
/// and scrolled groups pass behind the glass pills. The column starts at the
|
||||||
|
/// bar's own side inset, so the groups line up under the title pill, and stops
|
||||||
|
/// at [settingsContentMaxWidth] on a wide window. Cupertino paints the page in
|
||||||
|
/// the grouped background its inset-grouped sections are designed for.
|
||||||
|
class SettingsPageBody extends StatelessWidget {
|
||||||
|
const SettingsPageBody({super.key, required this.children});
|
||||||
|
|
||||||
|
final List<Widget> children;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final insets = MediaQuery.paddingOf(context);
|
||||||
|
// The inset-grouped section already pads above its own header.
|
||||||
|
final gap = usesCupertinoControls(context)
|
||||||
|
? settingsTitleGap
|
||||||
|
: settingsSectionGap;
|
||||||
|
final Widget list = SingleChildScrollView(
|
||||||
|
key: const ValueKey<String>('settings.scroll'),
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
insets.left + settingsPageSidePadding,
|
||||||
|
insets.top + settingsPageTopPadding,
|
||||||
|
insets.right + settingsPageSidePadding,
|
||||||
|
insets.bottom + settingsPageBottomPadding,
|
||||||
|
),
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.topStart,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: settingsContentMaxWidth),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
for (final (index, child) in children.indexed) ...<Widget>[
|
||||||
|
if (index > 0) SizedBox(height: gap),
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (!usesCupertinoControls(context)) return list;
|
||||||
|
return ColoredBox(
|
||||||
|
color: settingsCupertinoBackground.resolveFrom(context),
|
||||||
|
child: list,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The Cupertino Settings page background: the system grouped background, so
|
||||||
|
/// the inset sections' rows read as raised cards in light and dark.
|
||||||
|
const CupertinoDynamicColor settingsCupertinoBackground =
|
||||||
|
AppColors.groupedBackground;
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
|
/// One row of a [SettingsGroup]: Material [ListTile], Cupertino
|
||||||
|
/// [CupertinoListTile]. The subtitle wraps (the Cupertino tile otherwise caps
|
||||||
|
/// it at one line), so addresses and status details stay readable at large
|
||||||
|
/// text.
|
||||||
|
class SettingsRow extends StatelessWidget {
|
||||||
|
const SettingsRow({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.leading,
|
||||||
|
this.trailing,
|
||||||
|
this.onTap,
|
||||||
|
this.chevron = false,
|
||||||
|
this.action = false,
|
||||||
|
this.enabled = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Widget title;
|
||||||
|
final Widget? subtitle;
|
||||||
|
final Widget? leading;
|
||||||
|
final Widget? trailing;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
|
/// A navigation row: shows the platform's disclosure chevron.
|
||||||
|
final bool chevron;
|
||||||
|
|
||||||
|
/// A command row (Reconnect, Add server): the title takes the accent
|
||||||
|
/// colour, as a button would.
|
||||||
|
final bool action;
|
||||||
|
final bool enabled;
|
||||||
|
|
||||||
|
Widget _wrapping(Widget child) => Builder(
|
||||||
|
builder: (context) => DefaultTextStyle(
|
||||||
|
style: DefaultTextStyle.of(context).style,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final tap = enabled ? onTap : null;
|
||||||
|
final subtitle = this.subtitle;
|
||||||
|
if (usesCupertinoControls(context)) {
|
||||||
|
final accent = CupertinoTheme.of(context).primaryColor;
|
||||||
|
final disabled = CupertinoColors.tertiaryLabel.resolveFrom(context);
|
||||||
|
return CupertinoListTile(
|
||||||
|
leading: leading == null
|
||||||
|
? null
|
||||||
|
: IconTheme.merge(
|
||||||
|
data: IconThemeData(color: enabled ? accent : disabled),
|
||||||
|
child: leading!,
|
||||||
|
),
|
||||||
|
title: DefaultTextStyle.merge(
|
||||||
|
style: TextStyle(
|
||||||
|
color: !enabled
|
||||||
|
? disabled
|
||||||
|
: action
|
||||||
|
? accent
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
child: title,
|
||||||
|
),
|
||||||
|
subtitle: subtitle == null ? null : _wrapping(subtitle),
|
||||||
|
trailing:
|
||||||
|
trailing ?? (chevron ? const CupertinoListTileChevron() : null),
|
||||||
|
onTap: tap,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
return ListTile(
|
||||||
|
enabled: enabled,
|
||||||
|
leading: leading,
|
||||||
|
iconColor: action ? scheme.primary : null,
|
||||||
|
textColor: action ? scheme.primary : null,
|
||||||
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
trailing: trailing ?? (chevron ? const Icon(Icons.chevron_right) : null),
|
||||||
|
onTap: tap,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import '../../ui/theme/app_theme.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_keys.dart';
|
import 'settings_keys.dart';
|
||||||
|
import 'settings_row.dart';
|
||||||
import 'settings_theme.dart';
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
/// The Settings entry to the saved-schedule list.
|
/// The Settings entry to the saved-schedule list.
|
||||||
@@ -13,37 +13,23 @@ const String settingsSchedulesLabel = 'Browse schedules';
|
|||||||
const String settingsSchedulesSecondary =
|
const String settingsSchedulesSecondary =
|
||||||
'Saved run configurations for every pipeline.';
|
'Saved run configurations for every pipeline.';
|
||||||
|
|
||||||
|
/// A navigation row (chevron) for a Settings group.
|
||||||
class SettingsSchedulesSection extends StatelessWidget {
|
class SettingsSchedulesSection extends StatelessWidget {
|
||||||
const SettingsSchedulesSection({super.key, required this.onOpen});
|
const SettingsSchedulesSection({super.key, required this.onOpen});
|
||||||
|
|
||||||
final VoidCallback onOpen;
|
final VoidCallback onOpen;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => SettingsRow(
|
||||||
if (usesCupertinoControls(context)) {
|
key: SettingsKeys.schedules,
|
||||||
return CupertinoListSection.insetGrouped(
|
leading: Icon(
|
||||||
backgroundColor: AppColors.groupedBackground,
|
usesCupertinoControls(context)
|
||||||
margin: EdgeInsets.zero,
|
? CupertinoIcons.calendar
|
||||||
children: <Widget>[
|
: Icons.event_repeat_outlined,
|
||||||
CupertinoListTile(
|
),
|
||||||
key: SettingsKeys.schedules,
|
title: const Text(settingsSchedulesLabel),
|
||||||
title: const Text(settingsSchedulesLabel),
|
subtitle: const Text(settingsSchedulesSecondary),
|
||||||
subtitle: const Text(settingsSchedulesSecondary),
|
chevron: true,
|
||||||
trailing: const CupertinoListTileChevron(),
|
onTap: onOpen,
|
||||||
onTap: onOpen,
|
);
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Card(
|
|
||||||
margin: EdgeInsets.zero,
|
|
||||||
child: ListTile(
|
|
||||||
key: SettingsKeys.schedules,
|
|
||||||
title: const Text(settingsSchedulesLabel),
|
|
||||||
subtitle: const Text(settingsSchedulesSecondary),
|
|
||||||
trailing: const Icon(Icons.chevron_right),
|
|
||||||
onTap: onOpen,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../core/transport/pipelines_client.dart' as transport;
|
import '../../core/transport/pipelines_client.dart' as transport;
|
||||||
import '../attention/notify/notification_controller.dart';
|
import '../attention/notify/notification_controller.dart';
|
||||||
import '../attention/notify/notification_models.dart';
|
|
||||||
import 'default_endpoint.dart';
|
import 'default_endpoint.dart';
|
||||||
import 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
import 'settings_controls.dart';
|
import 'settings_controls.dart';
|
||||||
import 'settings_layout.dart';
|
import 'settings_group.dart';
|
||||||
|
import 'settings_page_body.dart';
|
||||||
import 'settings_notifications_section.dart';
|
import 'settings_notifications_section.dart';
|
||||||
import 'settings_ntfy_section.dart';
|
import 'settings_ntfy_section.dart';
|
||||||
import 'settings_android_download_section.dart';
|
import 'settings_android_download_section.dart';
|
||||||
@@ -24,7 +24,6 @@ import 'settings_templates_section.dart';
|
|||||||
import 'server_connections.dart';
|
import 'server_connections.dart';
|
||||||
import 'saved_servers_section.dart';
|
import 'saved_servers_section.dart';
|
||||||
import 'managed_connection_section.dart';
|
import 'managed_connection_section.dart';
|
||||||
import '../../ui/adaptive/floating_bar_layout.dart';
|
|
||||||
|
|
||||||
/// The Settings destination: the server connection and the server-side
|
/// The Settings destination: the server connection and the server-side
|
||||||
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
|
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
|
||||||
@@ -133,148 +132,79 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get _endpoint => widget.servers == null
|
||||||
|
? _controller.serverUrl
|
||||||
|
: widget.client.endpoint?.toString() ?? '';
|
||||||
|
|
||||||
|
void _reconnectAfterSignIn() {
|
||||||
|
final endpoint = widget.client.endpoint;
|
||||||
|
if (endpoint != null) {
|
||||||
|
widget.client.connectAny(
|
||||||
|
widget.client.endpoints.isEmpty ? [endpoint] : widget.client.endpoints,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// The content scrolls behind a floating tab bar and pads its end clear of
|
final servers = widget.servers;
|
||||||
// it (or of the system inset on its own page).
|
final content = SettingsPageBody(
|
||||||
final content = SafeArea(
|
children: <Widget>[
|
||||||
bottom: false,
|
if (servers != null) ...<Widget>[
|
||||||
child: SingleChildScrollView(
|
SavedServersSection(connections: servers),
|
||||||
// Web `.settings` page insets: 20 above the title, 16 at the sides and
|
ManagedConnectionSection(
|
||||||
// a clear 32 below the last section.
|
client: widget.client,
|
||||||
padding: withFloatingBarClearance(
|
controller: _controller,
|
||||||
context,
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(
|
|
||||||
settingsPageSidePadding,
|
|
||||||
settingsPageTopPadding,
|
|
||||||
settingsPageSidePadding,
|
|
||||||
settingsPageBottomPadding,
|
|
||||||
),
|
),
|
||||||
),
|
] else
|
||||||
child: Center(
|
SettingsConnectionSection(
|
||||||
child: ConstrainedBox(
|
controller: _controller,
|
||||||
constraints: const BoxConstraints(
|
serverUrlField: _serverUrlField,
|
||||||
maxWidth: settingsContentMaxWidth,
|
),
|
||||||
),
|
// A phone signs in at the web login; a browser has its own.
|
||||||
child: Column(
|
if (widget.showSignIn)
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
_single(
|
||||||
children: <Widget>[
|
'Sign in',
|
||||||
if (widget.servers != null) ...[
|
SettingsSignInSection(
|
||||||
_SettingsSection(
|
endpoint: _endpoint,
|
||||||
title: 'Servers',
|
onChanged: _reconnectAfterSignIn,
|
||||||
child: SavedServersSection(connections: widget.servers!),
|
|
||||||
),
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
],
|
|
||||||
_SettingsSection(
|
|
||||||
title: 'Connection',
|
|
||||||
child: widget.servers != null
|
|
||||||
? ManagedConnectionSection(
|
|
||||||
client: widget.client,
|
|
||||||
controller: _controller,
|
|
||||||
)
|
|
||||||
: SettingsConnectionSection(
|
|
||||||
controller: _controller,
|
|
||||||
serverUrlField: _serverUrlField,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// A phone signs in at the web login; a browser has its own.
|
|
||||||
if (widget.showSignIn) ...<Widget>[
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
_SettingsSection(
|
|
||||||
title: 'Sign in',
|
|
||||||
child: SettingsSignInSection(
|
|
||||||
endpoint: widget.servers == null
|
|
||||||
? _controller.serverUrl
|
|
||||||
: widget.client.endpoint?.toString() ?? '',
|
|
||||||
onChanged: () {
|
|
||||||
final endpoint = widget.client.endpoint;
|
|
||||||
if (endpoint != null) {
|
|
||||||
widget.client.connectAny(
|
|
||||||
widget.client.endpoints.isEmpty
|
|
||||||
? [endpoint]
|
|
||||||
: widget.client.endpoints,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
// The web page links the Android app the server offers.
|
|
||||||
if (widget.showAndroidDownload) ...<Widget>[
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
const _SettingsSection(
|
|
||||||
title: 'Android app',
|
|
||||||
child: SettingsAndroidDownloadSection(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
// A phone installs newer builds from the server.
|
|
||||||
if (widget.showSignIn && appUpdatesSupported) ...<Widget>[
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
_SettingsSection(
|
|
||||||
title: 'App updates',
|
|
||||||
child: SettingsUpdatesSection(
|
|
||||||
endpoint: widget.servers == null
|
|
||||||
? _controller.serverUrl
|
|
||||||
: widget.client.endpoint?.toString() ?? '',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
_SettingsSection(
|
|
||||||
title: 'Workspace',
|
|
||||||
child: SettingsWorkspaceSection(
|
|
||||||
controller: _controller,
|
|
||||||
workspaceField: _workspaceField,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.notifications != null) ...<Widget>[
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
_SettingsSection(
|
|
||||||
title: notificationSectionTitle,
|
|
||||||
child: SettingsNotificationsSection(
|
|
||||||
controller: widget.notifications!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
// The server's ntfy choices, beside the in-app permission.
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
_SettingsSection(
|
|
||||||
title: ntfySectionTitle,
|
|
||||||
child: SettingsNtfySection(
|
|
||||||
gateway: widget.client,
|
|
||||||
connected:
|
|
||||||
widget.client.state.kind ==
|
|
||||||
transport.ConnectionKind.connected,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.onOpenSchedules != null) ...<Widget>[
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
_SettingsSection(
|
|
||||||
title: 'Schedules',
|
|
||||||
child: SettingsSchedulesSection(
|
|
||||||
onOpen: widget.onOpenSchedules!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
if (widget.onOpenTemplates != null) ...<Widget>[
|
|
||||||
const SizedBox(height: settingsSectionGap),
|
|
||||||
_SettingsSection(
|
|
||||||
title: 'Templates',
|
|
||||||
child: SettingsTemplatesSection(
|
|
||||||
onOpen: widget.onOpenTemplates!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// The web page links the Android app the server offers.
|
||||||
|
if (widget.showAndroidDownload)
|
||||||
|
_single('Android app', const SettingsAndroidDownloadSection()),
|
||||||
|
// A phone installs newer builds from the server.
|
||||||
|
if (widget.showSignIn && appUpdatesSupported)
|
||||||
|
_single('App updates', SettingsUpdatesSection(endpoint: _endpoint)),
|
||||||
|
SettingsWorkspaceSection(
|
||||||
|
controller: _controller,
|
||||||
|
workspaceField: _workspaceField,
|
||||||
),
|
),
|
||||||
),
|
if (widget.notifications case final notifications?)
|
||||||
|
SettingsNotificationsSection(controller: notifications),
|
||||||
|
// The server's ntfy choices, beside the in-app permission.
|
||||||
|
SettingsNtfySection(
|
||||||
|
gateway: widget.client,
|
||||||
|
connected:
|
||||||
|
widget.client.state.kind == transport.ConnectionKind.connected,
|
||||||
|
),
|
||||||
|
if (widget.onOpenSchedules != null || widget.onOpenTemplates != null)
|
||||||
|
SettingsGroup(
|
||||||
|
title: 'Library',
|
||||||
|
leadingRows: true,
|
||||||
|
children: <Widget>[
|
||||||
|
if (widget.onOpenSchedules case final open?)
|
||||||
|
SettingsSchedulesSection(onOpen: open),
|
||||||
|
if (widget.onOpenTemplates case final open?)
|
||||||
|
SettingsTemplatesSection(onOpen: open),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
if (widget.embedded) return content;
|
if (widget.embedded) return content;
|
||||||
if (usesCupertinoControls(context)) {
|
if (usesCupertinoControls(context)) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
|
backgroundColor: settingsCupertinoBackground,
|
||||||
navigationBar: const SegmentedBar(cupertino: true, title: 'Settings'),
|
navigationBar: const SegmentedBar(cupertino: true, title: 'Settings'),
|
||||||
child: content,
|
child: content,
|
||||||
);
|
);
|
||||||
@@ -285,29 +215,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
body: content,
|
body: content,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// A group holding one free-form block (a form, a status with buttons).
|
||||||
/// One grouped Settings section: a compact title followed by its body at the
|
Widget _single(String title, Widget child) => SettingsGroup(
|
||||||
/// web's 8px title gap. Sections are separated by [settingsSectionGap]. A null
|
title: title,
|
||||||
/// title lets a body (the notification tile) draw its own compact heading.
|
children: <Widget>[SettingsGroupItem(child: child)],
|
||||||
class _SettingsSection extends StatelessWidget {
|
);
|
||||||
const _SettingsSection({required this.child, this.title});
|
|
||||||
|
|
||||||
final String? title;
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final title = this.title;
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: <Widget>[
|
|
||||||
if (title != null) ...<Widget>[
|
|
||||||
Text(title, style: settingsTextStyle(context, title: true)),
|
|
||||||
const SizedBox(height: settingsTitleGap),
|
|
||||||
],
|
|
||||||
child,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,20 @@ import 'dart:async';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/transport/pipelines_client.dart' as transport;
|
|
||||||
import 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
import 'settings_controls.dart';
|
import 'settings_controls.dart';
|
||||||
import 'settings_copy.dart';
|
import 'settings_copy.dart';
|
||||||
|
import 'settings_group.dart';
|
||||||
import 'settings_keys.dart';
|
import 'settings_keys.dart';
|
||||||
import 'settings_trust_warning.dart';
|
|
||||||
import 'settings_layout.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
|
export 'settings_status_row.dart';
|
||||||
/// the trusted-network warning. Every action goes through the shared client the
|
|
||||||
|
/// 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.
|
/// controller was given; nothing here opens a second connection.
|
||||||
class SettingsConnectionSection extends StatelessWidget {
|
class SettingsConnectionSection extends StatelessWidget {
|
||||||
const SettingsConnectionSection({
|
const SettingsConnectionSection({
|
||||||
@@ -26,133 +30,89 @@ class SettingsConnectionSection extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
final errors = <String>[
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
if (controller.endpointSaveError.isNotEmpty) controller.endpointSaveError,
|
||||||
|
if (controller.actionError.isNotEmpty) controller.actionError,
|
||||||
|
];
|
||||||
|
return SettingsGroup(
|
||||||
|
title: 'Connection',
|
||||||
|
footer: settingsConnectionFooter(controller),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SettingsTextField(
|
SettingsGroupItem(
|
||||||
controller: serverUrlField,
|
child: Column(
|
||||||
key: SettingsKeys.serverUrl,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
label: 'Server URL',
|
children: <Widget>[
|
||||||
placeholder: serverUrlPlaceholder,
|
SettingsTextField(
|
||||||
helper: serverUrlHelper,
|
controller: serverUrlField,
|
||||||
error: controller.urlError,
|
key: SettingsKeys.serverUrl,
|
||||||
onChanged: controller.updateServerUrl,
|
label: 'Server URL',
|
||||||
maxLines: 2,
|
placeholder: serverUrlPlaceholder,
|
||||||
),
|
helper: serverUrlHelper,
|
||||||
const SizedBox(height: settingsTitleGap),
|
error: controller.urlError,
|
||||||
SettingsActions(
|
onChanged: controller.updateServerUrl,
|
||||||
primaryLabel: controller.primaryActionLabel,
|
maxLines: 2,
|
||||||
secondaryLabel: controller.secondaryActionLabel,
|
),
|
||||||
primaryKey: controller.connectionActive
|
const SizedBox(height: settingsTitleGap),
|
||||||
? SettingsKeys.disconnect
|
SettingsActions(
|
||||||
: SettingsKeys.connect,
|
primaryLabel: controller.primaryActionLabel,
|
||||||
secondaryKey: controller.connectionActive
|
secondaryLabel: controller.secondaryActionLabel,
|
||||||
? SettingsKeys.connect
|
primaryKey: controller.connectionActive
|
||||||
: SettingsKeys.reconnect,
|
? SettingsKeys.disconnect
|
||||||
onPrimary: () => unawaited(
|
: SettingsKeys.connect,
|
||||||
controller.connectionActive
|
secondaryKey: controller.connectionActive
|
||||||
? controller.disconnect()
|
? SettingsKeys.connect
|
||||||
: controller.connect(),
|
: SettingsKeys.reconnect,
|
||||||
),
|
onPrimary: () => unawaited(
|
||||||
onSecondary: () => unawaited(
|
controller.connectionActive
|
||||||
controller.connectionActive
|
? controller.disconnect()
|
||||||
? controller.connect()
|
: controller.connect(),
|
||||||
: controller.reconnect(),
|
),
|
||||||
|
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>[
|
SettingsStatusRow(controller: controller),
|
||||||
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),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The status card's first line is the state; the remaining lines are the
|
/// The Connection group's footer: the trust warning, then a protocol
|
||||||
/// build/time/reason/backoff facts. Missing ping values stay explicit.
|
/// mismatch when the server reports one.
|
||||||
class SettingsStatusCard extends StatelessWidget {
|
Widget settingsConnectionFooter(SettingsController controller) => Column(
|
||||||
const SettingsStatusCard({super.key, required this.controller});
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
final SettingsController controller;
|
const SettingsTrustWarning(),
|
||||||
|
if (controller.protocolWarning case final warning?)
|
||||||
@override
|
Builder(
|
||||||
Widget build(BuildContext context) {
|
// A live region announces a mismatch the operator did not ask to
|
||||||
final theme = Theme.of(context);
|
// reveal.
|
||||||
final state = controller.connection;
|
builder: (context) => Padding(
|
||||||
final lines = controller.connectionLines;
|
padding: const EdgeInsets.only(top: settingsTitleGap),
|
||||||
final title = lines.isEmpty ? '' : lines.first;
|
child: Semantics(
|
||||||
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
liveRegion: true,
|
||||||
final titleColor = switch (state.kind) {
|
child: Text(
|
||||||
transport.ConnectionKind.connected =>
|
warning,
|
||||||
usesCupertinoControls(context)
|
style: TextStyle(color: settingsErrorColor(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)),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
],
|
||||||
}
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/// Workspace controls. The path is resolved by the execution server, and the
|
/// 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 {
|
class SettingsWorkspaceSection extends StatelessWidget {
|
||||||
const SettingsWorkspaceSection({
|
const SettingsWorkspaceSection({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -167,46 +127,55 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final saveError = controller.workspaceSaveError;
|
final saveError = controller.workspaceSaveError;
|
||||||
final canSave = canSaveWorkspace(controller.workspaceDraft);
|
final canSave = canSaveWorkspace(controller.workspaceDraft);
|
||||||
return Column(
|
final save = canSave ? () => unawaited(controller.saveWorkspace()) : null;
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
return SettingsGroup(
|
||||||
|
title: 'Workspace',
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
SettingsTextField(
|
SettingsGroupItem(
|
||||||
controller: workspaceField,
|
child: Column(
|
||||||
key: SettingsKeys.workspace,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
label: 'Workspace path (on the server)',
|
children: <Widget>[
|
||||||
placeholder: workspacePlaceholder,
|
SettingsTextField(
|
||||||
helper: workspaceHelper,
|
controller: workspaceField,
|
||||||
error: controller.workspaceError,
|
key: SettingsKeys.workspace,
|
||||||
onChanged: controller.updateWorkspace,
|
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)),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../core/transport/pipelines_client.dart' as transport;
|
||||||
|
import 'settings_controller.dart';
|
||||||
|
import 'settings_row.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
|
/// The connection's state as one row: a status icon, the state as the title
|
||||||
|
/// and the build/time/reason/backoff facts as its subtitle lines. Missing ping
|
||||||
|
/// values stay explicit.
|
||||||
|
class SettingsStatusRow extends StatelessWidget {
|
||||||
|
const SettingsStatusRow({super.key, required this.controller});
|
||||||
|
|
||||||
|
final SettingsController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino = usesCupertinoControls(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 connectedColor = cupertino
|
||||||
|
? CupertinoColors.systemGreen.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.primary;
|
||||||
|
final Color? color = switch (state.kind) {
|
||||||
|
transport.ConnectionKind.connected => connectedColor,
|
||||||
|
transport.ConnectionKind.disconnected => settingsErrorColor(context),
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
final Widget leading = switch (state.kind) {
|
||||||
|
transport.ConnectionKind.connecting =>
|
||||||
|
cupertino
|
||||||
|
? const CupertinoActivityIndicator()
|
||||||
|
: const SizedBox.square(
|
||||||
|
dimension: 20,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
),
|
||||||
|
transport.ConnectionKind.connected => Icon(
|
||||||
|
cupertino ? CupertinoIcons.checkmark_circle_fill : Icons.check_circle,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
transport.ConnectionKind.disconnected => Icon(
|
||||||
|
cupertino ? CupertinoIcons.xmark_circle_fill : Icons.error_outline,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
transport.ConnectionKind.idle => Icon(
|
||||||
|
cupertino ? CupertinoIcons.circle : Icons.radio_button_unchecked,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
return SettingsRow(
|
||||||
|
leading: leading,
|
||||||
|
title: Text(
|
||||||
|
title,
|
||||||
|
style: TextStyle(color: color, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
subtitle: details.isEmpty
|
||||||
|
? null
|
||||||
|
: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[for (final line in details) Text(line)],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +1,36 @@
|
|||||||
import '../../ui/theme/app_theme.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_keys.dart';
|
import 'settings_keys.dart';
|
||||||
|
import 'settings_row.dart';
|
||||||
import 'settings_theme.dart';
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
/// The Settings entry to the Templates gallery.
|
/// The Settings entry to the Templates gallery.
|
||||||
///
|
///
|
||||||
/// The row wording matches the current web Settings page: `Browse templates`
|
/// The row wording matches the web Settings page: `Browse templates` with the
|
||||||
/// with the server-catalogue secondary line, under its `Templates` heading. It
|
/// server-catalogue secondary line. It only opens the route; loading the
|
||||||
/// only opens the route; loading the catalogue is the gallery's own read.
|
/// catalogue is the gallery's own read.
|
||||||
const String settingsTemplatesLabel = 'Browse templates';
|
const String settingsTemplatesLabel = 'Browse templates';
|
||||||
const String settingsTemplatesSecondary =
|
const String settingsTemplatesSecondary =
|
||||||
'Reusable pipeline definitions offered by the server.';
|
'Reusable pipeline definitions offered by the server.';
|
||||||
|
|
||||||
|
/// A navigation row (chevron) for a Settings group.
|
||||||
class SettingsTemplatesSection extends StatelessWidget {
|
class SettingsTemplatesSection extends StatelessWidget {
|
||||||
const SettingsTemplatesSection({super.key, required this.onOpen});
|
const SettingsTemplatesSection({super.key, required this.onOpen});
|
||||||
|
|
||||||
final VoidCallback onOpen;
|
final VoidCallback onOpen;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => SettingsRow(
|
||||||
if (usesCupertinoControls(context)) {
|
key: SettingsKeys.templates,
|
||||||
return CupertinoListSection.insetGrouped(
|
leading: Icon(
|
||||||
backgroundColor: AppColors.groupedBackground,
|
usesCupertinoControls(context)
|
||||||
margin: EdgeInsets.zero,
|
? CupertinoIcons.square_grid_2x2
|
||||||
children: <Widget>[
|
: Icons.widgets_outlined,
|
||||||
CupertinoListTile(
|
),
|
||||||
key: SettingsKeys.templates,
|
title: const Text(settingsTemplatesLabel),
|
||||||
title: const Text(settingsTemplatesLabel),
|
subtitle: const Text(settingsTemplatesSecondary),
|
||||||
subtitle: const Text(settingsTemplatesSecondary),
|
chevron: true,
|
||||||
trailing: const CupertinoListTileChevron(),
|
onTap: onOpen,
|
||||||
onTap: onOpen,
|
);
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Card(
|
|
||||||
margin: EdgeInsets.zero,
|
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: ListTile(
|
|
||||||
key: SettingsKeys.templates,
|
|
||||||
leading: const Icon(Icons.widgets_outlined),
|
|
||||||
title: const Text(settingsTemplatesLabel),
|
|
||||||
subtitle: const Text(settingsTemplatesSecondary),
|
|
||||||
trailing: const Icon(Icons.chevron_right),
|
|
||||||
onTap: onOpen,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_controls.dart';
|
|
||||||
import 'settings_copy.dart';
|
import 'settings_copy.dart';
|
||||||
import 'settings_layout.dart';
|
import 'settings_layout.dart';
|
||||||
|
import 'settings_theme.dart';
|
||||||
|
|
||||||
/// The trusted-network warning, using the app's exact web/Android copy. It is a
|
/// The trusted-network warning, shown as the Connection group's footer: a
|
||||||
/// card, not a dialog: no confirmation is required to read it.
|
/// warning icon, the title in the error colour and the short body. It is not a
|
||||||
|
/// dialog: no confirmation is required to read it.
|
||||||
class SettingsTrustWarning extends StatelessWidget {
|
class SettingsTrustWarning extends StatelessWidget {
|
||||||
const SettingsTrustWarning({super.key});
|
const SettingsTrustWarning({super.key});
|
||||||
|
|
||||||
@@ -15,30 +16,25 @@ class SettingsTrustWarning extends StatelessWidget {
|
|||||||
final icon = usesCupertinoControls(context)
|
final icon = usesCupertinoControls(context)
|
||||||
? CupertinoIcons.exclamationmark_triangle
|
? CupertinoIcons.exclamationmark_triangle
|
||||||
: Icons.warning_amber_rounded;
|
: Icons.warning_amber_rounded;
|
||||||
return SettingsCard(
|
final error = settingsErrorColor(context);
|
||||||
child: Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(icon, color: settingsErrorColor(context)),
|
Icon(icon, color: error, semanticLabel: 'Warning'),
|
||||||
const SizedBox(width: settingsControlGap),
|
const SizedBox(width: settingsControlGap),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
trustTitle,
|
trustTitle,
|
||||||
style: settingsTextStyle(context, title: true, error: true),
|
style: TextStyle(color: error, fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
const SizedBox(height: settingsFieldGap),
|
const Text(trustBody),
|
||||||
Text(
|
],
|
||||||
trustBody,
|
|
||||||
style: settingsTextStyle(context, secondary: true),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import 'package:pipelines_app/core/servers/server_catalog_store.dart';
|
|||||||
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
|
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
|
||||||
import 'package:pipelines_app/features/settings/server_connections.dart';
|
import 'package:pipelines_app/features/settings/server_connections.dart';
|
||||||
|
|
||||||
|
import 'saved_server_menu.dart';
|
||||||
|
|
||||||
class _ControlledStore extends MemoryServerCatalogStore {
|
class _ControlledStore extends MemoryServerCatalogStore {
|
||||||
_ControlledStore({super.catalog});
|
_ControlledStore({super.catalog});
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ Future<void> _openEditor(
|
|||||||
)
|
)
|
||||||
: MaterialApp(home: Scaffold(body: body)),
|
: MaterialApp(home: Scaffold(body: body)),
|
||||||
);
|
);
|
||||||
|
if (edit) await openSavedServerMenu(tester);
|
||||||
await tester.tap(find.text(edit ? 'Edit Home' : 'Add server'));
|
await tester.tap(find.text(edit ? 'Edit Home' : 'Add server'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.enterText(
|
await tester.enterText(
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
/// Opens the only saved server's actions menu (Use, Edit, Remove).
|
||||||
|
Future<void> openSavedServerMenu(WidgetTester tester) async {
|
||||||
|
await tester.tap(
|
||||||
|
find.byWidgetPredicate((widget) {
|
||||||
|
final key = widget.key;
|
||||||
|
return key is ValueKey<String> &&
|
||||||
|
key.value.startsWith('settings.server.') &&
|
||||||
|
key.value.endsWith('.menu');
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ import 'package:pipelines_app/core/servers/server_catalog_store.dart';
|
|||||||
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
|
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
|
||||||
import 'package:pipelines_app/features/settings/server_connections.dart';
|
import 'package:pipelines_app/features/settings/server_connections.dart';
|
||||||
|
|
||||||
|
import 'saved_server_menu.dart';
|
||||||
|
|
||||||
SavedServer profile(String id, List<String> urls) =>
|
SavedServer profile(String id, List<String> urls) =>
|
||||||
SavedServer.validated(id: id, name: id, endpoints: urls);
|
SavedServer.validated(id: id, name: id, endpoints: urls);
|
||||||
|
|
||||||
@@ -140,6 +142,7 @@ void main() {
|
|||||||
find.text('Backup 1: ws://192.168.1.2:8083/connect'),
|
find.text('Backup 1: ws://192.168.1.2:8083/connect'),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
|
await openSavedServerMenu(tester);
|
||||||
await tester.tap(find.text('Edit Home'));
|
await tester.tap(find.text('Edit Home'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.enterText(
|
await tester.enterText(
|
||||||
|
|||||||
@@ -1,48 +1,110 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/core/servers/server_catalog.dart';
|
||||||
|
import 'package:pipelines_app/core/servers/server_catalog_store.dart';
|
||||||
import 'package:pipelines_app/core/transport/pipelines_client.dart'
|
import 'package:pipelines_app/core/transport/pipelines_client.dart'
|
||||||
as transport;
|
as transport;
|
||||||
import 'package:pipelines_app/features/attention/notify/notification_controller.dart';
|
import 'package:pipelines_app/features/attention/notify/notification_controller.dart';
|
||||||
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
|
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
|
||||||
|
import 'package:pipelines_app/features/settings/saved_server_row.dart';
|
||||||
|
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
|
||||||
|
import 'package:pipelines_app/features/settings/server_connections.dart';
|
||||||
|
import 'package:pipelines_app/features/settings/settings_group.dart';
|
||||||
import 'package:pipelines_app/features/settings/settings_layout.dart';
|
import 'package:pipelines_app/features/settings/settings_layout.dart';
|
||||||
import 'package:pipelines_app/features/settings/settings_screen.dart';
|
import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||||
import 'package:pipelines_app/features/settings/settings_trust_warning.dart';
|
import 'package:pipelines_app/features/settings/settings_trust_warning.dart';
|
||||||
|
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||||
|
|
||||||
import 'fake_channel.dart';
|
import 'fake_channel.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('sections use one centred column and the web rhythm', (
|
testWidgets('groups start at the bar inset and stop at the reading width', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await _pump(tester, size: const Size(1200, 1600));
|
||||||
|
|
||||||
|
final groups = find.byType(SettingsGroup);
|
||||||
|
expect(groups, findsWidgets);
|
||||||
|
for (final group in groups.evaluate()) {
|
||||||
|
final rect = tester.getRect(find.byWidget(group.widget));
|
||||||
|
// The column starts where the bar's title pill does, not centred.
|
||||||
|
expect(rect.left, closeTo(settingsPageSidePadding, 0.01));
|
||||||
|
expect(rect.width, closeTo(settingsContentMaxWidth, 0.01));
|
||||||
|
}
|
||||||
|
// A header's text lines up with its rows' text.
|
||||||
|
final header = tester.getRect(find.text('Connection'));
|
||||||
|
expect(
|
||||||
|
header.left,
|
||||||
|
closeTo(settingsPageSidePadding + settingsRowInset, 0.01),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Material groups are flat surfaces, not elevated cards', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
await _pump(tester);
|
await _pump(tester);
|
||||||
|
|
||||||
final connection = tester.getRect(find.text('Connection'));
|
expect(find.byType(Card), findsNothing);
|
||||||
final serverUrlLabel = tester.getRect(find.text('Server URL'));
|
final surfaces = tester.widgetList<Material>(
|
||||||
final warning = tester.getRect(find.byType(SettingsTrustWarning));
|
find.descendant(
|
||||||
final workspace = tester.getRect(find.text('Workspace'));
|
of: find.byType(SettingsGroup),
|
||||||
|
matching: find.byType(Material),
|
||||||
// One column: the 720px reading width is centred in an 800px window.
|
),
|
||||||
expect(connection.left, closeTo(40, 0.01));
|
|
||||||
expect(connection.right, closeTo(760, 0.01));
|
|
||||||
|
|
||||||
// The compact title sits 8px above its grouped body, and sections are 16px
|
|
||||||
// apart, as on the web Settings page.
|
|
||||||
expect(
|
|
||||||
serverUrlLabel.top - connection.bottom,
|
|
||||||
closeTo(settingsTitleGap, 0.01),
|
|
||||||
);
|
);
|
||||||
expect(workspace.top - warning.bottom, closeTo(settingsSectionGap, 0.01));
|
final scheme = Theme.of(
|
||||||
|
tester.element(find.byType(SettingsGroup).first),
|
||||||
|
).colorScheme;
|
||||||
|
final groupSurfaces = surfaces.where(
|
||||||
|
(material) => material.color == scheme.surfaceContainer,
|
||||||
|
);
|
||||||
|
expect(groupSurfaces, isNotEmpty);
|
||||||
|
for (final material in groupSurfaces) {
|
||||||
|
expect(material.elevation, 0);
|
||||||
|
}
|
||||||
|
// The trust warning is the Connection group's footer, not a card.
|
||||||
|
expect(find.byType(SettingsTrustWarning), findsOneWidget);
|
||||||
|
final title = tester.widget<Text>(find.text('Connection'));
|
||||||
|
final theme = Theme.of(tester.element(find.text('Connection')));
|
||||||
|
expect(title.style?.color, theme.colorScheme.primary);
|
||||||
|
});
|
||||||
|
|
||||||
// The field label is a compact secondary line, not a second title.
|
testWidgets('content starts below the bar and scrolls behind it', (
|
||||||
final label = tester.widget<Text>(find.text('Server URL'));
|
tester,
|
||||||
final theme = Theme.of(tester.element(find.text('Server URL')));
|
) async {
|
||||||
expect(label.style?.color, theme.colorScheme.onSurfaceVariant);
|
const barHeight = 72.0;
|
||||||
expect(label.style?.fontSize, theme.textTheme.labelMedium?.fontSize);
|
await _pump(tester, topPadding: barHeight);
|
||||||
|
|
||||||
|
final first = tester.getRect(find.byType(SettingsGroup).first);
|
||||||
|
expect(first.top, closeTo(barHeight + settingsPageTopPadding, 0.01));
|
||||||
|
// No top SafeArea: the scroll view itself reaches the top edge.
|
||||||
expect(
|
expect(
|
||||||
label.style?.fontSize,
|
tester.getRect(find.byKey(const ValueKey('settings.scroll'))).top,
|
||||||
lessThan(theme.textTheme.titleMedium!.fontSize!),
|
0,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Cupertino uses inset-grouped sections on the grouped page', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await _pump(tester, platform: TargetPlatform.iOS);
|
||||||
|
|
||||||
|
expect(find.byType(Card), findsNothing);
|
||||||
|
expect(find.byType(CupertinoListSection), findsWidgets);
|
||||||
|
for (final section in tester.widgetList<CupertinoListSection>(
|
||||||
|
find.byType(CupertinoListSection),
|
||||||
|
)) {
|
||||||
|
expect(section.type, CupertinoListSectionType.insetGrouped);
|
||||||
|
}
|
||||||
|
final context = tester.element(find.byType(SettingsGroup).first);
|
||||||
|
expect(
|
||||||
|
find.byWidgetPredicate(
|
||||||
|
(widget) =>
|
||||||
|
widget is ColoredBox &&
|
||||||
|
widget.color == AppColors.groupedBackground.resolveFrom(context),
|
||||||
|
),
|
||||||
|
findsWidgets,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -72,14 +134,69 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
testWidgets('server rows show which server is selected ($cupertino)', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final connections = ServerConnections(
|
||||||
|
store: MemoryServerCatalogStore(
|
||||||
|
catalog: ServerCatalog(
|
||||||
|
servers: [
|
||||||
|
SavedServer.validated(
|
||||||
|
id: 'Home',
|
||||||
|
name: 'Home',
|
||||||
|
endpoints: const ['wss://home.test/connect'],
|
||||||
|
),
|
||||||
|
SavedServer.validated(
|
||||||
|
id: 'Work',
|
||||||
|
name: 'Work',
|
||||||
|
endpoints: const ['wss://work.test/connect'],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
selectedId: 'Home',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSelected: (_) async {},
|
||||||
|
);
|
||||||
|
addTearDown(connections.dispose);
|
||||||
|
await connections.load();
|
||||||
|
final body = SingleChildScrollView(
|
||||||
|
child: SavedServersSection(connections: connections),
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
cupertino
|
||||||
|
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||||
|
: MaterialApp(home: Scaffold(body: body)),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(find.byType(SavedServerRow), findsNWidgets(2));
|
||||||
|
expect(find.text('Selected server'), findsOneWidget);
|
||||||
|
expect(
|
||||||
|
find.byWidgetPredicate(
|
||||||
|
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
expect(find.text('Preferred: wss://work.test/connect'), findsOneWidget);
|
||||||
|
expect(find.byKey(savedServerMenuKey('Home')), findsOneWidget);
|
||||||
|
expect(find.text('Add server'), findsOneWidget);
|
||||||
|
// Tapping another server's row uses it.
|
||||||
|
await tester.tap(find.text('Work'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(connections.catalog.active?.id, 'Work');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _pump(
|
Future<void> _pump(
|
||||||
WidgetTester tester, {
|
WidgetTester tester, {
|
||||||
TargetPlatform platform = TargetPlatform.android,
|
TargetPlatform platform = TargetPlatform.android,
|
||||||
NotificationController? notifications,
|
NotificationController? notifications,
|
||||||
|
Size size = const Size(800, 1600),
|
||||||
|
double topPadding = 0,
|
||||||
}) async {
|
}) async {
|
||||||
await tester.binding.setSurfaceSize(const Size(800, 1600));
|
await tester.binding.setSurfaceSize(size);
|
||||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||||
final factory = FakeChannelFactory();
|
final factory = FakeChannelFactory();
|
||||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||||
@@ -87,10 +204,19 @@ Future<void> _pump(
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(platform: platform),
|
theme: ThemeData(platform: platform),
|
||||||
home: SettingsScreen(
|
builder: (context, child) => MediaQuery(
|
||||||
client: client,
|
data: MediaQuery.of(
|
||||||
store: MemorySettingsStore(),
|
context,
|
||||||
notifications: notifications,
|
).copyWith(padding: EdgeInsets.only(top: topPadding)),
|
||||||
|
child: child!,
|
||||||
|
),
|
||||||
|
home: Scaffold(
|
||||||
|
body: SettingsScreen(
|
||||||
|
client: client,
|
||||||
|
store: MemorySettingsStore(),
|
||||||
|
notifications: notifications,
|
||||||
|
embedded: true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ bool _checked(WidgetTester tester, String key, {required bool cupertino}) {
|
|||||||
final tile = find.byKey(ntfySettingKey(key));
|
final tile = find.byKey(ntfySettingKey(key));
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return tester
|
return tester
|
||||||
.widget<CupertinoCheckbox>(
|
.widget<CupertinoSwitch>(
|
||||||
find.descendant(of: tile, matching: find.byType(CupertinoCheckbox)),
|
find.descendant(of: tile, matching: find.byType(CupertinoSwitch)),
|
||||||
)
|
)
|
||||||
.value!;
|
.value;
|
||||||
}
|
}
|
||||||
return tester.widget<CheckboxListTile>(tile).value!;
|
return tester.widget<CheckboxListTile>(tile).value!;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user