mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix: flags not showing up, html in descriptions
This commit is contained in:
parent
d8cf2ae131
commit
5a563ef428
@ -9,6 +9,15 @@ import 'package:spotube/hooks/use_breakpoint_value.dart';
|
|||||||
import 'package:spotube/hooks/use_brightness_value.dart';
|
import 'package:spotube/hooks/use_brightness_value.dart';
|
||||||
import 'package:spotube/utils/platform.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 {
|
class PlaybuttonCard extends HookWidget {
|
||||||
final void Function()? onTap;
|
final void Function()? onTap;
|
||||||
final void Function()? onPlaybuttonPressed;
|
final void Function()? onPlaybuttonPressed;
|
||||||
@ -40,19 +49,17 @@ class PlaybuttonCard extends HookWidget {
|
|||||||
final radius = BorderRadius.circular(15);
|
final radius = BorderRadius.circular(15);
|
||||||
|
|
||||||
final double size = useBreakpointValue<double>(
|
final double size = useBreakpointValue<double>(
|
||||||
xs: 130,
|
xs: 130,
|
||||||
sm: 130,
|
sm: 130,
|
||||||
md: 150,
|
md: 150,
|
||||||
others: 170,
|
others: 170,
|
||||||
) ??
|
);
|
||||||
170;
|
|
||||||
|
|
||||||
final end = useBreakpointValue<double>(
|
final end = useBreakpointValue<double>(
|
||||||
xs: 15,
|
xs: 15,
|
||||||
sm: 15,
|
sm: 15,
|
||||||
others: 20,
|
others: 20,
|
||||||
) ??
|
);
|
||||||
20;
|
|
||||||
|
|
||||||
final textsHeight = useState(
|
final textsHeight = useState(
|
||||||
(textsKey.currentContext?.findRenderObject() as RenderBox?)
|
(textsKey.currentContext?.findRenderObject() as RenderBox?)
|
||||||
@ -61,6 +68,8 @@ class PlaybuttonCard extends HookWidget {
|
|||||||
110.00,
|
110.00,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final cleanDescription = useDescription(description);
|
||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
textsHeight.value =
|
textsHeight.value =
|
||||||
@ -123,11 +132,11 @@ class PlaybuttonCard extends HookWidget {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (description != null)
|
if (cleanDescription != null)
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||||
child: AutoSizeText(
|
child: AutoSizeText(
|
||||||
description!,
|
cleanDescription,
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
style: theme.textTheme.bodySmall?.copyWith(
|
style: theme.textTheme.bodySmall?.copyWith(
|
||||||
color:
|
color:
|
||||||
|
@ -9,6 +9,7 @@ import 'package:spotube/collections/assets.gen.dart';
|
|||||||
import 'package:spotube/collections/spotube_icons.dart';
|
import 'package:spotube/collections/spotube_icons.dart';
|
||||||
import 'package:spotube/components/album/album_card.dart';
|
import 'package:spotube/components/album/album_card.dart';
|
||||||
import 'package:spotube/components/shared/image/universal_image.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/constrains.dart';
|
||||||
import 'package:spotube/extensions/context.dart';
|
import 'package:spotube/extensions/context.dart';
|
||||||
|
|
||||||
@ -42,6 +43,8 @@ class TrackCollectionHeading<T> extends HookConsumerWidget {
|
|||||||
Widget build(BuildContext context, ref) {
|
Widget build(BuildContext context, ref) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
|
|
||||||
|
final cleanDescription = useDescription(description);
|
||||||
|
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constrains) {
|
builder: (context, constrains) {
|
||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
@ -111,13 +114,13 @@ class TrackCollectionHeading<T> extends HookConsumerWidget {
|
|||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (description != null)
|
if (cleanDescription != null)
|
||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: constrains.mdAndDown ? 400 : 300,
|
maxWidth: constrains.mdAndDown ? 400 : 300,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
description!,
|
cleanDescription,
|
||||||
style: const TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
overflow: TextOverflow.fade,
|
overflow: TextOverflow.fade,
|
||||||
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
|
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:piped_client/piped_client.dart';
|
import 'package:piped_client/piped_client.dart';
|
||||||
import 'package:spotube/collections/env.dart';
|
import 'package:spotube/collections/env.dart';
|
||||||
@ -323,7 +324,8 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
title:
|
title:
|
||||||
Text(context.l10n.piped_instance),
|
Text(context.l10n.piped_instance),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
context.l10n.piped_description),
|
context.l10n.piped_description,
|
||||||
|
),
|
||||||
value: preferences.pipedInstance,
|
value: preferences.pipedInstance,
|
||||||
showValueWhenUnfolded: false,
|
showValueWhenUnfolded: false,
|
||||||
options: data
|
options: data
|
||||||
@ -331,9 +333,26 @@ class SettingsPage extends HookConsumerWidget {
|
|||||||
.map(
|
.map(
|
||||||
(e) => DropdownMenuItem(
|
(e) => DropdownMenuItem(
|
||||||
value: e.apiUrl,
|
value: e.apiUrl,
|
||||||
child: Text(
|
child: RichText(
|
||||||
"${e.name}\n"
|
text: TextSpan(
|
||||||
"${e.locations.map(countryCodeToEmoji).join(" ")}",
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text:
|
||||||
|
"${e.name.trim()}\n",
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelLarge,
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
text: e.locations
|
||||||
|
.map(
|
||||||
|
countryCodeToEmoji)
|
||||||
|
.join(""),
|
||||||
|
style: GoogleFonts
|
||||||
|
.notoColorEmoji(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -77,13 +77,13 @@ class UserPreferences extends PersistedChangeNotifier {
|
|||||||
this.checkUpdate = true,
|
this.checkUpdate = true,
|
||||||
this.audioQuality = AudioQuality.high,
|
this.audioQuality = AudioQuality.high,
|
||||||
this.downloadLocation = "",
|
this.downloadLocation = "",
|
||||||
this.closeBehavior = CloseBehavior.minimizeToTray,
|
this.closeBehavior = CloseBehavior.close,
|
||||||
this.showSystemTrayIcon = true,
|
this.showSystemTrayIcon = true,
|
||||||
this.locale = const Locale("system", "system"),
|
this.locale = const Locale("system", "system"),
|
||||||
this.pipedInstance = "https://pipedapi.kavin.rocks",
|
this.pipedInstance = "https://pipedapi.kavin.rocks",
|
||||||
this.searchMode = SearchMode.youtube,
|
this.searchMode = SearchMode.youtubeMusic,
|
||||||
this.skipNonMusic = true,
|
this.skipNonMusic = true,
|
||||||
this.youtubeApiType = YoutubeApiType.youtube,
|
this.youtubeApiType = YoutubeApiType.piped,
|
||||||
}) : super() {
|
}) : super() {
|
||||||
if (downloadLocation.isEmpty) {
|
if (downloadLocation.isEmpty) {
|
||||||
_getDefaultDownloadDirectory().then(
|
_getDefaultDownloadDirectory().then(
|
||||||
|
@ -881,6 +881,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.6"
|
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:
|
gotrue:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -98,6 +98,7 @@ dependencies:
|
|||||||
disable_battery_optimization: ^1.1.0+1
|
disable_battery_optimization: ^1.1.0+1
|
||||||
youtube_explode_dart: ^1.12.4
|
youtube_explode_dart: ^1.12.4
|
||||||
flutter_displaymode: ^0.6.0
|
flutter_displaymode: ^0.6.0
|
||||||
|
google_fonts: ^4.0.4
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
build_runner: ^2.3.2
|
build_runner: ^2.3.2
|
||||||
|
Loading…
Reference in New Issue
Block a user