Files
pipelines/app/lib/features/settings/settings_theme.dart
T
alan 493e950195 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.
2026-11-03 16:07:48 +00:00

43 lines
1.4 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/adaptive/host.dart';
/// 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)
: 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(
BuildContext context, {
bool title = false,
bool secondary = 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 base = (title
? theme.textTheme.titleMedium
: theme.textTheme.bodyMedium)!;
return base.copyWith(
color: error
? theme.colorScheme.error
: secondary
? theme.colorScheme.onSurfaceVariant
: base.color,
);
}