1
0
forked from firka/firka

added pfp for homescreen

This commit is contained in:
2025-09-15 23:26:32 +02:00
committed by Armand
parent ae06a61b05
commit 6c64ac4a35
6 changed files with 36 additions and 5 deletions

View File

@@ -19,4 +19,5 @@ Future<void> pickProfilePicture(
await File(p.join(dataDir.path, "profile.webp")).writeAsBytes(bytes);
data.profilePicture = bytes;
data.profilePictureUpdateNotifier.update();
}

View File

@@ -73,6 +73,7 @@ class AppInitialization {
Uint8List? profilePicture;
SettingsStore settings;
UpdateNotifier settingsUpdateNotifier = UpdateNotifier();
UpdateNotifier profilePictureUpdateNotifier = UpdateNotifier();
AppLocalizations l10n;
AppInitialization({

View File

@@ -251,6 +251,10 @@ class _HomeScreenState extends FirkaState<HomeScreen> {
widget.data.settingsUpdateNotifier.addListener(settingsUpdateListener);
widget.data.profilePictureUpdateNotifier.addListener(() {
if (mounted) setState(() {});
});
prefetch();
_preloadImages();
}
@@ -533,10 +537,14 @@ class _HomeScreenState extends FirkaState<HomeScreen> {
showExtrasBottomSheet(context, widget.data);
},
false,
Majesticon.globeEarthLine,
widget.data.profilePicture != null
? widget.data.profilePicture!
: Majesticon.menuLine,
widget.data.l10n.other,
appStyle.colors.secondary,
appStyle.colors.textPrimary,
isProfilePicture:
widget.data.profilePicture != null,
),
],
),
@@ -576,12 +584,19 @@ class _HomeScreenState extends FirkaState<HomeScreen> {
@override
void dispose() {
_pageController.dispose();
super.dispose();
widget.data.settingsUpdateNotifier.removeListener(settingsUpdateListener);
widget.data.profilePictureUpdateNotifier
.removeListener(settingsUpdateListener);
widget.data.profilePictureUpdateNotifier.removeListener(() {
if (mounted) setState(() {});
});
_disposed = true;
_fetching = false;
_prefetched = false;
activeToast = ActiveToastType.none;
super.dispose();
}
}

View File

@@ -8,14 +8,15 @@ import '../../widget/firka_icon.dart';
class BottomNavIconWidget extends StatelessWidget {
final void Function() onTap;
final bool active;
final Uint8List icon;
final dynamic icon;
final String text;
final Color iconColor;
final Color textColor;
final bool isProfilePicture;
const BottomNavIconWidget(this.onTap, this.active, this.icon, this.text,
this.iconColor, this.textColor,
{super.key});
{this.isProfilePicture = false, super.key});
@override
Widget build(BuildContext context) {
@@ -30,7 +31,20 @@ class BottomNavIconWidget extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FirkaIconWidget(FirkaIconType.majesticons, icon,
if (isProfilePicture && icon != null)
Container(
width: 24,
height: 24,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: MemoryImage(icon as Uint8List),
fit: BoxFit.cover,
),
),
)
else
FirkaIconWidget(FirkaIconType.majesticons, icon as Uint8List,
color: iconColor, size: 24)
.build(context),
const SizedBox(height: 4),