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 '../../shell/shell_bar.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import '../../ui/adaptive/top_bar_notices.dart';
|
||||
import 'data/template_repository.dart';
|
||||
import 'domain/template_entry.dart';
|
||||
@@ -170,7 +169,7 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
context: context,
|
||||
template: template,
|
||||
repository: _repository,
|
||||
cupertino: usesCupertinoHost(context),
|
||||
cupertino: false,
|
||||
onCreated: (detail) => widget.onCreated?.call(detail),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'template_create_wording.dart';
|
||||
@@ -13,6 +12,8 @@ class TemplateCreateNameField extends StatelessWidget {
|
||||
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 TextEditingController controller;
|
||||
final bool enabled;
|
||||
@@ -26,24 +27,14 @@ class TemplateCreateNameField extends StatelessWidget {
|
||||
children: [
|
||||
const Text(templateCreateNameLabel),
|
||||
const SizedBox(height: 8),
|
||||
if (cupertino)
|
||||
CupertinoTextField(
|
||||
key: templateCreateNameKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
autofocus: true,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => onSubmit(),
|
||||
)
|
||||
else
|
||||
TextField(
|
||||
key: templateCreateNameKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
autofocus: true,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => onSubmit(),
|
||||
),
|
||||
TextField(
|
||||
key: templateCreateNameKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
autofocus: true,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => onSubmit(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -56,14 +47,6 @@ Widget templateCreateDialogAction({
|
||||
required Widget child,
|
||||
bool primary = false,
|
||||
}) {
|
||||
if (cupertino) {
|
||||
return CupertinoDialogAction(
|
||||
key: key,
|
||||
isDefaultAction: primary,
|
||||
onPressed: onPressed,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
if (primary) {
|
||||
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/rendering.dart';
|
||||
|
||||
@@ -12,6 +11,9 @@ import 'template_create_controls.dart';
|
||||
/// 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
|
||||
/// `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({
|
||||
required BuildContext context,
|
||||
required TemplateEntry template,
|
||||
@@ -22,33 +24,24 @@ Future<void> showTemplateCreateDialog({
|
||||
final dialog = _TemplateCreateDialog(
|
||||
template: template,
|
||||
repository: repository,
|
||||
cupertino: cupertino,
|
||||
onCreated: onCreated,
|
||||
);
|
||||
return cupertino
|
||||
? showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
)
|
||||
: showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
);
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => dialog,
|
||||
);
|
||||
}
|
||||
|
||||
class _TemplateCreateDialog extends StatefulWidget {
|
||||
const _TemplateCreateDialog({
|
||||
required this.template,
|
||||
required this.repository,
|
||||
required this.cupertino,
|
||||
required this.onCreated,
|
||||
});
|
||||
|
||||
final TemplateEntry template;
|
||||
final TemplateRepository repository;
|
||||
final bool cupertino;
|
||||
final ValueChanged<JsonMap> onCreated;
|
||||
|
||||
@override
|
||||
@@ -150,15 +143,13 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = widget.cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error;
|
||||
final color = Theme.of(context).colorScheme.error;
|
||||
final content = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
TemplateCreateNameField(
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
controller: _name,
|
||||
enabled: _fieldEnabled,
|
||||
onSubmit: _create,
|
||||
@@ -196,7 +187,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
);
|
||||
final actions = [
|
||||
templateCreateDialogAction(
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
key: templateCreateCancelKey,
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: Text(
|
||||
@@ -206,7 +197,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
),
|
||||
),
|
||||
templateCreateDialogAction(
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
key: templateCreateConfirmKey,
|
||||
primary: true,
|
||||
onPressed: _canSubmit ? _create : null,
|
||||
@@ -216,20 +207,10 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
|
||||
),
|
||||
];
|
||||
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(
|
||||
canPop: !_sending,
|
||||
child: CupertinoAlertDialog(
|
||||
child: AlertDialog(
|
||||
scrollable: true,
|
||||
title: title,
|
||||
content: content,
|
||||
actions: actions,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
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;
|
||||
@@ -63,14 +61,13 @@ 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),
|
||||
if (showBack) _backRow(context),
|
||||
templatesColumn(
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
@@ -91,7 +88,7 @@ class TemplateDetail extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_createButton(cupertino),
|
||||
_createButton(),
|
||||
const SizedBox(height: 16),
|
||||
// The key and the schedule on one quiet line, not a
|
||||
// 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
|
||||
/// spanning a wide window.
|
||||
Widget _createButton(bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton.filled(
|
||||
key: templateCreateActionKey,
|
||||
sizeStyle: CupertinoButtonSize.medium,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
Widget _createButton() {
|
||||
return FilledButton.icon(
|
||||
key: templateCreateActionKey,
|
||||
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.
|
||||
final back = SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
child: SegmentedBackButton(
|
||||
key: templateDetailBackKey,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: onBack,
|
||||
),
|
||||
);
|
||||
@@ -179,35 +168,15 @@ class TemplateDetail extends StatelessWidget {
|
||||
}
|
||||
|
||||
TextStyle? templateTitleStyle(BuildContext context) =>
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle
|
||||
: Theme.of(context).textTheme.headlineSmall;
|
||||
Theme.of(context).textTheme.headlineSmall;
|
||||
|
||||
TextStyle? templateSectionStyle(BuildContext context) =>
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleMedium;
|
||||
Theme.of(context).textTheme.titleMedium;
|
||||
|
||||
TextStyle? templateBodyStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
// 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? templateBodyStyle(BuildContext context) =>
|
||||
Theme.of(context).textTheme.bodyMedium;
|
||||
|
||||
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);
|
||||
return theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
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';
|
||||
@@ -70,13 +68,13 @@ class TemplateGallery extends StatelessWidget {
|
||||
onRetry: onRetry,
|
||||
);
|
||||
}
|
||||
return _loadingState(context);
|
||||
return _loadingState();
|
||||
}
|
||||
if (templates.isEmpty) return _emptyState(context);
|
||||
return _list(context);
|
||||
}
|
||||
|
||||
Widget _loadingState(BuildContext context) {
|
||||
Widget _loadingState() {
|
||||
return Center(
|
||||
key: templatesLoadingKey,
|
||||
child: Semantics(
|
||||
@@ -85,9 +83,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
usesCupertinoHost(context)
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 12),
|
||||
const Text(_loadingMessage),
|
||||
],
|
||||
@@ -107,7 +103,6 @@ class TemplateGallery extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _list(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// The rows scroll behind the bar and the floating tab bar.
|
||||
return ListView.builder(
|
||||
key: templatesGalleryKey,
|
||||
@@ -118,14 +113,14 @@ class TemplateGallery extends StatelessWidget {
|
||||
return templatesColumn(
|
||||
AppListRow(
|
||||
key: templateRowKey(entry.key),
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
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),
|
||||
color: _avatarColor(context, entry.key),
|
||||
),
|
||||
),
|
||||
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
|
||||
/// 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];
|
||||
}
|
||||
Color _avatarColor(BuildContext context, String key) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final colors = [scheme.primary, scheme.secondary, scheme.tertiary];
|
||||
final hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
|
||||
return colors[hash % colors.length];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
const templatesErrorKey = ValueKey<String>('templates-error');
|
||||
const templatesRetryKey = ValueKey<String>('templates-retry');
|
||||
const templatesErrorBannerKey = ValueKey<String>('templates-error-banner');
|
||||
@@ -36,7 +33,6 @@ class TemplatesFailureState extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_retryButton(
|
||||
context,
|
||||
buttonKey: templatesRetryKey,
|
||||
retrying: retrying,
|
||||
onRetry: onRetry,
|
||||
@@ -76,15 +72,10 @@ class TemplatesFailureBanner extends StatelessWidget {
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
||||
),
|
||||
),
|
||||
_retryButton(
|
||||
context,
|
||||
buttonKey: templatesBannerRetryKey,
|
||||
retrying: retrying,
|
||||
onRetry: onRetry,
|
||||
@@ -95,21 +86,12 @@ class TemplatesFailureBanner extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _retryButton(
|
||||
BuildContext context, {
|
||||
Widget _retryButton({
|
||||
required Key buttonKey,
|
||||
required bool retrying,
|
||||
required VoidCallback onRetry,
|
||||
}) {
|
||||
final onPressed = retrying ? null : onRetry;
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton(
|
||||
key: buttonKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: const Text('Retry'),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: buttonKey,
|
||||
onPressed: onPressed,
|
||||
|
||||
@@ -2,10 +2,8 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/navigation/bar_icon_button.dart';
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
|
||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||
const templatesBackKey = ValueKey<String>('templates-back');
|
||||
@@ -44,7 +42,6 @@ class TemplatesFrame extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
if (embedded) {
|
||||
if (ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
@@ -70,11 +67,11 @@ class TemplatesFrame extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
leading: canGoBack
|
||||
? SegmentedBackButton(
|
||||
key: templatesBackKey,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
@@ -84,19 +81,12 @@ class TemplatesFrame extends StatelessWidget {
|
||||
);
|
||||
// The body reaches the top edge and scrolls behind the bar.
|
||||
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);
|
||||
}
|
||||
|
||||
Widget _refreshButton() => BarIconButton(
|
||||
key: templatesRefreshKey,
|
||||
cupertino: false,
|
||||
icon: Icons.refresh,
|
||||
cupertinoIcon: CupertinoIcons.refresh,
|
||||
label: 'Refresh',
|
||||
|
||||
Reference in New Issue
Block a user