Merge: Material host and controls on every platform

This commit is contained in:
2026-11-03 16:08:08 +00:00
13 changed files with 139 additions and 130 deletions
@@ -5,18 +5,13 @@ import 'package:flutter/material.dart';
/// Which standard control family this screen renders.
enum ChatControlsStyle { material, cupertino }
/// Cupertino under a Cupertino app or an iOS/macOS Material theme, Material
/// everywhere else. The shell decides the app class, so a bare Cupertino app
/// never has to grow a Material ancestor just for this screen.
ChatControlsStyle chatControlsStyleOf(BuildContext context) {
if (context.findAncestorWidgetOfExactType<MaterialApp>() == null) {
return ChatControlsStyle.cupertino;
}
final platform = Theme.of(context).platform;
return platform == TargetPlatform.iOS || platform == TargetPlatform.macOS
? ChatControlsStyle.cupertino
: ChatControlsStyle.material;
}
/// Cupertino under an explicit Cupertino app, Material everywhere else,
/// whatever the target platform. The shell decides the app class, so a bare
/// Cupertino app never has to grow a Material ancestor just for this screen.
ChatControlsStyle chatControlsStyleOf(BuildContext context) =>
context.findAncestorWidgetOfExactType<MaterialApp>() == null
? ChatControlsStyle.cupertino
: ChatControlsStyle.material;
class ChatBarAction extends StatelessWidget {
const ChatBarAction({
@@ -100,7 +100,7 @@ class _ChatAttachmentThumbnailState extends State<ChatAttachmentThumbnail> {
child: Center(
child: widget.cupertino
? const CupertinoActivityIndicator()
: const CircularProgressIndicator.adaptive(),
: const CircularProgressIndicator(),
),
);
@@ -6,11 +6,9 @@ import '../../../ui/adaptive/segmented_bar.dart';
import '../pipeline_query.dart';
/// The one platform decision for this feature. The screen itself receives no
/// platform flag, so tests and integration obey Flutter's target platform.
bool useCupertinoControls(BuildContext context) =>
usesCupertinoHost(context) ||
Theme.of(context).platform == TargetPlatform.iOS;
/// The one control-family decision for this feature: Cupertino only under an
/// explicit Cupertino host, Material on every platform otherwise.
bool useCupertinoControls(BuildContext context) => usesCupertinoHost(context);
/// Standard platform activity indicator with an accessible status label.
class PipelineProgress extends StatelessWidget {
+3 -8
View File
@@ -81,14 +81,9 @@ class _SearchScreenState extends State<SearchScreen> {
@override
Widget build(BuildContext context) {
// Follow the actual host app class first: a CupertinoApp supplies no
// Material theme, so reading only the platform would pick Material controls
// inside a Cupertino host on macOS/iOS.
final cupertino =
widget.cupertino ??
(usesCupertinoHost(context) ||
Theme.of(context).platform == TargetPlatform.iOS ||
Theme.of(context).platform == TargetPlatform.macOS);
// Follow the actual host app class: Cupertino only under an explicit
// Cupertino host, Material on every platform otherwise.
final cupertino = widget.cupertino ?? usesCupertinoHost(context);
if (widget.embedded) {
// The shell's bar carries the controls; without a shell (a bare embed)
// they lead the results instead.
@@ -3,9 +3,9 @@ import 'package:flutter/material.dart';
import '../../ui/adaptive/host.dart';
bool usesCupertinoControls(BuildContext context) =>
usesCupertinoHost(context) ||
Theme.of(context).platform == TargetPlatform.iOS;
/// Cupertino only under an explicit Cupertino host; Material on every
/// platform otherwise.
bool usesCupertinoControls(BuildContext context) => usesCupertinoHost(context);
Color settingsErrorColor(BuildContext context) => usesCupertinoControls(context)
? CupertinoColors.destructiveRed.resolveFrom(context)
+8 -8
View File
@@ -1,8 +1,8 @@
import 'package:flutter/foundation.dart';
/// Browsers use Material consistently, regardless of their host OS.
bool prefersCupertino({bool web = kIsWeb, TargetPlatform? platform}) {
final target = platform ?? defaultTargetPlatform;
return !web &&
(target == TargetPlatform.iOS || target == TargetPlatform.macOS);
}
/// The app renders the same Material layout and design on every platform:
/// web, Android, iOS and macOS. The Cupertino host and controls remain
/// available only when a caller asks for them explicitly (`cupertino: true`);
/// they are never chosen from the target platform.
///
/// Flutter's automatic platform behaviours (scroll physics, text selection,
/// page transitions and back-swipe) still follow the target platform.
bool prefersCupertino() => false;