ui_kit-ui_components/feat/export-ui-kit #157
@ -15,6 +15,7 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:wyatt_ui_components/src/core/utils/theme_helper.dart';
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/theme_style.dart';
|
import 'package:wyatt_ui_components/src/domain/entities/theme_style.dart';
|
||||||
|
|
||||||
/// {@template theme_resolver}
|
/// {@template theme_resolver}
|
||||||
@ -38,52 +39,34 @@ abstract class ThemeResolver<S extends ThemeStyle<S>, T, E> {
|
|||||||
S? Function(BuildContext context, {E? extra}) get customStyleFn;
|
S? Function(BuildContext context, {E? extra}) get customStyleFn;
|
||||||
|
|
||||||
/// Compute default value from Flutter Theme or with hardcoded values.
|
/// Compute default value from Flutter Theme or with hardcoded values.
|
||||||
S computeDefaultValue(BuildContext context, {E? extra});
|
S computeDefaultValue(
|
||||||
|
BuildContext context, {
|
||||||
S? computeExtensionValueFn(
|
|
||||||
BuildContext context,
|
|
||||||
T themeExtension, {
|
|
||||||
E? extra,
|
E? extra,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Compute values from the extension if found
|
/// Compute extension value from custom component extension.
|
||||||
S? _computeExtensionValue(
|
S? computeExtensionValueFn(
|
||||||
BuildContext context, {
|
BuildContext context,
|
||||||
|
T? themeExtension, {
|
||||||
E? extra,
|
E? extra,
|
||||||
}) {
|
});
|
||||||
final themeExtension = Theme.of(context).extension<T>();
|
|
||||||
if (themeExtension != null) {
|
|
||||||
return computeExtensionValueFn(
|
|
||||||
context,
|
|
||||||
themeExtension,
|
|
||||||
extra: extra,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compute custom value
|
|
||||||
S? _computeCustomValue(
|
|
||||||
BuildContext context, {
|
|
||||||
E? extra,
|
|
||||||
}) {
|
|
||||||
final customStyle = customStyleFn(
|
|
||||||
context,
|
|
||||||
extra: extra,
|
|
||||||
);
|
|
||||||
if (customStyle != null) {
|
|
||||||
return customStyle;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Choose most suitable style for a given context.
|
/// Choose most suitable style for a given context.
|
||||||
S negotiate(BuildContext context, {E? extra}) {
|
S negotiate(BuildContext context, {E? extra}) {
|
||||||
S style = computeDefaultValue(context, extra: extra);
|
final style = computeDefaultValue(context, extra: extra);
|
||||||
style =
|
return ThemeHelper.getThemeElement<S, S>(
|
||||||
style.mergeWith(_computeExtensionValue(context, extra: extra)) ?? style;
|
[
|
||||||
style =
|
style,
|
||||||
style.mergeWith(_computeCustomValue(context, extra: extra)) ?? style;
|
computeExtensionValueFn(
|
||||||
return style;
|
context,
|
||||||
|
Theme.of(context).extension<T>(),
|
||||||
|
extra: extra,
|
||||||
|
),
|
||||||
|
customStyleFn(context, extra: extra)
|
||||||
malo marked this conversation as resolved
|
|||||||
|
],
|
||||||
|
transform: (value) => value,
|
||||||
|
combine: (value, element) => value?.mergeWith(element),
|
||||||
|
) ??
|
||||||
|
style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,5 @@
|
|||||||
|
|
||||||
export 'multi_color.dart';
|
export 'multi_color.dart';
|
||||||
export 'text_wrapper.dart';
|
export 'text_wrapper.dart';
|
||||||
|
export 'theme_helper.dart';
|
||||||
export 'theme_resolver.dart';
|
export 'theme_resolver.dart';
|
||||||
|
@ -14,9 +14,49 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/entities.dart';
|
import 'package:wyatt_ui_components/src/domain/entities/entities.dart';
|
||||||
|
part 'component_theme_data.g.dart';
|
||||||
|
|
||||||
|
@CopyWith()
|
||||||
malo marked this conversation as resolved
hugo
commented
no need to merge ComponentThemeData? in which case you should not use this extension. no need to merge ComponentThemeData? in which case you should not use this extension.
|
|||||||
class ComponentThemeData {
|
class ComponentThemeData {
|
||||||
|
factory ComponentThemeData({
|
||||||
|
TopAppBarComponent? appBar,
|
||||||
|
TopNavigationBarComponent? topNavigationBarComponent,
|
||||||
|
BottomNavigationBarComponent? bottomNavigationBar,
|
||||||
|
ErrorWidgetComponent? errorWidget,
|
||||||
|
LoadingWidgetComponent? loadingWidget,
|
||||||
|
LoaderComponent? loaderComponent,
|
||||||
|
RichTextBuilderComponent? richTextBuilderComponent,
|
||||||
|
TextInputComponent? textInputComponent,
|
||||||
|
FileSelectionButtonComponent? fileSelectionButtonComponent,
|
||||||
|
FlatButtonComponent? flatButtonComponent,
|
||||||
|
SimpleIconButtonComponent? simpleIconButtonComponent,
|
||||||
|
SymbolButtonComponent? symbolButtonComponent,
|
||||||
|
InformationCardComponent? informationCardComponent,
|
||||||
|
PortfolioCardComponent? portfolioCardComponent,
|
||||||
|
QuoteCardComponent? quoteCardComponent,
|
||||||
|
SkillCardComponent? skillCardComponent,
|
||||||
|
}) =>
|
||||||
|
ComponentThemeData.raw(
|
||||||
|
appBar: appBar,
|
||||||
|
topNavigationBarComponent: topNavigationBarComponent,
|
||||||
|
bottomNavigationBar: bottomNavigationBar,
|
||||||
|
errorWidget: errorWidget,
|
||||||
|
loadingWidget: loadingWidget,
|
||||||
|
loaderComponent: loaderComponent,
|
||||||
|
richTextBuilderComponent: richTextBuilderComponent,
|
||||||
|
textInputComponent: textInputComponent,
|
||||||
|
fileSelectionButtonComponent: fileSelectionButtonComponent,
|
||||||
|
flatButtonComponent: flatButtonComponent,
|
||||||
|
simpleIconButtonComponent: simpleIconButtonComponent,
|
||||||
|
symbolButtonComponent: symbolButtonComponent,
|
||||||
|
informationCardComponent: informationCardComponent,
|
||||||
|
portfolioCardComponent: portfolioCardComponent,
|
||||||
|
quoteCardComponent: quoteCardComponent,
|
||||||
|
skillCardComponent: skillCardComponent,
|
||||||
|
);
|
||||||
|
|
||||||
const ComponentThemeData.raw({
|
const ComponentThemeData.raw({
|
||||||
this.appBar,
|
this.appBar,
|
||||||
this.topNavigationBarComponent,
|
this.topNavigationBarComponent,
|
||||||
@ -35,11 +75,11 @@ class ComponentThemeData {
|
|||||||
this.quoteCardComponent,
|
this.quoteCardComponent,
|
||||||
this.skillCardComponent,
|
this.skillCardComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
final TopAppBarComponent? appBar;
|
final TopAppBarComponent? appBar;
|
||||||
|
|
||||||
final TopNavigationBarComponent? topNavigationBarComponent;
|
final TopNavigationBarComponent? topNavigationBarComponent;
|
||||||
final BottomNavigationBarComponent? bottomNavigationBar;
|
final BottomNavigationBarComponent? bottomNavigationBar;
|
||||||
|
|
||||||
final ErrorWidgetComponent? errorWidget;
|
final ErrorWidgetComponent? errorWidget;
|
||||||
final LoadingWidgetComponent? loadingWidget;
|
final LoadingWidgetComponent? loadingWidget;
|
||||||
final LoaderComponent? loaderComponent;
|
final LoaderComponent? loaderComponent;
|
||||||
|
@ -0,0 +1,265 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'component_theme_data.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// CopyWithGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
abstract class _$ComponentThemeDataCWProxy {
|
||||||
|
ComponentThemeData appBar(TopAppBarComponent? appBar);
|
||||||
|
|
||||||
|
ComponentThemeData topNavigationBarComponent(
|
||||||
|
TopNavigationBarComponent? topNavigationBarComponent);
|
||||||
|
|
||||||
|
ComponentThemeData bottomNavigationBar(
|
||||||
|
BottomNavigationBarComponent? bottomNavigationBar);
|
||||||
|
|
||||||
|
ComponentThemeData errorWidget(ErrorWidgetComponent? errorWidget);
|
||||||
|
|
||||||
|
ComponentThemeData loadingWidget(LoadingWidgetComponent? loadingWidget);
|
||||||
|
|
||||||
|
ComponentThemeData loaderComponent(LoaderComponent? loaderComponent);
|
||||||
|
|
||||||
|
ComponentThemeData richTextBuilderComponent(
|
||||||
|
RichTextBuilderComponent? richTextBuilderComponent);
|
||||||
|
|
||||||
|
ComponentThemeData textInputComponent(TextInputComponent? textInputComponent);
|
||||||
|
|
||||||
|
ComponentThemeData fileSelectionButtonComponent(
|
||||||
|
FileSelectionButtonComponent? fileSelectionButtonComponent);
|
||||||
|
|
||||||
|
ComponentThemeData flatButtonComponent(
|
||||||
|
FlatButtonComponent? flatButtonComponent);
|
||||||
|
|
||||||
|
ComponentThemeData simpleIconButtonComponent(
|
||||||
|
SimpleIconButtonComponent? simpleIconButtonComponent);
|
||||||
|
|
||||||
|
ComponentThemeData symbolButtonComponent(
|
||||||
|
SymbolButtonComponent? symbolButtonComponent);
|
||||||
|
|
||||||
|
ComponentThemeData informationCardComponent(
|
||||||
|
InformationCardComponent? informationCardComponent);
|
||||||
|
|
||||||
|
ComponentThemeData portfolioCardComponent(
|
||||||
|
PortfolioCardComponent? portfolioCardComponent);
|
||||||
|
|
||||||
|
ComponentThemeData quoteCardComponent(QuoteCardComponent? quoteCardComponent);
|
||||||
|
|
||||||
|
ComponentThemeData skillCardComponent(SkillCardComponent? skillCardComponent);
|
||||||
|
|
||||||
|
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `ComponentThemeData(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||||
|
///
|
||||||
|
/// Usage
|
||||||
|
/// ```dart
|
||||||
|
/// ComponentThemeData(...).copyWith(id: 12, name: "My name")
|
||||||
|
/// ````
|
||||||
|
ComponentThemeData call({
|
||||||
|
TopAppBarComponent? appBar,
|
||||||
|
TopNavigationBarComponent? topNavigationBarComponent,
|
||||||
|
BottomNavigationBarComponent? bottomNavigationBar,
|
||||||
|
ErrorWidgetComponent? errorWidget,
|
||||||
|
LoadingWidgetComponent? loadingWidget,
|
||||||
|
LoaderComponent? loaderComponent,
|
||||||
|
RichTextBuilderComponent? richTextBuilderComponent,
|
||||||
|
TextInputComponent? textInputComponent,
|
||||||
|
FileSelectionButtonComponent? fileSelectionButtonComponent,
|
||||||
|
FlatButtonComponent? flatButtonComponent,
|
||||||
|
SimpleIconButtonComponent? simpleIconButtonComponent,
|
||||||
|
SymbolButtonComponent? symbolButtonComponent,
|
||||||
|
InformationCardComponent? informationCardComponent,
|
||||||
|
PortfolioCardComponent? portfolioCardComponent,
|
||||||
|
QuoteCardComponent? quoteCardComponent,
|
||||||
|
SkillCardComponent? skillCardComponent,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfComponentThemeData.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfComponentThemeData.copyWith.fieldName(...)`
|
||||||
|
class _$ComponentThemeDataCWProxyImpl implements _$ComponentThemeDataCWProxy {
|
||||||
|
const _$ComponentThemeDataCWProxyImpl(this._value);
|
||||||
|
|
||||||
|
final ComponentThemeData _value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData appBar(TopAppBarComponent? appBar) => this(appBar: appBar);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData topNavigationBarComponent(
|
||||||
|
TopNavigationBarComponent? topNavigationBarComponent) =>
|
||||||
|
this(topNavigationBarComponent: topNavigationBarComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData bottomNavigationBar(
|
||||||
|
BottomNavigationBarComponent? bottomNavigationBar) =>
|
||||||
|
this(bottomNavigationBar: bottomNavigationBar);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData errorWidget(ErrorWidgetComponent? errorWidget) =>
|
||||||
|
this(errorWidget: errorWidget);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData loadingWidget(LoadingWidgetComponent? loadingWidget) =>
|
||||||
|
this(loadingWidget: loadingWidget);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData loaderComponent(LoaderComponent? loaderComponent) =>
|
||||||
|
this(loaderComponent: loaderComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData richTextBuilderComponent(
|
||||||
|
RichTextBuilderComponent? richTextBuilderComponent) =>
|
||||||
|
this(richTextBuilderComponent: richTextBuilderComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData textInputComponent(
|
||||||
|
TextInputComponent? textInputComponent) =>
|
||||||
|
this(textInputComponent: textInputComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData fileSelectionButtonComponent(
|
||||||
|
FileSelectionButtonComponent? fileSelectionButtonComponent) =>
|
||||||
|
this(fileSelectionButtonComponent: fileSelectionButtonComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData flatButtonComponent(
|
||||||
|
FlatButtonComponent? flatButtonComponent) =>
|
||||||
|
this(flatButtonComponent: flatButtonComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData simpleIconButtonComponent(
|
||||||
|
SimpleIconButtonComponent? simpleIconButtonComponent) =>
|
||||||
|
this(simpleIconButtonComponent: simpleIconButtonComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData symbolButtonComponent(
|
||||||
|
SymbolButtonComponent? symbolButtonComponent) =>
|
||||||
|
this(symbolButtonComponent: symbolButtonComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData informationCardComponent(
|
||||||
|
InformationCardComponent? informationCardComponent) =>
|
||||||
|
this(informationCardComponent: informationCardComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData portfolioCardComponent(
|
||||||
|
PortfolioCardComponent? portfolioCardComponent) =>
|
||||||
|
this(portfolioCardComponent: portfolioCardComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData quoteCardComponent(
|
||||||
|
QuoteCardComponent? quoteCardComponent) =>
|
||||||
|
this(quoteCardComponent: quoteCardComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ComponentThemeData skillCardComponent(
|
||||||
|
SkillCardComponent? skillCardComponent) =>
|
||||||
|
this(skillCardComponent: skillCardComponent);
|
||||||
|
|
||||||
|
@override
|
||||||
|
|
||||||
|
/// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `ComponentThemeData(...).copyWith.fieldName(...)` to override fields one at a time with nullification support.
|
||||||
|
///
|
||||||
|
/// Usage
|
||||||
|
/// ```dart
|
||||||
|
/// ComponentThemeData(...).copyWith(id: 12, name: "My name")
|
||||||
|
/// ````
|
||||||
|
ComponentThemeData call({
|
||||||
|
Object? appBar = const $CopyWithPlaceholder(),
|
||||||
|
Object? topNavigationBarComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? bottomNavigationBar = const $CopyWithPlaceholder(),
|
||||||
|
Object? errorWidget = const $CopyWithPlaceholder(),
|
||||||
|
Object? loadingWidget = const $CopyWithPlaceholder(),
|
||||||
|
Object? loaderComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? richTextBuilderComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? textInputComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? fileSelectionButtonComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? flatButtonComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? simpleIconButtonComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? symbolButtonComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? informationCardComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? portfolioCardComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? quoteCardComponent = const $CopyWithPlaceholder(),
|
||||||
|
Object? skillCardComponent = const $CopyWithPlaceholder(),
|
||||||
|
}) {
|
||||||
|
return ComponentThemeData(
|
||||||
|
appBar: appBar == const $CopyWithPlaceholder()
|
||||||
|
? _value.appBar
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: appBar as TopAppBarComponent?,
|
||||||
|
topNavigationBarComponent:
|
||||||
|
topNavigationBarComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.topNavigationBarComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: topNavigationBarComponent as TopNavigationBarComponent?,
|
||||||
|
bottomNavigationBar: bottomNavigationBar == const $CopyWithPlaceholder()
|
||||||
|
? _value.bottomNavigationBar
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: bottomNavigationBar as BottomNavigationBarComponent?,
|
||||||
|
errorWidget: errorWidget == const $CopyWithPlaceholder()
|
||||||
|
? _value.errorWidget
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: errorWidget as ErrorWidgetComponent?,
|
||||||
|
loadingWidget: loadingWidget == const $CopyWithPlaceholder()
|
||||||
|
? _value.loadingWidget
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: loadingWidget as LoadingWidgetComponent?,
|
||||||
|
loaderComponent: loaderComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.loaderComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: loaderComponent as LoaderComponent?,
|
||||||
|
richTextBuilderComponent:
|
||||||
|
richTextBuilderComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.richTextBuilderComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: richTextBuilderComponent as RichTextBuilderComponent?,
|
||||||
|
textInputComponent: textInputComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.textInputComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: textInputComponent as TextInputComponent?,
|
||||||
|
fileSelectionButtonComponent:
|
||||||
|
fileSelectionButtonComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.fileSelectionButtonComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: fileSelectionButtonComponent as FileSelectionButtonComponent?,
|
||||||
|
flatButtonComponent: flatButtonComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.flatButtonComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: flatButtonComponent as FlatButtonComponent?,
|
||||||
|
simpleIconButtonComponent:
|
||||||
|
simpleIconButtonComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.simpleIconButtonComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: simpleIconButtonComponent as SimpleIconButtonComponent?,
|
||||||
|
symbolButtonComponent:
|
||||||
|
symbolButtonComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.symbolButtonComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: symbolButtonComponent as SymbolButtonComponent?,
|
||||||
|
informationCardComponent:
|
||||||
|
informationCardComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.informationCardComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: informationCardComponent as InformationCardComponent?,
|
||||||
|
portfolioCardComponent:
|
||||||
|
portfolioCardComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.portfolioCardComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: portfolioCardComponent as PortfolioCardComponent?,
|
||||||
|
quoteCardComponent: quoteCardComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.quoteCardComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: quoteCardComponent as QuoteCardComponent?,
|
||||||
|
skillCardComponent: skillCardComponent == const $CopyWithPlaceholder()
|
||||||
|
? _value.skillCardComponent
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: skillCardComponent as SkillCardComponent?,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension $ComponentThemeDataCopyWith on ComponentThemeData {
|
||||||
|
/// Returns a callable class that can be used as follows: `instanceOfComponentThemeData.copyWith(...)` or like so:`instanceOfComponentThemeData.copyWith.fieldName(...)`.
|
||||||
|
// ignore: library_private_types_in_public_api
|
||||||
|
_$ComponentThemeDataCWProxy get copyWith =>
|
||||||
|
_$ComponentThemeDataCWProxyImpl(this);
|
||||||
|
}
|
@ -10,17 +10,20 @@ environment:
|
|||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter: { sdk: flutter }
|
flutter: { sdk: flutter }
|
||||||
|
copy_with_extension: ^5.0.0
|
||||||
wyatt_component_copy_with_extension:
|
wyatt_component_copy_with_extension:
|
||||||
git:
|
git:
|
||||||
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
||||||
path: packages/wyatt_component_copy_with_extension
|
path: packages/wyatt_component_copy_with_extension
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^2.3.3
|
|
||||||
flutter_test: { sdk: flutter }
|
flutter_test: { sdk: flutter }
|
||||||
wyatt_analysis:
|
wyatt_analysis:
|
||||||
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
|
||||||
version: ^2.4.0
|
version: ^2.4.0
|
||||||
|
|
||||||
|
build_runner: ^2.3.3
|
||||||
|
copy_with_extension_gen: ^5.0.0
|
||||||
wyatt_component_copy_with_gen:
|
wyatt_component_copy_with_gen:
|
||||||
git:
|
git:
|
||||||
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
||||||
|
@ -42,7 +42,7 @@ class NavigationItem extends StatelessWidget {
|
|||||||
context
|
context
|
||||||
.themeExtension<TopBarThemeExtension>()
|
.themeExtension<TopBarThemeExtension>()
|
||||||
?.secondaryColor,
|
?.secondaryColor,
|
||||||
Theme.of(context).primaryColor,
|
context.colorScheme.primary
|
||||||
],
|
],
|
||||||
valueValidator: (value) => value != null,
|
valueValidator: (value) => value != null,
|
||||||
transform: (value) => value,
|
transform: (value) => value,
|
||||||
|
@ -80,33 +80,33 @@ class FileSelectionButtonThemeResolver extends ThemeResolver<
|
|||||||
@override
|
@override
|
||||||
FileSelectionButtonStyle? computeExtensionValueFn(
|
FileSelectionButtonStyle? computeExtensionValueFn(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
FileSelectionButtonThemeExtension themeExtension, {
|
FileSelectionButtonThemeExtension? themeExtension, {
|
||||||
ButtonState? extra,
|
ButtonState? extra,
|
||||||
}) {
|
}) {
|
||||||
FileSelectionButtonStyle? style;
|
FileSelectionButtonStyle? style;
|
||||||
switch (extra?.state) {
|
switch (extra?.state) {
|
||||||
case ControlState.disabled:
|
case ControlState.disabled:
|
||||||
style = themeExtension.disabledStyle;
|
style = themeExtension?.disabledStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.focused:
|
case ControlState.focused:
|
||||||
style = themeExtension.focusedStyle;
|
style = themeExtension?.focusedStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.hovered:
|
case ControlState.hovered:
|
||||||
style = themeExtension.hoveredStyle;
|
style = themeExtension?.hoveredStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.tapped:
|
case ControlState.tapped:
|
||||||
style = themeExtension.tappedStyle;
|
style = themeExtension?.tappedStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.normal:
|
case ControlState.normal:
|
||||||
case null:
|
case null:
|
||||||
style = themeExtension.normalStyle;
|
style = themeExtension?.normalStyle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (extra?.isSelected ?? false) {
|
if (extra?.isSelected ?? false) {
|
||||||
style = themeExtension.selectedStyle;
|
style = themeExtension?.selectedStyle;
|
||||||
}
|
}
|
||||||
if (extra?.isInvalid ?? false) {
|
if (extra?.isInvalid ?? false) {
|
||||||
style = themeExtension.invalidStyle;
|
style = themeExtension?.invalidStyle;
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
@ -76,21 +76,21 @@ class FlatButtonThemeResolver extends ThemeResolver<FlatButtonStyle,
|
|||||||
@override
|
@override
|
||||||
FlatButtonStyle? computeExtensionValueFn(
|
FlatButtonStyle? computeExtensionValueFn(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
FlatButtonThemeExtension themeExtension, {
|
FlatButtonThemeExtension? themeExtension, {
|
||||||
ControlState? extra,
|
ControlState? extra,
|
||||||
}) {
|
}) {
|
||||||
switch (extra) {
|
switch (extra) {
|
||||||
case ControlState.disabled:
|
case ControlState.disabled:
|
||||||
return themeExtension.disabledStyle;
|
return themeExtension?.disabledStyle;
|
||||||
case ControlState.focused:
|
case ControlState.focused:
|
||||||
return themeExtension.focusedStyle;
|
return themeExtension?.focusedStyle;
|
||||||
case ControlState.hovered:
|
case ControlState.hovered:
|
||||||
return themeExtension.hoveredStyle;
|
return themeExtension?.hoveredStyle;
|
||||||
case ControlState.tapped:
|
case ControlState.tapped:
|
||||||
return themeExtension.tappedStyle;
|
return themeExtension?.tappedStyle;
|
||||||
case ControlState.normal:
|
case ControlState.normal:
|
||||||
case null:
|
case null:
|
||||||
return themeExtension.normalStyle;
|
return themeExtension?.normalStyle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,21 +74,21 @@ class SimpleIconButtonThemeResolver extends ThemeResolver<SimpleIconButtonStyle,
|
|||||||
@override
|
@override
|
||||||
SimpleIconButtonStyle? computeExtensionValueFn(
|
SimpleIconButtonStyle? computeExtensionValueFn(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
SimpleIconButtonThemeExtension themeExtension, {
|
SimpleIconButtonThemeExtension? themeExtension, {
|
||||||
ControlState? extra,
|
ControlState? extra,
|
||||||
}) {
|
}) {
|
||||||
switch (extra) {
|
switch (extra) {
|
||||||
case ControlState.disabled:
|
case ControlState.disabled:
|
||||||
return themeExtension.disabledStyle;
|
return themeExtension?.disabledStyle;
|
||||||
case ControlState.focused:
|
case ControlState.focused:
|
||||||
return themeExtension.focusedStyle;
|
return themeExtension?.focusedStyle;
|
||||||
case ControlState.hovered:
|
case ControlState.hovered:
|
||||||
return themeExtension.hoveredStyle;
|
return themeExtension?.hoveredStyle;
|
||||||
case ControlState.tapped:
|
case ControlState.tapped:
|
||||||
return themeExtension.tappedStyle;
|
return themeExtension?.tappedStyle;
|
||||||
case ControlState.normal:
|
case ControlState.normal:
|
||||||
case null:
|
case null:
|
||||||
return themeExtension.normalStyle;
|
return themeExtension?.normalStyle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,30 +76,30 @@ class SymbolButtonThemeResolver extends ThemeResolver<SymbolButtonStyle,
|
|||||||
@override
|
@override
|
||||||
SymbolButtonStyle? computeExtensionValueFn(
|
SymbolButtonStyle? computeExtensionValueFn(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
SymbolButtonThemeExtension themeExtension, {
|
SymbolButtonThemeExtension? themeExtension, {
|
||||||
ButtonState? extra,
|
ButtonState? extra,
|
||||||
}) {
|
}) {
|
||||||
SymbolButtonStyle? style;
|
SymbolButtonStyle? style;
|
||||||
switch (extra?.state) {
|
switch (extra?.state) {
|
||||||
case ControlState.disabled:
|
case ControlState.disabled:
|
||||||
style = themeExtension.disabledStyle;
|
style = themeExtension?.disabledStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.focused:
|
case ControlState.focused:
|
||||||
style = themeExtension.focusedStyle;
|
style = themeExtension?.focusedStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.hovered:
|
case ControlState.hovered:
|
||||||
style = themeExtension.hoveredStyle;
|
style = themeExtension?.hoveredStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.tapped:
|
case ControlState.tapped:
|
||||||
style = themeExtension.tappedStyle;
|
style = themeExtension?.tappedStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.normal:
|
case ControlState.normal:
|
||||||
case null:
|
case null:
|
||||||
style = themeExtension.normalStyle;
|
style = themeExtension?.normalStyle;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (extra?.isSelected ?? false) {
|
if (extra?.isSelected ?? false) {
|
||||||
style = themeExtension.selectedStyle;
|
style = themeExtension?.selectedStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
|
@ -48,11 +48,11 @@ class LoaderThemeResolver
|
|||||||
@override
|
@override
|
||||||
LoaderStyle? computeExtensionValueFn(
|
LoaderStyle? computeExtensionValueFn(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
LoaderThemeExtension themeExtension, {
|
LoaderThemeExtension? themeExtension, {
|
||||||
void extra,
|
void extra,
|
||||||
}) =>
|
}) =>
|
||||||
LoaderStyle(
|
LoaderStyle(
|
||||||
colors: themeExtension.colors,
|
colors: themeExtension?.colors,
|
||||||
stroke: themeExtension.stroke,
|
stroke: themeExtension?.stroke,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,11 @@ class RichTextBuilderThemeResolver extends ThemeResolver<RichTextBuilderStyle,
|
|||||||
@override
|
@override
|
||||||
RichTextBuilderStyle? computeExtensionValueFn(
|
RichTextBuilderStyle? computeExtensionValueFn(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
RichTextBuilderThemeExtension themeExtension, {
|
RichTextBuilderThemeExtension? themeExtension, {
|
||||||
void extra,
|
void extra,
|
||||||
}) =>
|
}) =>
|
||||||
RichTextBuilderStyle(
|
RichTextBuilderStyle(
|
||||||
defaultStyle: themeExtension.defaultStyle,
|
defaultStyle: themeExtension?.defaultStyle,
|
||||||
styles: themeExtension.styles,
|
styles: themeExtension?.styles,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ part 'text_input.g.dart';
|
|||||||
|
|
||||||
@ComponentCopyWithExtension()
|
@ComponentCopyWithExtension()
|
||||||
class TextInput extends TextInputComponent with $TextInputCWMixin {
|
class TextInput extends TextInputComponent with $TextInputCWMixin {
|
||||||
TextInput({
|
const TextInput({
|
||||||
super.expand,
|
super.expand,
|
||||||
super.validator,
|
super.validator,
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -118,19 +118,19 @@ class TextInputThemeResolver extends ThemeResolver<TextInputStyle,
|
|||||||
@override
|
@override
|
||||||
TextInputStyle? computeExtensionValueFn(
|
TextInputStyle? computeExtensionValueFn(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
TextInputThemeExtension themeExtension, {
|
TextInputThemeExtension? themeExtension, {
|
||||||
TextInputState? extra,
|
TextInputState? extra,
|
||||||
}) {
|
}) {
|
||||||
TextInputStyle? textInputStyle;
|
TextInputStyle? textInputStyle;
|
||||||
switch (extra?.controlState) {
|
switch (extra?.controlState) {
|
||||||
case ControlState.focused:
|
case ControlState.focused:
|
||||||
textInputStyle = themeExtension.focusedStyle;
|
textInputStyle = themeExtension?.focusedStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.disabled:
|
case ControlState.disabled:
|
||||||
textInputStyle = themeExtension.disableStyle;
|
textInputStyle = themeExtension?.disableStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.normal:
|
case ControlState.normal:
|
||||||
textInputStyle = themeExtension.normalStyle;
|
textInputStyle = themeExtension?.normalStyle;
|
||||||
break;
|
break;
|
||||||
case ControlState.hovered:
|
case ControlState.hovered:
|
||||||
case ControlState.tapped:
|
case ControlState.tapped:
|
||||||
@ -141,7 +141,7 @@ class TextInputThemeResolver extends ThemeResolver<TextInputStyle,
|
|||||||
TextInputStyle? style;
|
TextInputStyle? style;
|
||||||
switch (extra?.statusState) {
|
switch (extra?.statusState) {
|
||||||
case StatusState.error:
|
case StatusState.error:
|
||||||
style = themeExtension.errorStyle;
|
style = themeExtension?.errorStyle;
|
||||||
break;
|
break;
|
||||||
case StatusState.initial:
|
case StatusState.initial:
|
||||||
case StatusState.success:
|
case StatusState.success:
|
||||||
|
@ -15,4 +15,3 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
export './linear_gradient_helper.dart';
|
export './linear_gradient_helper.dart';
|
||||||
export './theme_helper.dart';
|
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (C) 2023 WYATT GROUP
|
||||||
|
// Please see the AUTHORS file for details.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||||
|
import 'package:wyatt_ui_kit/wyatt_ui_kit.dart';
|
||||||
|
|
||||||
|
class WyattComponentThemeData {
|
||||||
|
static ComponentThemeData get wyattComponentThemeData => ComponentThemeData(
|
||||||
|
appBar: const TopAppBar(),
|
||||||
|
topNavigationBarComponent: const TopNavigationBar(),
|
||||||
|
loaderComponent: const Loader(),
|
||||||
|
richTextBuilderComponent: const RichTextBuilder(),
|
||||||
|
textInputComponent: const TextInput(),
|
||||||
|
fileSelectionButtonComponent: FileSelectionButton(),
|
||||||
|
flatButtonComponent: FlatButton(),
|
||||||
|
simpleIconButtonComponent: SimpleIconButton(),
|
||||||
|
symbolButtonComponent: SymbolButton(),
|
||||||
|
informationCardComponent: const InformationCard(),
|
||||||
|
portfolioCardComponent: const PortfolioCard(),
|
||||||
|
quoteCardComponent: const QuoteCard(),
|
||||||
|
skillCardComponent: const SkillCard(),
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user
remove this useless