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:
@@ -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/server_connections.dart';
|
||||
|
||||
import 'saved_server_menu.dart';
|
||||
|
||||
class _ControlledStore extends MemoryServerCatalogStore {
|
||||
_ControlledStore({super.catalog});
|
||||
|
||||
@@ -38,6 +40,7 @@ Future<void> _openEditor(
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
if (edit) await openSavedServerMenu(tester);
|
||||
await tester.tap(find.text(edit ? 'Edit Home' : 'Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
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/server_connections.dart';
|
||||
|
||||
import 'saved_server_menu.dart';
|
||||
|
||||
SavedServer profile(String id, List<String> 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'),
|
||||
findsOneWidget,
|
||||
);
|
||||
await openSavedServerMenu(tester);
|
||||
await tester.tap(find.text('Edit Home'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
|
||||
@@ -1,48 +1,110 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.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'
|
||||
as transport;
|
||||
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/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_screen.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_trust_warning.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
|
||||
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,
|
||||
) async {
|
||||
await _pump(tester);
|
||||
|
||||
final connection = tester.getRect(find.text('Connection'));
|
||||
final serverUrlLabel = tester.getRect(find.text('Server URL'));
|
||||
final warning = tester.getRect(find.byType(SettingsTrustWarning));
|
||||
final workspace = tester.getRect(find.text('Workspace'));
|
||||
|
||||
// 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(find.byType(Card), findsNothing);
|
||||
final surfaces = tester.widgetList<Material>(
|
||||
find.descendant(
|
||||
of: find.byType(SettingsGroup),
|
||||
matching: find.byType(Material),
|
||||
),
|
||||
);
|
||||
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.
|
||||
final label = tester.widget<Text>(find.text('Server URL'));
|
||||
final theme = Theme.of(tester.element(find.text('Server URL')));
|
||||
expect(label.style?.color, theme.colorScheme.onSurfaceVariant);
|
||||
expect(label.style?.fontSize, theme.textTheme.labelMedium?.fontSize);
|
||||
testWidgets('content starts below the bar and scrolls behind it', (
|
||||
tester,
|
||||
) async {
|
||||
const barHeight = 72.0;
|
||||
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(
|
||||
label.style?.fontSize,
|
||||
lessThan(theme.textTheme.titleMedium!.fontSize!),
|
||||
tester.getRect(find.byKey(const ValueKey('settings.scroll'))).top,
|
||||
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));
|
||||
});
|
||||
|
||||
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(
|
||||
WidgetTester tester, {
|
||||
TargetPlatform platform = TargetPlatform.android,
|
||||
NotificationController? notifications,
|
||||
Size size = const Size(800, 1600),
|
||||
double topPadding = 0,
|
||||
}) async {
|
||||
await tester.binding.setSurfaceSize(const Size(800, 1600));
|
||||
await tester.binding.setSurfaceSize(size);
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
@@ -87,10 +204,19 @@ Future<void> _pump(
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: platform),
|
||||
home: SettingsScreen(
|
||||
client: client,
|
||||
store: MemorySettingsStore(),
|
||||
notifications: notifications,
|
||||
builder: (context, child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).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));
|
||||
if (cupertino) {
|
||||
return tester
|
||||
.widget<CupertinoCheckbox>(
|
||||
find.descendant(of: tile, matching: find.byType(CupertinoCheckbox)),
|
||||
.widget<CupertinoSwitch>(
|
||||
find.descendant(of: tile, matching: find.byType(CupertinoSwitch)),
|
||||
)
|
||||
.value!;
|
||||
.value;
|
||||
}
|
||||
return tester.widget<CheckboxListTile>(tile).value!;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user