diff --git a/lib/components/shared/playbutton_card.dart b/lib/components/shared/playbutton_card.dart index f381e7ced..86c3f0463 100644 --- a/lib/components/shared/playbutton_card.dart +++ b/lib/components/shared/playbutton_card.dart @@ -9,6 +9,15 @@ import 'package:spotube/hooks/use_breakpoint_value.dart'; import 'package:spotube/hooks/use_brightness_value.dart'; import 'package:spotube/utils/platform.dart'; +final htmlTagRegexp = RegExp(r"<[^>]*>", caseSensitive: true); + +String? useDescription(String? description) { + return useMemoized(() { + if (description == null) return null; + return description.replaceAll(htmlTagRegexp, ''); + }, [description]); +} + class PlaybuttonCard extends HookWidget { final void Function()? onTap; final void Function()? onPlaybuttonPressed; @@ -40,19 +49,17 @@ class PlaybuttonCard extends HookWidget { final radius = BorderRadius.circular(15); final double size = useBreakpointValue( - xs: 130, - sm: 130, - md: 150, - others: 170, - ) ?? - 170; + xs: 130, + sm: 130, + md: 150, + others: 170, + ); final end = useBreakpointValue( - xs: 15, - sm: 15, - others: 20, - ) ?? - 20; + xs: 15, + sm: 15, + others: 20, + ); final textsHeight = useState( (textsKey.currentContext?.findRenderObject() as RenderBox?) @@ -61,6 +68,8 @@ class PlaybuttonCard extends HookWidget { 110.00, ); + final cleanDescription = useDescription(description); + useEffect(() { WidgetsBinding.instance.addPostFrameCallback((_) { textsHeight.value = @@ -123,11 +132,11 @@ class PlaybuttonCard extends HookWidget { overflow: TextOverflow.ellipsis, ), ), - if (description != null) + if (cleanDescription != null) Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), child: AutoSizeText( - description!, + cleanDescription, maxLines: 2, style: theme.textTheme.bodySmall?.copyWith( color: diff --git a/lib/components/shared/track_table/track_collection_view/track_collection_heading.dart b/lib/components/shared/track_table/track_collection_view/track_collection_heading.dart index 1aeb9107e..1c6cb4d41 100644 --- a/lib/components/shared/track_table/track_collection_view/track_collection_heading.dart +++ b/lib/components/shared/track_table/track_collection_view/track_collection_heading.dart @@ -9,6 +9,7 @@ import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/components/album/album_card.dart'; import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/shared/playbutton_card.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; @@ -42,6 +43,8 @@ class TrackCollectionHeading extends HookConsumerWidget { Widget build(BuildContext context, ref) { final theme = Theme.of(context); + final cleanDescription = useDescription(description); + return LayoutBuilder( builder: (context, constrains) { return DecoratedBox( @@ -111,13 +114,13 @@ class TrackCollectionHeading extends HookConsumerWidget { fontWeight: FontWeight.normal, ), ), - if (description != null) + if (cleanDescription != null) ConstrainedBox( constraints: BoxConstraints( maxWidth: constrains.mdAndDown ? 400 : 300, ), child: Text( - description!, + cleanDescription, style: const TextStyle(color: Colors.white), maxLines: 2, overflow: TextOverflow.fade, diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index 9e935e493..546e59ffc 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; +import 'package:google_fonts/google_fonts.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:piped_client/piped_client.dart'; import 'package:spotube/collections/env.dart'; @@ -323,7 +324,8 @@ class SettingsPage extends HookConsumerWidget { title: Text(context.l10n.piped_instance), subtitle: Text( - context.l10n.piped_description), + context.l10n.piped_description, + ), value: preferences.pipedInstance, showValueWhenUnfolded: false, options: data @@ -331,9 +333,26 @@ class SettingsPage extends HookConsumerWidget { .map( (e) => DropdownMenuItem( value: e.apiUrl, - child: Text( - "${e.name}\n" - "${e.locations.map(countryCodeToEmoji).join(" ")}", + child: RichText( + text: TextSpan( + children: [ + TextSpan( + text: + "${e.name.trim()}\n", + style: Theme.of(context) + .textTheme + .labelLarge, + ), + TextSpan( + text: e.locations + .map( + countryCodeToEmoji) + .join(""), + style: GoogleFonts + .notoColorEmoji(), + ), + ], + ), ), ), ) diff --git a/lib/provider/user_preferences_provider.dart b/lib/provider/user_preferences_provider.dart index fcd951098..cbaaa197d 100644 --- a/lib/provider/user_preferences_provider.dart +++ b/lib/provider/user_preferences_provider.dart @@ -77,13 +77,13 @@ class UserPreferences extends PersistedChangeNotifier { this.checkUpdate = true, this.audioQuality = AudioQuality.high, this.downloadLocation = "", - this.closeBehavior = CloseBehavior.minimizeToTray, + this.closeBehavior = CloseBehavior.close, this.showSystemTrayIcon = true, this.locale = const Locale("system", "system"), this.pipedInstance = "https://pipedapi.kavin.rocks", - this.searchMode = SearchMode.youtube, + this.searchMode = SearchMode.youtubeMusic, this.skipNonMusic = true, - this.youtubeApiType = YoutubeApiType.youtube, + this.youtubeApiType = YoutubeApiType.piped, }) : super() { if (downloadLocation.isEmpty) { _getDefaultDownloadDirectory().then( diff --git a/pubspec.lock b/pubspec.lock index 18afa0fe1..4d7f27e6e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -881,6 +881,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.6" + google_fonts: + dependency: "direct main" + description: + name: google_fonts + sha256: "6b6f10f0ce3c42f6552d1c70d2c28d764cf22bb487f50f66cca31dcd5194f4d6" + url: "https://pub.dev" + source: hosted + version: "4.0.4" gotrue: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c03a58c79..ac2e022cb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -98,6 +98,7 @@ dependencies: disable_battery_optimization: ^1.1.0+1 youtube_explode_dart: ^1.12.4 flutter_displaymode: ^0.6.0 + google_fonts: ^4.0.4 dev_dependencies: build_runner: ^2.3.2