From f76c7dc309dcbf8ce69833cf98bcbd984d74bc00 Mon Sep 17 00:00:00 2001 From: Alexandru Mariuti Date: Sat, 30 Mar 2024 15:31:52 +0100 Subject: [PATCH] chore/remove shad assets --- CHANGELOG.md | 5 + assets/alert-circle.svg | 15 -- assets/bell-ring.svg | 16 -- assets/check.svg | 13 -- assets/chevron-down.svg | 13 -- assets/chevron-up.svg | 13 -- assets/terminal.svg | 14 -- assets/x.svg | 4 - example/lib/pages/alert.dart | 4 +- example/lib/pages/card.dart | 4 +- lib/shadcn_ui.dart | 4 +- lib/src/assets.dart | 11 - lib/src/components/accordion.dart | 6 +- lib/src/components/alert.dart | 2 +- lib/src/components/checkbox.dart | 4 +- lib/src/components/dialog.dart | 6 +- lib/src/components/image.dart | 212 +++++++++++--------- lib/src/components/select.dart | 10 +- lib/src/components/sheet.dart | 3 +- lib/src/components/toast.dart | 6 +- lib/src/theme/components/accordion.dart | 5 +- lib/src/theme/components/dialog.dart | 5 +- lib/src/theme/components/sheet.dart | 5 +- lib/src/theme/components/toast.dart | 5 +- lib/src/theme/themes/component_default.dart | 10 +- playground/lib/pages/alert.dart | 4 +- playground/lib/pages/card.dart | 4 +- pubspec.yaml | 12 +- 28 files changed, 170 insertions(+), 245 deletions(-) delete mode 100644 assets/alert-circle.svg delete mode 100644 assets/bell-ring.svg delete mode 100644 assets/check.svg delete mode 100644 assets/chevron-down.svg delete mode 100644 assets/chevron-up.svg delete mode 100644 assets/terminal.svg delete mode 100644 assets/x.svg delete mode 100644 lib/src/assets.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 5088cd3..e7cee83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.6 + +- Fix buttons state not updated correctly +- Remove `ShadAssets` in favor of `LucideIcons` + ## 0.2.5 - Add `width` and `height` to `ShadCard` diff --git a/assets/alert-circle.svg b/assets/alert-circle.svg deleted file mode 100644 index 578d25c..0000000 --- a/assets/alert-circle.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/assets/bell-ring.svg b/assets/bell-ring.svg deleted file mode 100644 index 7e672cd..0000000 --- a/assets/bell-ring.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/assets/check.svg b/assets/check.svg deleted file mode 100644 index 5abe152..0000000 --- a/assets/check.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/assets/chevron-down.svg b/assets/chevron-down.svg deleted file mode 100644 index e70d30b..0000000 --- a/assets/chevron-down.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/assets/chevron-up.svg b/assets/chevron-up.svg deleted file mode 100644 index b011f77..0000000 --- a/assets/chevron-up.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/assets/terminal.svg b/assets/terminal.svg deleted file mode 100644 index 7091ea2..0000000 --- a/assets/terminal.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/assets/x.svg b/assets/x.svg deleted file mode 100644 index 2f94dee..0000000 --- a/assets/x.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/example/lib/pages/alert.dart b/example/lib/pages/alert.dart index 66a5db5..d3c7065 100644 --- a/example/lib/pages/alert.dart +++ b/example/lib/pages/alert.dart @@ -14,7 +14,7 @@ class AlertPage extends StatelessWidget { ConstrainedBox( constraints: const BoxConstraints(maxWidth: 600), child: const ShadAlert( - iconSrc: ShadAssets.terminal, + iconSrc: LucideIcons.terminal, title: Text('Heads up!'), description: Text('You can add components to your app using the cli.'), @@ -23,7 +23,7 @@ class AlertPage extends StatelessWidget { ConstrainedBox( constraints: const BoxConstraints(maxWidth: 600), child: const ShadAlert.destructive( - iconSrc: ShadAssets.alertCircle, + iconSrc: LucideIcons.circleAlert, title: Text('Error'), description: Text('Your session has expired. Please log in again.'), ), diff --git a/example/lib/pages/card.dart b/example/lib/pages/card.dart index badc928..8a8828c 100644 --- a/example/lib/pages/card.dart +++ b/example/lib/pages/card.dart @@ -106,7 +106,7 @@ class _CardPageState extends State { child: Row( children: [ ShadImage.square( - ShadAssets.bellRing, + LucideIcons.bellRing, size: 24, color: theme.colorScheme.foreground, ), @@ -183,7 +183,7 @@ class _CardPageState extends State { text: const Text('Mark all as read'), icon: const Padding( padding: EdgeInsets.only(right: 8), - child: ShadImage.square(ShadAssets.check, size: 16), + child: ShadImage.square(LucideIcons.check, size: 16), ), onPressed: () {}, ), diff --git a/lib/shadcn_ui.dart b/lib/shadcn_ui.dart index dc2b599..f824fa6 100644 --- a/lib/shadcn_ui.dart +++ b/lib/shadcn_ui.dart @@ -31,9 +31,6 @@ export 'src/components/switch.dart'; export 'src/components/toast.dart'; export 'src/components/tooltip.dart'; -// Assets -export 'src/assets.dart'; - // Raw Components export 'src/raw_components/portal.dart'; export 'src/raw_components/same_width_column.dart'; @@ -92,3 +89,4 @@ export 'src/utils/extensions.dart'; export 'package:flutter_animate/flutter_animate.dart'; export 'package:boxy/boxy.dart'; export 'package:boxy/flex.dart'; +export 'package:lucide_icons_flutter/lucide_icons.dart'; diff --git a/lib/src/assets.dart b/lib/src/assets.dart deleted file mode 100644 index 224b33b..0000000 --- a/lib/src/assets.dart +++ /dev/null @@ -1,11 +0,0 @@ -abstract class ShadAssets { - static const _assetsFolder = 'packages/shadcn_ui/assets'; - - static const alertCircle = '$_assetsFolder/alert-circle.svg'; - static const bellRing = '$_assetsFolder/bell-ring.svg'; - static const check = '$_assetsFolder/check.svg'; - static const chevronDown = '$_assetsFolder/chevron-down.svg'; - static const chevronUp = '$_assetsFolder/chevron-up.svg'; - static const terminal = '$_assetsFolder/terminal.svg'; - static const x = '$_assetsFolder/x.svg'; -} diff --git a/lib/src/components/accordion.dart b/lib/src/components/accordion.dart index c812aa4..dee5cac 100644 --- a/lib/src/components/accordion.dart +++ b/lib/src/components/accordion.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; -import 'package:shadcn_ui/src/assets.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; import 'package:shadcn_ui/src/components/image.dart'; import 'package:shadcn_ui/src/theme/theme.dart'; import 'package:shadcn_ui/src/utils/animation_builder.dart'; @@ -116,7 +116,7 @@ class ShadAccordionItem extends StatefulWidget { final Widget content; final Widget? separator; final Widget? icon; - final String? iconSrc; + final ShadImageSrc? iconSrc; final List>? iconEffects; final Widget Function(Animation animation, Widget child)? transitionBuilder; @@ -177,7 +177,7 @@ class _ShadAccordionItemState extends State> final effectiveIconSrc = widget.iconSrc ?? theme.accordionTheme.iconSrc ?? - ShadAssets.chevronDown; + LucideIcons.chevronDown; final effectiveIcon = widget.icon ?? ShadImage.square( diff --git a/lib/src/components/alert.dart b/lib/src/components/alert.dart index f6678d5..c702a84 100644 --- a/lib/src/components/alert.dart +++ b/lib/src/components/alert.dart @@ -49,7 +49,7 @@ class ShadAlert extends StatelessWidget { final ShadAlertVariant variant; final Widget? icon; - final String? iconSrc; + final ShadImageSrc? iconSrc; final Widget? title; final Widget? description; final TextDirection? textDirection; diff --git a/lib/src/components/checkbox.dart b/lib/src/components/checkbox.dart index cb948ed..b834bf0 100644 --- a/lib/src/components/checkbox.dart +++ b/lib/src/components/checkbox.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_animate/flutter_animate.dart'; -import 'package:shadcn_ui/src/assets.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; import 'package:shadcn_ui/src/components/disabled.dart'; import 'package:shadcn_ui/src/components/focused.dart'; import 'package:shadcn_ui/src/components/image.dart'; @@ -109,7 +109,7 @@ class _ShadCheckboxState extends State { widget.radius ?? theme.checkboxTheme.radius ?? theme.radius; final effectiveIcon = widget.icon ?? ShadImage.square( - ShadAssets.check, + LucideIcons.check, color: theme.colorScheme.primaryForeground, size: effectiveSize, ); diff --git a/lib/src/components/dialog.dart b/lib/src/components/dialog.dart index 536d109..3369e33 100644 --- a/lib/src/components/dialog.dart +++ b/lib/src/components/dialog.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; -import 'package:shadcn_ui/src/assets.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; import 'package:shadcn_ui/src/components/button.dart'; import 'package:shadcn_ui/src/components/image.dart'; import 'package:shadcn_ui/src/raw_components/same_width_column.dart'; @@ -142,7 +142,7 @@ class ShadDialog extends StatelessWidget { final ShadDialogVariant variant; final List actions; final Widget? closeIcon; - final String? closeIconSrc; + final ShadImageSrc? closeIconSrc; final ShadPosition? closeIconPosition; final BorderRadius? radius; final Color? backgroundColor; @@ -183,7 +183,7 @@ class ShadDialog extends StatelessWidget { size: 16, closeIconSrc ?? effectiveDialogTheme.closeIconSrc ?? - ShadAssets.x, + LucideIcons.x, ), width: 20, height: 20, diff --git a/lib/src/components/image.dart b/lib/src/components/image.dart index 057ef87..00c5b81 100644 --- a/lib/src/components/image.dart +++ b/lib/src/components/image.dart @@ -3,6 +3,8 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:rive/rive.dart'; import 'package:vector_graphics/vector_graphics.dart'; +typedef ShadImageSrc = Object; + /// {@template image} /// Unifies the display of an image. /// @@ -19,7 +21,7 @@ import 'package:vector_graphics/vector_graphics.dart'; /// /// Finally it takes a [fit], that defauls to [BoxFit.contain]. /// {@endtemplate} -class ShadImage extends StatelessWidget { +class ShadImage extends StatelessWidget { /// {@macro image} const ShadImage( this.src, { @@ -40,7 +42,10 @@ class ShadImage extends StatelessWidget { this.controllers = const [], this.onInit, this.svgTheme, - }); + }) : assert( + src is String || src is IconData, + 'src must be a String or IconData', + ); /// {@macro image} const ShadImage.square( @@ -62,7 +67,11 @@ class ShadImage extends StatelessWidget { this.onInit, this.svgTheme, }) : width = size, - height = size; + height = size, + assert( + src is String || src is IconData, + 'src must be a String or IconData', + ); /// The src of the image. /// @@ -74,7 +83,7 @@ class ShadImage extends StatelessWidget { /// - assets/email.svg /// - assets/email.svg.vec /// - https://picsum.photos/200 - final String src; + final T src; /// The width of the image final double? width; @@ -125,16 +134,16 @@ class ShadImage extends StatelessWidget { final SvgTheme? svgTheme; /// Returns `true` if the image is remote. - bool get isRemote => Uri.tryParse(src)?.host.isNotEmpty ?? false; + bool get isRemote => Uri.tryParse(src as String)?.host.isNotEmpty ?? false; /// Returns `true` if the image is an svg. - bool get isSvg => src.contains('.svg'); + bool get isSvg => (src as String).contains('.svg'); /// Returns `true` if the image is a rive asset. - bool get isRive => src.contains('.riv'); + bool get isRive => (src as String).contains('.riv'); /// Returns `true` if the image is a vector asset. - bool get isSvgVector => src.contains('.svg.vec'); + bool get isSvgVector => (src as String).contains('.svg.vec'); @override Widget build(BuildContext context) { @@ -144,15 +153,100 @@ class ShadImage extends StatelessWidget { : null; final Widget image; - // If the image is remote, download and display it. - // Otherwise if the image is a svg image, use the [SvgPicture] class - // In any other case, display the image as a [png/jpg]. - // - // Finally, if there is a [gradient], apply a shader mask to the image. - if (isRemote) { - if (isSvg) { - image = SvgPicture.network( - src, + + // If the image is an IconData, use it as an icon + if (src is IconData) { + image = Icon( + src as IconData, + size: width, + color: imageColor, + semanticLabel: semanticLabel, + ); + } else { + final sourceString = src as String; + // If the image is remote, download and display it. + // Otherwise if the image is a svg image, use the [SvgPicture] class + // In any other case, display the image as a [png/jpg]. + // + // Finally, if there is a [gradient], apply a shader mask to the image. + if (isRemote) { + if (isSvg) { + image = SvgPicture.network( + sourceString, + width: width, + height: height, + fit: fit, + colorFilter: colorFilter, + clipBehavior: Clip.antiAlias, + alignment: alignment, + placeholderBuilder: + placeholder != null ? (_) => placeholder! : null, + semanticsLabel: semanticLabel, + ); + } else if (isRive) { + image = SizedBox( + width: width, + height: height, + child: RiveAnimation.network( + sourceString, + fit: fit, + animations: animations, + artboard: artboard, + stateMachines: stateMachines, + placeHolder: placeholder, + alignment: alignment, + antialiasing: antialiasing, + useArtboardSize: useArtboardSize, + controllers: controllers, + onInit: onInit, + ), + ); + } else if (isSvg) { + image = SvgPicture.network( + sourceString, + width: width, + height: height, + fit: fit, + colorFilter: colorFilter, + clipBehavior: Clip.antiAlias, + alignment: alignment, + placeholderBuilder: + placeholder != null ? (_) => placeholder! : null, + semanticsLabel: semanticLabel, + ); + } else { + image = Image.network( + sourceString, + width: width, + height: height, + fit: fit, + semanticLabel: semanticLabel, + color: imageColor, + alignment: alignment, + isAntiAlias: antialiasing, + frameBuilder: (context, child, frame, wasSynchronouslyLoaded) { + if (frame == null) { + return placeholder ?? const SizedBox.shrink(); + } + return child; + }, + ); + } + } else if (isSvgVector) { + image = SvgPicture( + AssetBytesLoader(sourceString), + width: width, + height: height, + fit: fit, + alignment: alignment, + colorFilter: colorFilter, + clipBehavior: Clip.antiAlias, + placeholderBuilder: placeholder != null ? (_) => placeholder! : null, + semanticsLabel: semanticLabel, + ); + } else if (isSvg) { + image = SvgPicture.asset( + sourceString, width: width, height: height, fit: fit, @@ -166,10 +260,9 @@ class ShadImage extends StatelessWidget { image = SizedBox( width: width, height: height, - child: RiveAnimation.network( - src, + child: RiveAnimation.asset( + sourceString, fit: fit, - animations: animations, artboard: artboard, stateMachines: stateMachines, placeHolder: placeholder, @@ -180,95 +273,26 @@ class ShadImage extends StatelessWidget { onInit: onInit, ), ); - } else if (isSvg) { - image = SvgPicture.network( - src, - width: width, - height: height, - fit: fit, - colorFilter: colorFilter, - clipBehavior: Clip.antiAlias, - alignment: alignment, - placeholderBuilder: placeholder != null ? (_) => placeholder! : null, - semanticsLabel: semanticLabel, - ); } else { - image = Image.network( - src, + image = Image.asset( + sourceString, width: width, height: height, fit: fit, - semanticLabel: semanticLabel, color: imageColor, - alignment: alignment, isAntiAlias: antialiasing, + alignment: alignment, frameBuilder: (context, child, frame, wasSynchronouslyLoaded) { if (frame == null) { return placeholder ?? const SizedBox.shrink(); } return child; }, + semanticLabel: semanticLabel, ); } - } else if (isSvgVector) { - image = SvgPicture( - AssetBytesLoader(src), - width: width, - height: height, - fit: fit, - alignment: alignment, - colorFilter: colorFilter, - clipBehavior: Clip.antiAlias, - placeholderBuilder: placeholder != null ? (_) => placeholder! : null, - semanticsLabel: semanticLabel, - ); - } else if (isSvg) { - image = SvgPicture.asset( - src, - width: width, - height: height, - fit: fit, - colorFilter: colorFilter, - clipBehavior: Clip.antiAlias, - alignment: alignment, - placeholderBuilder: placeholder != null ? (_) => placeholder! : null, - semanticsLabel: semanticLabel, - ); - } else if (isRive) { - image = SizedBox( - width: width, - height: height, - child: RiveAnimation.asset( - src, - fit: fit, - artboard: artboard, - stateMachines: stateMachines, - placeHolder: placeholder, - alignment: alignment, - antialiasing: antialiasing, - useArtboardSize: useArtboardSize, - controllers: controllers, - onInit: onInit, - ), - ); - } else { - image = Image.asset( - src, - width: width, - height: height, - fit: fit, - color: imageColor, - isAntiAlias: antialiasing, - alignment: alignment, - frameBuilder: (context, child, frame, wasSynchronouslyLoaded) { - if (frame == null) { - return placeholder ?? const SizedBox.shrink(); - } - return child; - }, - semanticLabel: semanticLabel, - ); } + if (gradient == null) return image; return ShaderMask( diff --git a/lib/src/components/select.dart b/lib/src/components/select.dart index 620012f..6c6bed9 100644 --- a/lib/src/components/select.dart +++ b/lib/src/components/select.dart @@ -3,7 +3,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; -import 'package:shadcn_ui/src/assets.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; import 'package:shadcn_ui/src/components/disabled.dart'; import 'package:shadcn_ui/src/components/focused.dart'; @@ -300,7 +300,7 @@ class ShadSelectState extends State> { final effectiveTrailing = widget.trailing ?? ShadImage.square( - ShadAssets.chevronDown, + LucideIcons.chevronDown, size: 16, color: theme.colorScheme.popoverForeground.withOpacity(.5), ); @@ -377,7 +377,7 @@ class ShadSelectState extends State> { width: calculatedMinWidth, padding: const EdgeInsets.symmetric(vertical: 4), child: ShadImage.square( - ShadAssets.chevronUp, + LucideIcons.chevronUp, size: 16, color: theme.colorScheme.popoverForeground, ), @@ -406,7 +406,7 @@ class ShadSelectState extends State> { width: calculatedMinWidth, padding: const EdgeInsets.symmetric(vertical: 4), child: ShadImage.square( - ShadAssets.chevronDown, + LucideIcons.chevronDown, size: 16, color: theme.colorScheme.popoverForeground, ), @@ -584,7 +584,7 @@ class _ShadOptionState extends State> { child: Padding( padding: const EdgeInsets.only(right: 8), child: ShadImage.square( - ShadAssets.check, + LucideIcons.check, size: 16, color: theme.colorScheme.popoverForeground, ), diff --git a/lib/src/components/sheet.dart b/lib/src/components/sheet.dart index 008b0d4..e1efb08 100644 --- a/lib/src/components/sheet.dart +++ b/lib/src/components/sheet.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:shadcn_ui/src/components/dialog.dart'; +import 'package:shadcn_ui/src/components/image.dart'; import 'package:shadcn_ui/src/theme/theme.dart'; import 'package:shadcn_ui/src/utils/position.dart'; @@ -157,7 +158,7 @@ class ShadSheet extends StatelessWidget { final BoxConstraints? constraints; final bool? expandCrossSide; final Widget? closeIcon; - final String? closeIconSrc; + final ShadImageSrc? closeIconSrc; final ShadPosition? closeIconPosition; final BorderRadius? radius; final Color? backgroundColor; diff --git a/lib/src/components/toast.dart b/lib/src/components/toast.dart index 7c41188..8da4460 100644 --- a/lib/src/components/toast.dart +++ b/lib/src/components/toast.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; -import 'package:shadcn_ui/src/assets.dart'; import 'package:shadcn_ui/src/components/button.dart'; import 'package:shadcn_ui/src/components/image.dart'; import 'package:shadcn_ui/src/theme/theme.dart'; @@ -331,7 +331,7 @@ class ShadToast extends StatefulWidget { final Widget? description; final Widget? action; final Widget? closeIcon; - final String? closeIconSrc; + final ShadImageSrc? closeIconSrc; final Alignment? alignment; final Offset? offset; final Duration? duration; @@ -384,7 +384,7 @@ class _ShadToastState extends State { size: 16, widget.closeIconSrc ?? effectiveToastTheme.closeIconSrc ?? - ShadAssets.x, + LucideIcons.x, ), width: 20, height: 20, diff --git a/lib/src/theme/components/accordion.dart b/lib/src/theme/components/accordion.dart index 8c04646..0e3ac89 100644 --- a/lib/src/theme/components/accordion.dart +++ b/lib/src/theme/components/accordion.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_animate/flutter_animate.dart'; +import 'package:shadcn_ui/src/components/image.dart'; @immutable class ShadAccordionTheme { @@ -17,7 +18,7 @@ class ShadAccordionTheme { }); final bool merge; - final String? iconSrc; + final ShadImageSrc? iconSrc; final List>? iconEffects; final Widget Function(Animation animation, Widget child)? transitionBuilder; @@ -89,7 +90,7 @@ class ShadAccordionTheme { ShadAccordionTheme copyWith({ bool? merge, - String? iconSrc, + ShadImageSrc? iconSrc, List>? iconEffects, EdgeInsets? padding, bool? underlineTitleOnHover, diff --git a/lib/src/theme/components/dialog.dart b/lib/src/theme/components/dialog.dart index c75c13c..e4a9b00 100644 --- a/lib/src/theme/components/dialog.dart +++ b/lib/src/theme/components/dialog.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_animate/flutter_animate.dart'; +import 'package:shadcn_ui/src/components/image.dart'; import 'package:shadcn_ui/src/utils/position.dart'; @@ -35,7 +36,7 @@ class ShadDialogTheme { }); final bool merge; - final String? closeIconSrc; + final ShadImageSrc? closeIconSrc; final ShadPosition? closeIconPosition; final BorderRadius? radius; final Color? backgroundColor; @@ -95,7 +96,7 @@ class ShadDialogTheme { ShadDialogTheme copyWith({ bool? merge, - String? closeIconSrc, + ShadImageSrc? closeIconSrc, ShadPosition? closeIconPosition, BorderRadius? radius, Color? backgroundColor, diff --git a/lib/src/theme/components/sheet.dart b/lib/src/theme/components/sheet.dart index 851ebff..af6c851 100644 --- a/lib/src/theme/components/sheet.dart +++ b/lib/src/theme/components/sheet.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_animate/flutter_animate.dart'; +import 'package:shadcn_ui/src/components/image.dart'; import 'package:shadcn_ui/src/utils/position.dart'; @@ -39,7 +40,7 @@ class ShadSheetTheme { final BoxConstraints? constraints; final bool? expandCrossSide; final Widget? closeIcon; - final String? closeIconSrc; + final ShadImageSrc? closeIconSrc; final ShadPosition? closeIconPosition; final BorderRadius? radius; final Color? backgroundColor; @@ -100,7 +101,7 @@ class ShadSheetTheme { BoxConstraints? constraints, bool? expandCrossSide, Widget? closeIcon, - String? closeIconSrc, + ShadImageSrc? closeIconSrc, ShadPosition? closeIconPosition, BorderRadius? radius, Color? backgroundColor, diff --git a/lib/src/theme/components/toast.dart b/lib/src/theme/components/toast.dart index 66f66c8..2bc2bc7 100644 --- a/lib/src/theme/components/toast.dart +++ b/lib/src/theme/components/toast.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_animate/flutter_animate.dart'; +import 'package:shadcn_ui/src/components/image.dart'; import 'package:shadcn_ui/src/utils/position.dart'; @@ -31,7 +32,7 @@ class ShadToastTheme { final bool merge; final Color? backgroundColor; - final String? closeIconSrc; + final ShadImageSrc? closeIconSrc; final Alignment? alignment; final Offset? offset; final Duration? duration; @@ -85,7 +86,7 @@ class ShadToastTheme { ShadToastTheme copyWith({ bool? merge, Color? backgroundColor, - String? closeIconSrc, + ShadImageSrc? closeIconSrc, Alignment? alignment, Offset? offset, Duration? duration, diff --git a/lib/src/theme/themes/component_default.dart b/lib/src/theme/themes/component_default.dart index b3b9339..1246826 100644 --- a/lib/src/theme/themes/component_default.dart +++ b/lib/src/theme/themes/component_default.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; -import 'package:shadcn_ui/src/assets.dart'; +import 'package:lucide_icons_flutter/lucide_icons.dart'; import 'package:shadcn_ui/src/theme/color_scheme/base.dart'; import 'package:shadcn_ui/src/theme/components/accordion.dart'; import 'package:shadcn_ui/src/theme/components/alert.dart'; @@ -471,7 +471,7 @@ abstract class ShadComponentDefaultTheme { }) { return ShadToastTheme( alignment: Alignment.bottomRight, - closeIconSrc: ShadAssets.x, + closeIconSrc: LucideIcons.x, titleStyle: textTheme.muted.copyWith( fontWeight: FontWeight.w500, color: colorScheme.foreground, @@ -497,7 +497,7 @@ abstract class ShadComponentDefaultTheme { }) { return ShadToastTheme( alignment: Alignment.bottomRight, - closeIconSrc: ShadAssets.x, + closeIconSrc: LucideIcons.x, titleStyle: textTheme.muted.copyWith( fontWeight: FontWeight.w500, color: colorScheme.destructiveForeground, @@ -576,7 +576,7 @@ abstract class ShadComponentDefaultTheme { required ShadTextTheme textTheme, }) { return ShadDialogTheme( - closeIconSrc: ShadAssets.x, + closeIconSrc: LucideIcons.x, radius: const BorderRadius.all(Radius.circular(8)), backgroundColor: colorScheme.background, removeBorderRadiusWhenTiny: true, @@ -678,7 +678,7 @@ abstract class ShadComponentDefaultTheme { const bezierCurve = Cubic(0.87, 0, 0.13, 1); const duration = Duration(milliseconds: 300); return ShadAccordionTheme( - iconSrc: ShadAssets.chevronDown, + iconSrc: LucideIcons.chevronDown, padding: const EdgeInsets.symmetric(vertical: 16), underlineTitleOnHover: true, duration: duration, diff --git a/playground/lib/pages/alert.dart b/playground/lib/pages/alert.dart index e259e21..acb97bc 100644 --- a/playground/lib/pages/alert.dart +++ b/playground/lib/pages/alert.dart @@ -19,13 +19,13 @@ class AlertPage extends StatelessWidget { child: () { return switch (style) { ShadAlertVariant.primary => const ShadAlert( - iconSrc: ShadAssets.terminal, + iconSrc: LucideIcons.terminal, title: Text('Heads up!'), description: Text('You can add components to your app using the cli.'), ), ShadAlertVariant.destructive => const ShadAlert.destructive( - iconSrc: ShadAssets.alertCircle, + iconSrc: LucideIcons.circleAlert, title: Text('Error'), description: Text('Your session has expired. Please log in again.'), diff --git a/playground/lib/pages/card.dart b/playground/lib/pages/card.dart index 62362fe..323f695 100644 --- a/playground/lib/pages/card.dart +++ b/playground/lib/pages/card.dart @@ -137,7 +137,7 @@ class _CardNotificationsState extends State { child: Row( children: [ ShadImage.square( - ShadAssets.bellRing, + LucideIcons.bellRing, size: 24, color: theme.colorScheme.foreground, ), @@ -213,7 +213,7 @@ class _CardNotificationsState extends State { text: const Text('Mark all as read'), icon: const Padding( padding: EdgeInsets.only(right: 8), - child: ShadImage.square(ShadAssets.check, size: 16), + child: ShadImage.square(LucideIcons.check, size: 16), ), onPressed: () {}, ), diff --git a/pubspec.yaml b/pubspec.yaml index 46bbc97..2202d68 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: shadcn_ui description: shadcn-ui ported in Flutter. Awesome UI components for Flutter, fully customizable. -version: 0.2.5 +version: 0.2.6 homepage: https://mariuti.com/shadcn-ui repository: https://github.com/nank1ro/flutter-shadcn-ui documentation: https://mariuti.com/shadcn-ui @@ -19,6 +19,7 @@ dependencies: flutter_localizations: sdk: flutter flutter_svg: ^2.0.10+1 + lucide_icons_flutter: ^1.0.8 rive: ^0.13.1 vector_graphics: ^1.1.11+1 @@ -28,15 +29,6 @@ dev_dependencies: very_good_analysis: ^5.1.0 flutter: - assets: - - assets/alert-circle.svg - - assets/bell-ring.svg - - assets/check.svg - - assets/chevron-down.svg - - assets/chevron-up.svg - - assets/terminal.svg - - assets/x.svg - fonts: - family: Geist fonts: