mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-22 06:08:54 -04:00
more log work
This commit is contained in:
parent
9c1d780d93
commit
39b0262d0e
35 changed files with 906 additions and 606 deletions
|
@ -4,6 +4,7 @@ import 'radix_generator.dart';
|
|||
import 'scale_color.dart';
|
||||
import 'scale_input_decorator_theme.dart';
|
||||
import 'scale_scheme.dart';
|
||||
import 'scale_theme.dart';
|
||||
|
||||
ScaleColor _contrastScaleColor(
|
||||
{required Brightness brightness,
|
||||
|
@ -261,14 +262,16 @@ ThemeData contrastGenerator({
|
|||
final colorScheme = scaleScheme.toColorScheme(
|
||||
brightness,
|
||||
);
|
||||
final scaleTheme = ScaleTheme(
|
||||
textTheme: textTheme, scheme: scaleScheme, config: scaleConfig);
|
||||
|
||||
final themeData = ThemeData.from(
|
||||
final baseThemeData = ThemeData.from(
|
||||
colorScheme: colorScheme, textTheme: textTheme, useMaterial3: true);
|
||||
return themeData.copyWith(
|
||||
appBarTheme: themeData.appBarTheme.copyWith(
|
||||
final themeData = baseThemeData.copyWith(
|
||||
appBarTheme: baseThemeData.appBarTheme.copyWith(
|
||||
backgroundColor: scaleScheme.primaryScale.border,
|
||||
foregroundColor: scaleScheme.primaryScale.borderText),
|
||||
bottomSheetTheme: themeData.bottomSheetTheme.copyWith(
|
||||
bottomSheetTheme: baseThemeData.bottomSheetTheme.copyWith(
|
||||
elevation: 0,
|
||||
modalElevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
|
@ -277,7 +280,7 @@ ThemeData contrastGenerator({
|
|||
topRight:
|
||||
Radius.circular(16 * scaleConfig.borderRadiusScale)))),
|
||||
canvasColor: scaleScheme.primaryScale.subtleBackground,
|
||||
chipTheme: themeData.chipTheme.copyWith(
|
||||
chipTheme: baseThemeData.chipTheme.copyWith(
|
||||
backgroundColor: scaleScheme.primaryScale.elementBackground,
|
||||
selectedColor: scaleScheme.primaryScale.activeElementBackground,
|
||||
surfaceTintColor: scaleScheme.primaryScale.hoverElementBackground,
|
||||
|
@ -303,5 +306,8 @@ ThemeData contrastGenerator({
|
|||
extensions: <ThemeExtension<dynamic>>[
|
||||
scaleScheme,
|
||||
scaleConfig,
|
||||
scaleTheme
|
||||
]);
|
||||
|
||||
return themeData;
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@ export 'chat_theme.dart';
|
|||
export 'radix_generator.dart';
|
||||
export 'scale_color.dart';
|
||||
export 'scale_scheme.dart';
|
||||
export 'scale_theme.dart';
|
||||
export 'slider_tile.dart';
|
||||
export 'theme_preference.dart';
|
||||
|
|
|
@ -7,6 +7,7 @@ import '../../tools/tools.dart';
|
|||
import 'scale_color.dart';
|
||||
import 'scale_input_decorator_theme.dart';
|
||||
import 'scale_scheme.dart';
|
||||
import 'scale_theme.dart';
|
||||
|
||||
enum RadixThemeColor {
|
||||
scarlet, // red + violet + tomato
|
||||
|
@ -610,10 +611,14 @@ ThemeData radixGenerator(Brightness brightness, RadixThemeColor themeColor) {
|
|||
borderRadiusScale: 1,
|
||||
);
|
||||
|
||||
final themeData = ThemeData.from(
|
||||
final scaleTheme = ScaleTheme(
|
||||
textTheme: textTheme, scheme: scaleScheme, config: scaleConfig);
|
||||
|
||||
final baseThemeData = ThemeData.from(
|
||||
colorScheme: colorScheme, textTheme: textTheme, useMaterial3: true);
|
||||
return themeData.copyWith(
|
||||
scrollbarTheme: themeData.scrollbarTheme.copyWith(
|
||||
|
||||
final themeData = baseThemeData.copyWith(
|
||||
scrollbarTheme: baseThemeData.scrollbarTheme.copyWith(
|
||||
thumbColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.pressed)) {
|
||||
return scaleScheme.primaryScale.border;
|
||||
|
@ -636,10 +641,10 @@ ThemeData radixGenerator(Brightness brightness, RadixThemeColor themeColor) {
|
|||
}
|
||||
return scaleScheme.primaryScale.subtleBorder;
|
||||
})),
|
||||
appBarTheme: themeData.appBarTheme.copyWith(
|
||||
appBarTheme: baseThemeData.appBarTheme.copyWith(
|
||||
backgroundColor: scaleScheme.primaryScale.border,
|
||||
foregroundColor: scaleScheme.primaryScale.borderText),
|
||||
bottomSheetTheme: themeData.bottomSheetTheme.copyWith(
|
||||
bottomSheetTheme: baseThemeData.bottomSheetTheme.copyWith(
|
||||
elevation: 0,
|
||||
modalElevation: 0,
|
||||
shape: const RoundedRectangleBorder(
|
||||
|
@ -647,7 +652,7 @@ ThemeData radixGenerator(Brightness brightness, RadixThemeColor themeColor) {
|
|||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16)))),
|
||||
canvasColor: scaleScheme.primaryScale.subtleBackground,
|
||||
chipTheme: themeData.chipTheme.copyWith(
|
||||
chipTheme: baseThemeData.chipTheme.copyWith(
|
||||
backgroundColor: scaleScheme.primaryScale.elementBackground,
|
||||
selectedColor: scaleScheme.primaryScale.activeElementBackground,
|
||||
surfaceTintColor: scaleScheme.primaryScale.hoverElementBackground,
|
||||
|
@ -666,5 +671,11 @@ ThemeData radixGenerator(Brightness brightness, RadixThemeColor themeColor) {
|
|||
),
|
||||
inputDecorationTheme:
|
||||
ScaleInputDecoratorTheme(scaleScheme, scaleConfig, textTheme),
|
||||
extensions: <ThemeExtension<dynamic>>[scaleScheme, scaleConfig]);
|
||||
extensions: <ThemeExtension<dynamic>>[
|
||||
scaleScheme,
|
||||
scaleConfig,
|
||||
scaleTheme
|
||||
]);
|
||||
|
||||
return themeData;
|
||||
}
|
||||
|
|
|
@ -145,33 +145,3 @@ class ScaleConfig extends ThemeExtension<ScaleConfig> {
|
|||
lerpDouble(borderRadiusScale, other.borderRadiusScale, t) ?? 1);
|
||||
}
|
||||
}
|
||||
|
||||
class ScaleTheme extends ThemeExtension<ScaleTheme> {
|
||||
ScaleTheme({
|
||||
required this.scheme,
|
||||
required this.config,
|
||||
});
|
||||
|
||||
final ScaleScheme scheme;
|
||||
final ScaleConfig config;
|
||||
|
||||
@override
|
||||
ScaleTheme copyWith({
|
||||
ScaleScheme? scheme,
|
||||
ScaleConfig? config,
|
||||
}) =>
|
||||
ScaleTheme(
|
||||
scheme: scheme ?? this.scheme,
|
||||
config: config ?? this.config,
|
||||
);
|
||||
|
||||
@override
|
||||
ScaleTheme lerp(ScaleTheme? other, double t) {
|
||||
if (other is! ScaleTheme) {
|
||||
return this;
|
||||
}
|
||||
return ScaleTheme(
|
||||
scheme: scheme.lerp(other.scheme, t),
|
||||
config: config.lerp(other.config, t));
|
||||
}
|
||||
}
|
||||
|
|
88
lib/theme/models/scale_theme.dart
Normal file
88
lib/theme/models/scale_theme.dart
Normal file
|
@ -0,0 +1,88 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'scale_scheme.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;
|
||||
}
|
||||
|
||||
class ScaleTheme extends ThemeExtension<ScaleTheme> {
|
||||
ScaleTheme({
|
||||
required this.textTheme,
|
||||
required this.scheme,
|
||||
required this.config,
|
||||
});
|
||||
|
||||
final TextTheme textTheme;
|
||||
final ScaleScheme scheme;
|
||||
final ScaleConfig config;
|
||||
|
||||
@override
|
||||
ScaleTheme copyWith({
|
||||
TextTheme? textTheme,
|
||||
ScaleScheme? scheme,
|
||||
ScaleConfig? config,
|
||||
}) =>
|
||||
ScaleTheme(
|
||||
textTheme: textTheme ?? this.textTheme,
|
||||
scheme: scheme ?? this.scheme,
|
||||
config: config ?? this.config,
|
||||
);
|
||||
|
||||
@override
|
||||
ScaleTheme lerp(ScaleTheme? other, double t) {
|
||||
if (other is! ScaleTheme) {
|
||||
return this;
|
||||
}
|
||||
return ScaleTheme(
|
||||
textTheme: TextTheme.lerp(textTheme, other.textTheme, t),
|
||||
scheme: scheme.lerp(other.scheme, t),
|
||||
config: config.lerp(other.config, t));
|
||||
}
|
||||
|
||||
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, strokeAlign: 0)
|
||||
: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(8 * config.borderRadiusScale));
|
||||
|
||||
return ScaleTileTheme(
|
||||
textColor: textColor,
|
||||
backgroundColor: backgroundColor,
|
||||
borderColor: borderColor,
|
||||
shapeBorder: shapeBorder,
|
||||
largeTextStyle: largeTextStyle,
|
||||
smallTextStyle: smallTextStyle,
|
||||
);
|
||||
}
|
||||
}
|
|
@ -69,29 +69,15 @@ class SliderTile extends StatelessWidget {
|
|||
// ignore: prefer_expression_function_bodies
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final scale = theme.extension<ScaleScheme>()!;
|
||||
final tileColor = scale.scale(!disabled ? tileScale : ScaleKind.gray);
|
||||
final scaleConfig = theme.extension<ScaleConfig>()!;
|
||||
|
||||
final borderColor = selected ? tileColor.hoverBorder : tileColor.border;
|
||||
final backgroundColor = scaleConfig.useVisualIndicators && !selected
|
||||
? tileColor.borderText
|
||||
: borderColor;
|
||||
final textColor = scaleConfig.useVisualIndicators && !selected
|
||||
? borderColor
|
||||
: tileColor.borderText;
|
||||
final scaleTheme = theme.extension<ScaleTheme>()!;
|
||||
final scaleTileTheme = scaleTheme.tileTheme(
|
||||
disabled: disabled, selected: selected, scaleKind: tileScale);
|
||||
|
||||
return Container(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: ShapeDecoration(
|
||||
color: backgroundColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
side: scaleConfig.useVisualIndicators
|
||||
? BorderSide(width: 2, color: borderColor, strokeAlign: 0)
|
||||
: BorderSide.none,
|
||||
borderRadius:
|
||||
BorderRadius.circular(8 * scaleConfig.borderRadiusScale),
|
||||
)),
|
||||
color: scaleTileTheme.backgroundColor,
|
||||
shape: scaleTileTheme.shapeBorder),
|
||||
child: Slidable(
|
||||
// Specify a key if the Slidable is dismissible.
|
||||
key: key,
|
||||
|
@ -99,50 +85,39 @@ class SliderTile extends StatelessWidget {
|
|||
? null
|
||||
: ActionPane(
|
||||
motion: const DrawerMotion(),
|
||||
children: endActions
|
||||
.map(
|
||||
(a) => SlidableAction(
|
||||
onPressed: disabled ? null : a.onPressed,
|
||||
backgroundColor: scaleConfig.useVisualIndicators
|
||||
? (selected
|
||||
? tileColor.borderText
|
||||
: tileColor.border)
|
||||
: scale.scale(a.actionScale).primary,
|
||||
foregroundColor: scaleConfig.useVisualIndicators
|
||||
? (selected
|
||||
? tileColor.border
|
||||
: tileColor.borderText)
|
||||
: scale.scale(a.actionScale).primaryText,
|
||||
icon: subtitle.isEmpty ? a.icon : null,
|
||||
label: a.label,
|
||||
padding: const EdgeInsets.all(2)),
|
||||
)
|
||||
.toList()),
|
||||
children: endActions.map((a) {
|
||||
final scaleActionTheme = scaleTheme.tileTheme(
|
||||
disabled: disabled,
|
||||
selected: true,
|
||||
scaleKind: a.actionScale);
|
||||
return SlidableAction(
|
||||
onPressed: disabled ? null : a.onPressed,
|
||||
backgroundColor: scaleActionTheme.backgroundColor,
|
||||
foregroundColor: scaleActionTheme.textColor,
|
||||
icon: subtitle.isEmpty ? a.icon : null,
|
||||
label: a.label,
|
||||
padding: const EdgeInsets.all(2));
|
||||
}).toList()),
|
||||
startActionPane: startActions.isEmpty
|
||||
? null
|
||||
: ActionPane(
|
||||
motion: const DrawerMotion(),
|
||||
children: startActions
|
||||
.map(
|
||||
(a) => SlidableAction(
|
||||
onPressed: disabled ? null : a.onPressed,
|
||||
backgroundColor: scaleConfig.useVisualIndicators
|
||||
? (selected
|
||||
? tileColor.borderText
|
||||
: tileColor.border)
|
||||
: scale.scale(a.actionScale).primary,
|
||||
foregroundColor: scaleConfig.useVisualIndicators
|
||||
? (selected
|
||||
? tileColor.border
|
||||
: tileColor.borderText)
|
||||
: scale.scale(a.actionScale).primaryText,
|
||||
icon: subtitle.isEmpty ? a.icon : null,
|
||||
label: a.label,
|
||||
padding: const EdgeInsets.all(2)),
|
||||
)
|
||||
.toList()),
|
||||
children: startActions.map((a) {
|
||||
final scaleActionTheme = scaleTheme.tileTheme(
|
||||
disabled: disabled,
|
||||
selected: true,
|
||||
scaleKind: a.actionScale);
|
||||
|
||||
return SlidableAction(
|
||||
onPressed: disabled ? null : a.onPressed,
|
||||
backgroundColor: scaleActionTheme.backgroundColor,
|
||||
foregroundColor: scaleActionTheme.textColor,
|
||||
icon: subtitle.isEmpty ? a.icon : null,
|
||||
label: a.label,
|
||||
padding: const EdgeInsets.all(2));
|
||||
}).toList()),
|
||||
child: Padding(
|
||||
padding: scaleConfig.useVisualIndicators
|
||||
padding: scaleTheme.config.useVisualIndicators
|
||||
? EdgeInsets.zero
|
||||
: const EdgeInsets.fromLTRB(0, 2, 0, 2),
|
||||
child: GestureDetector(
|
||||
|
@ -157,8 +132,8 @@ class SliderTile extends StatelessWidget {
|
|||
softWrap: false,
|
||||
),
|
||||
subtitle: subtitle.isNotEmpty ? Text(subtitle) : null,
|
||||
iconColor: textColor,
|
||||
textColor: textColor,
|
||||
iconColor: scaleTileTheme.textColor,
|
||||
textColor: scaleTileTheme.textColor,
|
||||
leading: FittedBox(child: leading),
|
||||
trailing: FittedBox(child: trailing))))));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue