Remove Cupertino template branches
Keep the Material-only template implementation and narrow its tests to the runtime path. Retain public Cupertino parameters for compatibility while removing unreachable hosts, widgets, and test variants.
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../core/api_gateway.dart';
|
import '../../core/api_gateway.dart';
|
||||||
import '../../shell/shell_bar.dart';
|
import '../../shell/shell_bar.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
|
||||||
import '../../ui/adaptive/top_bar_notices.dart';
|
import '../../ui/adaptive/top_bar_notices.dart';
|
||||||
import 'data/template_repository.dart';
|
import 'data/template_repository.dart';
|
||||||
import 'domain/template_entry.dart';
|
import 'domain/template_entry.dart';
|
||||||
@@ -170,7 +169,7 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
|||||||
context: context,
|
context: context,
|
||||||
template: template,
|
template: template,
|
||||||
repository: _repository,
|
repository: _repository,
|
||||||
cupertino: usesCupertinoHost(context),
|
cupertino: false,
|
||||||
onCreated: (detail) => widget.onCreated?.call(detail),
|
onCreated: (detail) => widget.onCreated?.call(detail),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'template_create_wording.dart';
|
import 'template_create_wording.dart';
|
||||||
@@ -13,6 +12,8 @@ class TemplateCreateNameField extends StatelessWidget {
|
|||||||
required this.onSubmit,
|
required this.onSubmit,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Retained for callers that still pass it; the field is always the
|
||||||
|
/// Material one whether this is set or not.
|
||||||
final bool cupertino;
|
final bool cupertino;
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
@@ -26,24 +27,14 @@ class TemplateCreateNameField extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const Text(templateCreateNameLabel),
|
const Text(templateCreateNameLabel),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
if (cupertino)
|
TextField(
|
||||||
CupertinoTextField(
|
key: templateCreateNameKey,
|
||||||
key: templateCreateNameKey,
|
controller: controller,
|
||||||
controller: controller,
|
enabled: enabled,
|
||||||
enabled: enabled,
|
autofocus: true,
|
||||||
autofocus: true,
|
textInputAction: TextInputAction.done,
|
||||||
textInputAction: TextInputAction.done,
|
onSubmitted: (_) => onSubmit(),
|
||||||
onSubmitted: (_) => onSubmit(),
|
),
|
||||||
)
|
|
||||||
else
|
|
||||||
TextField(
|
|
||||||
key: templateCreateNameKey,
|
|
||||||
controller: controller,
|
|
||||||
enabled: enabled,
|
|
||||||
autofocus: true,
|
|
||||||
textInputAction: TextInputAction.done,
|
|
||||||
onSubmitted: (_) => onSubmit(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -56,14 +47,6 @@ Widget templateCreateDialogAction({
|
|||||||
required Widget child,
|
required Widget child,
|
||||||
bool primary = false,
|
bool primary = false,
|
||||||
}) {
|
}) {
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoDialogAction(
|
|
||||||
key: key,
|
|
||||||
isDefaultAction: primary,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (primary) {
|
if (primary) {
|
||||||
return FilledButton(key: key, onPressed: onPressed, child: child);
|
return FilledButton(key: key, onPressed: onPressed, child: child);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
@@ -12,6 +11,9 @@ import 'template_create_controls.dart';
|
|||||||
/// Cancel send nothing; Create validates the source first and only a passing
|
/// Cancel send nothing; Create validates the source first and only a passing
|
||||||
/// validate submits it create-only. A refusal keeps the typed name; an accepted
|
/// validate submits it create-only. A refusal keeps the typed name; an accepted
|
||||||
/// `detail` is delivered through [onCreated] once.
|
/// `detail` is delivered through [onCreated] once.
|
||||||
|
///
|
||||||
|
/// [cupertino] is retained for callers that still pass it; the prompt is
|
||||||
|
/// always the Material dialog.
|
||||||
Future<void> showTemplateCreateDialog({
|
Future<void> showTemplateCreateDialog({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required TemplateEntry template,
|
required TemplateEntry template,
|
||||||
@@ -22,33 +24,24 @@ Future<void> showTemplateCreateDialog({
|
|||||||
final dialog = _TemplateCreateDialog(
|
final dialog = _TemplateCreateDialog(
|
||||||
template: template,
|
template: template,
|
||||||
repository: repository,
|
repository: repository,
|
||||||
cupertino: cupertino,
|
|
||||||
onCreated: onCreated,
|
onCreated: onCreated,
|
||||||
);
|
);
|
||||||
return cupertino
|
return showDialog<void>(
|
||||||
? showCupertinoDialog<void>(
|
context: context,
|
||||||
context: context,
|
barrierDismissible: false,
|
||||||
barrierDismissible: false,
|
builder: (_) => dialog,
|
||||||
builder: (_) => dialog,
|
);
|
||||||
)
|
|
||||||
: showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => dialog,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TemplateCreateDialog extends StatefulWidget {
|
class _TemplateCreateDialog extends StatefulWidget {
|
||||||
const _TemplateCreateDialog({
|
const _TemplateCreateDialog({
|
||||||
required this.template,
|
required this.template,
|
||||||
required this.repository,
|
required this.repository,
|
||||||
required this.cupertino,
|
|
||||||
required this.onCreated,
|
required this.onCreated,
|
||||||
});
|
});
|
||||||
|
|
||||||
final TemplateEntry template;
|
final TemplateEntry template;
|
||||||
final TemplateRepository repository;
|
final TemplateRepository repository;
|
||||||
final bool cupertino;
|
|
||||||
final ValueChanged<JsonMap> onCreated;
|
final ValueChanged<JsonMap> onCreated;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -150,15 +143,13 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final color = widget.cupertino
|
final color = Theme.of(context).colorScheme.error;
|
||||||
? CupertinoColors.systemRed.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.error;
|
|
||||||
final content = Column(
|
final content = Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
TemplateCreateNameField(
|
TemplateCreateNameField(
|
||||||
cupertino: widget.cupertino,
|
cupertino: false,
|
||||||
controller: _name,
|
controller: _name,
|
||||||
enabled: _fieldEnabled,
|
enabled: _fieldEnabled,
|
||||||
onSubmit: _create,
|
onSubmit: _create,
|
||||||
@@ -196,7 +187,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
);
|
);
|
||||||
final actions = [
|
final actions = [
|
||||||
templateCreateDialogAction(
|
templateCreateDialogAction(
|
||||||
cupertino: widget.cupertino,
|
cupertino: false,
|
||||||
key: templateCreateCancelKey,
|
key: templateCreateCancelKey,
|
||||||
onPressed: _sending ? null : _cancel,
|
onPressed: _sending ? null : _cancel,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -206,7 +197,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
templateCreateDialogAction(
|
templateCreateDialogAction(
|
||||||
cupertino: widget.cupertino,
|
cupertino: false,
|
||||||
key: templateCreateConfirmKey,
|
key: templateCreateConfirmKey,
|
||||||
primary: true,
|
primary: true,
|
||||||
onPressed: _canSubmit ? _create : null,
|
onPressed: _canSubmit ? _create : null,
|
||||||
@@ -216,20 +207,10 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
final title = Text(templateCreateTitle(widget.template));
|
final title = Text(templateCreateTitle(widget.template));
|
||||||
if (!widget.cupertino) {
|
|
||||||
return PopScope(
|
|
||||||
canPop: !_sending,
|
|
||||||
child: AlertDialog(
|
|
||||||
scrollable: true,
|
|
||||||
title: title,
|
|
||||||
content: content,
|
|
||||||
actions: actions,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: !_sending,
|
canPop: !_sending,
|
||||||
child: CupertinoAlertDialog(
|
child: AlertDialog(
|
||||||
|
scrollable: true,
|
||||||
title: title,
|
title: title,
|
||||||
content: content,
|
content: content,
|
||||||
actions: actions,
|
actions: actions,
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
import '../../../ui/adaptive/segmented_bar.dart';
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../domain/template_entry.dart';
|
import '../domain/template_entry.dart';
|
||||||
import 'template_gallery.dart' show templatesColumn;
|
import 'template_gallery.dart' show templatesColumn;
|
||||||
@@ -63,14 +61,13 @@ class TemplateDetail extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
final muted = templateMutedStyle(context);
|
final muted = templateMutedStyle(context);
|
||||||
final description = entry.description.trim();
|
final description = entry.description.trim();
|
||||||
return ListView(
|
return ListView(
|
||||||
key: templateDetailKey,
|
key: templateDetailKey,
|
||||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
|
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
|
||||||
children: [
|
children: [
|
||||||
if (showBack) _backRow(context, cupertino),
|
if (showBack) _backRow(context),
|
||||||
templatesColumn(
|
templatesColumn(
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||||
@@ -91,7 +88,7 @@ class TemplateDetail extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
],
|
],
|
||||||
_createButton(cupertino),
|
_createButton(),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// The key and the schedule on one quiet line, not a
|
// The key and the schedule on one quiet line, not a
|
||||||
// label/value document.
|
// label/value document.
|
||||||
@@ -136,15 +133,7 @@ class TemplateDetail extends StatelessWidget {
|
|||||||
|
|
||||||
/// A compact button at its own width: the page's one action, never a bar
|
/// A compact button at its own width: the page's one action, never a bar
|
||||||
/// spanning a wide window.
|
/// spanning a wide window.
|
||||||
Widget _createButton(bool cupertino) {
|
Widget _createButton() {
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoButton.filled(
|
|
||||||
key: templateCreateActionKey,
|
|
||||||
sizeStyle: CupertinoButtonSize.medium,
|
|
||||||
onPressed: onCreate,
|
|
||||||
child: const Text(templateCreateActionLabel),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return FilledButton.icon(
|
return FilledButton.icon(
|
||||||
key: templateCreateActionKey,
|
key: templateCreateActionKey,
|
||||||
onPressed: onCreate,
|
onPressed: onCreate,
|
||||||
@@ -153,13 +142,13 @@ class TemplateDetail extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _backRow(BuildContext context, bool cupertino) {
|
Widget _backRow(BuildContext context) {
|
||||||
// Only without a bar above: the same round Back the bar would show.
|
// Only without a bar above: the same round Back the bar would show.
|
||||||
final back = SegmentedPill(
|
final back = SegmentedPill(
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
child: SegmentedBackButton(
|
child: SegmentedBackButton(
|
||||||
key: templateDetailBackKey,
|
key: templateDetailBackKey,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
onPressed: onBack,
|
onPressed: onBack,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -179,35 +168,15 @@ class TemplateDetail extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextStyle? templateTitleStyle(BuildContext context) =>
|
TextStyle? templateTitleStyle(BuildContext context) =>
|
||||||
usesCupertinoHost(context)
|
Theme.of(context).textTheme.headlineSmall;
|
||||||
? CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle
|
|
||||||
: Theme.of(context).textTheme.headlineSmall;
|
|
||||||
|
|
||||||
TextStyle? templateSectionStyle(BuildContext context) =>
|
TextStyle? templateSectionStyle(BuildContext context) =>
|
||||||
usesCupertinoHost(context)
|
Theme.of(context).textTheme.titleMedium;
|
||||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
|
||||||
: Theme.of(context).textTheme.titleMedium;
|
|
||||||
|
|
||||||
TextStyle? templateBodyStyle(BuildContext context) {
|
TextStyle? templateBodyStyle(BuildContext context) =>
|
||||||
if (usesCupertinoHost(context)) {
|
Theme.of(context).textTheme.bodyMedium;
|
||||||
// SelectableText needs an explicit baseline when it inherits no style.
|
|
||||||
return CupertinoTheme.of(
|
|
||||||
context,
|
|
||||||
).textTheme.textStyle.copyWith(inherit: true);
|
|
||||||
}
|
|
||||||
return Theme.of(context).textTheme.bodyMedium;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextStyle? templateMutedStyle(BuildContext context) {
|
TextStyle? templateMutedStyle(BuildContext context) {
|
||||||
if (usesCupertinoHost(context)) {
|
|
||||||
// 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),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
return theme.textTheme.bodySmall?.copyWith(
|
return theme.textTheme.bodySmall?.copyWith(
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/floating_bar_layout.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_avatar.dart';
|
||||||
import '../../../ui/layout/app_list_row.dart';
|
import '../../../ui/layout/app_list_row.dart';
|
||||||
import '../domain/template_entry.dart';
|
import '../domain/template_entry.dart';
|
||||||
@@ -70,13 +68,13 @@ class TemplateGallery extends StatelessWidget {
|
|||||||
onRetry: onRetry,
|
onRetry: onRetry,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return _loadingState(context);
|
return _loadingState();
|
||||||
}
|
}
|
||||||
if (templates.isEmpty) return _emptyState(context);
|
if (templates.isEmpty) return _emptyState(context);
|
||||||
return _list(context);
|
return _list(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _loadingState(BuildContext context) {
|
Widget _loadingState() {
|
||||||
return Center(
|
return Center(
|
||||||
key: templatesLoadingKey,
|
key: templatesLoadingKey,
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
@@ -85,9 +83,7 @@ class TemplateGallery extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
usesCupertinoHost(context)
|
const CircularProgressIndicator(),
|
||||||
? const CupertinoActivityIndicator()
|
|
||||||
: const CircularProgressIndicator(),
|
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
const Text(_loadingMessage),
|
const Text(_loadingMessage),
|
||||||
],
|
],
|
||||||
@@ -107,7 +103,6 @@ class TemplateGallery extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _list(BuildContext context) {
|
Widget _list(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
// The rows scroll behind the bar and the floating tab bar.
|
// The rows scroll behind the bar and the floating tab bar.
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
key: templatesGalleryKey,
|
key: templatesGalleryKey,
|
||||||
@@ -118,14 +113,14 @@ class TemplateGallery extends StatelessWidget {
|
|||||||
return templatesColumn(
|
return templatesColumn(
|
||||||
AppListRow(
|
AppListRow(
|
||||||
key: templateRowKey(entry.key),
|
key: templateRowKey(entry.key),
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
divider: index < templates.length - 1,
|
divider: index < templates.length - 1,
|
||||||
onTap: () => onOpen(entry.key),
|
onTap: () => onOpen(entry.key),
|
||||||
leading: ExcludeSemantics(
|
leading: ExcludeSemantics(
|
||||||
child: AppListAvatar.initial(
|
child: AppListAvatar.initial(
|
||||||
templateDetailName(entry),
|
templateDetailName(entry),
|
||||||
key: templateAvatarKey(entry.key),
|
key: templateAvatarKey(entry.key),
|
||||||
color: _avatarColor(context, entry.key, cupertino),
|
color: _avatarColor(context, entry.key),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(templateGalleryName(entry)),
|
title: Text(templateGalleryName(entry)),
|
||||||
@@ -138,18 +133,9 @@ class TemplateGallery extends StatelessWidget {
|
|||||||
|
|
||||||
/// One of the theme's accents, picked by the template key so a row keeps
|
/// One of the theme's accents, picked by the template key so a row keeps
|
||||||
/// its colour across reloads (the Pipelines list's palette).
|
/// its colour across reloads (the Pipelines list's palette).
|
||||||
Color _avatarColor(BuildContext context, String key, bool cupertino) {
|
Color _avatarColor(BuildContext context, String key) {
|
||||||
final List<Color> colors;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
if (cupertino) {
|
final colors = [scheme.primary, scheme.secondary, scheme.tertiary];
|
||||||
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 hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
|
final hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
|
||||||
return colors[hash % colors.length];
|
return colors[hash % colors.length];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
|
|
||||||
const templatesErrorKey = ValueKey<String>('templates-error');
|
const templatesErrorKey = ValueKey<String>('templates-error');
|
||||||
const templatesRetryKey = ValueKey<String>('templates-retry');
|
const templatesRetryKey = ValueKey<String>('templates-retry');
|
||||||
const templatesErrorBannerKey = ValueKey<String>('templates-error-banner');
|
const templatesErrorBannerKey = ValueKey<String>('templates-error-banner');
|
||||||
@@ -36,7 +33,6 @@ class TemplatesFailureState extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_retryButton(
|
_retryButton(
|
||||||
context,
|
|
||||||
buttonKey: templatesRetryKey,
|
buttonKey: templatesRetryKey,
|
||||||
retrying: retrying,
|
retrying: retrying,
|
||||||
onRetry: onRetry,
|
onRetry: onRetry,
|
||||||
@@ -76,15 +72,10 @@ class TemplatesFailureBanner extends StatelessWidget {
|
|||||||
liveRegion: true,
|
liveRegion: true,
|
||||||
child: Text(
|
child: Text(
|
||||||
message,
|
message,
|
||||||
style: TextStyle(
|
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||||
color: usesCupertinoHost(context)
|
|
||||||
? CupertinoColors.systemRed.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.error,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
_retryButton(
|
_retryButton(
|
||||||
context,
|
|
||||||
buttonKey: templatesBannerRetryKey,
|
buttonKey: templatesBannerRetryKey,
|
||||||
retrying: retrying,
|
retrying: retrying,
|
||||||
onRetry: onRetry,
|
onRetry: onRetry,
|
||||||
@@ -95,21 +86,12 @@ class TemplatesFailureBanner extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _retryButton(
|
Widget _retryButton({
|
||||||
BuildContext context, {
|
|
||||||
required Key buttonKey,
|
required Key buttonKey,
|
||||||
required bool retrying,
|
required bool retrying,
|
||||||
required VoidCallback onRetry,
|
required VoidCallback onRetry,
|
||||||
}) {
|
}) {
|
||||||
final onPressed = retrying ? null : onRetry;
|
final onPressed = retrying ? null : onRetry;
|
||||||
if (usesCupertinoHost(context)) {
|
|
||||||
return CupertinoButton(
|
|
||||||
key: buttonKey,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: const Text('Retry'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return TextButton(
|
return TextButton(
|
||||||
key: buttonKey,
|
key: buttonKey,
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../shell/shell_bar.dart';
|
import '../../../shell/shell_bar.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
import '../../../ui/adaptive/segmented_bar.dart';
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../../../ui/navigation/bar_icon_button.dart';
|
import '../../../ui/navigation/bar_icon_button.dart';
|
||||||
import '../../../ui/theme/app_theme.dart';
|
|
||||||
|
|
||||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||||
const templatesBackKey = ValueKey<String>('templates-back');
|
const templatesBackKey = ValueKey<String>('templates-back');
|
||||||
@@ -44,7 +42,6 @@ class TemplatesFrame extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
if (embedded) {
|
if (embedded) {
|
||||||
if (ShellBar.available(context)) {
|
if (ShellBar.available(context)) {
|
||||||
return ShellBar(
|
return ShellBar(
|
||||||
@@ -70,11 +67,11 @@ class TemplatesFrame extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
final bar = SegmentedBar(
|
final bar = SegmentedBar(
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
leading: canGoBack
|
leading: canGoBack
|
||||||
? SegmentedBackButton(
|
? SegmentedBackButton(
|
||||||
key: templatesBackKey,
|
key: templatesBackKey,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
onPressed: onBack,
|
onPressed: onBack,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
@@ -84,19 +81,12 @@ class TemplatesFrame extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
// The body reaches the top edge and scrolls behind the bar.
|
// The body reaches the top edge and scrolls behind the bar.
|
||||||
final page = SafeArea(top: false, bottom: false, child: body);
|
final page = SafeArea(top: false, bottom: false, child: body);
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoPageScaffold(
|
|
||||||
// Plain list rows on the page background, like the other lists.
|
|
||||||
backgroundColor: AppColors.background,
|
|
||||||
navigationBar: bar,
|
|
||||||
child: page,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: page);
|
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: page);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _refreshButton() => BarIconButton(
|
Widget _refreshButton() => BarIconButton(
|
||||||
key: templatesRefreshKey,
|
key: templatesRefreshKey,
|
||||||
|
cupertino: false,
|
||||||
icon: Icons.refresh,
|
icon: Icons.refresh,
|
||||||
cupertinoIcon: CupertinoIcons.refresh,
|
cupertinoIcon: CupertinoIcons.refresh,
|
||||||
label: 'Refresh',
|
label: 'Refresh',
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/application/templates_destination.dart';
|
import 'package:pipelines_app/application/templates_destination.dart';
|
||||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||||
import 'package:pipelines_app/features/templates/screen.dart';
|
import 'package:pipelines_app/features/templates/screen.dart';
|
||||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
|
||||||
|
|
||||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||||
import '../features/pipelines/fixtures.dart';
|
import '../features/pipelines/fixtures.dart';
|
||||||
@@ -13,81 +12,55 @@ import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp;
|
|||||||
|
|
||||||
/// The app-level Templates page: one bar (Back + Refresh), the gallery and an
|
/// 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
|
/// open template reach the top edge, start below the bar at rest and scroll
|
||||||
/// behind it. Both hosts draw the shared list rows on the page background.
|
/// behind it. The shared list rows sit on the page background.
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('the gallery and detail scroll behind the bar', (tester) async {
|
||||||
final host = cupertino ? 'Cupertino' : 'Material';
|
final channel = FakeChannel()..readyCompleter.complete();
|
||||||
|
final client = PipelinesClient(channelFactory: (_) => channel);
|
||||||
testWidgets('$host: the gallery and detail scroll behind the bar', (
|
final provider = PlatformRouteInformationProvider(
|
||||||
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
|
||||||
|
);
|
||||||
|
addTearDown(provider.dispose);
|
||||||
|
await pumpApp(
|
||||||
tester,
|
tester,
|
||||||
) async {
|
channel: channel,
|
||||||
final channel = FakeChannel()..readyCompleter.complete();
|
client: client,
|
||||||
final client = PipelinesClient(channelFactory: (_) => channel);
|
provider: provider,
|
||||||
final provider = PlatformRouteInformationProvider(
|
cupertino: false,
|
||||||
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
|
);
|
||||||
);
|
await replyPipelines(tester, channel, PipelineFixture());
|
||||||
addTearDown(provider.dispose);
|
await openSettings(tester, channel, provider);
|
||||||
await pumpApp(
|
await openTemplates(tester, channel, provider);
|
||||||
tester,
|
await tester.pumpAndSettle();
|
||||||
channel: channel,
|
|
||||||
client: client,
|
|
||||||
provider: provider,
|
|
||||||
cupertino: cupertino,
|
|
||||||
);
|
|
||||||
await replyPipelines(tester, channel, PipelineFixture());
|
|
||||||
await openSettings(tester, channel, provider);
|
|
||||||
await openTemplates(tester, channel, provider);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
final bar = find.ancestor(
|
final bar = find.ancestor(
|
||||||
of: find.byKey(templatesPageBackKey),
|
of: find.byKey(templatesPageBackKey),
|
||||||
matching: find.byType(SegmentedBar),
|
matching: find.byType(SegmentedBar),
|
||||||
);
|
);
|
||||||
final barBottom = tester.getRect(bar).bottom;
|
final barBottom = tester.getRect(bar).bottom;
|
||||||
// One bar: Back and Refresh are its pieces.
|
// One bar: Back and Refresh are its pieces.
|
||||||
expect(
|
expect(
|
||||||
find.descendant(of: bar, matching: find.byKey(templatesRefreshKey)),
|
find.descendant(of: bar, matching: find.byKey(templatesRefreshKey)),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
|
|
||||||
final gallery = find.byKey(templatesGalleryKey);
|
final gallery = find.byKey(templatesGalleryKey);
|
||||||
expect(tester.getTopLeft(gallery).dy, 0);
|
expect(tester.getTopLeft(gallery).dy, 0);
|
||||||
final row = find.byKey(templateRowKey('release'));
|
final row = find.byKey(templateRowKey('release'));
|
||||||
expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8));
|
expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8));
|
||||||
// Scrolling moves the row up behind the bar.
|
// Scrolling moves the row up behind the bar.
|
||||||
final before = tester.getTopLeft(row).dy;
|
final before = tester.getTopLeft(row).dy;
|
||||||
await tester.drag(gallery, const Offset(0, -40));
|
await tester.drag(gallery, const Offset(0, -40));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(tester.getTopLeft(row).dy, lessThanOrEqualTo(before));
|
expect(tester.getTopLeft(row).dy, lessThanOrEqualTo(before));
|
||||||
|
|
||||||
if (cupertino) {
|
await tester.tap(row);
|
||||||
final scaffold = tester.widget<CupertinoPageScaffold>(
|
await tester.pumpAndSettle();
|
||||||
find
|
final detail = find.byKey(templateDetailKey);
|
||||||
.ancestor(
|
expect(tester.getTopLeft(detail).dy, 0);
|
||||||
of: gallery,
|
expect(
|
||||||
matching: find.byType(CupertinoPageScaffold),
|
tester.getTopLeft(find.byKey(templateCreateActionKey)).dy,
|
||||||
)
|
greaterThanOrEqualTo(barBottom - 8),
|
||||||
.first,
|
);
|
||||||
);
|
});
|
||||||
// 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),
|
|
||||||
),
|
|
||||||
findsNothing,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await tester.tap(row);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
final detail = find.byKey(templateDetailKey);
|
|
||||||
expect(tester.getTopLeft(detail).dy, 0);
|
|
||||||
expect(
|
|
||||||
tester.getTopLeft(find.byKey(templateCreateActionKey)).dy,
|
|
||||||
greaterThanOrEqualTo(barBottom - 8),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,16 +73,12 @@ Future<void> pumpApp(
|
|||||||
tester.view.devicePixelRatio = 1;
|
tester.view.devicePixelRatio = 1;
|
||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
if (cupertino) {
|
|
||||||
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
|
|
||||||
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
|
|
||||||
}
|
|
||||||
SharedPreferences.setMockInitialValues({});
|
SharedPreferences.setMockInitialValues({});
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
PipelinesApp(
|
PipelinesApp(
|
||||||
server: webServer(),
|
server: webServer(),
|
||||||
client: client,
|
client: client,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
routeInformationProvider: provider,
|
routeInformationProvider: provider,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -156,114 +152,106 @@ void main() {
|
|||||||
expect(gateway.callsOf('list_templates'), hasLength(1));
|
expect(gateway.callsOf('list_templates'), hasLength(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets(
|
||||||
testWidgets(
|
'Settings opens the embedded Templates page and Back restores it',
|
||||||
'Settings opens the embedded Templates page and Back restores it '
|
(tester) async {
|
||||||
'($cupertino)',
|
final fixture = PipelineFixture();
|
||||||
(tester) async {
|
final channel = FakeChannel()..readyCompleter.complete();
|
||||||
final fixture = PipelineFixture();
|
var sockets = 0;
|
||||||
final channel = FakeChannel()..readyCompleter.complete();
|
final client = PipelinesClient(
|
||||||
var sockets = 0;
|
channelFactory: (_) {
|
||||||
final client = PipelinesClient(
|
sockets++;
|
||||||
channelFactory: (_) {
|
return channel;
|
||||||
sockets++;
|
},
|
||||||
return channel;
|
);
|
||||||
},
|
final provider = PlatformRouteInformationProvider(
|
||||||
);
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
|
||||||
final provider = PlatformRouteInformationProvider(
|
);
|
||||||
initialRouteInformation: RouteInformation(
|
addTearDown(provider.dispose);
|
||||||
uri: Uri.parse('/pipelines'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
addTearDown(provider.dispose);
|
|
||||||
|
|
||||||
await pumpApp(
|
await pumpApp(
|
||||||
tester,
|
tester,
|
||||||
channel: channel,
|
channel: channel,
|
||||||
client: client,
|
client: client,
|
||||||
provider: provider,
|
provider: provider,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
);
|
);
|
||||||
await replyPipelines(tester, channel, fixture);
|
await replyPipelines(tester, channel, fixture);
|
||||||
|
|
||||||
await openSettings(tester, channel, provider);
|
await openSettings(tester, channel, provider);
|
||||||
// An edit that only Settings owns must survive the Templates detour.
|
// An edit that only Settings owns must survive the Templates detour.
|
||||||
await tester.enterText(find.byType(EditableText).first, 'edited url');
|
await tester.enterText(find.byType(EditableText).first, 'edited url');
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('edited url'), findsOneWidget);
|
expect(find.text('edited url'), findsOneWidget);
|
||||||
|
|
||||||
await openTemplates(tester, channel, provider);
|
await openTemplates(tester, channel, provider);
|
||||||
final screen = tester.widget<TemplatesScreen>(
|
final screen = tester.widget<TemplatesScreen>(
|
||||||
find.byType(TemplatesScreen),
|
find.byType(TemplatesScreen),
|
||||||
);
|
);
|
||||||
expect(screen.embedded, isTrue);
|
expect(screen.embedded, isTrue);
|
||||||
expect(find.text('Release workflow'), findsOneWidget);
|
expect(find.text('Release workflow'), findsOneWidget);
|
||||||
// One visible navigation bar: the Templates page owns it, the shell is
|
// One visible navigation bar: the Templates page owns it, the shell is
|
||||||
// preserved underneath.
|
// preserved underneath.
|
||||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||||
if (cupertino) {
|
expect(sockets, 1);
|
||||||
expect(find.byType(Material), findsNothing);
|
expect(requestsOf(channel, 'list_templates'), hasLength(1));
|
||||||
}
|
|
||||||
expect(sockets, 1);
|
|
||||||
expect(requestsOf(channel, 'list_templates'), hasLength(1));
|
|
||||||
|
|
||||||
// Refresh sits in the bar's actions pill, not in the body.
|
// Refresh sits in the bar's actions pill, not in the body.
|
||||||
Finder inBar(Key key) => find.descendant(
|
Finder inBar(Key key) => find.descendant(
|
||||||
of: find.byType(SegmentedBar),
|
of: find.byType(SegmentedBar),
|
||||||
matching: find.byKey(key),
|
matching: find.byKey(key),
|
||||||
);
|
);
|
||||||
expect(inBar(templatesRefreshKey), findsOneWidget);
|
expect(inBar(templatesRefreshKey), findsOneWidget);
|
||||||
expect(find.byKey(templatesRefreshKey), findsOneWidget);
|
expect(find.byKey(templatesRefreshKey), findsOneWidget);
|
||||||
expect(inBar(templatesPageBackKey), findsOneWidget);
|
expect(inBar(templatesPageBackKey), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.byKey(templateRowKey('release')));
|
await tester.tap(find.byKey(templateRowKey('release')));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('Definition source'), findsOneWidget);
|
expect(find.text('Definition source'), findsOneWidget);
|
||||||
// One Back at a time, in the bar's round leading piece: the open
|
// One Back at a time, in the bar's round leading piece: the open
|
||||||
// template's Back replaces the page's.
|
// template's Back replaces the page's.
|
||||||
expect(inBar(templateDetailBackKey), findsOneWidget);
|
expect(inBar(templateDetailBackKey), findsOneWidget);
|
||||||
expect(find.byKey(templateDetailBackKey), findsOneWidget);
|
expect(find.byKey(templateDetailBackKey), findsOneWidget);
|
||||||
expect(find.byKey(templatesPageBackKey), findsNothing);
|
expect(find.byKey(templatesPageBackKey), findsNothing);
|
||||||
|
|
||||||
// Detail Back returns to the gallery, then the page Back restores the
|
// Detail Back returns to the gallery, then the page Back restores the
|
||||||
// same Settings state.
|
// same Settings state.
|
||||||
await tester.tap(find.byKey(templateDetailBackKey));
|
await tester.tap(find.byKey(templateDetailBackKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
// The gallery hands the bar back to the page's Back on the next frame.
|
// The gallery hands the bar back to the page's Back on the next frame.
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.tap(find.byKey(templatesPageBackKey));
|
await tester.tap(find.byKey(templatesPageBackKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(provider.value.uri.path, '/settings');
|
expect(provider.value.uri.path, '/settings');
|
||||||
expect(find.byType(TemplatesScreen), findsNothing);
|
expect(find.byType(TemplatesScreen), findsNothing);
|
||||||
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
|
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
|
||||||
await selectSettingsTopic(tester, 'Connection');
|
await selectSettingsTopic(tester, 'Connection');
|
||||||
expect(find.text('edited url'), findsOneWidget);
|
expect(find.text('edited url'), findsOneWidget);
|
||||||
expect(find.text('Server URL'), findsOneWidget);
|
expect(find.text('Server URL'), findsOneWidget);
|
||||||
expect(sockets, 1);
|
expect(sockets, 1);
|
||||||
expect(requestsOf(channel, 'ping'), hasLength(1));
|
expect(requestsOf(channel, 'ping'), hasLength(1));
|
||||||
|
|
||||||
// Browser Back from /templates follows the same close path.
|
// Browser Back from /templates follows the same close path.
|
||||||
await openTemplates(tester, channel, provider, listRead: 2);
|
await openTemplates(tester, channel, provider, listRead: 2);
|
||||||
expect(find.byType(TemplatesScreen), findsOneWidget);
|
expect(find.byType(TemplatesScreen), findsOneWidget);
|
||||||
await provider.didPushRouteInformation(
|
await provider.didPushRouteInformation(
|
||||||
RouteInformation(uri: Uri.parse('/settings')),
|
RouteInformation(uri: Uri.parse('/settings')),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(provider.value.uri.path, '/settings');
|
expect(provider.value.uri.path, '/settings');
|
||||||
expect(find.byType(TemplatesScreen), findsNothing);
|
expect(find.byType(TemplatesScreen), findsNothing);
|
||||||
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
|
expect(find.byKey(SettingsKeys.templates), findsOneWidget);
|
||||||
await selectSettingsTopic(tester, 'Connection');
|
await selectSettingsTopic(tester, 'Connection');
|
||||||
expect(find.text('edited url'), findsOneWidget);
|
expect(find.text('edited url'), findsOneWidget);
|
||||||
expect(requestsOf(channel, 'list_templates'), hasLength(2));
|
expect(requestsOf(channel, 'list_templates'), hasLength(2));
|
||||||
expect(sockets, 1);
|
expect(sockets, 1);
|
||||||
|
|
||||||
await tester.pumpWidget(const SizedBox.shrink());
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
testWidgets('an accepted create re-reads Pipelines exactly once', (
|
testWidgets('an accepted create re-reads Pipelines exactly once', (
|
||||||
tester,
|
tester,
|
||||||
|
|||||||
@@ -192,34 +192,28 @@ void main() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('the name field is labelled for screen readers on both hosts', (
|
testWidgets('the name field is labelled for screen readers', (tester) async {
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final handle = tester.ensureSemantics();
|
final handle = tester.ensureSemantics();
|
||||||
for (final cupertino in <bool>[false, true]) {
|
await tester.pumpWidget(
|
||||||
await tester.pumpWidget(
|
templateCreateApp(
|
||||||
templateCreateApp(
|
TemplateCreateHost(
|
||||||
TemplateCreateHost(
|
gateway: FakeTemplateCreateGateway(acceptedTemplateCreate),
|
||||||
gateway: FakeTemplateCreateGateway(acceptedTemplateCreate),
|
onCreated: (_) {},
|
||||||
onCreated: (_) {},
|
|
||||||
cupertino: cupertino,
|
|
||||||
),
|
|
||||||
cupertino: cupertino,
|
|
||||||
textScale: 2,
|
|
||||||
),
|
),
|
||||||
);
|
textScale: 2,
|
||||||
await tester.tap(find.byKey(templateCreateOpenKey));
|
),
|
||||||
await tester.pumpAndSettle();
|
);
|
||||||
await tester.enterText(find.byKey(templateCreateNameKey), 'Scaled');
|
await tester.tap(find.byKey(templateCreateOpenKey));
|
||||||
await tester.pump();
|
await tester.pumpAndSettle();
|
||||||
|
await tester.enterText(find.byKey(templateCreateNameKey), 'Scaled');
|
||||||
|
await tester.pump();
|
||||||
|
|
||||||
final data = tester
|
final data = tester
|
||||||
.getSemantics(find.byKey(templateCreateNameKey))
|
.getSemantics(find.byKey(templateCreateNameKey))
|
||||||
.getSemanticsData();
|
.getSemanticsData();
|
||||||
expect(data.label, templateCreateNameLabel);
|
expect(data.label, templateCreateNameLabel);
|
||||||
expect(data.value, 'Scaled');
|
expect(data.value, 'Scaled');
|
||||||
expect(data.flagsCollection.isTextField, isTrue);
|
expect(data.flagsCollection.isTextField, isTrue);
|
||||||
}
|
|
||||||
handle.dispose();
|
handle.dispose();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
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/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/core/transport/connection_state.dart';
|
import 'package:pipelines_app/core/transport/connection_state.dart';
|
||||||
import 'package:pipelines_app/features/templates/ui/template_create_wording.dart';
|
import 'package:pipelines_app/features/templates/ui/template_create_wording.dart';
|
||||||
|
|
||||||
import '../data/template_test_support.dart' show source;
|
|
||||||
import 'template_create_test_support.dart';
|
import 'template_create_test_support.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@@ -107,65 +105,4 @@ void main() {
|
|||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('cupertino prompt uses native controls for the same flow', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final gateway = FakeTemplateCreateGateway(
|
|
||||||
(type, fields) async => type == 'validate'
|
|
||||||
? {'graph': {}}
|
|
||||||
: {
|
|
||||||
'detail': {'id': 3},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
final created = <JsonMap>[];
|
|
||||||
await tester.pumpWidget(
|
|
||||||
templateCreateApp(
|
|
||||||
TemplateCreateHost(
|
|
||||||
gateway: gateway,
|
|
||||||
onCreated: created.add,
|
|
||||||
cupertino: true,
|
|
||||||
),
|
|
||||||
cupertino: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
await tester.tap(find.byKey(templateCreateOpenKey));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
|
||||||
expect(find.byType(AlertDialog), findsNothing);
|
|
||||||
expect(find.byType(CupertinoTextField), findsOneWidget);
|
|
||||||
expect(find.text(templateCreateNameLabel), findsOneWidget);
|
|
||||||
expect(cupertinoTemplateName(tester), '');
|
|
||||||
expect(
|
|
||||||
tester
|
|
||||||
.widget<CupertinoDialogAction>(find.byKey(templateCreateConfirmKey))
|
|
||||||
.onPressed,
|
|
||||||
isNull,
|
|
||||||
);
|
|
||||||
|
|
||||||
await tester.enterText(find.byKey(templateCreateNameKey), ' Unicode 🚀 ');
|
|
||||||
await tester.pump();
|
|
||||||
await tester.tap(find.byKey(templateCreateConfirmKey));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
expect(gateway.calls.map((call) => call.type), ['validate', 'submit']);
|
|
||||||
expect(gateway.calls[1].fields, {
|
|
||||||
'name': 'Unicode 🚀',
|
|
||||||
'source': source,
|
|
||||||
'create_only': true,
|
|
||||||
});
|
|
||||||
expect(
|
|
||||||
find.text('Created "Unicode 🚀". It is in the Pipelines list.'),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
expect(created.single, {'id': 3});
|
|
||||||
expect(
|
|
||||||
tester
|
|
||||||
.widget<CupertinoTextField>(find.byKey(templateCreateNameKey))
|
|
||||||
.enabled,
|
|
||||||
isFalse,
|
|
||||||
);
|
|
||||||
expect(find.text('Close'), findsOneWidget);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
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/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -46,11 +45,6 @@ String materialTemplateName(WidgetTester tester) => tester
|
|||||||
.controller!
|
.controller!
|
||||||
.text;
|
.text;
|
||||||
|
|
||||||
String cupertinoTemplateName(WidgetTester tester) => tester
|
|
||||||
.widget<CupertinoTextField>(find.byKey(templateCreateNameKey))
|
|
||||||
.controller!
|
|
||||||
.text;
|
|
||||||
|
|
||||||
Future<JsonMap> acceptedTemplateCreate(String type, JsonMap fields) async {
|
Future<JsonMap> acceptedTemplateCreate(String type, JsonMap fields) async {
|
||||||
if (type == 'validate') {
|
if (type == 'validate') {
|
||||||
return {'graph': {}};
|
return {'graph': {}};
|
||||||
@@ -75,6 +69,8 @@ class TemplateCreateHost extends StatelessWidget {
|
|||||||
|
|
||||||
final FakeTemplateCreateGateway gateway;
|
final FakeTemplateCreateGateway gateway;
|
||||||
final ValueChanged<JsonMap> onCreated;
|
final ValueChanged<JsonMap> onCreated;
|
||||||
|
|
||||||
|
/// Retained for callers that still pass it; the host is always Material.
|
||||||
final bool cupertino;
|
final bool cupertino;
|
||||||
final TemplateEntry template;
|
final TemplateEntry template;
|
||||||
|
|
||||||
@@ -91,21 +87,12 @@ class TemplateCreateHost extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final body = Center(
|
final body = Center(
|
||||||
child: cupertino
|
child: FilledButton(
|
||||||
? CupertinoButton(
|
key: templateCreateOpenKey,
|
||||||
key: templateCreateOpenKey,
|
onPressed: () => _open(context),
|
||||||
onPressed: () => _open(context),
|
child: const Text('Open'),
|
||||||
child: const Text('Open'),
|
),
|
||||||
)
|
|
||||||
: FilledButton(
|
|
||||||
key: templateCreateOpenKey,
|
|
||||||
onPressed: () => _open(context),
|
|
||||||
child: const Text('Open'),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoPageScaffold(child: body);
|
|
||||||
}
|
|
||||||
return Scaffold(body: body);
|
return Scaffold(body: body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,7 +108,5 @@ Widget templateCreateApp(
|
|||||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||||
child: app!,
|
child: app!,
|
||||||
);
|
);
|
||||||
return cupertino
|
return MaterialApp(builder: media, home: child);
|
||||||
? CupertinoApp(builder: media, home: child)
|
|
||||||
: MaterialApp(builder: media, home: child);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
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/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -76,30 +75,4 @@ void main() {
|
|||||||
expect(gateway.callsOf('submit'), hasLength(1));
|
expect(gateway.callsOf('submit'), hasLength(1));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
testWidgets('the callback is optional and Cupertino uses its native prompt', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final gateway = GalleryGateway((type, fields) async {
|
|
||||||
if (type == 'list_templates') return templatesReply(galleryTemplates);
|
|
||||||
return acceptedCreate(type, fields);
|
|
||||||
});
|
|
||||||
await pumpGallery(tester, gateway, cupertino: true);
|
|
||||||
await openRelease(tester);
|
|
||||||
|
|
||||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
|
||||||
expect(find.byType(AlertDialog), findsNothing);
|
|
||||||
await tester.enterText(find.byKey(templateCreateNameKey), 'Cupertino');
|
|
||||||
await tester.pump();
|
|
||||||
await tester.tap(find.byKey(templateCreateConfirmKey));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
expect(gateway.callsOf('validate'), hasLength(3));
|
|
||||||
expect(gateway.callsOf('submit'), hasLength(1));
|
|
||||||
expect(
|
|
||||||
find.text('Created "Created release". It is in the Pipelines list.'),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
expect(find.byKey(templateCreateCancelKey), findsOneWidget);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
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/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -241,85 +240,54 @@ void main() {
|
|||||||
expect(find.byKey(templatesGalleryKey), findsOneWidget);
|
expect(find.byKey(templatesGalleryKey), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Cupertino host uses its own list, back and detail controls', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
final gateway = GalleryGateway(
|
|
||||||
(type, fields) async => templatesReply(galleryTemplates),
|
|
||||||
);
|
|
||||||
await pumpGallery(tester, gateway, cupertino: true);
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
expect(find.byKey(templateDetailKey), findsOneWidget);
|
|
||||||
expect(selectableSource(source), findsOneWidget);
|
|
||||||
expect(
|
|
||||||
tester
|
|
||||||
.widget<CupertinoButton>(find.byKey(templateCreateActionKey))
|
|
||||||
.onPressed,
|
|
||||||
isNotNull,
|
|
||||||
);
|
|
||||||
expect(find.byType(BackButton), findsNothing);
|
|
||||||
|
|
||||||
await tester.tap(find.byKey(templatesBackKey));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'a failed refresh with a template open is visible and retryable',
|
'a failed refresh with a template open is visible and retryable',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
for (final cupertino in [false, true]) {
|
var mode = 'ok';
|
||||||
var mode = 'ok';
|
final gateway = GalleryGateway((type, fields) async {
|
||||||
final gateway = GalleryGateway((type, fields) async {
|
if (type != 'list_templates') throw StateError('unexpected $type');
|
||||||
if (type != 'list_templates') throw StateError('unexpected $type');
|
if (mode == 'refuse') throw Exception('refresh unavailable');
|
||||||
if (mode == 'refuse') throw Exception('refresh unavailable');
|
return templatesReply(galleryTemplates);
|
||||||
return templatesReply(galleryTemplates);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
await pumpGallery(tester, gateway, cupertino: cupertino);
|
await pumpGallery(tester, gateway);
|
||||||
await tester.tap(find.byKey(templateRowKey('release')));
|
await tester.tap(find.byKey(templateRowKey('release')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byKey(templateDetailKey), findsOneWidget);
|
expect(find.byKey(templateDetailKey), findsOneWidget);
|
||||||
|
|
||||||
mode = 'refuse';
|
mode = 'refuse';
|
||||||
await tester.tap(find.byKey(templatesRefreshKey));
|
await tester.tap(find.byKey(templatesRefreshKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(gateway.callsOf('list_templates'), hasLength(2));
|
expect(gateway.callsOf('list_templates'), hasLength(2));
|
||||||
expect(find.byKey(templateDetailKey), findsOneWidget);
|
expect(find.byKey(templateDetailKey), findsOneWidget);
|
||||||
expect(find.byKey(templatesErrorBannerKey), findsOneWidget);
|
expect(find.byKey(templatesErrorBannerKey), findsOneWidget);
|
||||||
expect(find.text('refresh unavailable'), findsOneWidget);
|
expect(find.text('refresh unavailable'), findsOneWidget);
|
||||||
expect(find.byKey(templatesBannerRetryKey), findsOneWidget);
|
expect(find.byKey(templatesBannerRetryKey), findsOneWidget);
|
||||||
expect(find.byKey(templatesErrorKey), findsNothing);
|
expect(find.byKey(templatesErrorKey), findsNothing);
|
||||||
expect(find.text(templateSourceLabel), findsOneWidget);
|
expect(find.text(templateSourceLabel), findsOneWidget);
|
||||||
expect(find.text(templateCreateActionLabel), findsOneWidget);
|
expect(find.text(templateCreateActionLabel), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
tester.widget(find.byKey(templatesBannerRetryKey)),
|
tester.widget(find.byKey(templatesBannerRetryKey)),
|
||||||
cupertino ? isA<CupertinoButton>() : isA<TextButton>(),
|
isA<TextButton>(),
|
||||||
);
|
);
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
|
|
||||||
mode = 'ok';
|
mode = 'ok';
|
||||||
await tester.tap(find.byKey(templatesBannerRetryKey));
|
await tester.tap(find.byKey(templatesBannerRetryKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(find.text('refresh unavailable'), findsNothing);
|
expect(find.text('refresh unavailable'), findsNothing);
|
||||||
expect(find.byKey(templatesErrorBannerKey), findsNothing);
|
expect(find.byKey(templatesErrorBannerKey), findsNothing);
|
||||||
expect(find.byKey(templateDetailKey), findsOneWidget);
|
expect(find.byKey(templateDetailKey), findsOneWidget);
|
||||||
expect(find.text(templateSourceLabel), findsOneWidget);
|
expect(find.text(templateSourceLabel), findsOneWidget);
|
||||||
expect(gateway.callsOf('list_templates'), hasLength(3));
|
expect(gateway.callsOf('list_templates'), hasLength(3));
|
||||||
|
|
||||||
await tester.tap(find.byKey(templatesBackKey));
|
await tester.tap(find.byKey(templatesBackKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byKey(templatesGalleryKey), findsOneWidget);
|
expect(find.byKey(templatesGalleryKey), findsOneWidget);
|
||||||
expect(find.text('Release workflow'), findsOneWidget);
|
expect(find.text('Release workflow'), findsOneWidget);
|
||||||
expect(find.text('(unnamed template)'), findsOneWidget);
|
expect(find.text('(unnamed template)'), findsOneWidget);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
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/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
@@ -79,7 +78,7 @@ Future<JsonMap> acceptedCreate(String type, JsonMap fields) async {
|
|||||||
throw StateError('Unexpected request $type');
|
throw StateError('Unexpected request $type');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pumps the gallery in a real Material or Cupertino host without fixed sizes.
|
/// Pumps the gallery in a real Material host without fixed sizes.
|
||||||
Future<void> pumpGallery(
|
Future<void> pumpGallery(
|
||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
GalleryGateway gateway, {
|
GalleryGateway gateway, {
|
||||||
@@ -105,16 +104,8 @@ Future<void> pumpGallery(
|
|||||||
embedded: embedded,
|
embedded: embedded,
|
||||||
onCreated: onCreated,
|
onCreated: onCreated,
|
||||||
);
|
);
|
||||||
final home = embedded
|
final home = embedded ? Scaffold(body: screen) : screen;
|
||||||
? (cupertino
|
await tester.pumpWidget(MaterialApp(builder: media, home: home));
|
||||||
? CupertinoPageScaffold(child: screen)
|
|
||||||
: Scaffold(body: screen))
|
|
||||||
: screen;
|
|
||||||
await tester.pumpWidget(
|
|
||||||
cupertino
|
|
||||||
? CupertinoApp(builder: media, home: home)
|
|
||||||
: MaterialApp(builder: media, home: home),
|
|
||||||
);
|
|
||||||
if (settle) await tester.pumpAndSettle();
|
if (settle) await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,62 +11,52 @@ import 'template_gallery_test_support.dart';
|
|||||||
/// Settings reading width, start-aligned; the bar names the open template and
|
/// Settings reading width, start-aligned; the bar names the open template and
|
||||||
/// the Create action is a compact button, not a full-width bar.
|
/// the Create action is a compact button, not a full-width bar.
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('rows and detail are capped at 720 on a wide window', (
|
||||||
final host = cupertino ? 'Cupertino' : 'Material';
|
tester,
|
||||||
|
) async {
|
||||||
|
final gateway = GalleryGateway(
|
||||||
|
(type, fields) async => templatesReply(galleryTemplates),
|
||||||
|
);
|
||||||
|
await pumpGallery(tester, gateway, size: const Size(1200, 800));
|
||||||
|
|
||||||
testWidgets('$host: rows and detail are capped at 720 on a wide window', (
|
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('the detail fits 320 at 2x text', (tester) async {
|
||||||
|
final gateway = GalleryGateway(
|
||||||
|
(type, fields) async => templatesReply(galleryTemplates),
|
||||||
|
);
|
||||||
|
await pumpGallery(
|
||||||
tester,
|
tester,
|
||||||
) async {
|
gateway,
|
||||||
final gateway = GalleryGateway(
|
size: const Size(320, 800),
|
||||||
(type, fields) async => templatesReply(galleryTemplates),
|
textScale: 2,
|
||||||
);
|
);
|
||||||
await pumpGallery(
|
expect(tester.takeException(), isNull);
|
||||||
tester,
|
await tester.tap(find.byKey(templateRowKey('release')));
|
||||||
gateway,
|
await tester.pumpAndSettle();
|
||||||
cupertino: cupertino,
|
expect(find.byKey(templateCreateActionKey), findsOneWidget);
|
||||||
size: const Size(1200, 800),
|
expect(tester.takeException(), isNull);
|
||||||
);
|
});
|
||||||
|
|
||||||
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