feat(profile): add local profiles with backup and restore

Move Mornye Settings to the Home avatar and keep search above the profile card. Center the metadata artwork and actions, and make artist names clickable in the Material player.
This commit is contained in:
zarzet committed 2026-09-21 17:28:18 +07:00
1 parent 5b519070a3
commit d8d46108bc
19 files changed
+1003 -80

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
import 'dart:io';
import 'dart:typed_data';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:spotiflac_android/services/user_profile_store.dart';
final userProfileStoreProvider = Provider<UserProfileStore>(
(ref) => UserProfileStore(),
);
final userProfileProvider =
AsyncNotifierProvider<UserProfileNotifier, UserProfile>(
UserProfileNotifier.new,
);
class UserProfileNotifier extends AsyncNotifier<UserProfile> {
@override
Future<UserProfile> build() => ref.watch(userProfileStoreProvider).read();
Future<void> restoreFromBackup(UserProfile profile) async {
final path = profile.photoPath;
final photo = path == null
? null
: await prepareProfilePhoto(await File(path).readAsBytes());
await save(name: profile.name, photo: photo, removePhoto: photo == null);
}
Future<void> save({
required String name,
Uint8List? photo,
bool removePhoto = false,
}) async {
await future;
final profile = await ref
.read(userProfileStoreProvider)
.save(name: name, photo: photo, removePhoto: removePhoto);
state = AsyncData(profile);
}
}