Merge commit '03915fbb35c202d554d9e4cbc1549c0c4e62bdef' into pipelines/run-20261111-0420-cupertino-out-artifacts-9258
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'action_refusal.dart';
|
||||
@@ -21,16 +20,8 @@ Future<void> showCancelRunPrompt({
|
||||
}) {
|
||||
final prompt = _CancelPrompt(
|
||||
runId: runId,
|
||||
cupertino: cupertino,
|
||||
onSubmit: onSubmit,
|
||||
);
|
||||
if (cupertino) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
);
|
||||
}
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -39,14 +30,9 @@ Future<void> showCancelRunPrompt({
|
||||
}
|
||||
|
||||
class _CancelPrompt extends StatefulWidget {
|
||||
const _CancelPrompt({
|
||||
required this.runId,
|
||||
required this.cupertino,
|
||||
required this.onSubmit,
|
||||
});
|
||||
const _CancelPrompt({required this.runId, required this.onSubmit});
|
||||
|
||||
final num runId;
|
||||
final bool cupertino;
|
||||
final CancelSubmit onSubmit;
|
||||
|
||||
@override
|
||||
@@ -97,8 +83,7 @@ class _CancelPromptState extends State<_CancelPrompt> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
||||
return PopScope(canPop: !_sending, child: dialog);
|
||||
return PopScope(canPop: !_sending, child: _material(context));
|
||||
}
|
||||
|
||||
bool get _confirmDisabled => _sending || _checking || _blocked;
|
||||
@@ -124,30 +109,6 @@ class _CancelPromptState extends State<_CancelPrompt> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(cancelDialogTitle(widget.runId)),
|
||||
content: _body(
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
key: cancelKeepKey,
|
||||
onPressed: _sending ? null : _keep,
|
||||
child: const Text(cancelKeepLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: cancelConfirmKey,
|
||||
isDestructiveAction: true,
|
||||
onPressed: _confirmDisabled ? null : _confirm,
|
||||
child: const Text(cancelConfirmLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body({required TextStyle errorStyle}) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -36,14 +35,6 @@ class _CancelRunActionState extends State<CancelRunAction> {
|
||||
bool _dialogOpen = false;
|
||||
Future<bool?>? _resync;
|
||||
|
||||
bool _usesCupertino(BuildContext context) {
|
||||
final material = Localizations.of<MaterialLocalizations>(
|
||||
context,
|
||||
MaterialLocalizations,
|
||||
);
|
||||
return material == null;
|
||||
}
|
||||
|
||||
Future<void> _open() async {
|
||||
final id = cancelRunId(widget.run);
|
||||
if (id == null || !canCancelRun(widget.run) || _dialogOpen) return;
|
||||
@@ -52,7 +43,7 @@ class _CancelRunActionState extends State<CancelRunAction> {
|
||||
await showCancelRunPrompt(
|
||||
context: context,
|
||||
runId: id,
|
||||
cupertino: _usesCupertino(context),
|
||||
cupertino: false,
|
||||
onSubmit: () => _submit(id),
|
||||
);
|
||||
} finally {
|
||||
@@ -103,16 +94,6 @@ class _CancelRunActionState extends State<CancelRunAction> {
|
||||
if (cancelRunId(widget.run) == null || !canCancelRun(widget.run)) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
if (_usesCupertino(context)) {
|
||||
// The web tints Cancel as the one destructive run action.
|
||||
return CupertinoButton.tinted(
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
key: cancelActionKey,
|
||||
color: CupertinoColors.systemRed,
|
||||
onPressed: _open,
|
||||
child: const Text(cancelActionLabel),
|
||||
);
|
||||
}
|
||||
return OutlinedButton(
|
||||
key: cancelActionKey,
|
||||
style: OutlinedButton.styleFrom(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -30,7 +29,8 @@ class HumanDecisionAction extends StatefulWidget {
|
||||
final ApiGateway gateway;
|
||||
final ValueChanged<JsonMap> onRunChanged;
|
||||
|
||||
/// Overrides the platform style; by default it follows the enclosing app.
|
||||
/// Retained for callers that still pass a host style; the Material prompt is
|
||||
/// used everywhere now.
|
||||
final bool? cupertino;
|
||||
|
||||
@override
|
||||
@@ -53,15 +53,6 @@ class _HumanDecisionActionState extends State<HumanDecisionAction> {
|
||||
_pending = pendingDecision(widget.run);
|
||||
}
|
||||
|
||||
bool _usesCupertino(BuildContext context) {
|
||||
if (widget.cupertino != null) return widget.cupertino!;
|
||||
final material = Localizations.of<MaterialLocalizations>(
|
||||
context,
|
||||
MaterialLocalizations,
|
||||
);
|
||||
return material == null;
|
||||
}
|
||||
|
||||
Future<void> _open() async {
|
||||
final decision = _pending;
|
||||
if (decision == null || _dialogOpen) return;
|
||||
@@ -71,7 +62,7 @@ class _HumanDecisionActionState extends State<HumanDecisionAction> {
|
||||
context: context,
|
||||
run: widget.run,
|
||||
gateway: widget.gateway,
|
||||
cupertino: _usesCupertino(context),
|
||||
cupertino: widget.cupertino ?? false,
|
||||
onRunChanged: _acceptRun,
|
||||
isCurrent: () => _owns(decision.runId),
|
||||
);
|
||||
@@ -93,13 +84,6 @@ class _HumanDecisionActionState extends State<HumanDecisionAction> {
|
||||
Widget build(BuildContext context) {
|
||||
final decision = _pending;
|
||||
if (decision == null) return const SizedBox.shrink();
|
||||
if (_usesCupertino(context)) {
|
||||
return CupertinoButton.filled(
|
||||
key: decisionActionKey,
|
||||
onPressed: _open,
|
||||
child: const Text(decisionActionLabel),
|
||||
);
|
||||
}
|
||||
return FilledButton(
|
||||
key: decisionActionKey,
|
||||
onPressed: _open,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/run_decisions.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import 'action_refusal.dart';
|
||||
import 'decision_option_row.dart';
|
||||
import 'decision_wording.dart';
|
||||
|
||||
/// Sends the draft to the server. Returns null on success, or an
|
||||
@@ -19,18 +17,7 @@ Future<void> showHumanDecisionPrompt({
|
||||
required bool cupertino,
|
||||
required DecisionSubmit onSubmit,
|
||||
}) {
|
||||
final prompt = _DecisionPrompt(
|
||||
decision: decision,
|
||||
cupertino: cupertino,
|
||||
onSubmit: onSubmit,
|
||||
);
|
||||
if (cupertino) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
);
|
||||
}
|
||||
final prompt = _DecisionPrompt(decision: decision, onSubmit: onSubmit);
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -39,14 +26,9 @@ Future<void> showHumanDecisionPrompt({
|
||||
}
|
||||
|
||||
class _DecisionPrompt extends StatefulWidget {
|
||||
const _DecisionPrompt({
|
||||
required this.decision,
|
||||
required this.cupertino,
|
||||
required this.onSubmit,
|
||||
});
|
||||
const _DecisionPrompt({required this.decision, required this.onSubmit});
|
||||
|
||||
final PendingDecision decision;
|
||||
final bool cupertino;
|
||||
final DecisionSubmit onSubmit;
|
||||
|
||||
@override
|
||||
@@ -112,8 +94,7 @@ class _DecisionPromptState extends State<_DecisionPrompt> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
||||
return PopScope(canPop: !_sending, child: dialog);
|
||||
return PopScope(canPop: !_sending, child: _material(context));
|
||||
}
|
||||
|
||||
bool get _confirmDisabled => _sending || _checking || _blocked;
|
||||
@@ -166,52 +147,6 @@ class _DecisionPromptState extends State<_DecisionPrompt> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text(decisionWaitingTitle),
|
||||
content: _body(
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
options: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final (index, option) in widget.decision.options.indexed)
|
||||
DecisionOptionRow(
|
||||
key: decisionOptionKey(option.key),
|
||||
label: option.key,
|
||||
target: _targetText(option),
|
||||
selected: _draft.selected == option.key,
|
||||
divider: index > 0,
|
||||
onTap: _sending ? null : () => _select(option.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
feedback: CupertinoTextField(
|
||||
key: decisionFeedbackKey,
|
||||
controller: _feedback,
|
||||
enabled: !_sending,
|
||||
placeholder: decisionFeedbackLabel,
|
||||
textInputAction: TextInputAction.done,
|
||||
onChanged: _feedbackChanged,
|
||||
onSubmitted: (_) => _confirm(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: const Text(decisionCancelLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: _confirmDisabled || !_draft.canSubmit ? null : _confirm,
|
||||
child: Text(_sending ? decisionSendingLabel : decisionConfirmLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body({
|
||||
required TextStyle errorStyle,
|
||||
required Widget options,
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
/// One option row in the Cupertino decision prompt, keyed by the option.
|
||||
ValueKey<String> decisionOptionKey(String option) =>
|
||||
ValueKey<String>('human-decision-option-$option');
|
||||
|
||||
/// One choice of the Cupertino decision prompt: a check-list row.
|
||||
///
|
||||
/// The option reads as text in the label colour, not as a blue link, with its
|
||||
/// target underneath in the secondary colour. An empty circle marks an
|
||||
/// unpicked row and a filled check circle the picked one, so the choice is
|
||||
/// visible before Confirm. The whole row is the tap target; semantics report
|
||||
/// it as a selectable member of one exclusive group. A null [onTap] (while
|
||||
/// sending) dims the row.
|
||||
class DecisionOptionRow extends StatelessWidget {
|
||||
const DecisionOptionRow({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.selected,
|
||||
required this.onTap,
|
||||
this.target,
|
||||
this.divider = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String? target;
|
||||
final bool selected;
|
||||
final bool divider;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final enabled = onTap != null;
|
||||
final labelColor = enabled
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context);
|
||||
final mark = selected
|
||||
? Icon(
|
||||
CupertinoIcons.checkmark_circle_fill,
|
||||
color: enabled
|
||||
? theme.primaryColor
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Icon(
|
||||
CupertinoIcons.circle,
|
||||
color: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
);
|
||||
final row = Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
mark,
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
color: labelColor,
|
||||
fontWeight: selected ? FontWeight.w600 : null,
|
||||
),
|
||||
),
|
||||
if (target case final target?)
|
||||
Text(
|
||||
target,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return Semantics(
|
||||
inMutuallyExclusiveGroup: true,
|
||||
selected: selected,
|
||||
checked: selected,
|
||||
button: true,
|
||||
enabled: enabled,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: divider
|
||||
? Border(
|
||||
top: BorderSide(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
width: 0,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: row,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../data/runs_repository.dart';
|
||||
import '../domain/run_deletion.dart';
|
||||
import 'delete_runs_dialog.dart';
|
||||
@@ -25,7 +24,7 @@ Future<bool> confirmDeleteRuns(
|
||||
context: context,
|
||||
count: ids.length,
|
||||
size: runsSizeLabel(deletable),
|
||||
cupertino: cupertino ?? usesCupertinoHost(context),
|
||||
cupertino: cupertino ?? false,
|
||||
onSubmit: () async {
|
||||
try {
|
||||
onDeleted(await RunsRepository(gateway).deleteRuns(ids));
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/run_deletion.dart';
|
||||
@@ -22,23 +21,12 @@ Future<bool> showDeleteRunsPrompt({
|
||||
required bool cupertino,
|
||||
required DeleteRunsSubmit onSubmit,
|
||||
}) async {
|
||||
final prompt = _DeleteRunsPrompt(
|
||||
count: count,
|
||||
size: size,
|
||||
cupertino: cupertino,
|
||||
onSubmit: onSubmit,
|
||||
final prompt = _DeleteRunsPrompt(count: count, size: size, onSubmit: onSubmit);
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
);
|
||||
final result = cupertino
|
||||
? await showCupertinoDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
)
|
||||
: await showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
);
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
@@ -46,13 +34,11 @@ class _DeleteRunsPrompt extends StatefulWidget {
|
||||
const _DeleteRunsPrompt({
|
||||
required this.count,
|
||||
required this.size,
|
||||
required this.cupertino,
|
||||
required this.onSubmit,
|
||||
});
|
||||
|
||||
final int count;
|
||||
final String? size;
|
||||
final bool cupertino;
|
||||
final DeleteRunsSubmit onSubmit;
|
||||
|
||||
@override
|
||||
@@ -88,7 +74,7 @@ class _DeleteRunsPromptState extends State<_DeleteRunsPrompt> {
|
||||
@override
|
||||
Widget build(BuildContext context) => PopScope(
|
||||
canPop: !_sending,
|
||||
child: widget.cupertino ? _cupertinoDialog(context) : _material(context),
|
||||
child: _material(context),
|
||||
);
|
||||
|
||||
Widget _material(BuildContext context) {
|
||||
@@ -116,26 +102,6 @@ class _DeleteRunsPromptState extends State<_DeleteRunsPrompt> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoDialog(BuildContext context) => CupertinoAlertDialog(
|
||||
title: Text(deleteRunsTitle(widget.count)),
|
||||
content: _body(
|
||||
TextStyle(color: CupertinoColors.systemRed.resolveFrom(context)),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
key: deleteRunsKeepKey,
|
||||
onPressed: _sending ? null : _keep,
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: deleteRunsConfirmKey,
|
||||
isDestructiveAction: true,
|
||||
onPressed: _sending ? null : _confirm,
|
||||
child: Text(_sending ? 'Deleting…' : 'Delete'),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _body(TextStyle errorStyle) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -42,8 +41,6 @@ class RetryRunAction extends StatefulWidget {
|
||||
class _RetryRunActionState extends State<RetryRunAction> {
|
||||
bool _dialogOpen = false;
|
||||
|
||||
bool _usesCupertino(BuildContext context) => _cupertinoLocale(context);
|
||||
|
||||
Future<void> _open() async {
|
||||
if (_dialogOpen) return;
|
||||
_dialogOpen = true;
|
||||
@@ -67,14 +64,6 @@ class _RetryRunActionState extends State<RetryRunAction> {
|
||||
if (retryRunId(widget.run) == null || !canRetryRun(widget.run)) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
if (_usesCupertino(context)) {
|
||||
return CupertinoButton.tinted(
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
key: retryActionKey,
|
||||
onPressed: _open,
|
||||
child: const Text(retryActionLabel),
|
||||
);
|
||||
}
|
||||
return OutlinedButton(
|
||||
key: retryActionKey,
|
||||
onPressed: _open,
|
||||
@@ -83,10 +72,6 @@ class _RetryRunActionState extends State<RetryRunAction> {
|
||||
}
|
||||
}
|
||||
|
||||
bool _cupertinoLocale(BuildContext context) =>
|
||||
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations) ==
|
||||
null;
|
||||
|
||||
/// Opens the retry prompt for a failed [run]; only its confirm sends
|
||||
/// `retry_run`. An accepted reply reaches [onRunChanged] while [owns] still
|
||||
/// holds, and a new run id opens through [onRunOpened]. A refusal re-reads the
|
||||
@@ -121,7 +106,7 @@ Future<void> openRetryRunPrompt(
|
||||
await showRetryRunPrompt(
|
||||
context: context,
|
||||
runId: id,
|
||||
cupertino: _cupertinoLocale(context),
|
||||
cupertino: false,
|
||||
onSubmit: (intent) async {
|
||||
try {
|
||||
final updated = await repository.retryRun(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'action_refusal.dart';
|
||||
@@ -24,16 +23,8 @@ Future<void> showRetryRunPrompt({
|
||||
}) {
|
||||
final prompt = _RetryPrompt(
|
||||
runId: runId,
|
||||
cupertino: cupertino,
|
||||
onSubmit: onSubmit,
|
||||
);
|
||||
if (cupertino) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
);
|
||||
}
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -42,14 +33,9 @@ Future<void> showRetryRunPrompt({
|
||||
}
|
||||
|
||||
class _RetryPrompt extends StatefulWidget {
|
||||
const _RetryPrompt({
|
||||
required this.runId,
|
||||
required this.cupertino,
|
||||
required this.onSubmit,
|
||||
});
|
||||
const _RetryPrompt({required this.runId, required this.onSubmit});
|
||||
|
||||
final num runId;
|
||||
final bool cupertino;
|
||||
final RetrySubmit onSubmit;
|
||||
|
||||
@override
|
||||
@@ -116,8 +102,7 @@ class _RetryPromptState extends State<_RetryPrompt> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
||||
return PopScope(canPop: !_sending, child: dialog);
|
||||
return PopScope(canPop: !_sending, child: _material(context));
|
||||
}
|
||||
|
||||
bool get _confirmDisabled => _sending || _checking || _blocked;
|
||||
@@ -150,36 +135,6 @@ class _RetryPromptState extends State<_RetryPrompt> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(_dialogTitle),
|
||||
content: _body(
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
if (_showRestart)
|
||||
CupertinoDialogAction(
|
||||
key: retryRestartKey,
|
||||
onPressed: _sending || _checking ? null : _restart,
|
||||
child: const Text(restartConfirmLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: retryKeepKey,
|
||||
onPressed: _sending ? null : _keep,
|
||||
child: const Text(retryKeepLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: retryConfirmKey,
|
||||
isDestructiveAction: _mode == RetryMode.restart,
|
||||
onPressed: _confirmDisabled ? null : _confirm,
|
||||
child: Text(_confirmLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body({required TextStyle errorStyle}) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/error_reason.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../data/runs_repository.dart';
|
||||
|
||||
/// The browser client's export-only repair wording, kept verbatim.
|
||||
@@ -131,22 +129,15 @@ class _SessionExportRepairActionState extends State<SessionExportRepairAction> {
|
||||
final label = _sending
|
||||
? sessionExportRepairBusyLabel
|
||||
: sessionExportRepairLabel;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final button = cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: enabled ? _send : null,
|
||||
child: Text(label),
|
||||
)
|
||||
: TextButton(onPressed: enabled ? _send : null, child: Text(label));
|
||||
final button = TextButton(
|
||||
onPressed: enabled ? _send : null,
|
||||
child: Text(label),
|
||||
);
|
||||
return Column(
|
||||
key: sessionExportRepairKey,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (cupertino)
|
||||
button
|
||||
else
|
||||
Tooltip(message: sessionExportRepairHelp, child: button),
|
||||
Tooltip(message: sessionExportRepairHelp, child: button),
|
||||
if (_refusal != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -33,8 +32,6 @@ class RunTitleAction extends StatefulWidget {
|
||||
class _RunTitleActionState extends State<RunTitleAction> {
|
||||
bool _dialogOpen = false;
|
||||
|
||||
bool _usesCupertino(BuildContext context) => _cupertinoLocale(context);
|
||||
|
||||
Future<void> _open() async {
|
||||
if (_dialogOpen) return;
|
||||
_dialogOpen = true;
|
||||
@@ -55,14 +52,6 @@ class _RunTitleActionState extends State<RunTitleAction> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (runTitleId(widget.run) == null) return const SizedBox.shrink();
|
||||
if (_usesCupertino(context)) {
|
||||
return CupertinoButton.tinted(
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
key: runTitleActionKey,
|
||||
onPressed: _open,
|
||||
child: const Text(runTitleActionLabel),
|
||||
);
|
||||
}
|
||||
return OutlinedButton(
|
||||
key: runTitleActionKey,
|
||||
onPressed: _open,
|
||||
@@ -71,10 +60,6 @@ class _RunTitleActionState extends State<RunTitleAction> {
|
||||
}
|
||||
}
|
||||
|
||||
bool _cupertinoLocale(BuildContext context) =>
|
||||
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations) ==
|
||||
null;
|
||||
|
||||
/// Opens the rename prompt for [run]; only Save sends `set_run_title`, and the
|
||||
/// server's returned detail reaches [onRunChanged] while [owns] still holds
|
||||
/// for that run id. Shared by the button and the run detail's more menu.
|
||||
@@ -92,7 +77,7 @@ Future<void> openRunTitleEditor(
|
||||
context: context,
|
||||
runId: id,
|
||||
initialTitle: storedRunTitle(run),
|
||||
cupertino: _cupertinoLocale(context),
|
||||
cupertino: false,
|
||||
onSubmit: (title) async {
|
||||
if (saving) return const ActionRefusal(actionAlreadySending);
|
||||
saving = true;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'action_refusal.dart';
|
||||
@@ -26,16 +25,8 @@ Future<void> showRunTitlePrompt({
|
||||
final prompt = _TitlePrompt(
|
||||
runId: runId,
|
||||
initialTitle: initialTitle,
|
||||
cupertino: cupertino,
|
||||
onSubmit: onSubmit,
|
||||
);
|
||||
if (cupertino) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
);
|
||||
}
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -47,13 +38,11 @@ class _TitlePrompt extends StatefulWidget {
|
||||
const _TitlePrompt({
|
||||
required this.runId,
|
||||
required this.initialTitle,
|
||||
required this.cupertino,
|
||||
required this.onSubmit,
|
||||
});
|
||||
|
||||
final num runId;
|
||||
final String initialTitle;
|
||||
final bool cupertino;
|
||||
final TitleSubmit onSubmit;
|
||||
|
||||
@override
|
||||
@@ -97,8 +86,7 @@ class _TitlePromptState extends State<_TitlePrompt> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
|
||||
return PopScope(canPop: !_sending, child: dialog);
|
||||
return PopScope(canPop: !_sending, child: _material(context));
|
||||
}
|
||||
|
||||
Widget _material(BuildContext context) {
|
||||
@@ -133,39 +121,6 @@ class _TitlePromptState extends State<_TitlePrompt> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text(runTitleDialogTitle),
|
||||
content: _body(
|
||||
field: CupertinoTextField(
|
||||
key: runTitleFieldKey,
|
||||
controller: _title,
|
||||
enabled: !_sending,
|
||||
autofocus: true,
|
||||
placeholder: runTitleFieldLabel,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => _save(),
|
||||
),
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
key: runTitleCancelKey,
|
||||
onPressed: _sending ? null : _cancel,
|
||||
child: const Text(runTitleCancelLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: runTitleSaveKey,
|
||||
isDefaultAction: true,
|
||||
onPressed: _sending ? null : _save,
|
||||
child: const Text(runTitleSaveLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body({required Widget field, required TextStyle errorStyle}) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -73,19 +73,13 @@ class _SchedulesScreenState extends State<SchedulesScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
Localizations.of<MaterialLocalizations>(
|
||||
context,
|
||||
MaterialLocalizations,
|
||||
) ==
|
||||
null;
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) => SchedulesListView(
|
||||
controller: _controller,
|
||||
searchController: _searchController,
|
||||
scrollController: _scrollController,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onOpen: widget.onOpen,
|
||||
onRefresh: () => unawaited(_controller.refresh()),
|
||||
),
|
||||
|
||||
@@ -1,29 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Secondary text under a field, using the host's own colours and text theme.
|
||||
/// Secondary text under a field, using the app's colours and text theme.
|
||||
TextStyle scheduleEditorSecondaryStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
// The host's own secondary-label style; no invented point size.
|
||||
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return (theme.textTheme.bodySmall ?? const TextStyle()).copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
}
|
||||
|
||||
/// The host's semantic error colour, never a form-specific palette.
|
||||
/// The app's semantic error colour, never a form-specific palette.
|
||||
TextStyle scheduleEditorErrorStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
return TextStyle(color: Theme.of(context).colorScheme.error);
|
||||
}
|
||||
|
||||
@@ -47,9 +33,7 @@ class ScheduleEditorField extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final labelStyle = usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyMedium;
|
||||
final labelStyle = Theme.of(context).textTheme.bodyMedium;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -103,27 +87,16 @@ class ScheduleEditorTextField extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final field = usesCupertinoHost(context)
|
||||
? CupertinoTextField(
|
||||
key: fieldKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboardType,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
textInputAction: textInputAction,
|
||||
onChanged: onChanged,
|
||||
)
|
||||
: TextField(
|
||||
key: fieldKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboardType,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
textInputAction: textInputAction,
|
||||
onChanged: onChanged,
|
||||
);
|
||||
final field = TextField(
|
||||
key: fieldKey,
|
||||
controller: controller,
|
||||
enabled: enabled,
|
||||
keyboardType: keyboardType,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
textInputAction: textInputAction,
|
||||
onChanged: onChanged,
|
||||
);
|
||||
return MergeSemantics(
|
||||
child: ScheduleEditorField(
|
||||
label: label,
|
||||
@@ -156,17 +129,11 @@ class ScheduleEditorSwitchField extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final control = usesCupertinoHost(context)
|
||||
? CupertinoSwitch(
|
||||
key: switchKey,
|
||||
value: value,
|
||||
onChanged: enabled ? onChanged : null,
|
||||
)
|
||||
: Switch(
|
||||
key: switchKey,
|
||||
value: value,
|
||||
onChanged: enabled ? onChanged : null,
|
||||
);
|
||||
final control = Switch(
|
||||
key: switchKey,
|
||||
value: value,
|
||||
onChanged: enabled ? onChanged : null,
|
||||
);
|
||||
return MergeSemantics(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../domain/editor/schedule_draft.dart';
|
||||
import '../../domain/schedule_rule.dart';
|
||||
import 'schedule_editor_form_body.dart';
|
||||
@@ -151,7 +149,6 @@ class _ScheduleEditorFormState extends State<ScheduleEditorForm> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return ScheduleEditorFormBody(
|
||||
heading: _heading,
|
||||
showHeading: widget.showHeading,
|
||||
@@ -193,25 +190,17 @@ class _ScheduleEditorFormState extends State<ScheduleEditorForm> {
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
if (widget.onCancel != null)
|
||||
_cancelButton(cupertino)
|
||||
_cancelButton()
|
||||
else
|
||||
const SizedBox.shrink(),
|
||||
_saveButton(cupertino),
|
||||
_saveButton(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cancelButton(bool cupertino) {
|
||||
Widget _cancelButton() {
|
||||
final onPressed = _sending ? null : widget.onCancel;
|
||||
if (cupertino) {
|
||||
return CupertinoButton(
|
||||
key: scheduleEditorCancelKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: const Text(scheduleEditorCancelLabel),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: scheduleEditorCancelKey,
|
||||
onPressed: onPressed,
|
||||
@@ -219,18 +208,11 @@ class _ScheduleEditorFormState extends State<ScheduleEditorForm> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _saveButton(bool cupertino) {
|
||||
Widget _saveButton() {
|
||||
final label = Text(
|
||||
_sending ? scheduleEditorSendingLabel : scheduleEditorSubmitLabel,
|
||||
);
|
||||
final onPressed = _sending ? null : _submit;
|
||||
if (cupertino) {
|
||||
return CupertinoButton.filled(
|
||||
key: scheduleEditorSubmitKey,
|
||||
onPressed: onPressed,
|
||||
child: label,
|
||||
);
|
||||
}
|
||||
return FilledButton(
|
||||
key: scheduleEditorSubmitKey,
|
||||
onPressed: onPressed,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../domain/editor/schedule_draft.dart';
|
||||
import 'schedule_editor_fields.dart';
|
||||
import 'schedule_editor_selectors.dart';
|
||||
@@ -100,10 +98,7 @@ class ScheduleEditorFormBody extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final titleStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleLarge;
|
||||
final titleStyle = Theme.of(context).textTheme.titleLarge;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../domain/schedule_rule.dart';
|
||||
import 'schedule_editor_fields.dart';
|
||||
|
||||
@@ -17,7 +15,7 @@ class ScheduleEditorChoice<T> {
|
||||
final String label;
|
||||
}
|
||||
|
||||
/// A native drop-down on Material and a native action sheet on Cupertino.
|
||||
/// A native drop-down of the field's options.
|
||||
class ScheduleEditorChoiceField<T> extends StatelessWidget {
|
||||
const ScheduleEditorChoiceField({
|
||||
super.key,
|
||||
@@ -40,65 +38,22 @@ class ScheduleEditorChoiceField<T> extends StatelessWidget {
|
||||
final String? error;
|
||||
final Key? fieldKey;
|
||||
|
||||
String get _selectedLabel {
|
||||
for (final option in options) {
|
||||
if (option.value == value) return option.label;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Future<void> _choose(BuildContext context) async {
|
||||
final chosen = await showCupertinoModalPopup<T>(
|
||||
context: context,
|
||||
builder: (sheetContext) => CupertinoActionSheet(
|
||||
title: Text(label),
|
||||
actions: [
|
||||
for (final option in options)
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(sheetContext, option.value),
|
||||
child: Text(option.label),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(sheetContext),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (chosen != null) onChanged(chosen);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final control = usesCupertinoHost(context)
|
||||
? CupertinoButton(
|
||||
key: fieldKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: enabled ? () => _choose(context) : null,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: Text(_selectedLabel)),
|
||||
const Icon(CupertinoIcons.chevron_down),
|
||||
],
|
||||
),
|
||||
)
|
||||
: DropdownButtonFormField<T>(
|
||||
key: fieldKey,
|
||||
initialValue: value,
|
||||
isExpanded: true,
|
||||
items: [
|
||||
for (final option in options)
|
||||
DropdownMenuItem<T>(
|
||||
value: option.value,
|
||||
child: Text(option.label),
|
||||
),
|
||||
],
|
||||
onChanged: enabled
|
||||
? (chosen) {
|
||||
if (chosen != null) onChanged(chosen);
|
||||
}
|
||||
: null,
|
||||
);
|
||||
final control = DropdownButtonFormField<T>(
|
||||
key: fieldKey,
|
||||
initialValue: value,
|
||||
isExpanded: true,
|
||||
items: [
|
||||
for (final option in options)
|
||||
DropdownMenuItem<T>(value: option.value, child: Text(option.label)),
|
||||
],
|
||||
onChanged: enabled
|
||||
? (chosen) {
|
||||
if (chosen != null) onChanged(chosen);
|
||||
}
|
||||
: null,
|
||||
);
|
||||
return MergeSemantics(
|
||||
child: ScheduleEditorField(
|
||||
label: label,
|
||||
@@ -164,18 +119,11 @@ class _DayToggle extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final checkbox = cupertino
|
||||
? CupertinoCheckbox(
|
||||
key: scheduleEditorDayKey(day),
|
||||
value: selected,
|
||||
onChanged: enabled ? (_) => onTap() : null,
|
||||
)
|
||||
: Checkbox(
|
||||
key: scheduleEditorDayKey(day),
|
||||
value: selected,
|
||||
onChanged: enabled ? (_) => onTap() : null,
|
||||
);
|
||||
final checkbox = Checkbox(
|
||||
key: scheduleEditorDayKey(day),
|
||||
value: selected,
|
||||
onChanged: enabled ? (_) => onTap() : null,
|
||||
);
|
||||
final content = Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
|
||||
child: Row(
|
||||
@@ -184,17 +132,11 @@ class _DayToggle extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
return MergeSemantics(
|
||||
child: cupertino
|
||||
? GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: enabled ? onTap : null,
|
||||
child: content,
|
||||
)
|
||||
: InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: enabled ? onTap : null,
|
||||
child: content,
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: enabled ? onTap : null,
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/layout/app_list_avatar.dart';
|
||||
@@ -27,10 +26,10 @@ class ScheduleListRow extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppListRow(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
divider: divider,
|
||||
onTap: onOpen,
|
||||
leading: ScheduleAvatar(schedule: schedule, cupertino: cupertino),
|
||||
leading: ScheduleAvatar(schedule: schedule, cupertino: false),
|
||||
title: Text(scheduleDisplayName(schedule)),
|
||||
time: scheduleNextDueShort(schedule),
|
||||
subtitle: Text(
|
||||
@@ -56,17 +55,13 @@ class ScheduleAvatar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Color? enabled = schedule.enabled
|
||||
? (cupertino
|
||||
? CupertinoColors.systemGreen.resolveFrom(context)
|
||||
: Colors.green.shade700)
|
||||
: null;
|
||||
final Color? enabled = schedule.enabled ? Colors.green.shade700 : null;
|
||||
return Semantics(
|
||||
label: scheduleStatusLabel(schedule),
|
||||
child: ExcludeSemantics(
|
||||
child: AppListAvatar(
|
||||
foreground: enabled,
|
||||
child: Icon(cupertino ? CupertinoIcons.clock : Icons.schedule),
|
||||
child: const Icon(Icons.schedule),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -30,7 +30,7 @@ class ScheduleRefreshAction extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => BarIconButton(
|
||||
key: controller.isLoading ? null : scheduleRefreshKey,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
icon: Icons.refresh,
|
||||
cupertinoIcon: CupertinoIcons.refresh,
|
||||
label: 'Refresh schedules',
|
||||
@@ -69,7 +69,7 @@ class ScheduleListToolbar extends StatelessWidget {
|
||||
final refresh = switch (onRefresh) {
|
||||
final refresh? => ScheduleRefreshAction(
|
||||
controller: controller,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onRefresh: refresh,
|
||||
),
|
||||
null => null,
|
||||
@@ -119,29 +119,13 @@ class ScheduleListToolbar extends StatelessWidget {
|
||||
Widget _search(BuildContext context) => AppSearchField(
|
||||
fieldKey: scheduleSearchFieldKey,
|
||||
controller: searchController,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
placeholder: 'Search schedules',
|
||||
onChanged: controller.setQuery,
|
||||
onCleared: controller.clearQuery,
|
||||
);
|
||||
|
||||
Widget _filter(BuildContext context) {
|
||||
if (cupertino) {
|
||||
return CupertinoSlidingSegmentedControl<ScheduleListFilter>(
|
||||
key: scheduleFilterKey,
|
||||
groupValue: controller.filter,
|
||||
onValueChanged: (value) {
|
||||
if (value != null) controller.setFilter(value);
|
||||
},
|
||||
children: {
|
||||
for (final filter in ScheduleListFilter.values)
|
||||
filter: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
child: Text(filter.label),
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
return SegmentedButton<ScheduleListFilter>(
|
||||
key: scheduleFilterKey,
|
||||
segments: [
|
||||
@@ -159,12 +143,8 @@ class ScheduleListToolbar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
TextStyle? _metaStyle(BuildContext context) => cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
TextStyle? _metaStyle(BuildContext context) => Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(color: Theme.of(context).colorScheme.onSurfaceVariant);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/floating_bar_layout.dart';
|
||||
@@ -55,13 +54,13 @@ class SchedulesListView extends StatelessWidget {
|
||||
edge: FloatingBarEdge.top,
|
||||
bar: TopGlassStrip(
|
||||
key: scheduleToolbarKey,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
maxWidth: kScheduleToolbarMaxWidth,
|
||||
padding: EdgeInsets.zero,
|
||||
child: ScheduleListToolbar(
|
||||
controller: controller,
|
||||
searchController: searchController,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onRefresh: refreshInToolbar ? onRefresh : null,
|
||||
),
|
||||
),
|
||||
@@ -118,7 +117,7 @@ class SchedulesListView extends StatelessWidget {
|
||||
'schedule-row-$index-${schedule.id ?? 'unknown'}',
|
||||
),
|
||||
schedule: schedule,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
divider: index < schedules.length - 1,
|
||||
onOpen: () => onOpen(schedule),
|
||||
),
|
||||
@@ -136,9 +135,7 @@ class SchedulesListView extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
cupertino
|
||||
? const CupertinoActivityIndicator()
|
||||
: const CircularProgressIndicator(),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 12),
|
||||
const Text('Loading schedules…'),
|
||||
],
|
||||
@@ -161,9 +158,7 @@ class SchedulesListView extends StatelessWidget {
|
||||
detail,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: cupertino
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -204,9 +199,7 @@ class SchedulesListView extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _failureText(BuildContext context, ScheduleListFailure failure) {
|
||||
final color = cupertino
|
||||
? CupertinoColors.systemRed.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.error;
|
||||
final color = Theme.of(context).colorScheme.error;
|
||||
return Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(
|
||||
@@ -218,14 +211,6 @@ class SchedulesListView extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _retryButton() {
|
||||
if (cupertino) {
|
||||
return CupertinoButton(
|
||||
key: scheduleRetryKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRefresh,
|
||||
child: const Text('Retry'),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: scheduleRetryKey,
|
||||
onPressed: onRefresh,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import 'schedule_pipeline_wording.dart';
|
||||
|
||||
/// Deletes the exact schedule revision. Returns null once the server accepted
|
||||
@@ -18,13 +16,6 @@ Future<void> showScheduleDeleteDialog({
|
||||
required ScheduleDeleteSubmit onSubmit,
|
||||
}) {
|
||||
final prompt = _ScheduleDeletePrompt(name: name, onSubmit: onSubmit);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => prompt,
|
||||
);
|
||||
}
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
@@ -70,10 +61,7 @@ class _ScheduleDeletePromptState extends State<_ScheduleDeletePrompt> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final dialog = usesCupertinoHost(context)
|
||||
? _cupertino(context)
|
||||
: _material(context);
|
||||
return PopScope(canPop: !_sending, child: dialog);
|
||||
return PopScope(canPop: !_sending, child: _material(context));
|
||||
}
|
||||
|
||||
Widget _material(BuildContext context) {
|
||||
@@ -98,30 +86,6 @@ class _ScheduleDeletePromptState extends State<_ScheduleDeletePrompt> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: Text(scheduleDeleteTitle(widget.name)),
|
||||
content: _body(
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
key: scheduleDeleteKeepKey,
|
||||
onPressed: _sending ? null : _keep,
|
||||
child: const Text(scheduleDeleteKeepLabel),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
key: scheduleDeleteConfirmKey,
|
||||
isDestructiveAction: true,
|
||||
onPressed: _sending ? null : _confirm,
|
||||
child: const Text(scheduleDeleteConfirmLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body({required TextStyle errorStyle}) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import '../../../../ui/adaptive/segmented_bar.dart';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../domain/editor/schedule_draft.dart';
|
||||
import '../editor/schedule_editor_form.dart';
|
||||
import '../editor/schedule_editor_wording.dart';
|
||||
@@ -40,22 +38,14 @@ Future<void> openSchedulePipelineEditor(
|
||||
final title = draft.source == null
|
||||
? scheduleEditorAddTitle
|
||||
: scheduleEditorEditTitle;
|
||||
final route = usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||
child: SafeArea(child: page),
|
||||
),
|
||||
)
|
||||
: MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(cupertino: false, title: title),
|
||||
body: SafeArea(child: page),
|
||||
),
|
||||
);
|
||||
final route = MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (_) => Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(cupertino: false, title: title),
|
||||
body: SafeArea(child: page),
|
||||
),
|
||||
);
|
||||
return Navigator.of(context).push(route);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../../../ui/layout/section_heading.dart';
|
||||
import '../../domain/saved_schedule.dart';
|
||||
import '../list/schedule_list_controller.dart';
|
||||
@@ -83,24 +81,12 @@ class SchedulePipelineListBody extends StatelessWidget {
|
||||
/// the section reloads after every accepted change and offers Retry when a
|
||||
/// load fails.
|
||||
Widget _header(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final add = cupertino
|
||||
? CupertinoButton(
|
||||
key: scheduleAddKey,
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size.square(44),
|
||||
onPressed: onAdd,
|
||||
child: const Icon(
|
||||
CupertinoIcons.add,
|
||||
semanticLabel: scheduleAddLabel,
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
key: scheduleAddKey,
|
||||
tooltip: scheduleAddLabel,
|
||||
onPressed: onAdd,
|
||||
icon: const Icon(Icons.add),
|
||||
);
|
||||
final add = IconButton(
|
||||
key: scheduleAddKey,
|
||||
tooltip: scheduleAddLabel,
|
||||
onPressed: onAdd,
|
||||
icon: const Icon(Icons.add),
|
||||
);
|
||||
return SectionHeading(
|
||||
title: controller.hasLoaded && controller.failure == null
|
||||
? '$scheduleSectionTitle (${controller.schedules.length})'
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../../../ui/layout/app_list_row.dart';
|
||||
import '../../../../ui/layout/app_overflow_menu.dart';
|
||||
import '../../domain/saved_schedule.dart';
|
||||
@@ -39,12 +38,11 @@ class SchedulePipelineRow extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final id = schedule.id;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final row = AppListRow(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
divider: divider && error == null,
|
||||
onTap: busy ? null : onEdit,
|
||||
leading: ScheduleAvatar(schedule: schedule, cupertino: cupertino),
|
||||
leading: ScheduleAvatar(schedule: schedule, cupertino: false),
|
||||
title: Text(scheduleDisplayName(schedule)),
|
||||
time: scheduleNextDueShort(schedule),
|
||||
subtitle: Text(
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Host text roles and standard buttons for the pipeline schedule section.
|
||||
/// Material text roles and standard buttons for the pipeline schedule section.
|
||||
/// No palette, font family or explicit point size is introduced.
|
||||
TextStyle? schedulePipelineHeadingStyle(BuildContext context) =>
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleMedium;
|
||||
Theme.of(context).textTheme.titleMedium;
|
||||
|
||||
TextStyle? schedulePipelineMutedStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
@@ -25,32 +15,18 @@ TextStyle? schedulePipelineMutedStyle(BuildContext context) {
|
||||
TextStyle? schedulePipelineStatusStyle(BuildContext context, bool enabled) {
|
||||
final base = schedulePipelineMutedStyle(context);
|
||||
if (!enabled) return base;
|
||||
return usesCupertinoHost(context)
|
||||
? base?.copyWith(color: CupertinoTheme.of(context).primaryColor)
|
||||
: base?.copyWith(color: Theme.of(context).colorScheme.primary);
|
||||
return base?.copyWith(color: Theme.of(context).colorScheme.primary);
|
||||
}
|
||||
|
||||
TextStyle? schedulePipelineErrorStyle(BuildContext context) =>
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
)
|
||||
: TextStyle(color: Theme.of(context).colorScheme.error);
|
||||
TextStyle(color: Theme.of(context).colorScheme.error);
|
||||
|
||||
/// A standard platform text action.
|
||||
/// A standard text action.
|
||||
Widget schedulePipelineTextButton(
|
||||
BuildContext context, {
|
||||
required String label,
|
||||
required VoidCallback? onPressed,
|
||||
Key? key,
|
||||
}) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton(
|
||||
key: key,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
return TextButton(key: key, onPressed: onPressed, child: Text(label));
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../../../ui/adaptive/host.dart';
|
||||
import '../../data/schedules_repository.dart';
|
||||
import '../../domain/editor/schedule_draft.dart';
|
||||
import '../../domain/schedule_json.dart';
|
||||
@@ -84,19 +82,11 @@ class _ScheduleRunActionState extends State<ScheduleRunAction> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!canScheduleRun(widget.run)) return const SizedBox.shrink();
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final action = cupertino
|
||||
? CupertinoButton.tinted(
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
key: scheduleRunActionKey,
|
||||
onPressed: _open,
|
||||
child: const Text(scheduleRunActionLabel),
|
||||
)
|
||||
: OutlinedButton(
|
||||
key: scheduleRunActionKey,
|
||||
onPressed: _open,
|
||||
child: const Text(scheduleRunActionLabel),
|
||||
);
|
||||
final action = OutlinedButton(
|
||||
key: scheduleRunActionKey,
|
||||
onPressed: _open,
|
||||
child: const Text(scheduleRunActionLabel),
|
||||
);
|
||||
return Tooltip(message: scheduleRunActionHint, child: action);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user