mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-30 13:19:44 +02:00
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.
88 lines
2.4 KiB
Dart
88 lines
2.4 KiB
Dart
import 'dart:io';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:spotiflac_android/l10n/l10n.dart';
|
|
import 'package:spotiflac_android/providers/user_profile_provider.dart';
|
|
import 'package:spotiflac_android/services/shell_navigation_service.dart';
|
|
|
|
class ProfileAvatar extends StatelessWidget {
|
|
const ProfileAvatar({
|
|
super.key,
|
|
this.name = '',
|
|
this.photoPath,
|
|
this.photo,
|
|
this.size = 40,
|
|
});
|
|
|
|
final String name;
|
|
final String? photoPath;
|
|
final Uint8List? photo;
|
|
final double size;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final scheme = Theme.of(context).colorScheme;
|
|
final fallback = ColoredBox(
|
|
color: scheme.primaryContainer,
|
|
child: Center(
|
|
child: name.trim().isEmpty
|
|
? Icon(
|
|
Icons.person,
|
|
size: size * 0.55,
|
|
color: scheme.onPrimaryContainer,
|
|
)
|
|
: Text(
|
|
name.trim().characters.first.toUpperCase(),
|
|
style: TextStyle(
|
|
fontSize: size * 0.42,
|
|
fontWeight: FontWeight.w600,
|
|
color: scheme.onPrimaryContainer,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
return ExcludeSemantics(
|
|
child: ClipOval(
|
|
child: SizedBox.square(
|
|
dimension: size,
|
|
child: photo != null
|
|
? Image.memory(
|
|
photo!,
|
|
fit: BoxFit.cover,
|
|
errorBuilder: (_, _, _) => fallback,
|
|
)
|
|
: photoPath != null
|
|
? Image.file(
|
|
File(photoPath!),
|
|
fit: BoxFit.cover,
|
|
cacheWidth: (size * MediaQuery.devicePixelRatioOf(context))
|
|
.ceil(),
|
|
errorBuilder: (_, _, _) => fallback,
|
|
)
|
|
: fallback,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HomeProfileButton extends ConsumerWidget {
|
|
const HomeProfileButton({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final profile = ref.watch(userProfileProvider).value;
|
|
return IconButton(
|
|
tooltip: context.l10n.settingsTitle,
|
|
onPressed: () => ShellNavigationService.requestTab(ShellTab.settings),
|
|
icon: ProfileAvatar(
|
|
name: profile?.name ?? '',
|
|
photoPath: profile?.photoPath,
|
|
size: 34,
|
|
),
|
|
);
|
|
}
|
|
}
|