Templates: shared list rows, named detail bar, compact create, 720 cap
This commit is contained in:
@@ -83,10 +83,10 @@ class _TemplatesDestinationState extends State<TemplatesDestination> {
|
||||
// behind the bar and pad their own content by its height.
|
||||
final page = SafeArea(top: false, bottom: false, child: body);
|
||||
if (cupertino) {
|
||||
// Inset-grouped rows on the grouped background, as in Settings; the
|
||||
// Plain list rows on the page background, like the other lists; the
|
||||
// bar's scrim takes the same colour.
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
backgroundColor: AppColors.background,
|
||||
navigationBar: _BarSlot(cupertino: true, child: bar),
|
||||
child: page,
|
||||
);
|
||||
@@ -115,6 +115,7 @@ class _TemplatesDestinationState extends State<TemplatesDestination> {
|
||||
onPressed: widget.onBack,
|
||||
),
|
||||
title: spec?.title ?? 'Templates',
|
||||
subtitle: spec?.subtitle,
|
||||
actions: spec?.actions ?? const [],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,10 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
onBack: _back,
|
||||
onCreate: () => _openCreate(selected),
|
||||
);
|
||||
final barTitle = selected == null ? null : templateBarTitle(selected);
|
||||
final framed = TemplatesFrame(
|
||||
title: barTitle?.title ?? templatesTitle,
|
||||
subtitle: barTitle?.subtitle,
|
||||
body: _withFailure(context, body),
|
||||
embedded: widget.embedded,
|
||||
canGoBack: selected != null,
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
import 'template_gallery.dart' show templatesColumn;
|
||||
|
||||
/// Browser wording for the gallery and the selected template, kept verbatim.
|
||||
const templateSourceLabel = 'Definition source';
|
||||
@@ -15,6 +16,17 @@ const templateDetailKey = ValueKey<String>('template-detail');
|
||||
const templateSourceKey = ValueKey<String>('template-source');
|
||||
const templateCreateActionKey = ValueKey<String>('template-create-action');
|
||||
const templateDetailBackKey = ValueKey<String>('template-detail-back');
|
||||
const templateKeyKey = ValueKey<String>('template-key');
|
||||
|
||||
/// What the bar's title pill shows for an open template: its name, and its
|
||||
/// description (when it has one) as the one-line subtitle.
|
||||
({String title, String? subtitle}) templateBarTitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim();
|
||||
return (
|
||||
title: templateDetailName(entry),
|
||||
subtitle: description.isEmpty ? null : description,
|
||||
);
|
||||
}
|
||||
|
||||
/// A gallery card's name: a blank name is the explicit unnamed placeholder.
|
||||
String templateGalleryName(TemplateEntry entry) {
|
||||
@@ -52,64 +64,92 @@ class TemplateDetail extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final muted = templateMutedStyle(context);
|
||||
final description = entry.description.trim();
|
||||
return ListView(
|
||||
key: templateDetailKey,
|
||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
|
||||
children: [
|
||||
if (showBack) _backRow(context, cupertino),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_createButton(context, cupertino),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
templateDetailName(entry),
|
||||
style: templateTitleStyle(context),
|
||||
),
|
||||
if (entry.description.trim().isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(entry.description),
|
||||
templatesColumn(
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// With a bar above, its title pill carries the name and the
|
||||
// description; only a bar-less page names the template here.
|
||||
if (showBack) ...[
|
||||
Text(
|
||||
templateDetailName(entry),
|
||||
style: templateTitleStyle(context),
|
||||
),
|
||||
if (description.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(entry.description),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_createButton(cupertino),
|
||||
const SizedBox(height: 16),
|
||||
// The key and the schedule on one quiet line, not a
|
||||
// label/value document.
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
SelectableText(
|
||||
entry.key,
|
||||
key: templateKeyKey,
|
||||
semanticsLabel: 'Key ${entry.key}',
|
||||
style: muted,
|
||||
),
|
||||
if (entry.scheduled) ...[
|
||||
Text('·', style: muted),
|
||||
Text(templateIncludesScheduleLabel, style: muted),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('Key', style: templateMutedStyle(context)),
|
||||
SelectableText(entry.key, style: templateBodyStyle(context)),
|
||||
if (entry.scheduled)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(templateIncludesScheduleLabel),
|
||||
const SizedBox(height: 20),
|
||||
Text(templateSourceLabel, style: templateSectionStyle(context)),
|
||||
const SizedBox(height: 8),
|
||||
// The server's source, byte-for-byte: no trim, re-indent or
|
||||
// re-encoding, so selecting it copies exactly what was
|
||||
// received.
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: SelectableText(
|
||||
entry.source,
|
||||
key: templateSourceKey,
|
||||
style: templateBodyStyle(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(templateSourceLabel, style: templateSectionStyle(context)),
|
||||
const SizedBox(height: 8),
|
||||
// The server's source, byte-for-byte: no trim, re-indent or
|
||||
// re-encoding, so selecting it copies exactly what was received.
|
||||
SelectableText(
|
||||
entry.source,
|
||||
key: templateSourceKey,
|
||||
style: templateBodyStyle(context),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _createButton(BuildContext context, bool cupertino) {
|
||||
/// A compact button at its own width: the page's one action, never a bar
|
||||
/// spanning a wide window.
|
||||
Widget _createButton(bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton.filled(
|
||||
key: templateCreateActionKey,
|
||||
sizeStyle: CupertinoButtonSize.medium,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
return FilledButton(
|
||||
return FilledButton.icon(
|
||||
key: templateCreateActionKey,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,7 +200,11 @@ TextStyle? templateBodyStyle(BuildContext context) {
|
||||
|
||||
TextStyle? templateMutedStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
// The list rows' secondary size, not the tab bar's 10pt caption.
|
||||
// SelectableText needs an explicit baseline when it inherits no style.
|
||||
return CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
inherit: true,
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/layout/app_list_avatar.dart';
|
||||
import '../../../ui/layout/app_list_row.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
import 'template_detail.dart';
|
||||
import 'templates_failure.dart';
|
||||
@@ -16,8 +18,23 @@ const _loadingMessage = 'Loading templates…';
|
||||
const _emptyMessage = 'No templates are available on this server.';
|
||||
|
||||
Key templateRowKey(String key) => ValueKey<String>('template-row-$key');
|
||||
Key templateAvatarKey(String key) => ValueKey<String>('template-avatar-$key');
|
||||
|
||||
/// The gallery's truthful states and native catalogue rows.
|
||||
/// The widest the gallery and an open template grow on a wide window: the
|
||||
/// Settings column's reading width, so the page opened from Settings lines up
|
||||
/// with it.
|
||||
const double templatesContentMaxWidth = 720;
|
||||
|
||||
/// Caps [child] at [templatesContentMaxWidth], start-aligned under the bar.
|
||||
Widget templatesColumn(Widget child) => Align(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: templatesContentMaxWidth),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
/// The gallery's truthful states and the app's shared list rows.
|
||||
///
|
||||
/// It owns no requests: loading, failure and the actual rows all come from the
|
||||
/// screen, so opening a row only selects an already-read template.
|
||||
@@ -44,9 +61,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
final ValueChanged<String> onOpen;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _body(context);
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
Widget build(BuildContext context) {
|
||||
if (!loaded) {
|
||||
if (error != null) {
|
||||
return TemplatesFailureState(
|
||||
@@ -58,9 +73,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
return _loadingState(context);
|
||||
}
|
||||
if (templates.isEmpty) return _emptyState(context);
|
||||
return usesCupertinoHost(context)
|
||||
? _cupertinoList(context)
|
||||
: _materialList(context);
|
||||
return _list(context);
|
||||
}
|
||||
|
||||
Widget _loadingState(BuildContext context) {
|
||||
@@ -93,82 +106,62 @@ class TemplateGallery extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialList(BuildContext context) {
|
||||
return ListView.separated(
|
||||
Widget _list(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// The rows scroll behind the bar and the floating tab bar.
|
||||
return ListView.builder(
|
||||
key: templatesGalleryKey,
|
||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 8)),
|
||||
itemCount: templates.length,
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final entry = templates[index];
|
||||
return ListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
subtitle: _materialSubtitle(entry),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => onOpen(entry.key),
|
||||
return templatesColumn(
|
||||
AppListRow(
|
||||
key: templateRowKey(entry.key),
|
||||
cupertino: cupertino,
|
||||
divider: index < templates.length - 1,
|
||||
onTap: () => onOpen(entry.key),
|
||||
leading: ExcludeSemantics(
|
||||
child: AppListAvatar.initial(
|
||||
templateDetailName(entry),
|
||||
key: templateAvatarKey(entry.key),
|
||||
color: _avatarColor(context, entry.key, cupertino),
|
||||
),
|
||||
),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
subtitle: _subtitle(entry),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoList(BuildContext context) {
|
||||
return ListView(
|
||||
key: templatesGalleryKey,
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final entry in templates)
|
||||
CupertinoListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: _cupertinoText(templateGalleryName(entry)),
|
||||
subtitle: _cupertinoSubtitle(entry),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
onTap: () => onOpen(entry.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The native tile is single-line by default. Let its content wrap at larger
|
||||
/// text sizes instead of ellipsizing a template's own name; the row grows
|
||||
/// with the content and nothing else about the tile is restyled.
|
||||
Widget _cupertinoText(String text) =>
|
||||
DefaultTextStyle.merge(maxLines: 3, child: Text(text));
|
||||
|
||||
Widget _materialSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: Text(entry.description);
|
||||
final count = Text(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: _cupertinoText(entry.description);
|
||||
final count = _cupertinoText(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
String _stageCountLabel(String key) {
|
||||
if (!stageCounts.containsKey(key) || stageCounts[key] == null) {
|
||||
return 'stage count unavailable';
|
||||
/// One of the theme's accents, picked by the template key so a row keeps
|
||||
/// its colour across reloads (the Pipelines list's palette).
|
||||
Color _avatarColor(BuildContext context, String key, bool cupertino) {
|
||||
final List<Color> colors;
|
||||
if (cupertino) {
|
||||
colors = [
|
||||
CupertinoTheme.of(context).primaryColor,
|
||||
CupertinoColors.systemIndigo.resolveFrom(context),
|
||||
CupertinoColors.systemTeal.resolveFrom(context),
|
||||
];
|
||||
} else {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
colors = [scheme.primary, scheme.secondary, scheme.tertiary];
|
||||
}
|
||||
final count = stageCounts[key]!;
|
||||
return '$count ${count == 1 ? 'stage' : 'stages'}';
|
||||
final hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
|
||||
return colors[hash % colors.length];
|
||||
}
|
||||
|
||||
/// The description, then the stage count when the server could parse the
|
||||
/// source. An unknown count is left out rather than announced on every row.
|
||||
Widget? _subtitle(TemplateEntry entry) {
|
||||
final count = stageCounts[entry.key];
|
||||
final parts = [
|
||||
if (entry.description.trim().isNotEmpty) entry.description.trim(),
|
||||
if (count != null) '$count ${count == 1 ? 'stage' : 'stages'}',
|
||||
];
|
||||
return parts.isEmpty ? null : Text(parts.join(' · '));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../ui/theme/app_theme.dart';
|
||||
|
||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||
const templatesBackKey = ValueKey<String>('templates-back');
|
||||
const templatesTitle = 'Templates';
|
||||
|
||||
/// The screen's native chrome.
|
||||
///
|
||||
@@ -26,8 +27,14 @@ class TemplatesFrame extends StatelessWidget {
|
||||
required this.refreshing,
|
||||
required this.onBack,
|
||||
required this.onRefresh,
|
||||
this.title = templatesTitle,
|
||||
this.subtitle,
|
||||
});
|
||||
|
||||
/// The bar's title pill: `Templates` on the gallery, the open template's
|
||||
/// name (with its description as [subtitle]) on a detail.
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final Widget body;
|
||||
final bool embedded;
|
||||
final bool canGoBack;
|
||||
@@ -41,7 +48,8 @@ class TemplatesFrame extends StatelessWidget {
|
||||
if (embedded) {
|
||||
if (ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
title: 'Templates',
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
onBack: canGoBack ? onBack : null,
|
||||
actions: [_refreshButton()],
|
||||
child: body,
|
||||
@@ -70,14 +78,16 @@ class TemplatesFrame extends StatelessWidget {
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
title: 'Templates',
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
actions: [_refreshButton()],
|
||||
);
|
||||
// The body reaches the top edge and scrolls behind the bar.
|
||||
final page = SafeArea(top: false, bottom: false, child: body);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// Plain list rows on the page background, like the other lists.
|
||||
backgroundColor: AppColors.background,
|
||||
navigationBar: bar,
|
||||
child: page,
|
||||
);
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp;
|
||||
|
||||
/// The app-level Templates page: one bar (Back + Refresh), the gallery and an
|
||||
/// open template reach the top edge, start below the bar at rest and scroll
|
||||
/// behind it. Cupertino draws inset-grouped rows on the grouped background.
|
||||
/// behind it. Both hosts draw the shared list rows on the page background.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
@@ -69,13 +69,14 @@ void main() {
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(scaffold.backgroundColor, AppColors.groupedBackground);
|
||||
// Plain shared rows on the page background, like the other lists.
|
||||
expect(scaffold.backgroundColor, AppColors.background);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: gallery,
|
||||
matching: find.byType(CupertinoListSection),
|
||||
),
|
||||
findsOneWidget,
|
||||
findsNothing,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/templates/screen.dart';
|
||||
import 'package:pipelines_app/features/templates/ui/template_detail.dart';
|
||||
import 'package:pipelines_app/features/templates/ui/template_gallery.dart'
|
||||
show templateAvatarKey;
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
|
||||
import '../data/template_test_support.dart' show source;
|
||||
import 'template_gallery_test_support.dart';
|
||||
@@ -31,15 +34,19 @@ void main() {
|
||||
|
||||
expect(find.byKey(templatesGalleryKey), findsOneWidget);
|
||||
expect(find.text('Release workflow'), findsOneWidget);
|
||||
expect(find.text('Ship a version'), findsOneWidget);
|
||||
expect(find.text('2 stages'), findsNWidgets(2));
|
||||
// One subtitle line: the description, then the parsed stage count.
|
||||
expect(find.text('Ship a version · 2 stages'), findsOneWidget);
|
||||
expect(find.text('No display name · 2 stages'), findsOneWidget);
|
||||
expect(find.text('(unnamed template)'), findsOneWidget);
|
||||
expect(find.byKey(templatesLoadingKey), findsNothing);
|
||||
// The app's shared rows with an initial avatar; no chevrons or tiles.
|
||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
||||
expect(find.byKey(templateAvatarKey('release')), findsOneWidget);
|
||||
expect(find.byType(ListTile), findsNothing);
|
||||
expect(find.byIcon(Icons.chevron_right), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('stage count is unavailable when server parsing refuses', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('an unknown stage count is left out of the row', (tester) async {
|
||||
final gateway =
|
||||
GalleryGateway((type, fields) async => templatesReply(galleryTemplates))
|
||||
..validationHandler = (type, fields) async {
|
||||
@@ -48,8 +55,9 @@ void main() {
|
||||
|
||||
await pumpGallery(tester, gateway);
|
||||
|
||||
expect(find.text('stage count unavailable'), findsNWidgets(2));
|
||||
expect(find.text('0 stages'), findsNothing);
|
||||
expect(find.textContaining('stage count'), findsNothing);
|
||||
expect(find.textContaining('stages'), findsNothing);
|
||||
expect(find.text('Ship a version'), findsOneWidget);
|
||||
expect(gateway.callsOf('validate'), hasLength(2));
|
||||
expect(
|
||||
gateway.callsOf('validate').first.fields['source'],
|
||||
@@ -162,9 +170,20 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(templateDetailKey), findsOneWidget);
|
||||
// The bar's title pill names the template; the body does not repeat it.
|
||||
final bar = find.byType(SegmentedBar);
|
||||
expect(
|
||||
find.descendant(of: bar, matching: find.text('Release workflow')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: bar, matching: find.text('Ship a version')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Release workflow'), findsOneWidget);
|
||||
expect(find.text('Ship a version'), findsOneWidget);
|
||||
expect(find.text('Key'), findsOneWidget);
|
||||
expect(find.text('Key'), findsNothing);
|
||||
expect(find.byKey(templateKeyKey), findsOneWidget);
|
||||
expect(find.text('Includes a schedule'), findsOneWidget);
|
||||
expect(find.text(templateSourceLabel), findsOneWidget);
|
||||
expect(selectableSource(source), findsOneWidget);
|
||||
@@ -230,7 +249,8 @@ void main() {
|
||||
);
|
||||
await pumpGallery(tester, gateway, cupertino: true);
|
||||
|
||||
expect(find.byType(CupertinoListTile), findsNWidgets(2));
|
||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
||||
expect(find.byType(CupertinoListTile), findsNothing);
|
||||
expect(find.byType(Scaffold), findsNothing);
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -247,7 +267,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(templatesBackKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoListTile), findsNWidgets(2));
|
||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/templates/screen.dart';
|
||||
import 'package:pipelines_app/features/templates/ui/template_detail.dart';
|
||||
import 'package:pipelines_app/features/templates/ui/template_gallery.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
import '../data/template_test_support.dart' show source;
|
||||
import 'template_gallery_test_support.dart';
|
||||
|
||||
/// The gallery and an open template on a wide window: the column stops at the
|
||||
/// Settings reading width, start-aligned; the bar names the open template and
|
||||
/// the Create action is a compact button, not a full-width bar.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: rows and detail are capped at 720 on a wide window', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = GalleryGateway(
|
||||
(type, fields) async => templatesReply(galleryTemplates),
|
||||
);
|
||||
await pumpGallery(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: cupertino,
|
||||
size: const Size(1200, 800),
|
||||
);
|
||||
|
||||
final row = tester.getRect(find.byKey(templateRowKey('release')));
|
||||
expect(row.left, 0);
|
||||
expect(row.width, templatesContentMaxWidth);
|
||||
expect(find.text('Templates'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final bar = find.byType(SegmentedBar);
|
||||
expect(
|
||||
find.descendant(of: bar, matching: find.text('Release workflow')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Templates'), findsNothing);
|
||||
|
||||
final create = tester.getRect(find.byKey(templateCreateActionKey));
|
||||
expect(create.left, 16);
|
||||
// Its own width, not stretched across the 688 content column.
|
||||
expect(create.width, lessThan(templatesContentMaxWidth - 32));
|
||||
final body = tester.getRect(selectableSource(source));
|
||||
expect(body.right, lessThanOrEqualTo(templatesContentMaxWidth));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('$host: the detail fits 320 at 2x text', (tester) async {
|
||||
final gateway = GalleryGateway(
|
||||
(type, fields) async => templatesReply(galleryTemplates),
|
||||
);
|
||||
await pumpGallery(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: cupertino,
|
||||
size: const Size(320, 800),
|
||||
textScale: 2,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(templateCreateActionKey), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user