get colors => _colors ?? [];
+ /// Returns `true` if the [MultiColor] is a [List] of [Color]s that is not
+ /// empty with a length greater than 1.
bool get isGradient => (_colors?.length ?? 0) > 1;
+
+ /// Returns `true` if the [MultiColor] is a [Color] or a [List] of [Color]s
+ /// that is not empty with a length greater than 1.
bool get isColor => _color != null || isGradient;
+ /// Lerps between two [MultiColor]s.
static MultiColor? lerp(MultiColor? a, MultiColor? b, double t) {
if (a == null && b == null) {
return null;
diff --git a/packages/wyatt_ui_components/lib/src/core/utils/text_wrapper.dart b/packages/wyatt_ui_components/lib/src/core/utils/text_wrapper.dart
index ba23b89b..2c6e248e 100644
--- a/packages/wyatt_ui_components/lib/src/core/utils/text_wrapper.dart
+++ b/packages/wyatt_ui_components/lib/src/core/utils/text_wrapper.dart
@@ -17,9 +17,12 @@
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart';
+/// {@template text_wrapper}
/// Wraps [String] and [TextStyle] into one object that can be
/// a [Text] or a [RichText].
+/// {@endtemplate}
class TextWrapper {
+ /// {@macro text_wrapper}
const TextWrapper(
this.data, {
this.style,
@@ -32,6 +35,7 @@ class TextWrapper {
this.selectionColor,
});
+ /// Creates a [TextWrapper] from a [Text] widget.
const TextWrapper.text(this.data)
: style = null,
gradientColors = null,
diff --git a/packages/wyatt_ui_components/lib/src/core/utils/theme_helper.dart b/packages/wyatt_ui_components/lib/src/core/utils/theme_helper.dart
index abefa83f..97fe94a0 100644
--- a/packages/wyatt_ui_components/lib/src/core/utils/theme_helper.dart
+++ b/packages/wyatt_ui_components/lib/src/core/utils/theme_helper.dart
@@ -28,7 +28,6 @@ abstract class ThemeHelper {
/// determines if a style element is valid.
/// [combine]: A function that combines two [P] type objects to create
/// a new object.
-
static T? getThemeElement(
List
? styles, {
required T? Function(P?)? transform,
diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/component.dart
index e7f984f1..9cd334b5 100644
--- a/packages/wyatt_ui_components/lib/src/domain/entities/component.dart
+++ b/packages/wyatt_ui_components/lib/src/domain/entities/component.dart
@@ -17,6 +17,9 @@
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/src/core/utils/theme_resolver.dart';
+/// {@template component}
+/// Base class for all components.
+/// {@endtemplate}
abstract class Component extends StatelessWidget {
const Component({this.themeResolver, super.key});
diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart
index a0a69ffb..89db71e2 100644
--- a/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart
+++ b/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart
@@ -14,7 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
+/// {@template theme_style}
+/// Base class for all theme styles.
+/// {@endtemplate}
abstract class ThemeStyle {
+ /// {@macro theme_style}
const ThemeStyle();
/// Merges non-null `other` attributes in `this` and returns a copy.
diff --git a/packages/wyatt_ui_components/lib/src/features/component_theme.dart b/packages/wyatt_ui_components/lib/src/features/component_theme.dart
index 0ed44487..c7dc79d3 100644
--- a/packages/wyatt_ui_components/lib/src/features/component_theme.dart
+++ b/packages/wyatt_ui_components/lib/src/features/component_theme.dart
@@ -17,7 +17,12 @@
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/src/features/features.dart';
+/// {@template component_theme}
+/// A [ComponentTheme] widget that provides a [ComponentThemeData] to its
+/// descendants.
+/// {@endtemplate}
class ComponentTheme extends StatelessWidget {
+ /// {@macro component_theme}
const ComponentTheme({
required this.child,
required this.componentThemeWidget,
@@ -26,6 +31,9 @@ class ComponentTheme extends StatelessWidget {
final Widget child;
final ComponentThemeData componentThemeWidget;
+ /// Returns the [ComponentThemeData] of the closest ancestor [ComponentTheme]
+ /// widget. If there is no ancestor [ComponentTheme] widget, it throws an
+ /// assertion error.
static ComponentThemeData of(BuildContext context) {
final _InheritedComponentTheme? inheritedThemeComponent =
context.dependOnInheritedWidgetOfExactType<_InheritedComponentTheme>();
@@ -37,6 +45,15 @@ class ComponentTheme extends StatelessWidget {
return inheritedThemeComponent!.themeWidget.componentThemeWidget;
}
+ /// Returns the [ComponentThemeData] of the closest ancestor [ComponentTheme]
+ /// widget. If there is no ancestor [ComponentTheme] widget, it returns null.
+ static ComponentThemeData? maybeOf(BuildContext context) {
+ final _InheritedComponentTheme? inheritedThemeComponent =
+ context.dependOnInheritedWidgetOfExactType<_InheritedComponentTheme>();
+
+ return inheritedThemeComponent?.themeWidget.componentThemeWidget;
+ }
+
@override
Widget build(BuildContext context) => _InheritedComponentTheme(
this,
diff --git a/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart b/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart
index aaff531d..c08e2502 100644
--- a/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart
+++ b/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart
@@ -18,6 +18,9 @@ import 'package:copy_with_extension/copy_with_extension.dart';
import 'package:wyatt_ui_components/src/domain/entities/entities.dart';
part 'component_theme_data.g.dart';
+/// {@template component_theme_data}
+/// A class that holds all the components that are used in the app.
+/// {@endtemplate}
@CopyWith()
class ComponentThemeData {
factory ComponentThemeData({
diff --git a/packages/wyatt_ui_components/lib/wyatt_ui_components.dart b/packages/wyatt_ui_components/lib/wyatt_ui_components.dart
index 3f16c3b1..e8cce321 100644
--- a/packages/wyatt_ui_components/lib/wyatt_ui_components.dart
+++ b/packages/wyatt_ui_components/lib/wyatt_ui_components.dart
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-/// Wyatt Ui Components
+/// Wyatt UI Components
library wyatt_ui_components;
export 'src/src.dart';
diff --git a/packages/wyatt_ui_components/pubspec.yaml b/packages/wyatt_ui_components/pubspec.yaml
index 81f439f9..eecf6f81 100644
--- a/packages/wyatt_ui_components/pubspec.yaml
+++ b/packages/wyatt_ui_components/pubspec.yaml
@@ -1,9 +1,9 @@
name: wyatt_ui_components
-description: Primary ui components
+description: Components that can be implemented in any application with copy constructor.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_ui_components
version: 0.0.1
-publish_to: none
+publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
environment:
sdk: ">=2.17.0 <3.0.0"
@@ -12,9 +12,8 @@ dependencies:
flutter: { sdk: flutter }
copy_with_extension: ^5.0.0
wyatt_component_copy_with_extension:
- git:
- url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
- path: packages/wyatt_component_copy_with_extension
+ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
+ version: ^1.0.0
dev_dependencies:
flutter_test: { sdk: flutter }
@@ -25,6 +24,5 @@ dev_dependencies:
build_runner: ^2.3.3
copy_with_extension_gen: ^5.0.0
wyatt_component_copy_with_gen:
- git:
- url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
- path: packages/wyatt_component_copy_with_gen
+ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
+ version: ^1.0.0