Merge: Material host and controls on every platform
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user