feat(app): register native Settings on the shared live session
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/adaptive/host.dart';
|
||||
|
||||
bool usesCupertinoControls(BuildContext context) =>
|
||||
usesCupertinoHost(context) ||
|
||||
Theme.of(context).platform == TargetPlatform.iOS;
|
||||
|
||||
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,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user