Remove Cupertino settings branches
Keep the Material settings implementation while preserving public Cupertino parameters for later cleanup. Narrow settings tests to the Material-only behavior.
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../ui/theme/app_theme.dart';
|
|
||||||
import 'settings_layout.dart';
|
import 'settings_layout.dart';
|
||||||
import 'settings_theme.dart';
|
|
||||||
|
|
||||||
/// The Settings page's scrolling column of groups.
|
/// The Settings page's scrolling column of groups.
|
||||||
///
|
///
|
||||||
@@ -11,8 +9,7 @@ import 'settings_theme.dart';
|
|||||||
/// floating tab bar's (the bottom media padding), so at rest nothing is hidden
|
/// floating tab bar's (the bottom media padding), so at rest nothing is hidden
|
||||||
/// and scrolled groups pass behind the glass pills. The column starts at the
|
/// and scrolled groups pass behind the glass pills. The column starts at the
|
||||||
/// bar's own side inset, so the groups line up under the title pill, and stops
|
/// bar's own side inset, so the groups line up under the title pill, and stops
|
||||||
/// at [settingsContentMaxWidth] on a wide window. Cupertino paints the page in
|
/// at [settingsContentMaxWidth] on a wide window.
|
||||||
/// the grouped background its inset-grouped sections are designed for.
|
|
||||||
class SettingsPageBody extends StatelessWidget {
|
class SettingsPageBody extends StatelessWidget {
|
||||||
const SettingsPageBody({super.key, required this.children});
|
const SettingsPageBody({super.key, required this.children});
|
||||||
|
|
||||||
@@ -21,11 +18,7 @@ class SettingsPageBody extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final insets = MediaQuery.paddingOf(context);
|
final insets = MediaQuery.paddingOf(context);
|
||||||
// The inset-grouped section already pads above its own header.
|
return SingleChildScrollView(
|
||||||
final gap = usesCupertinoControls(context)
|
|
||||||
? settingsTitleGap
|
|
||||||
: settingsSectionGap;
|
|
||||||
final Widget list = SingleChildScrollView(
|
|
||||||
key: const ValueKey<String>('settings.scroll'),
|
key: const ValueKey<String>('settings.scroll'),
|
||||||
padding: EdgeInsets.fromLTRB(
|
padding: EdgeInsets.fromLTRB(
|
||||||
insets.left + settingsPageSidePadding,
|
insets.left + settingsPageSidePadding,
|
||||||
@@ -41,7 +34,7 @@ class SettingsPageBody extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
for (final (index, child) in children.indexed) ...<Widget>[
|
for (final (index, child) in children.indexed) ...<Widget>[
|
||||||
if (index > 0) SizedBox(height: gap),
|
if (index > 0) const SizedBox(height: settingsSectionGap),
|
||||||
child,
|
child,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@@ -49,15 +42,5 @@ class SettingsPageBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (!usesCupertinoControls(context)) return list;
|
|
||||||
return ColoredBox(
|
|
||||||
color: settingsCupertinoBackground.resolveFrom(context),
|
|
||||||
child: list,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The Cupertino Settings page background: the system grouped background, so
|
|
||||||
/// the inset sections' rows read as raised cards in light and dark.
|
|
||||||
const CupertinoDynamicColor settingsCupertinoBackground =
|
|
||||||
AppColors.groupedBackground;
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../ui/motion/quick_switch_animation.dart';
|
import '../../ui/motion/quick_switch_animation.dart';
|
||||||
import 'settings_theme.dart';
|
import 'settings_theme.dart';
|
||||||
@@ -9,28 +8,6 @@ class SettingsQuickSwitchControl extends StatelessWidget {
|
|||||||
const SettingsQuickSwitchControl({super.key, required this.controller});
|
const SettingsQuickSwitchControl({super.key, required this.controller});
|
||||||
final QuickSwitchAnimationController controller;
|
final QuickSwitchAnimationController controller;
|
||||||
|
|
||||||
Future<void> _choose(BuildContext context) async {
|
|
||||||
final choice = await showCupertinoModalPopup<QuickSwitchAnimation>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoActionSheet(
|
|
||||||
title: const Text('Quick switch animation'),
|
|
||||||
actions: [
|
|
||||||
for (final animation in QuickSwitchAnimation.values)
|
|
||||||
CupertinoActionSheetAction(
|
|
||||||
isDefaultAction: animation == controller.value,
|
|
||||||
onPressed: () => Navigator.pop(context, animation),
|
|
||||||
child: Text(animation.label),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
cancelButton: CupertinoActionSheetAction(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (choice != null) await controller.setAnimation(choice);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => ListenableBuilder(
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
listenable: controller,
|
listenable: controller,
|
||||||
@@ -41,33 +18,17 @@ class SettingsQuickSwitchControl extends StatelessWidget {
|
|||||||
'Quick switch animation',
|
'Quick switch animation',
|
||||||
style: settingsTextStyle(context, title: true),
|
style: settingsTextStyle(context, title: true),
|
||||||
),
|
),
|
||||||
if (usesCupertinoControls(context))
|
DropdownButton<QuickSwitchAnimation>(
|
||||||
CupertinoButton(
|
value: controller.value,
|
||||||
onPressed: () => unawaited(_choose(context)),
|
isExpanded: true,
|
||||||
child: Row(
|
items: [
|
||||||
mainAxisSize: MainAxisSize.min,
|
for (final animation in QuickSwitchAnimation.values)
|
||||||
children: [
|
DropdownMenuItem(value: animation, child: Text(animation.label)),
|
||||||
Text(controller.value.label),
|
],
|
||||||
const SizedBox(width: 8),
|
onChanged: (value) {
|
||||||
const Icon(CupertinoIcons.chevron_down),
|
if (value != null) unawaited(controller.setAnimation(value));
|
||||||
],
|
},
|
||||||
),
|
),
|
||||||
)
|
|
||||||
else
|
|
||||||
DropdownButton<QuickSwitchAnimation>(
|
|
||||||
value: controller.value,
|
|
||||||
isExpanded: true,
|
|
||||||
items: [
|
|
||||||
for (final animation in QuickSwitchAnimation.values)
|
|
||||||
DropdownMenuItem(
|
|
||||||
value: animation,
|
|
||||||
child: Text(animation.label),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
onChanged: (value) {
|
|
||||||
if (value != null) unawaited(controller.setAnimation(value));
|
|
||||||
},
|
|
||||||
),
|
|
||||||
Text(controller.value.description),
|
Text(controller.value.description),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
QuickSwitchPreview(animation: controller.value),
|
QuickSwitchPreview(animation: controller.value),
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_theme.dart';
|
/// One row of a [SettingsGroup]: a Material [ListTile]. The subtitle wraps, so
|
||||||
|
/// addresses and status details stay readable at large text.
|
||||||
/// One row of a [SettingsGroup]: Material [ListTile], Cupertino
|
|
||||||
/// [CupertinoListTile]. The subtitle wraps (the Cupertino tile otherwise caps
|
|
||||||
/// it at one line), so addresses and status details stay readable at large
|
|
||||||
/// text.
|
|
||||||
class SettingsRow extends StatelessWidget {
|
class SettingsRow extends StatelessWidget {
|
||||||
const SettingsRow({
|
const SettingsRow({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -26,7 +21,7 @@ class SettingsRow extends StatelessWidget {
|
|||||||
final Widget? trailing;
|
final Widget? trailing;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
/// A navigation row: shows the platform's disclosure chevron.
|
/// A navigation row: shows the disclosure chevron.
|
||||||
final bool chevron;
|
final bool chevron;
|
||||||
|
|
||||||
/// A command row (Reconnect, Add server): the title takes the accent
|
/// A command row (Reconnect, Add server): the title takes the accent
|
||||||
@@ -34,43 +29,9 @@ class SettingsRow extends StatelessWidget {
|
|||||||
final bool action;
|
final bool action;
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
|
|
||||||
Widget _wrapping(Widget child) => Builder(
|
|
||||||
builder: (context) => DefaultTextStyle(
|
|
||||||
style: DefaultTextStyle.of(context).style,
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final tap = enabled ? onTap : null;
|
final tap = enabled ? onTap : null;
|
||||||
final subtitle = this.subtitle;
|
|
||||||
if (usesCupertinoControls(context)) {
|
|
||||||
final accent = CupertinoTheme.of(context).primaryColor;
|
|
||||||
final disabled = CupertinoColors.tertiaryLabel.resolveFrom(context);
|
|
||||||
return CupertinoListTile(
|
|
||||||
leading: leading == null
|
|
||||||
? null
|
|
||||||
: IconTheme.merge(
|
|
||||||
data: IconThemeData(color: enabled ? accent : disabled),
|
|
||||||
child: leading!,
|
|
||||||
),
|
|
||||||
title: DefaultTextStyle.merge(
|
|
||||||
style: TextStyle(
|
|
||||||
color: !enabled
|
|
||||||
? disabled
|
|
||||||
: action
|
|
||||||
? accent
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
child: title,
|
|
||||||
),
|
|
||||||
subtitle: subtitle == null ? null : _wrapping(subtitle),
|
|
||||||
trailing:
|
|
||||||
trailing ?? (chevron ? const CupertinoListTileChevron() : null),
|
|
||||||
onTap: tap,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final scheme = Theme.of(context).colorScheme;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
enabled: enabled,
|
enabled: enabled,
|
||||||
|
|||||||
@@ -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 '../../ui/scale/ui_scale.dart';
|
import '../../ui/scale/ui_scale.dart';
|
||||||
@@ -34,7 +33,6 @@ class _SettingsScaleSectionState extends State<SettingsScaleSection> {
|
|||||||
Widget build(BuildContext context) => ListenableBuilder(
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
listenable: _controller,
|
listenable: _controller,
|
||||||
builder: (context, _) {
|
builder: (context, _) {
|
||||||
final cupertino = usesCupertinoControls(context);
|
|
||||||
final value = _draft ?? _controller.scale;
|
final value = _draft ?? _controller.scale;
|
||||||
final label = '${value.toStringAsFixed(1)}×';
|
final label = '${value.toStringAsFixed(1)}×';
|
||||||
final reset = _controller.scale == 1 && _draft == null
|
final reset = _controller.scale == 1 && _draft == null
|
||||||
@@ -70,41 +68,23 @@ class _SettingsScaleSectionState extends State<SettingsScaleSection> {
|
|||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(label, style: settingsTextStyle(context, title: true)),
|
Text(label, style: settingsTextStyle(context, title: true)),
|
||||||
cupertino
|
TextButton(onPressed: reset, child: const Text('Reset')),
|
||||||
? CupertinoButton(
|
|
||||||
onPressed: reset,
|
|
||||||
child: const Text('Reset'),
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: reset,
|
|
||||||
child: const Text('Reset'),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Semantics(
|
Semantics(
|
||||||
label: 'Interface size',
|
label: 'Interface size',
|
||||||
child: cupertino
|
child: Slider(
|
||||||
? CupertinoSlider(
|
key: const Key('settings-ui-scale'),
|
||||||
key: const Key('settings-ui-scale'),
|
value: value,
|
||||||
value: value,
|
min: minUiScale,
|
||||||
min: minUiScale,
|
max: maxUiScale,
|
||||||
max: maxUiScale,
|
divisions: 15,
|
||||||
divisions: 15,
|
label: label,
|
||||||
onChanged: drag,
|
semanticFormatterCallback: (v) =>
|
||||||
onChangeEnd: _apply,
|
'${v.toStringAsFixed(1)} times',
|
||||||
)
|
onChanged: drag,
|
||||||
: Slider(
|
onChangeEnd: _apply,
|
||||||
key: const Key('settings-ui-scale'),
|
),
|
||||||
value: value,
|
|
||||||
min: minUiScale,
|
|
||||||
max: maxUiScale,
|
|
||||||
divisions: 15,
|
|
||||||
label: label,
|
|
||||||
semanticFormatterCallback: (v) =>
|
|
||||||
'${v.toStringAsFixed(1)} times',
|
|
||||||
onChanged: drag,
|
|
||||||
onChangeEnd: _apply,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const Wrap(
|
const Wrap(
|
||||||
alignment: WrapAlignment.spaceBetween,
|
alignment: WrapAlignment.spaceBetween,
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_keys.dart';
|
import 'settings_keys.dart';
|
||||||
import 'settings_row.dart';
|
import 'settings_row.dart';
|
||||||
import 'settings_theme.dart';
|
|
||||||
|
|
||||||
/// The Settings entry to the saved-schedule list.
|
/// The Settings entry to the saved-schedule list.
|
||||||
///
|
///
|
||||||
@@ -22,11 +20,7 @@ class SettingsSchedulesSection extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SettingsRow(
|
Widget build(BuildContext context) => SettingsRow(
|
||||||
key: SettingsKeys.schedules,
|
key: SettingsKeys.schedules,
|
||||||
leading: Icon(
|
leading: const Icon(Icons.event_repeat_outlined),
|
||||||
usesCupertinoControls(context)
|
|
||||||
? CupertinoIcons.calendar
|
|
||||||
: Icons.event_repeat_outlined,
|
|
||||||
),
|
|
||||||
title: const Text(settingsSchedulesLabel),
|
title: const Text(settingsSchedulesLabel),
|
||||||
subtitle: const Text(settingsSchedulesSecondary),
|
subtitle: const Text(settingsSchedulesSecondary),
|
||||||
chevron: true,
|
chevron: true,
|
||||||
|
|||||||
@@ -4,15 +4,12 @@ import '../../ui/adaptive/segmented_bar.dart';
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/transport/pipelines_client.dart' as transport;
|
import '../../core/transport/pipelines_client.dart' as transport;
|
||||||
import '../../shell/shell_bar.dart';
|
|
||||||
import '../attention/notify/notification_controller.dart';
|
import '../attention/notify/notification_controller.dart';
|
||||||
import 'default_endpoint.dart';
|
import 'default_endpoint.dart';
|
||||||
import 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
import 'settings_controls.dart';
|
|
||||||
import 'settings_font_section.dart';
|
import 'settings_font_section.dart';
|
||||||
import 'settings_animation_section.dart';
|
import 'settings_animation_section.dart';
|
||||||
import 'settings_scale_section.dart';
|
import 'settings_scale_section.dart';
|
||||||
@@ -44,7 +41,7 @@ import 'managed_connection_section.dart';
|
|||||||
part 'settings_topic_pages.dart';
|
part 'settings_topic_pages.dart';
|
||||||
|
|
||||||
/// The Settings destination: the server connection and the server-side
|
/// The Settings destination: the server connection and the server-side
|
||||||
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
|
/// workspace in native Material controls.
|
||||||
///
|
///
|
||||||
/// The shared [transport.PipelinesClient] is supplied by the shell. This screen
|
/// The shared [transport.PipelinesClient] is supplied by the shell. This screen
|
||||||
/// subscribes to it, connects/disconnects it and pings it on connected, but it
|
/// subscribes to it, connects/disconnects it and pings it on connected, but it
|
||||||
@@ -190,25 +187,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
pages: _topicPages(),
|
pages: _topicPages(),
|
||||||
navigationScope: widget.navigationScope,
|
navigationScope: widget.navigationScope,
|
||||||
);
|
);
|
||||||
if (widget.embedded) {
|
if (widget.embedded) return content;
|
||||||
// Under the shell's bar the Cupertino page is the grouped background
|
|
||||||
// right up to the top edge: the bar's scrim takes the same colour, so
|
|
||||||
// no white band or seam shows above the groups.
|
|
||||||
if (usesCupertinoControls(context) && ShellBar.available(context)) {
|
|
||||||
return ShellBar(
|
|
||||||
backgroundColor: settingsCupertinoBackground,
|
|
||||||
child: content,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
if (usesCupertinoControls(context)) {
|
|
||||||
return CupertinoPageScaffold(
|
|
||||||
backgroundColor: settingsCupertinoBackground,
|
|
||||||
navigationBar: const SegmentedBar(cupertino: true, title: 'Settings'),
|
|
||||||
child: content,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
appBar: const SegmentedBar(cupertino: false, title: 'Settings'),
|
appBar: const SegmentedBar(cupertino: false, title: 'Settings'),
|
||||||
|
|||||||
@@ -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 'settings_controller.dart';
|
import 'settings_controller.dart';
|
||||||
@@ -111,8 +110,8 @@ Widget settingsConnectionFooter(SettingsController controller) => Column(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// Workspace controls. The path is resolved by the execution server, and the
|
/// Workspace controls. The path is resolved by the execution server, and the
|
||||||
/// helper says so explicitly; an empty saved value is named "(none)". Save
|
/// helper says so explicitly; an empty saved value is named "(none)". Save is
|
||||||
/// stays a legible tonal (Cupertino: plain) button while it is unavailable.
|
/// a tonal button while it is unavailable.
|
||||||
class SettingsWorkspaceSection extends StatelessWidget {
|
class SettingsWorkspaceSection extends StatelessWidget {
|
||||||
const SettingsWorkspaceSection({
|
const SettingsWorkspaceSection({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -150,22 +149,11 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
|||||||
runSpacing: settingsFieldGap,
|
runSpacing: settingsFieldGap,
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (usesCupertinoControls(context))
|
FilledButton.tonal(
|
||||||
// A tinted button keeps its shape when disabled, so an
|
key: SettingsKeys.saveWorkspace,
|
||||||
// unsaved-nothing state reads as a disabled button,
|
onPressed: save,
|
||||||
// not as stray grey text.
|
child: const Text('Save workspace'),
|
||||||
CupertinoButton.tinted(
|
),
|
||||||
key: SettingsKeys.saveWorkspace,
|
|
||||||
sizeStyle: CupertinoButtonSize.small,
|
|
||||||
onPressed: save,
|
|
||||||
child: const Text('Save workspace'),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
FilledButton.tonal(
|
|
||||||
key: SettingsKeys.saveWorkspace,
|
|
||||||
onPressed: save,
|
|
||||||
child: const Text('Save workspace'),
|
|
||||||
),
|
|
||||||
Text(
|
Text(
|
||||||
savedWorkspaceLine(controller.savedWorkspace),
|
savedWorkspaceLine(controller.savedWorkspace),
|
||||||
style: settingsTextStyle(context, secondary: true),
|
style: settingsTextStyle(context, secondary: true),
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/session/server_session.dart';
|
import '../../core/session/server_session.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
|
||||||
|
|
||||||
/// Signs the phone in at the server's web login with the same password the
|
/// Signs the phone in at the server's web login with the same password the
|
||||||
/// browser uses, so the app can reach a server behind it (over Tailscale, for
|
/// browser uses, so the app can reach a server behind it (over Tailscale, for
|
||||||
@@ -64,45 +62,7 @@ class _SettingsSignInSectionState extends State<SettingsSignInSection> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
final signedIn = ServerSession.cookie != null;
|
final signedIn = ServerSession.cookie != null;
|
||||||
final field = cupertino
|
|
||||||
? CupertinoTextField(
|
|
||||||
key: const Key('settings-sign-in-password'),
|
|
||||||
controller: _password,
|
|
||||||
obscureText: true,
|
|
||||||
placeholder: 'Web password',
|
|
||||||
onSubmitted: (_) => _signIn(),
|
|
||||||
)
|
|
||||||
: TextField(
|
|
||||||
key: const Key('settings-sign-in-password'),
|
|
||||||
controller: _password,
|
|
||||||
obscureText: true,
|
|
||||||
decoration: const InputDecoration(labelText: 'Web password'),
|
|
||||||
onSubmitted: (_) => _signIn(),
|
|
||||||
);
|
|
||||||
final signIn = cupertino
|
|
||||||
? CupertinoButton.filled(
|
|
||||||
key: const Key('settings-sign-in'),
|
|
||||||
onPressed: _busy ? null : _signIn,
|
|
||||||
child: const Text('Sign in'),
|
|
||||||
)
|
|
||||||
: FilledButton(
|
|
||||||
key: const Key('settings-sign-in'),
|
|
||||||
onPressed: _busy ? null : _signIn,
|
|
||||||
child: const Text('Sign in'),
|
|
||||||
);
|
|
||||||
final signOut = cupertino
|
|
||||||
? CupertinoButton(
|
|
||||||
key: const Key('settings-sign-out'),
|
|
||||||
onPressed: _signOut,
|
|
||||||
child: const Text('Sign out'),
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
key: const Key('settings-sign-out'),
|
|
||||||
onPressed: _signOut,
|
|
||||||
child: const Text('Sign out'),
|
|
||||||
);
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
@@ -112,9 +72,30 @@ class _SettingsSignInSectionState extends State<SettingsSignInSection> {
|
|||||||
: 'Only needed when the server sits behind the web login.',
|
: 'Only needed when the server sits behind the web login.',
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
field,
|
TextField(
|
||||||
|
key: const Key('settings-sign-in-password'),
|
||||||
|
controller: _password,
|
||||||
|
obscureText: true,
|
||||||
|
decoration: const InputDecoration(labelText: 'Web password'),
|
||||||
|
onSubmitted: (_) => _signIn(),
|
||||||
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Wrap(spacing: 8, children: [signIn, if (signedIn) signOut]),
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
FilledButton(
|
||||||
|
key: const Key('settings-sign-in'),
|
||||||
|
onPressed: _busy ? null : _signIn,
|
||||||
|
child: const Text('Sign in'),
|
||||||
|
),
|
||||||
|
if (signedIn)
|
||||||
|
TextButton(
|
||||||
|
key: const Key('settings-sign-out'),
|
||||||
|
onPressed: _signOut,
|
||||||
|
child: const Text('Sign out'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
if (_message != null)
|
if (_message != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 4),
|
padding: const EdgeInsets.only(top: 4),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/transport/pipelines_client.dart' as transport;
|
import '../../core/transport/pipelines_client.dart' as transport;
|
||||||
@@ -16,38 +15,30 @@ class SettingsStatusRow extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoControls(context);
|
|
||||||
final state = controller.connection;
|
final state = controller.connection;
|
||||||
final lines = controller.connectionLines;
|
final lines = controller.connectionLines;
|
||||||
final title = lines.isEmpty ? '' : lines.first;
|
final title = lines.isEmpty ? '' : lines.first;
|
||||||
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
|
||||||
final connectedColor = cupertino
|
final connectedColor = Theme.of(context).colorScheme.primary;
|
||||||
? CupertinoColors.systemGreen.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.primary;
|
|
||||||
final Color? color = switch (state.kind) {
|
final Color? color = switch (state.kind) {
|
||||||
transport.ConnectionKind.connected => connectedColor,
|
transport.ConnectionKind.connected => connectedColor,
|
||||||
transport.ConnectionKind.disconnected => settingsErrorColor(context),
|
transport.ConnectionKind.disconnected => settingsErrorColor(context),
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
final Widget leading = switch (state.kind) {
|
final Widget leading = switch (state.kind) {
|
||||||
transport.ConnectionKind.connecting =>
|
transport.ConnectionKind.connecting => const SizedBox.square(
|
||||||
cupertino
|
dimension: 20,
|
||||||
? const CupertinoActivityIndicator()
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
: const SizedBox.square(
|
),
|
||||||
dimension: 20,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
),
|
|
||||||
transport.ConnectionKind.connected => Icon(
|
transport.ConnectionKind.connected => Icon(
|
||||||
cupertino ? CupertinoIcons.checkmark_circle_fill : Icons.check_circle,
|
Icons.check_circle,
|
||||||
color: color,
|
color: color,
|
||||||
),
|
),
|
||||||
transport.ConnectionKind.disconnected => Icon(
|
transport.ConnectionKind.disconnected => Icon(
|
||||||
cupertino ? CupertinoIcons.xmark_circle_fill : Icons.error_outline,
|
Icons.error_outline,
|
||||||
color: color,
|
color: color,
|
||||||
),
|
),
|
||||||
transport.ConnectionKind.idle => Icon(
|
transport.ConnectionKind.idle => Icon(Icons.radio_button_unchecked),
|
||||||
cupertino ? CupertinoIcons.circle : Icons.radio_button_unchecked,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
return SettingsRow(
|
return SettingsRow(
|
||||||
leading: leading,
|
leading: leading,
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'settings_layout.dart';
|
|
||||||
import 'settings_theme.dart';
|
|
||||||
import 'settings_page_body.dart';
|
|
||||||
import 'settings_topic_store.dart';
|
import 'settings_topic_store.dart';
|
||||||
import '../../core/storage/ordered_local_storage.dart';
|
import '../../core/storage/ordered_local_storage.dart';
|
||||||
import '../../ui/motion/surface_visibility.dart';
|
import '../../ui/motion/surface_visibility.dart';
|
||||||
@@ -133,37 +129,13 @@ class _SettingsTopicTabsState extends State<SettingsTopicTabs>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final tabs = usesCupertinoControls(context)
|
final tabs = TabBar(
|
||||||
? SingleChildScrollView(
|
controller: _tabs,
|
||||||
scrollDirection: Axis.horizontal,
|
isScrollable: true,
|
||||||
padding: const EdgeInsets.symmetric(
|
tabAlignment: TabAlignment.start,
|
||||||
horizontal: settingsPageSidePadding,
|
tabs: [for (final topic in SettingsTopic.values) Tab(text: topic.label)],
|
||||||
),
|
);
|
||||||
child: CupertinoSlidingSegmentedControl<SettingsTopic>(
|
return SafeArea(
|
||||||
groupValue: _selected,
|
|
||||||
children: {
|
|
||||||
for (final topic in SettingsTopic.values)
|
|
||||||
topic: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: settingsControlGap,
|
|
||||||
),
|
|
||||||
child: Text(topic.label),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
onValueChanged: (topic) {
|
|
||||||
if (topic != null) _tabs.index = topic.index;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: TabBar(
|
|
||||||
controller: _tabs,
|
|
||||||
isScrollable: true,
|
|
||||||
tabAlignment: TabAlignment.start,
|
|
||||||
tabs: [
|
|
||||||
for (final topic in SettingsTopic.values) Tab(text: topic.label),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
final body = SafeArea(
|
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
@@ -194,11 +166,5 @@ class _SettingsTopicTabsState extends State<SettingsTopicTabs>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return usesCupertinoControls(context)
|
|
||||||
? ColoredBox(
|
|
||||||
color: settingsCupertinoBackground.resolveFrom(context),
|
|
||||||
child: body,
|
|
||||||
)
|
|
||||||
: body;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_keys.dart';
|
import 'settings_keys.dart';
|
||||||
import 'settings_row.dart';
|
import 'settings_row.dart';
|
||||||
import 'settings_theme.dart';
|
|
||||||
|
|
||||||
/// The Settings entry to the Templates gallery.
|
/// The Settings entry to the Templates gallery.
|
||||||
///
|
///
|
||||||
@@ -23,11 +21,7 @@ class SettingsTemplatesSection extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SettingsRow(
|
Widget build(BuildContext context) => SettingsRow(
|
||||||
key: SettingsKeys.templates,
|
key: SettingsKeys.templates,
|
||||||
leading: Icon(
|
leading: const Icon(Icons.widgets_outlined),
|
||||||
usesCupertinoControls(context)
|
|
||||||
? CupertinoIcons.square_grid_2x2
|
|
||||||
: Icons.widgets_outlined,
|
|
||||||
),
|
|
||||||
title: const Text(settingsTemplatesLabel),
|
title: const Text(settingsTemplatesLabel),
|
||||||
subtitle: const Text(settingsTemplatesSecondary),
|
subtitle: const Text(settingsTemplatesSecondary),
|
||||||
chevron: true,
|
chevron: true,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../terminal/terminal_layout.dart';
|
import '../terminal/terminal_layout.dart';
|
||||||
@@ -16,41 +15,25 @@ class SettingsTerminalSection extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) => ListenableBuilder(
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
listenable: layout,
|
listenable: layout,
|
||||||
builder: (context, _) {
|
builder: (context, _) {
|
||||||
final cupertino = usesCupertinoControls(context);
|
final Widget choice = SegmentedButton<TerminalMode>(
|
||||||
final Widget choice = cupertino
|
segments: [
|
||||||
? CupertinoSlidingSegmentedControl<TerminalMode>(
|
for (final mode in TerminalMode.values)
|
||||||
groupValue: layout.mode,
|
ButtonSegment(
|
||||||
children: {
|
value: mode,
|
||||||
for (final mode in TerminalMode.values)
|
label: Text(
|
||||||
mode: Padding(
|
mode.label,
|
||||||
key: ValueKey('settings-terminal-${mode.name}'),
|
key: ValueKey('settings-terminal-${mode.name}'),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
),
|
||||||
child: Text(mode.label),
|
icon: Icon(
|
||||||
),
|
mode == TerminalMode.panel
|
||||||
},
|
? Icons.call_to_action_outlined
|
||||||
onValueChanged: (mode) {
|
: Icons.picture_in_picture_alt_outlined,
|
||||||
if (mode != null) layout.setMode(mode);
|
),
|
||||||
},
|
),
|
||||||
)
|
],
|
||||||
: SegmentedButton<TerminalMode>(
|
selected: {layout.mode},
|
||||||
segments: [
|
onSelectionChanged: (modes) => layout.setMode(modes.first),
|
||||||
for (final mode in TerminalMode.values)
|
);
|
||||||
ButtonSegment(
|
|
||||||
value: mode,
|
|
||||||
label: Text(
|
|
||||||
mode.label,
|
|
||||||
key: ValueKey('settings-terminal-${mode.name}'),
|
|
||||||
),
|
|
||||||
icon: Icon(
|
|
||||||
mode == TerminalMode.panel
|
|
||||||
? Icons.call_to_action_outlined
|
|
||||||
: Icons.picture_in_picture_alt_outlined,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
selected: {layout.mode},
|
|
||||||
onSelectionChanged: (modes) => layout.setMode(modes.first),
|
|
||||||
);
|
|
||||||
return SettingsGroup(
|
return SettingsGroup(
|
||||||
title: 'Terminal',
|
title: 'Terminal',
|
||||||
footer: Column(
|
footer: Column(
|
||||||
|
|||||||
@@ -1,33 +1,15 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../ui/adaptive/host.dart';
|
Color settingsErrorColor(BuildContext context) =>
|
||||||
|
Theme.of(context).colorScheme.error;
|
||||||
|
|
||||||
/// Cupertino only under an explicit Cupertino host; Material on every
|
/// Resolve the app's text roles from the Material theme.
|
||||||
/// platform otherwise.
|
|
||||||
bool usesCupertinoControls(BuildContext context) => usesCupertinoHost(context);
|
|
||||||
|
|
||||||
Color settingsErrorColor(BuildContext context) => usesCupertinoControls(context)
|
|
||||||
? CupertinoColors.destructiveRed.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.error;
|
|
||||||
|
|
||||||
/// Resolve native text roles from the actual host, not Material's fallback
|
|
||||||
/// light theme when mounted under a dark CupertinoApp.
|
|
||||||
TextStyle settingsTextStyle(
|
TextStyle settingsTextStyle(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
bool title = false,
|
bool title = false,
|
||||||
bool secondary = false,
|
bool secondary = false,
|
||||||
bool error = false,
|
bool error = false,
|
||||||
}) {
|
}) {
|
||||||
if (usesCupertinoControls(context)) {
|
|
||||||
final text = CupertinoTheme.of(context).textTheme;
|
|
||||||
return (title ? text.navTitleTextStyle : text.textStyle).copyWith(
|
|
||||||
color: error
|
|
||||||
? settingsErrorColor(context)
|
|
||||||
: (secondary ? CupertinoColors.secondaryLabel : CupertinoColors.label)
|
|
||||||
.resolveFrom(context),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final base = (title
|
final base = (title
|
||||||
? theme.textTheme.titleMedium
|
? theme.textTheme.titleMedium
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'settings_copy.dart';
|
import 'settings_copy.dart';
|
||||||
@@ -13,14 +12,15 @@ class SettingsTrustWarning extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final icon = usesCupertinoControls(context)
|
|
||||||
? CupertinoIcons.exclamationmark_triangle
|
|
||||||
: Icons.warning_amber_rounded;
|
|
||||||
final error = settingsErrorColor(context);
|
final error = settingsErrorColor(context);
|
||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(icon, color: error, semanticLabel: 'Warning'),
|
Icon(
|
||||||
|
Icons.warning_amber_rounded,
|
||||||
|
color: error,
|
||||||
|
semanticLabel: 'Warning',
|
||||||
|
),
|
||||||
const SizedBox(width: settingsControlGap),
|
const SizedBox(width: settingsControlGap),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../ui/adaptive/host.dart';
|
|
||||||
import '../updates/app_updates.dart';
|
import '../updates/app_updates.dart';
|
||||||
import 'server_connections.dart';
|
import 'server_connections.dart';
|
||||||
|
|
||||||
@@ -108,31 +106,14 @@ class _SettingsUpdatesSectionState extends State<SettingsUpdatesSection> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
Widget button(
|
Widget button(
|
||||||
Key key,
|
Key key,
|
||||||
String label,
|
String label,
|
||||||
VoidCallback? onPressed,
|
VoidCallback? onPressed,
|
||||||
bool primary,
|
bool primary,
|
||||||
) => cupertino
|
) => primary
|
||||||
? (primary
|
? FilledButton(key: key, onPressed: onPressed, child: Text(label))
|
||||||
? CupertinoButton.filled(
|
: OutlinedButton(key: key, onPressed: onPressed, child: Text(label));
|
||||||
key: key,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: Text(label),
|
|
||||||
)
|
|
||||||
: CupertinoButton(
|
|
||||||
key: key,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: Text(label),
|
|
||||||
))
|
|
||||||
: (primary
|
|
||||||
? FilledButton(key: key, onPressed: onPressed, child: Text(label))
|
|
||||||
: OutlinedButton(
|
|
||||||
key: key,
|
|
||||||
onPressed: onPressed,
|
|
||||||
child: Text(label),
|
|
||||||
));
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
@@ -166,11 +147,7 @@ class _SettingsUpdatesSectionState extends State<SettingsUpdatesSection> {
|
|||||||
if (_progress != null)
|
if (_progress != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 8),
|
padding: const EdgeInsets.only(top: 8),
|
||||||
child: cupertino
|
child: LinearProgressIndicator(value: _progress),
|
||||||
? CupertinoActivityIndicator.partiallyRevealed(
|
|
||||||
progress: _progress!,
|
|
||||||
)
|
|
||||||
: LinearProgressIndicator(value: _progress),
|
|
||||||
),
|
),
|
||||||
if (_message != null)
|
if (_message != null)
|
||||||
Padding(
|
Padding(
|
||||||
|
|||||||
@@ -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';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@@ -252,7 +251,6 @@ void main() {
|
|||||||
|
|
||||||
await _pump(tester, client, platform: TargetPlatform.iOS);
|
await _pump(tester, client, platform: TargetPlatform.iOS);
|
||||||
|
|
||||||
expect(find.byType(CupertinoTextField), findsNothing);
|
|
||||||
expect(find.byType(TextField), findsWidgets);
|
expect(find.byType(TextField), findsWidgets);
|
||||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
expect(find.byKey(SettingsKeys.connect), 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/features/settings/settings_tabs.dart';
|
import 'package:pipelines_app/features/settings/settings_tabs.dart';
|
||||||
@@ -33,7 +32,7 @@ class _PageState extends State<_Page> {
|
|||||||
controller: scroll,
|
controller: scroll,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
CupertinoTextField(controller: text),
|
TextField(controller: text),
|
||||||
for (var i = 0; i < 80; i++) Text('${widget.name} item $i'),
|
for (var i = 0; i < 80; i++) Text('${widget.name} item $i'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -41,84 +40,66 @@ class _PageState extends State<_Page> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('lazy topic pages retain draft and scroll', (tester) async {
|
||||||
testWidgets('lazy topic pages retain draft and scroll ($cupertino)', (
|
final mounts = <SettingsTopic, int>{};
|
||||||
tester,
|
final tabs = SettingsTopicTabs(
|
||||||
) async {
|
pages: {
|
||||||
final mounts = <SettingsTopic, int>{};
|
for (final topic in SettingsTopic.values)
|
||||||
final tabs = SettingsTopicTabs(
|
topic: (_) => _Page(
|
||||||
pages: {
|
name: topic.name,
|
||||||
for (final topic in SettingsTopic.values)
|
onMount: () =>
|
||||||
topic: (_) => _Page(
|
mounts.update(topic, (count) => count + 1, ifAbsent: () => 1),
|
||||||
name: topic.name,
|
),
|
||||||
onMount: () =>
|
},
|
||||||
mounts.update(topic, (count) => count + 1, ifAbsent: () => 1),
|
);
|
||||||
),
|
await tester.pumpWidget(MaterialApp(home: Scaffold(body: tabs)));
|
||||||
},
|
expect(mounts, {SettingsTopic.appearance: 1});
|
||||||
);
|
final appearance = tester.state<_PageState>(find.byType(_Page));
|
||||||
await tester.pumpWidget(
|
appearance.text.text = 'Keep this draft';
|
||||||
cupertino
|
appearance.scroll.jumpTo(150);
|
||||||
? CupertinoApp(home: CupertinoPageScaffold(child: tabs))
|
await tester.pump();
|
||||||
: MaterialApp(home: Scaffold(body: tabs)),
|
await selectSettingsTopic(tester, 'Connection');
|
||||||
);
|
expect(mounts, {SettingsTopic.appearance: 1, SettingsTopic.connection: 1});
|
||||||
expect(mounts, {SettingsTopic.appearance: 1});
|
final connection = tester.state<_PageState>(find.byType(_Page));
|
||||||
final appearance = tester.state<_PageState>(find.byType(_Page));
|
connection.text.text = 'Unsubmitted server';
|
||||||
appearance.text.text = 'Keep this draft';
|
connection.scroll.jumpTo(280);
|
||||||
appearance.scroll.jumpTo(150);
|
await selectSettingsTopic(tester, 'Appearance');
|
||||||
await tester.pump();
|
expect(tester.state(find.byType(_Page)), same(appearance));
|
||||||
await selectSettingsTopic(tester, 'Connection');
|
expect(appearance.text.text, 'Keep this draft');
|
||||||
expect(mounts, {
|
expect(appearance.scroll.offset, 150);
|
||||||
SettingsTopic.appearance: 1,
|
await selectSettingsTopic(tester, 'Connection');
|
||||||
SettingsTopic.connection: 1,
|
expect(tester.state(find.byType(_Page)), same(connection));
|
||||||
});
|
expect(connection.text.text, 'Unsubmitted server');
|
||||||
final connection = tester.state<_PageState>(find.byType(_Page));
|
expect(connection.scroll.offset, 280);
|
||||||
connection.text.text = 'Unsubmitted server';
|
expect(mounts.values, everyElement(1));
|
||||||
connection.scroll.jumpTo(280);
|
});
|
||||||
await selectSettingsTopic(tester, 'Appearance');
|
|
||||||
expect(tester.state(find.byType(_Page)), same(appearance));
|
|
||||||
expect(appearance.text.text, 'Keep this draft');
|
|
||||||
expect(appearance.scroll.offset, 150);
|
|
||||||
await selectSettingsTopic(tester, 'Connection');
|
|
||||||
expect(tester.state(find.byType(_Page)), same(connection));
|
|
||||||
expect(connection.text.text, 'Unsubmitted server');
|
|
||||||
expect(connection.scroll.offset, 280);
|
|
||||||
expect(mounts.values, everyElement(1));
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('all topics reachable at narrow large text ($cupertino)', (
|
testWidgets('all topics reachable at narrow large text', (tester) async {
|
||||||
tester,
|
tester.view.physicalSize = const Size(390, 844);
|
||||||
) async {
|
tester.view.devicePixelRatio = 1;
|
||||||
tester.view.physicalSize = const Size(390, 844);
|
addTearDown(tester.view.reset);
|
||||||
tester.view.devicePixelRatio = 1;
|
final tabs = SettingsTopicTabs(
|
||||||
addTearDown(tester.view.reset);
|
pages: {
|
||||||
final tabs = SettingsTopicTabs(
|
for (final topic in SettingsTopic.values)
|
||||||
pages: {
|
topic: (_) => Text('${topic.label} content'),
|
||||||
for (final topic in SettingsTopic.values)
|
},
|
||||||
topic: (_) => Text('${topic.label} content'),
|
);
|
||||||
},
|
Widget scale(BuildContext context, Widget? child) => MediaQuery(
|
||||||
);
|
data: MediaQuery.of(
|
||||||
Widget scale(BuildContext context, Widget? child) => MediaQuery(
|
context,
|
||||||
data: MediaQuery.of(
|
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||||
context,
|
child: child!,
|
||||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
);
|
||||||
child: child!,
|
await tester.pumpWidget(
|
||||||
);
|
MaterialApp(
|
||||||
await tester.pumpWidget(
|
builder: scale,
|
||||||
cupertino
|
home: Scaffold(body: tabs),
|
||||||
? CupertinoApp(
|
),
|
||||||
builder: scale,
|
);
|
||||||
home: CupertinoPageScaffold(child: tabs),
|
for (final topic in SettingsTopic.values) {
|
||||||
)
|
await selectSettingsTopic(tester, topic.label);
|
||||||
: MaterialApp(
|
expect(find.text('${topic.label} content'), findsOneWidget);
|
||||||
builder: scale,
|
expect(tester.takeException(), isNull);
|
||||||
home: Scaffold(body: tabs),
|
}
|
||||||
),
|
});
|
||||||
);
|
|
||||||
for (final topic in SettingsTopic.values) {
|
|
||||||
await selectSettingsTopic(tester, topic.label);
|
|
||||||
expect(find.text('${topic.label} content'), findsOneWidget);
|
|
||||||
expect(tester.takeException(), isNull);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/servers/server_scope.dart';
|
import 'package:pipelines_app/core/servers/server_scope.dart';
|
||||||
@@ -11,11 +10,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
|
|
||||||
import 'settings_topic_test_helper.dart';
|
import 'settings_topic_test_helper.dart';
|
||||||
|
|
||||||
Widget host({
|
Widget host({String? scope, SettingsTopicStore? store}) {
|
||||||
bool cupertino = false,
|
|
||||||
String? scope,
|
|
||||||
SettingsTopicStore? store,
|
|
||||||
}) {
|
|
||||||
final tabs = SettingsTopicTabs(
|
final tabs = SettingsTopicTabs(
|
||||||
navigationScope: scope,
|
navigationScope: scope,
|
||||||
selectionStore: store,
|
selectionStore: store,
|
||||||
@@ -24,9 +19,7 @@ Widget host({
|
|||||||
topic: (_) => Text('${topic.name} page'),
|
topic: (_) => Text('${topic.name} page'),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return cupertino
|
return MaterialApp(home: Scaffold(body: tabs));
|
||||||
? CupertinoApp(home: CupertinoPageScaffold(child: tabs))
|
|
||||||
: MaterialApp(home: Scaffold(body: tabs));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DelayedStore implements SettingsTopicStore {
|
class DelayedStore implements SettingsTopicStore {
|
||||||
@@ -67,26 +60,22 @@ class SharedQueuedTopicStore implements SettingsTopicStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('restores selected category after recreation', (tester) async {
|
||||||
testWidgets('restores selected category after recreation ($cupertino)', (
|
SharedPreferences.setMockInitialValues({});
|
||||||
tester,
|
await tester.pumpWidget(host(scope: 'server-a'));
|
||||||
) async {
|
await tester.pumpAndSettle();
|
||||||
SharedPreferences.setMockInitialValues({});
|
await selectSettingsTopic(tester, 'Connection');
|
||||||
await tester.pumpWidget(host(cupertino: cupertino, scope: 'server-a'));
|
expect(find.text('connection page'), findsOneWidget);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpWidget(const SizedBox.shrink());
|
||||||
await selectSettingsTopic(tester, 'Connection');
|
await tester.pumpWidget(host(scope: 'server-a'));
|
||||||
expect(find.text('connection page'), findsOneWidget);
|
await tester.pumpAndSettle();
|
||||||
await tester.pumpWidget(const SizedBox.shrink());
|
expect(find.text('connection page'), findsOneWidget);
|
||||||
await tester.pumpWidget(host(cupertino: cupertino, scope: 'server-a'));
|
final preferences = await SharedPreferences.getInstance();
|
||||||
await tester.pumpAndSettle();
|
expect(
|
||||||
expect(find.text('connection page'), findsOneWidget);
|
preferences.getString(scopedServerKey(settingsTopicKey, 'server-a')),
|
||||||
final preferences = await SharedPreferences.getInstance();
|
'connection',
|
||||||
expect(
|
);
|
||||||
preferences.getString(scopedServerKey(settingsTopicKey, 'server-a')),
|
});
|
||||||
'connection',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
testWidgets('server scopes and malformed selections are independent', (
|
testWidgets('server scopes and malformed selections are independent', (
|
||||||
tester,
|
tester,
|
||||||
|
|||||||
Reference in New Issue
Block a user