App uses the Material host and controls on every platform

iOS and macOS no longer switch to the Cupertino host or Cupertino controls by
target platform; they render the same Material UI as web and Android.
Cupertino paths remain for an explicit cupertino: true host. Flutter's
automatic platform behaviours (scroll physics, text selection, back-swipe
transitions) are unchanged.
This commit is contained in:
2026-11-03 16:07:48 +00:00
parent 5f51bbf53b
commit 493e950195
13 changed files with 139 additions and 130 deletions
@@ -10,19 +10,17 @@ Widget _host(
NotificationServiceBridge bridge, {
required bool cupertino,
Future<void> Function()? requestPermission,
}) => MaterialApp(
theme: ThemeData(
platform: cupertino ? TargetPlatform.iOS : TargetPlatform.android,
),
home: Scaffold(
body: SingleChildScrollView(
child: SettingsDeviceDeliverySection(
bridge: bridge,
requestNotificationPermission: requestPermission,
),
}) {
final body = SingleChildScrollView(
child: SettingsDeviceDeliverySection(
bridge: bridge,
requestNotificationPermission: requestPermission,
),
),
);
);
return cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body));
}
bool _switchValue(WidgetTester tester, {required bool cupertino}) {
final tile = find.byKey(DeviceDeliveryKeys.toggle);
@@ -88,7 +88,7 @@ void main() {
testWidgets('Cupertino uses inset-grouped sections on the grouped page', (
tester,
) async {
await _pump(tester, platform: TargetPlatform.iOS);
await _pump(tester, cupertino: true);
expect(find.byType(Card), findsNothing);
expect(find.byType(CupertinoListSection), findsWidgets);
@@ -124,7 +124,7 @@ void main() {
testWidgets('Cupertino keeps the compact secondary field label', (
tester,
) async {
await _pump(tester, platform: TargetPlatform.iOS);
await _pump(tester, cupertino: true);
final label = tester.widget<Text>(find.text('Server URL'));
final context = tester.element(find.text('Server URL'));
@@ -191,7 +191,7 @@ void main() {
Future<void> _pump(
WidgetTester tester, {
TargetPlatform platform = TargetPlatform.android,
bool cupertino = false,
NotificationController? notifications,
Size size = const Size(800, 1600),
double topPadding = 0,
@@ -201,24 +201,28 @@ Future<void> _pump(
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
final screen = SettingsScreen(
client: client,
store: MemorySettingsStore(),
notifications: notifications,
embedded: true,
);
Widget padded(BuildContext context, Widget? child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(padding: EdgeInsets.only(top: topPadding)),
child: child!,
);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: platform),
builder: (context, child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(padding: EdgeInsets.only(top: topPadding)),
child: child!,
),
home: Scaffold(
body: SettingsScreen(
client: client,
store: MemorySettingsStore(),
notifications: notifications,
embedded: true,
),
),
),
cupertino
? CupertinoApp(
builder: padded,
home: CupertinoPageScaffold(child: screen),
)
: MaterialApp(
builder: padded,
home: Scaffold(body: screen),
),
);
await tester.pump();
await tester.pump();
@@ -33,16 +33,14 @@ JsonMap _reply(bool run, bool needs, bool reply) => {
},
};
Widget _host(ApiGateway gateway, {required bool cupertino}) => MaterialApp(
theme: ThemeData(
platform: cupertino ? TargetPlatform.iOS : TargetPlatform.android,
),
home: Scaffold(
body: SingleChildScrollView(
child: SettingsNtfySection(gateway: gateway, connected: true),
),
),
);
Widget _host(ApiGateway gateway, {required bool cupertino}) {
final body = SingleChildScrollView(
child: SettingsNtfySection(gateway: gateway, connected: true),
);
return cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body));
}
bool _checked(WidgetTester tester, String key, {required bool cupertino}) {
final tile = find.byKey(ntfySettingKey(key));
@@ -242,14 +242,26 @@ void main() {
},
);
testWidgets('iOS uses Cupertino fields, buttons and navigation', (
testWidgets('iOS uses the same Material fields and buttons', (tester) async {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
await _pump(tester, client, platform: TargetPlatform.iOS);
expect(find.byType(CupertinoTextField), findsNothing);
expect(find.byType(TextField), findsWidgets);
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
});
testWidgets('an explicit Cupertino host uses Cupertino fields and buttons', (
tester,
) async {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
await _pump(tester, client, platform: TargetPlatform.iOS);
await _pump(tester, client, cupertino: true);
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.byType(CupertinoTextField), findsNWidgets(2));
@@ -354,11 +366,25 @@ Future<void> _pump(
transport.PipelinesClient client, {
SettingsStore? store,
TargetPlatform platform = TargetPlatform.android,
bool cupertino = false,
double textScale = 1,
Size size = const Size(800, 1200),
}) async {
await tester.binding.setSurfaceSize(size);
addTearDown(() => tester.binding.setSurfaceSize(null));
if (cupertino) {
await tester.pumpWidget(
CupertinoApp(
home: SettingsScreen(
client: client,
store: store ?? MemorySettingsStore(),
),
),
);
await tester.pump();
await tester.pump();
return;
}
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: platform),
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart'
@@ -22,23 +23,19 @@ void main() {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.settings,
destinationBodies: {
AppDestination.settings: (_) => SettingsScreen(
client: client,
store: MemorySettingsStore(),
embedded: true,
),
},
);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
platform: cupertino ? TargetPlatform.iOS : TargetPlatform.android,
),
home: AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.settings,
destinationBodies: {
AppDestination.settings: (_) => SettingsScreen(
client: client,
store: MemorySettingsStore(),
embedded: true,
),
},
),
),
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
await tester.pump();
await tester.pump();