From 6c64ac4a354afd100fa3b4d8621618966c49f007 Mon Sep 17 00:00:00 2001 From: zypherift Date: Mon, 15 Sep 2025 23:26:32 +0200 Subject: [PATCH] added pfp for homescreen --- firka/lib/helpers/profile_picture.dart | 1 + firka/lib/main.dart | 1 + .../phone/screens/home/home_bottom_nav.dart | 0 .../ui/phone/screens/home/home_screen.dart | 19 ++++++++++++++++-- .../lib/ui/phone/widgets/bottom_nav_icon.dart | 20 ++++++++++++++++--- .../lib/ui/phone/widgets/home_bottom_nav.dart | 0 6 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 firka/lib/ui/phone/screens/home/home_bottom_nav.dart create mode 100644 firka/lib/ui/phone/widgets/home_bottom_nav.dart diff --git a/firka/lib/helpers/profile_picture.dart b/firka/lib/helpers/profile_picture.dart index ccb0068..a42ab14 100644 --- a/firka/lib/helpers/profile_picture.dart +++ b/firka/lib/helpers/profile_picture.dart @@ -19,4 +19,5 @@ Future pickProfilePicture( await File(p.join(dataDir.path, "profile.webp")).writeAsBytes(bytes); data.profilePicture = bytes; + data.profilePictureUpdateNotifier.update(); } diff --git a/firka/lib/main.dart b/firka/lib/main.dart index 8af5adc..0ad2027 100644 --- a/firka/lib/main.dart +++ b/firka/lib/main.dart @@ -73,6 +73,7 @@ class AppInitialization { Uint8List? profilePicture; SettingsStore settings; UpdateNotifier settingsUpdateNotifier = UpdateNotifier(); + UpdateNotifier profilePictureUpdateNotifier = UpdateNotifier(); AppLocalizations l10n; AppInitialization({ diff --git a/firka/lib/ui/phone/screens/home/home_bottom_nav.dart b/firka/lib/ui/phone/screens/home/home_bottom_nav.dart new file mode 100644 index 0000000..e69de29 diff --git a/firka/lib/ui/phone/screens/home/home_screen.dart b/firka/lib/ui/phone/screens/home/home_screen.dart index d0cd056..e7fb19c 100644 --- a/firka/lib/ui/phone/screens/home/home_screen.dart +++ b/firka/lib/ui/phone/screens/home/home_screen.dart @@ -251,6 +251,10 @@ class _HomeScreenState extends FirkaState { widget.data.settingsUpdateNotifier.addListener(settingsUpdateListener); + widget.data.profilePictureUpdateNotifier.addListener(() { + if (mounted) setState(() {}); + }); + prefetch(); _preloadImages(); } @@ -533,10 +537,14 @@ class _HomeScreenState extends FirkaState { 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 { @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(); } } diff --git a/firka/lib/ui/phone/widgets/bottom_nav_icon.dart b/firka/lib/ui/phone/widgets/bottom_nav_icon.dart index 23dd052..e2d3b19 100644 --- a/firka/lib/ui/phone/widgets/bottom_nav_icon.dart +++ b/firka/lib/ui/phone/widgets/bottom_nav_icon.dart @@ -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), diff --git a/firka/lib/ui/phone/widgets/home_bottom_nav.dart b/firka/lib/ui/phone/widgets/home_bottom_nav.dart new file mode 100644 index 0000000..e69de29