mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
application about menu update
usePackageInfo hook getLyrics bug fixes
This commit is contained in:
parent
94cec4290c
commit
f8a5ca4beb
@ -79,8 +79,18 @@ class SyncedLyrics extends HookConsumerWidget {
|
||||
},
|
||||
),
|
||||
],
|
||||
content: const Text(
|
||||
"The found lyrics might not be properly synced. Do you want to default to static (genius.com) lyrics?"),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const [
|
||||
Text(
|
||||
"The found lyrics might not be properly synced. Do you want to default to static (genius.com) lyrics?",
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
"Hint: Wait for a moment to see if the lyric actually sync. Sometimes it may sync.",
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -8,6 +8,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:spotube/components/Settings/SettingsHotkeyTile.dart';
|
||||
import 'package:spotube/components/Shared/Hyperlink.dart';
|
||||
import 'package:spotube/components/Shared/PageWindowTitleBar.dart';
|
||||
import 'package:spotube/hooks/usePackageInfo.dart';
|
||||
import 'package:spotube/models/LocalStorageKeys.dart';
|
||||
import 'package:spotube/models/SpotifyMarkets.dart';
|
||||
import 'package:spotube/provider/Auth.dart';
|
||||
@ -33,6 +34,11 @@ class Settings extends HookConsumerWidget {
|
||||
preferences.setYtSearchFormat(ytSearchFormatController.value.text);
|
||||
});
|
||||
|
||||
final packageInfo = usePackageInfo(
|
||||
appName: 'Spotube',
|
||||
packageName: 'spotube',
|
||||
);
|
||||
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: PageWindowTitleBar(
|
||||
@ -252,7 +258,9 @@ class Settings extends HookConsumerWidget {
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 40),
|
||||
const Text("Spotube v2.0.0"),
|
||||
Text(
|
||||
"Spotube v${packageInfo.version}",
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
@ -130,7 +130,7 @@ Future<String?> getLyrics(
|
||||
if (results == null) return null;
|
||||
final worthyOne = results
|
||||
.map((result) {
|
||||
final gTitle = (result["title"] as String).toLowerCase();
|
||||
final gTitle = (result["full_title"] as String).toLowerCase();
|
||||
int points = 0;
|
||||
final hasTitle = gTitle.contains(title.toLowerCase());
|
||||
final hasAllArtists =
|
||||
@ -144,7 +144,7 @@ Future<String?> getLyrics(
|
||||
.sorted(
|
||||
(a, b) => ((b["points"] as int).compareTo(a["points"] as int)),
|
||||
)
|
||||
.first;
|
||||
.first["result"];
|
||||
|
||||
String? lyrics = await extractLyrics(Uri.parse(worthyOne["url"]));
|
||||
return lyrics;
|
||||
|
79
lib/hooks/usePackageInfo.dart
Normal file
79
lib/hooks/usePackageInfo.dart
Normal file
@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
PackageInfo usePackageInfo<PageKeyType, ItemType>({
|
||||
/// The app name. `CFBundleDisplayName` on iOS, `application/label` on Android.
|
||||
String appName = 'Unknown',
|
||||
|
||||
/// The package name. `bundleIdentifier` on iOS, `getPackageName` on Android.
|
||||
String packageName = 'Unknown',
|
||||
|
||||
/// The package version. `CFBundleShortVersionString` on iOS, `versionName` on Android.
|
||||
String version = 'Unknown',
|
||||
|
||||
/// The build number. `CFBundleVersion` on iOS, `versionCode` on Android.
|
||||
String buildNumber = 'Unknown',
|
||||
|
||||
/// The build signature. Empty string on iOS, signing key signature (hex) on Android.
|
||||
String buildSignature = '',
|
||||
List<Object?>? keys,
|
||||
}) {
|
||||
return use(
|
||||
_PackageInfoHook(
|
||||
appName: appName,
|
||||
buildNumber: buildNumber,
|
||||
packageName: packageName,
|
||||
version: version,
|
||||
buildSignature: buildSignature,
|
||||
keys: keys,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _PackageInfoHook<PageKeyType, ItemType> extends Hook<PackageInfo> {
|
||||
final String appName;
|
||||
final String packageName;
|
||||
final String version;
|
||||
final String buildNumber;
|
||||
final String buildSignature;
|
||||
|
||||
const _PackageInfoHook({
|
||||
required this.appName,
|
||||
required this.packageName,
|
||||
required this.version,
|
||||
required this.buildNumber,
|
||||
this.buildSignature = '',
|
||||
List<Object?>? keys,
|
||||
}) : super(keys: keys);
|
||||
|
||||
@override
|
||||
HookState<PackageInfo, Hook<PackageInfo>> createState() =>
|
||||
_PackageInfoHookState<PageKeyType, ItemType>();
|
||||
}
|
||||
|
||||
class _PackageInfoHookState<PageKeyType, ItemType>
|
||||
extends HookState<PackageInfo, _PackageInfoHook<PageKeyType, ItemType>> {
|
||||
late PackageInfo info = PackageInfo(
|
||||
appName: hook.appName,
|
||||
buildNumber: hook.buildNumber,
|
||||
packageName: hook.packageName,
|
||||
version: hook.version,
|
||||
);
|
||||
|
||||
@override
|
||||
void initHook() {
|
||||
PackageInfo.fromPlatform().then((packageInfo) {
|
||||
setState(() {
|
||||
info = packageInfo;
|
||||
});
|
||||
});
|
||||
super.initHook();
|
||||
}
|
||||
|
||||
@override
|
||||
PackageInfo build(BuildContext context) => info;
|
||||
|
||||
@override
|
||||
String get debugLabel => 'usePagingController';
|
||||
}
|
42
pubspec.lock
42
pubspec.lock
@ -450,6 +450,48 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
package_info_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: package_info_plus
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.2"
|
||||
package_info_plus_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
package_info_plus_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
package_info_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
package_info_plus_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
package_info_plus_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_info_plus_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
palette_generator:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -60,6 +60,7 @@ dependencies:
|
||||
permission_handler: ^9.2.0
|
||||
marquee: ^2.2.1
|
||||
scroll_to_index: ^2.1.1
|
||||
package_info_plus: ^1.4.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
Loading…
Reference in New Issue
Block a user