diff --git a/lib/components/Artist/ArtistCard.dart b/lib/components/Artist/ArtistCard.dart index c09fd3af..c36e899f 100644 --- a/lib/components/Artist/ArtistCard.dart +++ b/lib/components/Artist/ArtistCard.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:marquee/marquee.dart'; import 'package:spotify/spotify.dart'; +import 'package:spotube/components/Shared/SpotubeWidgets.dart'; class ArtistCard extends StatelessWidget { final Artist artist; @@ -45,21 +46,9 @@ class ArtistCard extends StatelessWidget { SizedBox( height: 30, child: artist.name!.length > 15 - ? Marquee( + ? SpotubeMarqueeText( text: artist.name!, - style: Theme.of(context).textTheme.headline5, - scrollAxis: Axis.horizontal, - crossAxisAlignment: CrossAxisAlignment.start, - blankSpace: 60.0, - velocity: 30.0, - startAfter: const Duration(seconds: 2), - pauseAfterRound: const Duration(seconds: 2), - accelerationDuration: const Duration(seconds: 1), - accelerationCurve: Curves.linear, - decelerationDuration: const Duration(milliseconds: 500), - decelerationCurve: Curves.easeOut, - fadingEdgeStartFraction: 0.15, - fadingEdgeEndFraction: 0.15, + textStyle: Theme.of(context).textTheme.headline5!, ) : Text( artist.name!, diff --git a/lib/components/Shared/PlaybuttonCard.dart b/lib/components/Shared/PlaybuttonCard.dart index a68ca745..169dd778 100644 --- a/lib/components/Shared/PlaybuttonCard.dart +++ b/lib/components/Shared/PlaybuttonCard.dart @@ -1,6 +1,6 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:marquee/marquee.dart'; +import 'package:spotube/components/Shared/SpotubeWidgets.dart'; class PlaybuttonCard extends StatelessWidget { final void Function()? onTap; @@ -88,10 +88,19 @@ class PlaybuttonCard extends StatelessWidget { children: [ Tooltip( message: title, - child: Text( - title, - style: const TextStyle(fontWeight: FontWeight.bold), - overflow: TextOverflow.ellipsis, + child: SizedBox( + height: 20, + child: title.length > 25 + ? SpotubeMarqueeText( + text: title, + textStyle: const TextStyle( + fontWeight: FontWeight.bold), + ) + : Text( + title, + style: const TextStyle( + fontWeight: FontWeight.bold), + ), ), ), if (description != null) ...[ @@ -99,29 +108,15 @@ class PlaybuttonCard extends StatelessWidget { SizedBox( height: 30, child: description!.length > 30 - ? Marquee( + ? SpotubeMarqueeText( text: description!, - style: TextStyle( + textStyle: TextStyle( fontSize: 13, color: Theme.of(context) .textTheme .headline4 ?.color, ), - scrollAxis: Axis.horizontal, - crossAxisAlignment: CrossAxisAlignment.start, - blankSpace: 60.0, - velocity: 30.0, - startAfter: const Duration(seconds: 2), - pauseAfterRound: const Duration(seconds: 2), - accelerationDuration: - const Duration(seconds: 1), - accelerationCurve: Curves.linear, - decelerationDuration: - const Duration(milliseconds: 500), - decelerationCurve: Curves.easeOut, - fadingEdgeStartFraction: 0.15, - fadingEdgeEndFraction: 0.15, ) : Text( description!, diff --git a/lib/components/Shared/SpotubeWidgets.dart b/lib/components/Shared/SpotubeWidgets.dart new file mode 100644 index 00000000..fe9d11c2 --- /dev/null +++ b/lib/components/Shared/SpotubeWidgets.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:marquee/marquee.dart'; + +class SpotubeMarqueeText extends StatelessWidget { + const SpotubeMarqueeText( + {Key? key, required this.text, required this.textStyle}) + : super(key: key); + final TextStyle textStyle; + final String text; + + @override + Widget build(BuildContext context) { + return Marquee( + text: text, + style: textStyle, + scrollAxis: Axis.horizontal, + crossAxisAlignment: CrossAxisAlignment.start, + blankSpace: 60.0, + velocity: 30.0, + startAfter: const Duration(seconds: 2), + pauseAfterRound: const Duration(seconds: 2), + accelerationDuration: const Duration(seconds: 1), + accelerationCurve: Curves.linear, + decelerationDuration: const Duration(milliseconds: 500), + decelerationCurve: Curves.easeOut, + fadingEdgeStartFraction: 0.15, + fadingEdgeEndFraction: 0.15, + ); + } +}