Files
pipelines/app/lib/features/chat/conversation/chat_card_styles.dart
T

57 lines
2.7 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// Host-native typography and colour for the approval and question cards.
///
/// The cards share one hierarchy: the card title uses the host's title style,
/// field/answer labels sit visibly below it, and recorded prose uses the body
/// style. Keeping the styles here stops each card file from inventing its own
/// size and colour; everything still comes from the active Material/Cupertino
/// theme, so light, dark and text scaling follow the host.
TextStyle? chatCardTitleStyle(BuildContext context, bool cupertino) =>
cupertino
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleMedium;
TextStyle? chatCardBodyStyle(BuildContext context, bool cupertino) => cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodyMedium;
/// A field or recorded-answer label. Under Cupertino the system tab-label style
/// (the same subordinate style the rest of the app uses for secondary copy)
/// keeps labels from reading as extra headings; Material keeps `titleSmall`.
TextStyle? chatCardLabelStyle(BuildContext context, bool cupertino) => cupertino
? CupertinoTheme.of(
context,
).textTheme.tabLabelTextStyle.copyWith(color: chatCardSecondaryColor(context, true))
: Theme.of(context).textTheme.titleSmall;
/// Body text that supports a control, such as a field description.
TextStyle? chatCardSecondaryStyle(BuildContext context, bool cupertino) =>
(chatCardBodyStyle(context, cupertino) ?? const TextStyle()).copyWith(
color: chatCardSecondaryColor(context, cupertino),
);
Color chatCardSecondaryColor(BuildContext context, bool cupertino) => cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
Color chatCardErrorColor(BuildContext context, bool cupertino) => cupertino
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error;
/// The amber risk hue: the host's warning role, never a bespoke palette.
Color chatCardWarningColor(BuildContext context, bool cupertino) => cupertino
? CupertinoColors.systemOrange.resolveFrom(context)
: Theme.of(context).colorScheme.tertiary;
/// A quiet inset surface for resource blocks and risk panels.
Color chatCardFillColor(BuildContext context, bool cupertino) => cupertino
? CupertinoColors.secondarySystemFill.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainerHighest;
Color chatCardWarningFillColor(BuildContext context, bool cupertino) =>
cupertino
? CupertinoColors.secondarySystemFill.resolveFrom(context)
: Theme.of(context).colorScheme.tertiaryContainer;