Merge commit '122f9fcd33b256842fcbde729e76fd031d988314' into pipelines/run-20261111-0040-cupertino-out-ui-status-text-scale-3de6
This commit is contained in:
@@ -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 'discovered_server.dart';
|
import 'discovered_server.dart';
|
||||||
|
|
||||||
/// One discovered machine. A machine with one route is used by tapping it. A
|
/// One discovered machine. A machine with one route is used by tapping it. A
|
||||||
@@ -48,7 +46,6 @@ class _DiscoveredServerRowState extends State<DiscoveredServerRow> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
final server = widget.server;
|
final server = widget.server;
|
||||||
final detail = _multiple
|
final detail = _multiple
|
||||||
? '${server.addresses.length} addresses'
|
? '${server.addresses.length} addresses'
|
||||||
@@ -57,47 +54,26 @@ class _DiscoveredServerRowState extends State<DiscoveredServerRow> {
|
|||||||
server.passwordRequired ? '$detail · password' : detail,
|
server.passwordRequired ? '$detail · password' : detail,
|
||||||
);
|
);
|
||||||
final onTap = widget.enabled ? _tap : null;
|
final onTap = widget.enabled ? _tap : null;
|
||||||
final Widget head = cupertino
|
final Widget head = ListTile(
|
||||||
? CupertinoListTile(
|
key: Key('discovered-${server.address}'),
|
||||||
key: Key('discovered-${server.address}'),
|
leading: const Icon(Icons.dns_outlined),
|
||||||
leading: const Icon(CupertinoIcons.desktopcomputer),
|
title: Text(server.name),
|
||||||
title: Text(server.name),
|
subtitle: subtitle,
|
||||||
subtitle: subtitle,
|
trailing: Icon(
|
||||||
trailing: _multiple
|
_multiple
|
||||||
? Icon(
|
? (_expanded ? Icons.expand_less : Icons.expand_more)
|
||||||
_expanded
|
: Icons.chevron_right,
|
||||||
? CupertinoIcons.chevron_up
|
),
|
||||||
: CupertinoIcons.chevron_down,
|
enabled: widget.enabled,
|
||||||
)
|
onTap: onTap,
|
||||||
: const CupertinoListTileChevron(),
|
);
|
||||||
onTap: onTap,
|
|
||||||
)
|
|
||||||
: ListTile(
|
|
||||||
key: Key('discovered-${server.address}'),
|
|
||||||
leading: const Icon(Icons.dns_outlined),
|
|
||||||
title: Text(server.name),
|
|
||||||
subtitle: subtitle,
|
|
||||||
trailing: Icon(
|
|
||||||
_multiple
|
|
||||||
? (_expanded ? Icons.expand_less : Icons.expand_more)
|
|
||||||
: Icons.chevron_right,
|
|
||||||
),
|
|
||||||
enabled: widget.enabled,
|
|
||||||
onTap: onTap,
|
|
||||||
);
|
|
||||||
if (!_multiple || !_expanded) return head;
|
if (!_multiple || !_expanded) return head;
|
||||||
final useLabel = 'Use ${server.name}';
|
final useLabel = 'Use ${server.name}';
|
||||||
final use = cupertino
|
final use = FilledButton(
|
||||||
? CupertinoButton.filled(
|
key: Key('discovered-use-${server.address}'),
|
||||||
key: Key('discovered-use-${server.address}'),
|
onPressed: widget.enabled && _chosen.isNotEmpty ? _use : null,
|
||||||
onPressed: widget.enabled && _chosen.isNotEmpty ? _use : null,
|
child: Text(useLabel),
|
||||||
child: Text(useLabel),
|
);
|
||||||
)
|
|
||||||
: FilledButton(
|
|
||||||
key: Key('discovered-use-${server.address}'),
|
|
||||||
onPressed: widget.enabled && _chosen.isNotEmpty ? _use : null,
|
|
||||||
child: Text(useLabel),
|
|
||||||
);
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
@@ -109,8 +85,7 @@ class _DiscoveredServerRowState extends State<DiscoveredServerRow> {
|
|||||||
'as routes to this one machine; the first is tried first.',
|
'as routes to this one machine; the first is tried first.',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
for (final address in server.addresses)
|
for (final address in server.addresses) _choice(address),
|
||||||
_choice(context, cupertino, address),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
child: Align(alignment: AlignmentDirectional.centerStart, child: use),
|
child: Align(alignment: AlignmentDirectional.centerStart, child: use),
|
||||||
@@ -119,11 +94,7 @@ class _DiscoveredServerRowState extends State<DiscoveredServerRow> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _choice(
|
Widget _choice(DiscoveredAddress address) {
|
||||||
BuildContext context,
|
|
||||||
bool cupertino,
|
|
||||||
DiscoveredAddress address,
|
|
||||||
) {
|
|
||||||
final checked = _chosen.contains(address);
|
final checked = _chosen.contains(address);
|
||||||
void toggle(bool? value) => setState(() {
|
void toggle(bool? value) => setState(() {
|
||||||
if (value ?? false) {
|
if (value ?? false) {
|
||||||
@@ -133,26 +104,12 @@ class _DiscoveredServerRowState extends State<DiscoveredServerRow> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
final key = Key('discovered-route-${address.endpoint}');
|
final key = Key('discovered-route-${address.endpoint}');
|
||||||
final title = Text(address.label);
|
|
||||||
final subtitle = Text(address.endpoint.toString());
|
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoListTile(
|
|
||||||
key: key,
|
|
||||||
title: title,
|
|
||||||
subtitle: subtitle,
|
|
||||||
trailing: CupertinoCheckbox(
|
|
||||||
value: checked,
|
|
||||||
onChanged: widget.enabled ? toggle : null,
|
|
||||||
),
|
|
||||||
onTap: widget.enabled ? () => toggle(!checked) : null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return CheckboxListTile(
|
return CheckboxListTile(
|
||||||
key: key,
|
key: key,
|
||||||
value: checked,
|
value: checked,
|
||||||
onChanged: widget.enabled ? toggle : null,
|
onChanged: widget.enabled ? toggle : null,
|
||||||
title: title,
|
title: Text(address.label),
|
||||||
subtitle: subtitle,
|
subtitle: Text(address.endpoint.toString()),
|
||||||
controlAffinity: ListTileControlAffinity.leading,
|
controlAffinity: ListTileControlAffinity.leading,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
import 'browser_server_discovery.dart';
|
import 'browser_server_discovery.dart';
|
||||||
import 'discovered_server.dart';
|
import 'discovered_server.dart';
|
||||||
import 'discovered_server_row.dart';
|
import 'discovered_server_row.dart';
|
||||||
@@ -88,42 +86,29 @@ class _DiscoveryPanelState extends State<DiscoveryPanel> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
final scanning = _phase == _Phase.scanning;
|
final scanning = _phase == _Phase.scanning;
|
||||||
final label = _phase == _Phase.idle
|
final label = _phase == _Phase.idle
|
||||||
? 'Find servers on this network'
|
? 'Find servers on this network'
|
||||||
: 'Search again';
|
: 'Search again';
|
||||||
final enabled = widget.enabled && !scanning;
|
final enabled = widget.enabled && !scanning;
|
||||||
final button = cupertino
|
final button = OutlinedButton.icon(
|
||||||
? CupertinoButton(
|
key: const Key('discovery-scan'),
|
||||||
key: const Key('discovery-scan'),
|
onPressed: enabled ? _start : null,
|
||||||
onPressed: enabled ? _start : null,
|
icon: const Icon(Icons.wifi_find),
|
||||||
child: Text(label),
|
label: Text(label),
|
||||||
)
|
);
|
||||||
: OutlinedButton.icon(
|
|
||||||
key: const Key('discovery-scan'),
|
|
||||||
onPressed: enabled ? _start : null,
|
|
||||||
icon: const Icon(Icons.wifi_find),
|
|
||||||
label: Text(label),
|
|
||||||
);
|
|
||||||
final status = switch (_phase) {
|
final status = switch (_phase) {
|
||||||
_Phase.scanning => _status(
|
_Phase.scanning => _status(
|
||||||
context,
|
|
||||||
cupertino,
|
|
||||||
const Key('discovery-scanning'),
|
const Key('discovery-scanning'),
|
||||||
'Looking for Pipelines servers…',
|
'Looking for Pipelines servers…',
|
||||||
busy: true,
|
busy: true,
|
||||||
),
|
),
|
||||||
_Phase.done when _servers.isEmpty => _status(
|
_Phase.done when _servers.isEmpty => _status(
|
||||||
context,
|
|
||||||
cupertino,
|
|
||||||
const Key('discovery-empty'),
|
const Key('discovery-empty'),
|
||||||
'No Pipelines servers answered on this network. '
|
'No Pipelines servers answered on this network. '
|
||||||
'Enter the address instead.',
|
'Enter the address instead.',
|
||||||
),
|
),
|
||||||
_Phase.failed => _status(
|
_Phase.failed => _status(
|
||||||
context,
|
|
||||||
cupertino,
|
|
||||||
const Key('discovery-error'),
|
const Key('discovery-error'),
|
||||||
'Could not search this network: $_error',
|
'Could not search this network: $_error',
|
||||||
error: true,
|
error: true,
|
||||||
@@ -149,30 +134,22 @@ class _DiscoveryPanelState extends State<DiscoveryPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _status(
|
Widget _status(
|
||||||
BuildContext context,
|
|
||||||
bool cupertino,
|
|
||||||
Key key,
|
Key key,
|
||||||
String text, {
|
String text, {
|
||||||
bool busy = false,
|
bool busy = false,
|
||||||
bool error = false,
|
bool error = false,
|
||||||
}) {
|
}) {
|
||||||
final color = !error
|
final color = !error ? null : Theme.of(context).colorScheme.error;
|
||||||
? null
|
|
||||||
: cupertino
|
|
||||||
? CupertinoColors.systemRed.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.error;
|
|
||||||
return Padding(
|
return Padding(
|
||||||
key: key,
|
key: key,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
if (busy) ...[
|
if (busy) ...[
|
||||||
cupertino
|
const SizedBox.square(
|
||||||
? const CupertinoActivityIndicator()
|
dimension: 16,
|
||||||
: const SizedBox.square(
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
dimension: 16,
|
),
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
],
|
],
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
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 '../../core/transport/server_url.dart';
|
import '../../core/transport/server_url.dart';
|
||||||
import '../../core/servers/server_probe.dart';
|
import '../../core/servers/server_probe.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
|
||||||
import 'discovery/discovered_server.dart';
|
import 'discovery/discovered_server.dart';
|
||||||
import 'discovery/discovery_panel.dart';
|
import 'discovery/discovery_panel.dart';
|
||||||
import 'discovery/server_discovery.dart';
|
import 'discovery/server_discovery.dart';
|
||||||
@@ -219,7 +217,6 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
|
||||||
final title = _passwordStep ? 'Sign in' : 'Connect to Pipelines';
|
final title = _passwordStep ? 'Sign in' : 'Connect to Pipelines';
|
||||||
final lead = _passwordStep
|
final lead = _passwordStep
|
||||||
? 'Enter the password chosen when Pipelines was installed on '
|
? 'Enter the password chosen when Pipelines was installed on '
|
||||||
@@ -228,7 +225,6 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
'wss://server.example/connect.';
|
'wss://server.example/connect.';
|
||||||
final field = _passwordStep
|
final field = _passwordStep
|
||||||
? _field(
|
? _field(
|
||||||
cupertino,
|
|
||||||
key: const Key('onboarding-password'),
|
key: const Key('onboarding-password'),
|
||||||
controller: _password,
|
controller: _password,
|
||||||
hint: 'Password',
|
hint: 'Password',
|
||||||
@@ -236,7 +232,6 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
onSubmitted: _signIn,
|
onSubmitted: _signIn,
|
||||||
)
|
)
|
||||||
: _field(
|
: _field(
|
||||||
cupertino,
|
|
||||||
key: const Key('onboarding-server'),
|
key: const Key('onboarding-server'),
|
||||||
controller: _server,
|
controller: _server,
|
||||||
hint: 'wss://server/connect',
|
hint: 'wss://server/connect',
|
||||||
@@ -245,26 +240,18 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
);
|
);
|
||||||
final action = _passwordStep ? _signIn : _continue;
|
final action = _passwordStep ? _signIn : _continue;
|
||||||
final label = _passwordStep ? 'Sign in' : 'Continue';
|
final label = _passwordStep ? 'Sign in' : 'Continue';
|
||||||
final button = cupertino
|
final button = FilledButton(
|
||||||
? CupertinoButton.filled(
|
key: const Key('onboarding-next'),
|
||||||
key: const Key('onboarding-next'),
|
onPressed: _busy ? null : action,
|
||||||
onPressed: _busy ? null : action,
|
child: _busy
|
||||||
child: _busy ? const CupertinoActivityIndicator() : Text(label),
|
? const SizedBox(
|
||||||
)
|
width: 18,
|
||||||
: FilledButton(
|
height: 18,
|
||||||
key: const Key('onboarding-next'),
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
onPressed: _busy ? null : action,
|
)
|
||||||
child: _busy
|
: Text(label),
|
||||||
? const SizedBox(
|
);
|
||||||
width: 18,
|
final errorColor = Theme.of(context).colorScheme.error;
|
||||||
height: 18,
|
|
||||||
child: CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
)
|
|
||||||
: Text(label),
|
|
||||||
);
|
|
||||||
final errorColor = cupertino
|
|
||||||
? CupertinoColors.systemRed.resolveFrom(context)
|
|
||||||
: Theme.of(context).colorScheme.error;
|
|
||||||
final body = SafeArea(
|
final body = SafeArea(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
@@ -274,14 +261,7 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(title, style: Theme.of(context).textTheme.headlineSmall),
|
||||||
title,
|
|
||||||
style: cupertino
|
|
||||||
? CupertinoTheme.of(
|
|
||||||
context,
|
|
||||||
).textTheme.navLargeTitleTextStyle
|
|
||||||
: Theme.of(context).textTheme.headlineSmall,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Text(lead),
|
Text(lead),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
@@ -289,7 +269,6 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
if (!_passwordStep) ...[
|
if (!_passwordStep) ...[
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_field(
|
_field(
|
||||||
cupertino,
|
|
||||||
key: const Key('onboarding-server-name'),
|
key: const Key('onboarding-server-name'),
|
||||||
controller: _name,
|
controller: _name,
|
||||||
hint: 'Machine name',
|
hint: 'Machine name',
|
||||||
@@ -324,15 +303,10 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
],
|
],
|
||||||
if (_passwordStep && !widget.startAtPassword) ...[
|
if (_passwordStep && !widget.startAtPassword) ...[
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
cupertino
|
TextButton(
|
||||||
? CupertinoButton(
|
onPressed: _busy ? null : _back,
|
||||||
onPressed: _busy ? null : _back,
|
child: const Text('Change server'),
|
||||||
child: const Text('Change server'),
|
),
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: _busy ? null : _back,
|
|
||||||
child: const Text('Change server'),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
if (widget.savedServers != null) ...[
|
if (widget.savedServers != null) ...[
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
@@ -344,13 +318,10 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return cupertino
|
return Scaffold(body: body);
|
||||||
? CupertinoPageScaffold(child: body)
|
|
||||||
: Scaffold(body: body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _field(
|
Widget _field({
|
||||||
bool cupertino, {
|
|
||||||
required Key key,
|
required Key key,
|
||||||
required TextEditingController controller,
|
required TextEditingController controller,
|
||||||
required String hint,
|
required String hint,
|
||||||
@@ -358,18 +329,6 @@ class _OnboardingFlowState extends State<OnboardingFlow> {
|
|||||||
bool obscure = false,
|
bool obscure = false,
|
||||||
TextInputType? keyboard,
|
TextInputType? keyboard,
|
||||||
}) {
|
}) {
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoTextField(
|
|
||||||
key: key,
|
|
||||||
controller: controller,
|
|
||||||
placeholder: hint,
|
|
||||||
obscureText: obscure,
|
|
||||||
autocorrect: false,
|
|
||||||
keyboardType: keyboard,
|
|
||||||
autofocus: true,
|
|
||||||
onSubmitted: (_) => onSubmitted(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return TextField(
|
return TextField(
|
||||||
key: key,
|
key: key,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'app_updates.dart';
|
import 'app_updates.dart';
|
||||||
@@ -10,113 +9,60 @@ Future<bool?> showLaunchUpdateDialog(
|
|||||||
required bool cupertino,
|
required bool cupertino,
|
||||||
String sourceName = '',
|
String sourceName = '',
|
||||||
String nativePlatform = 'android',
|
String nativePlatform = 'android',
|
||||||
}) => cupertino
|
}) => showDialog<bool>(
|
||||||
? showCupertinoDialog<bool>(
|
context: context,
|
||||||
context: context,
|
builder: (context) => AlertDialog(
|
||||||
builder: (context) => CupertinoAlertDialog(
|
title: const Text('Update available'),
|
||||||
title: const Text('Update available'),
|
content: Text(
|
||||||
content: Text(
|
web
|
||||||
web
|
? 'A newer Pipelines web build is available.'
|
||||||
? 'A newer Pipelines web build is available.'
|
: 'A newer ${nativePlatform == 'macos'
|
||||||
: 'A newer ${nativePlatform == 'macos'
|
? 'macOS'
|
||||||
? 'macOS'
|
: nativePlatform == 'linux'
|
||||||
: nativePlatform == 'linux'
|
? 'Linux'
|
||||||
? 'Linux'
|
: 'Android'} build is available${sourceName.isEmpty ? '' : ' from $sourceName'}.${switch (nativePlatform) {
|
||||||
: 'Android'} build is available${sourceName.isEmpty ? '' : ' from $sourceName'}.${switch (nativePlatform) {
|
'linux' => ' Pipelines installs it and restarts.',
|
||||||
'linux' => ' Pipelines installs it and restarts.',
|
'macos' => ' Download and extract the archive to update the app.',
|
||||||
'macos' => ' Download and extract the archive to update the app.',
|
_ => '',
|
||||||
_ => '',
|
}}',
|
||||||
}}',
|
),
|
||||||
),
|
actions: [
|
||||||
actions: [
|
TextButton(
|
||||||
CupertinoDialogAction(
|
onPressed: () => Navigator.pop(context, false),
|
||||||
onPressed: () => Navigator.pop(context, false),
|
child: const Text('Later'),
|
||||||
child: const Text('Later'),
|
),
|
||||||
),
|
FilledButton(
|
||||||
CupertinoDialogAction(
|
onPressed: () => Navigator.pop(context, true),
|
||||||
isDefaultAction: true,
|
child: Text(
|
||||||
onPressed: () => Navigator.pop(context, true),
|
web
|
||||||
child: Text(
|
? 'Refresh'
|
||||||
web
|
: nativePlatform == 'linux'
|
||||||
? 'Refresh'
|
? 'Install and restart'
|
||||||
: nativePlatform == 'linux'
|
: 'Download',
|
||||||
? 'Install and restart'
|
|
||||||
: 'Download',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
: showDialog<bool>(
|
],
|
||||||
context: context,
|
),
|
||||||
builder: (context) => AlertDialog(
|
);
|
||||||
title: const Text('Update available'),
|
|
||||||
content: Text(
|
|
||||||
web
|
|
||||||
? 'A newer Pipelines web build is available.'
|
|
||||||
: 'A newer ${nativePlatform == 'macos'
|
|
||||||
? 'macOS'
|
|
||||||
: nativePlatform == 'linux'
|
|
||||||
? 'Linux'
|
|
||||||
: 'Android'} build is available${sourceName.isEmpty ? '' : ' from $sourceName'}.${switch (nativePlatform) {
|
|
||||||
'linux' => ' Pipelines installs it and restarts.',
|
|
||||||
'macos' => ' Download and extract the archive to update the app.',
|
|
||||||
_ => '',
|
|
||||||
}}',
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context, false),
|
|
||||||
child: const Text('Later'),
|
|
||||||
),
|
|
||||||
FilledButton(
|
|
||||||
onPressed: () => Navigator.pop(context, true),
|
|
||||||
child: Text(
|
|
||||||
web
|
|
||||||
? 'Refresh'
|
|
||||||
: nativePlatform == 'linux'
|
|
||||||
? 'Install and restart'
|
|
||||||
: 'Download',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Future<void> showLaunchUpdateFailure(
|
Future<void> showLaunchUpdateFailure(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
Object error, {
|
Object error, {
|
||||||
required bool cupertino,
|
required bool cupertino,
|
||||||
}) async {
|
}) async {
|
||||||
if (cupertino) {
|
await showDialog<void>(
|
||||||
await showCupertinoDialog<void>(
|
context: context,
|
||||||
context: context,
|
builder: (context) => AlertDialog(
|
||||||
builder: (context) => CupertinoAlertDialog(
|
title: const Text('Update failed'),
|
||||||
title: const Text('Update failed'),
|
content: Text('$error'),
|
||||||
content: Text('$error'),
|
actions: [
|
||||||
actions: [
|
TextButton(
|
||||||
CupertinoDialogAction(
|
onPressed: () => Navigator.pop(context),
|
||||||
onPressed: () => Navigator.pop(context),
|
child: const Text('OK'),
|
||||||
child: const Text('OK'),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => AlertDialog(
|
|
||||||
title: const Text('Update failed'),
|
|
||||||
content: Text('$error'),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text('OK'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reuses the Settings installer while keeping download progress visible.
|
/// Reuses the Settings installer while keeping download progress visible.
|
||||||
@@ -126,24 +72,11 @@ Future<void> installLaunchUpdate(
|
|||||||
required UpdateInstaller installer,
|
required UpdateInstaller installer,
|
||||||
required bool cupertino,
|
required bool cupertino,
|
||||||
}) async {
|
}) async {
|
||||||
final result = cupertino
|
final result = await showDialog<_InstallResult>(
|
||||||
? await showCupertinoDialog<_InstallResult>(
|
context: context,
|
||||||
context: context,
|
barrierDismissible: false,
|
||||||
builder: (_) => _InstallProgress(
|
builder: (_) => _InstallProgress(update: update, installer: installer),
|
||||||
update: update,
|
);
|
||||||
installer: installer,
|
|
||||||
cupertino: true,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: await showDialog<_InstallResult>(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (_) => _InstallProgress(
|
|
||||||
update: update,
|
|
||||||
installer: installer,
|
|
||||||
cupertino: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (result?.error case final Object error) throw error;
|
if (result?.error case final Object error) throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,14 +86,9 @@ class _InstallResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _InstallProgress extends StatefulWidget {
|
class _InstallProgress extends StatefulWidget {
|
||||||
const _InstallProgress({
|
const _InstallProgress({required this.update, required this.installer});
|
||||||
required this.update,
|
|
||||||
required this.installer,
|
|
||||||
required this.cupertino,
|
|
||||||
});
|
|
||||||
final AppUpdate update;
|
final AppUpdate update;
|
||||||
final UpdateInstaller installer;
|
final UpdateInstaller installer;
|
||||||
final bool cupertino;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<_InstallProgress> createState() => _InstallProgressState();
|
State<_InstallProgress> createState() => _InstallProgressState();
|
||||||
@@ -200,19 +128,12 @@ class _InstallProgressState extends State<_InstallProgress> {
|
|||||||
: 'Downloading update… ${(progress * 100).round()}%',
|
: 'Downloading update… ${(progress * 100).round()}%',
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
widget.cupertino
|
LinearProgressIndicator(value: progress),
|
||||||
? const CupertinoActivityIndicator()
|
|
||||||
: LinearProgressIndicator(value: progress),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
child: widget.cupertino
|
child: AlertDialog(title: const Text('App update'), content: content),
|
||||||
? CupertinoAlertDialog(
|
|
||||||
title: const Text('App update'),
|
|
||||||
content: content,
|
|
||||||
)
|
|
||||||
: AlertDialog(title: const Text('App update'), content: content),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Cupertino removal — lib/features/updates
|
||||||
|
|
||||||
|
## Change
|
||||||
|
- `lib/features/updates/launch_update_dialog.dart`: deleted the Cupertino dialog
|
||||||
|
branches from `showLaunchUpdateDialog`, `showLaunchUpdateFailure` and
|
||||||
|
`installLaunchUpdate`, and from the private `_InstallProgress` widget
|
||||||
|
(`CupertinoAlertDialog`, `CupertinoActivityIndicator`, `CupertinoDialogAction`,
|
||||||
|
`showCupertinoDialog`). The Material `AlertDialog`/`LinearProgressIndicator`
|
||||||
|
path is unchanged.
|
||||||
|
- Public signatures keep `required bool cupertino` (unused now) so callers in
|
||||||
|
other directories continue to compile; nothing outside `lib/features/updates`
|
||||||
|
was edited.
|
||||||
|
- Removed the `package:flutter/cupertino.dart` import; no `CupertinoIcons` or
|
||||||
|
`CupertinoColors` were used in this directory.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
- `test/features/updates/native_update_dialog_test.dart`: existing Material
|
||||||
|
prompt loop retained (`cupertino: false`). Added regression tests for the
|
||||||
|
Material failure alert and the Material install-progress dialog/progress bar.
|
||||||
|
No Cupertino test variants were present to delete.
|
||||||
|
- `test/application/startup_update_flow_test.dart` (review follow-up): the web
|
||||||
|
refresh test no longer mounts with `cupertino: true`; it now asserts the
|
||||||
|
Material `AlertDialog`. The local `mount` helper lost its unused `cupertino`
|
||||||
|
parameter and passes `cupertino: false` explicitly. The
|
||||||
|
`package:flutter/cupertino.dart` import became `package:flutter/material.dart`.
|
||||||
|
- `test/application/startup_update_check_test.dart` already mounted Material
|
||||||
|
only (`cupertino: false`); no change.
|
||||||
|
- No other test reaches these dialogs with `cupertino: true` or a `CupertinoApp`
|
||||||
|
host; the remaining `cupertino: true` tests elsewhere cover unrelated UI.
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
- `tool/analyze.sh`: clean (16s, exit 0).
|
||||||
|
- `tool/memwatch/full.sh 'test/features/updates test/application/startup_update_flow_test.dart test/application/startup_update_check_test.dart'`:
|
||||||
|
38 passed, 0 failed, 0 skipped; 38s; exit 0.
|
||||||
|
- `grep -rn 'Cupertino\|cupertino' lib/features/updates`: only the three kept
|
||||||
|
`required bool cupertino` parameters. In the update tests only `cupertino:
|
||||||
|
false` arguments remain.
|
||||||
|
|
||||||
|
## UI states
|
||||||
|
- Update-available prompt, update-failure alert and install-progress dialog now
|
||||||
|
always render the existing Material variants. No pixel change on the Material
|
||||||
|
path; Cupertino host paths are unreachable in this Material-only app.
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Onboarding: Material-only
|
||||||
|
|
||||||
|
Removed the Cupertino branch from `lib/features/onboarding`:
|
||||||
|
|
||||||
|
- `onboarding_flow.dart`: Material `Scaffold`, `TextField` (outline border),
|
||||||
|
`FilledButton` with a small `CircularProgressIndicator`, `TextButton` for
|
||||||
|
"Change server", theme error colour and `headlineSmall` title. Dropped the
|
||||||
|
unused `flutter/cupertino.dart` and `ui/adaptive/host.dart` imports.
|
||||||
|
- `discovery/discovery_panel.dart`: `OutlinedButton.icon` scan action, Material
|
||||||
|
busy indicator and theme error colour.
|
||||||
|
- `discovery/discovered_server_row.dart`: Material `ListTile`,
|
||||||
|
`CheckboxListTile` and `FilledButton`; Cupertino list tiles, chevrons,
|
||||||
|
checkbox and activity indicators removed.
|
||||||
|
|
||||||
|
Public constructors (`OnboardingFlow`, `DiscoveryPanel`, `DiscoveredServerRow`)
|
||||||
|
are unchanged; no `cupertino` parameters existed there. Private helpers lost
|
||||||
|
their now-unused `cupertino`/`context` arguments. No Cupertino icons or colours
|
||||||
|
are kept: the Material path uses none of them.
|
||||||
|
|
||||||
|
## Affected UI states
|
||||||
|
|
||||||
|
First run server entry, machine name, discovery idle/scanning/empty/error, the
|
||||||
|
discovered single-route row, the multi-route checklist and "Use <name>", the
|
||||||
|
sign-in step, probe error text and the "Change server" action. All render the
|
||||||
|
same Material widgets as before on the Material path; no layout or copy changed.
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
- `tool/memwatch/full.sh 'test/features/onboarding '` — PASS, 24 tests, exit 0.
|
||||||
|
- `tool/memwatch/full.sh 'test/features/settings/saved_server_discovery_test.dart
|
||||||
|
test/application/pipelines_root_test.dart
|
||||||
|
test/application/zero_server_recovery_test.dart'` — PASS, 7 tests, exit 0
|
||||||
|
(other users of `OnboardingFlow`/`DiscoveryPanel`).
|
||||||
|
- `tool/analyze.sh` — clean, exit 0.
|
||||||
|
- `grep -rn 'Cupertino\|cupertino' lib/features/onboarding test/features/onboarding`
|
||||||
|
— no matches.
|
||||||
|
|
||||||
|
Test change: `discovery_panel_test.dart` lost its `CupertinoApp` host variant and
|
||||||
|
the `CupertinoListTile` expectation; the `host` helper now always builds a
|
||||||
|
`MaterialApp`. No Material test expectation changed. No UI capture was taken in
|
||||||
|
this stage.
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||||
@@ -14,7 +14,6 @@ void main() {
|
|||||||
Future<void> mount(
|
Future<void> mount(
|
||||||
WidgetTester tester, {
|
WidgetTester tester, {
|
||||||
bool web = true,
|
bool web = true,
|
||||||
bool cupertino = false,
|
|
||||||
Future<String?> Function(Uri)? read,
|
Future<String?> Function(Uri)? read,
|
||||||
Future<void> Function()? refresh,
|
Future<void> Function()? refresh,
|
||||||
UpdateInstaller? installer,
|
UpdateInstaller? installer,
|
||||||
@@ -31,7 +30,7 @@ void main() {
|
|||||||
web: true,
|
web: true,
|
||||||
),
|
),
|
||||||
client: PipelinesClient(channelFactory: (_) => channel),
|
client: PipelinesClient(channelFactory: (_) => channel),
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
routeInformationProvider: provider,
|
routeInformationProvider: provider,
|
||||||
webPlatform: web,
|
webPlatform: web,
|
||||||
webPageUri: Uri.parse('https://app.test/chats?selected=1'),
|
webPageUri: Uri.parse('https://app.test/chats?selected=1'),
|
||||||
@@ -180,7 +179,6 @@ void main() {
|
|||||||
var refreshes = 0;
|
var refreshes = 0;
|
||||||
await mount(
|
await mount(
|
||||||
tester,
|
tester,
|
||||||
cupertino: true,
|
|
||||||
read: (uri) async {
|
read: (uri) async {
|
||||||
expect(uri, Uri.parse('https://app.test/release.json'));
|
expect(uri, Uri.parse('https://app.test/release.json'));
|
||||||
return '{"schema":1,"platform":"web","buildId":"web-new"}';
|
return '{"schema":1,"platform":"web","buildId":"web-new"}';
|
||||||
@@ -189,7 +187,7 @@ void main() {
|
|||||||
refreshes++;
|
refreshes++;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
expect(refreshes, 0);
|
expect(refreshes, 0);
|
||||||
await tester.tap(find.text('Refresh'));
|
await tester.tap(find.text('Refresh'));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|||||||
@@ -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/session/server_session.dart';
|
import 'package:pipelines_app/core/session/server_session.dart';
|
||||||
@@ -33,8 +32,7 @@ const studio = DiscoveredServer(
|
|||||||
passwordRequired: false,
|
passwordRequired: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget host(Widget child, {bool cupertino = false}) =>
|
Widget host(Widget child) => MaterialApp(home: child);
|
||||||
cupertino ? CupertinoApp(home: child) : MaterialApp(home: child);
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late FakeDiscovery discovery;
|
late FakeDiscovery discovery;
|
||||||
@@ -146,22 +144,6 @@ void main() {
|
|||||||
expect(find.byKey(const Key('discovery-error')), findsOneWidget);
|
expect(find.byKey(const Key('discovery-error')), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Cupertino host lists and connects the same way', (tester) async {
|
|
||||||
await tester.pumpWidget(host(flow(discoverer: discovery), cupertino: true));
|
|
||||||
await tester.tap(find.byKey(const Key('discovery-scan')));
|
|
||||||
await tester.pump();
|
|
||||||
discovery.current.add([studio]);
|
|
||||||
await tester.pump();
|
|
||||||
expect(find.byType(CupertinoListTile), findsOneWidget);
|
|
||||||
await tester.tap(find.byKey(const Key('discovered-192.168.1.30:8080')));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(checked, isEmpty);
|
|
||||||
await tester.ensureVisible(find.byKey(const Key('onboarding-next')));
|
|
||||||
await tester.tap(find.byKey(const Key('onboarding-next')));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
expect(checked, [Uri.parse('ws://192.168.1.30:8080/connect')]);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('leaving the screen mid-scan stops browsing', (tester) async {
|
testWidgets('leaving the screen mid-scan stops browsing', (tester) async {
|
||||||
await tester.pumpWidget(host(flow(discoverer: discovery)));
|
await tester.pumpWidget(host(flow(discoverer: discovery)));
|
||||||
await tester.tap(find.byKey(const Key('discovery-scan')));
|
await tester.tap(find.byKey(const Key('discovery-scan')));
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
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/updates/app_updates.dart';
|
||||||
import 'package:pipelines_app/features/updates/launch_update_dialog.dart';
|
import 'package:pipelines_app/features/updates/launch_update_dialog.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@@ -34,4 +37,63 @@ void main() {
|
|||||||
expect(find.textContaining('Android'), findsNothing);
|
expect(find.textContaining('Android'), findsNothing);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testWidgets('update failure uses a Material alert', (tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Builder(
|
||||||
|
builder: (context) => TextButton(
|
||||||
|
onPressed: () =>
|
||||||
|
showLaunchUpdateFailure(context, 'boom', cupertino: false),
|
||||||
|
child: const Text('Fail'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.tap(find.text('Fail'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
|
expect(find.text('Update failed'), findsOneWidget);
|
||||||
|
expect(find.text('boom'), findsOneWidget);
|
||||||
|
expect(find.text('OK'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('install progress uses a Material alert and progress bar', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final finished = Completer<void>();
|
||||||
|
late BuildContext dialogContext;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
dialogContext = context;
|
||||||
|
return const SizedBox();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final install = installLaunchUpdate(
|
||||||
|
dialogContext,
|
||||||
|
AppUpdate(
|
||||||
|
versionCode: 2,
|
||||||
|
versionName: '2.0',
|
||||||
|
apk: Uri.parse('https://example.test/app.apk'),
|
||||||
|
),
|
||||||
|
installer: (update, {onProgress}) async {
|
||||||
|
onProgress?.call(0.5);
|
||||||
|
await finished.future;
|
||||||
|
},
|
||||||
|
cupertino: false,
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byType(AlertDialog), findsOneWidget);
|
||||||
|
expect(find.byType(LinearProgressIndicator), findsOneWidget);
|
||||||
|
expect(find.text('App update'), findsOneWidget);
|
||||||
|
expect(find.text('Downloading update… 50%'), findsOneWidget);
|
||||||
|
finished.complete();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byType(AlertDialog), findsNothing);
|
||||||
|
await install;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user