veilidchat/lib/theme/models/scale_theme/scale_tile_theme.dart
Christien Rioux 77c68aa45f ui cleanup
2025-03-17 00:51:16 -04:00

60 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'scale_scheme.dart';
import 'scale_theme.dart';
class ScaleTileTheme {
ScaleTileTheme(
{required this.textColor,
required this.backgroundColor,
required this.borderColor,
required this.shapeBorder,
required this.largeTextStyle,
required this.smallTextStyle});
final Color textColor;
final Color backgroundColor;
final Color borderColor;
final ShapeBorder shapeBorder;
final TextStyle largeTextStyle;
final TextStyle smallTextStyle;
}
extension ScaleTileThemeExt on ScaleTheme {
ScaleTileTheme tileTheme(
{bool disabled = false,
bool selected = false,
ScaleKind scaleKind = ScaleKind.primary}) {
final tileColor = scheme.scale(!disabled ? scaleKind : ScaleKind.gray);
final borderColor = selected ? tileColor.hoverBorder : tileColor.border;
final backgroundColor = config.useVisualIndicators && !selected
? tileColor.borderText
: borderColor;
final textColor = config.useVisualIndicators && !selected
? borderColor
: tileColor.borderText;
final largeTextStyle = textTheme.labelMedium!.copyWith(color: textColor);
final smallTextStyle = textTheme.labelSmall!.copyWith(color: textColor);
final shapeBorder = RoundedRectangleBorder(
side: config.useVisualIndicators
? BorderSide(
width: 2,
color: borderColor,
)
: BorderSide.none,
borderRadius: BorderRadius.circular(8 * config.borderRadiusScale));
return ScaleTileTheme(
textColor: textColor,
backgroundColor: backgroundColor,
borderColor: borderColor,
shapeBorder: shapeBorder,
largeTextStyle: largeTextStyle,
smallTextStyle: smallTextStyle,
);
}
}