feat(ui): move style implementation from component to ui_kit with theme resolver
This commit is contained in:
@@ -19,7 +19,4 @@ import 'package:wyatt_ui_components/src/features/features.dart';
|
||||
|
||||
extension ThemeComponentBuildContext on BuildContext {
|
||||
ComponentThemeData get components => ComponentTheme.of(this);
|
||||
TextTheme get textTheme => Theme.of(this).textTheme;
|
||||
ColorScheme get colorScheme => Theme.of(this).colorScheme;
|
||||
ButtonThemeData get buttonTheme => Theme.of(this).buttonTheme;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
// Copyright (C) 2023 WYATT GROUP
|
||||
// Please see the AUTHORS file for details.
|
||||
//
|
||||
@@ -52,4 +51,7 @@ class MultiColor {
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() => 'MultiColor(_colors: $_colors, _color: $_color)';
|
||||
}
|
||||
|
||||
@@ -62,4 +62,10 @@ abstract class ButtonStyle<T> {
|
||||
///
|
||||
/// Default to `null`
|
||||
final BoxShadow? shadow;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'ButtonStyle(radius: $radius, padding: $padding, foregroundColors: '
|
||||
'$foregroundColors, backgroundColors: $backgroundColors, borderColors: '
|
||||
'$borderColors, stroke: $stroke, shadow: $shadow)';
|
||||
}
|
||||
|
||||
-14
@@ -18,7 +18,6 @@ import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
@@ -38,19 +37,6 @@ class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory FileSelectionButtonStyle.fromFlutter(BuildContext context) =>
|
||||
FileSelectionButtonStyle(
|
||||
title: context.textTheme.labelLarge,
|
||||
subTitle: context.textTheme.labelSmall,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static FileSelectionButtonStyle? lerp(
|
||||
FileSelectionButtonStyle? a,
|
||||
|
||||
+4
-12
@@ -18,7 +18,6 @@ import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
@@ -37,17 +36,6 @@ class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory FlatButtonStyle.fromFlutter(BuildContext context) => FlatButtonStyle(
|
||||
label: context.textTheme.labelLarge,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static FlatButtonStyle? lerp(
|
||||
FlatButtonStyle? a,
|
||||
@@ -86,4 +74,8 @@ class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
|
||||
///
|
||||
/// Default to `TextTheme.labelLarge`
|
||||
final TextStyle? label;
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'FlatButtonStyle(label: $label), inherited: ${super.toString()}';
|
||||
}
|
||||
|
||||
-13
@@ -18,7 +18,6 @@ import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
@@ -37,18 +36,6 @@ class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory SimpleIconButtonStyle.fromFlutter(BuildContext context) =>
|
||||
SimpleIconButtonStyle(
|
||||
dimension: context.buttonTheme.height,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static SimpleIconButtonStyle? lerp(
|
||||
SimpleIconButtonStyle? a,
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
@@ -38,19 +37,6 @@ class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory SymbolButtonStyle.fromFlutter(BuildContext context) =>
|
||||
SymbolButtonStyle(
|
||||
label: context.textTheme.labelLarge,
|
||||
dimension: context.buttonTheme.height,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static SymbolButtonStyle? lerp(
|
||||
SymbolButtonStyle? a,
|
||||
|
||||
Reference in New Issue
Block a user