[PR #1735] [MERGED] Fix iOS Avatar color update toolbar item #51299

Closed
opened 2026-05-01 14:59:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/bitwarden/android/pull/1735
Author: @fedemkr
Created: 1/28/2022
Status: Merged
Merged: 1/28/2022
Merged by: @fedemkr

Base: accountswitchingHead: fix-avatar-color-accountswitch


📝 Commits (2)

  • c034f04 Fix avatar color update toolbar item issue on iOS for account switching
  • e55ebae Merge branch 'accountswitching' into fix-avatar-color-accountswitch

📊 Changes

7 files changed (+90 additions, -23 deletions)

View changed files

📝 src/App/Controls/AvatarImageSource.cs (+0 -5)
📝 src/App/Controls/ExtendedToolbarItem.cs (+23 -1)
📝 src/App/Pages/Accounts/HomePage.xaml.cs (+3 -0)
📝 src/App/Pages/Accounts/LockPage.xaml.cs (+16 -3)
📝 src/App/Pages/Accounts/LoginPage.xaml.cs (+9 -0)
📝 src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs (+2 -0)
📝 src/iOS.Core/Renderers/CustomNavigationRenderer.cs (+37 -14)

📄 Description

Type of change

  • Bug fix
  • New feature development
  • Tech debt (refactoring, code cleanup, dependency upgrades, etc)
  • Build/deploy pipeline (DevOps)
  • Other

Objective

Fix update on the toolbar item for the avatar icon color

Code changes

  • CustomNavigationRenderer: Here we have some HACKS because of how inaccessible is the NavigationRenderer of Xamarin Forms for extension. So here are a couple of hacks in order to make this work. Essentially we subscribe to the PropertyChanged of the ToolbarItem and update the rendering mode to display the icon accordingly (by default UIBarButtonItem uses AlwaysTemplate and we need to change that to AlwaysOriginal to display the icon successfully)
    The problem with this is correctly subscribing/unsubscribing the event, and given that we don't have access to all places where the NavigationRenderer disposes ToolbarItem objects, then I added some helper methods on the ExtendedToolbarItem to make this possible from the pages lifecycle.
  • ExtendedToolbarItem.cs: Added helper methods to help subscribing/unsubscribing for the hack on the CustomNavigationRenderer using the lifecycle methods of each page OnAppearing/OnDisappearing
  • ....Page.xaml.cs: Called helper methods to indirectly subscribe/unsubscribe the hack.

NavigationRenderer -> UpdateToolbarItems
ToolbarItemExtensions

Testing requirements

The icon for the account avatar should be updated accordingly depending on the account that is being shown.

Before you submit

  • I have added unit tests where it makes sense to do so (encouraged but not required)
  • This change requires a documentation update (notify the documentation team)
  • This change has particular deployment requirements (notify the DevOps team)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/bitwarden/android/pull/1735 **Author:** [@fedemkr](https://github.com/fedemkr) **Created:** 1/28/2022 **Status:** ✅ Merged **Merged:** 1/28/2022 **Merged by:** [@fedemkr](https://github.com/fedemkr) **Base:** `accountswitching` ← **Head:** `fix-avatar-color-accountswitch` --- ### 📝 Commits (2) - [`c034f04`](https://github.com/bitwarden/android/commit/c034f04ce031fc45e3595d8a1ff6a944a924dc94) Fix avatar color update toolbar item issue on iOS for account switching - [`e55ebae`](https://github.com/bitwarden/android/commit/e55ebaeb4ed076065d9a80a21f5882d74871ae0f) Merge branch 'accountswitching' into fix-avatar-color-accountswitch ### 📊 Changes **7 files changed** (+90 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `src/App/Controls/AvatarImageSource.cs` (+0 -5) 📝 `src/App/Controls/ExtendedToolbarItem.cs` (+23 -1) 📝 `src/App/Pages/Accounts/HomePage.xaml.cs` (+3 -0) 📝 `src/App/Pages/Accounts/LockPage.xaml.cs` (+16 -3) 📝 `src/App/Pages/Accounts/LoginPage.xaml.cs` (+9 -0) 📝 `src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs` (+2 -0) 📝 `src/iOS.Core/Renderers/CustomNavigationRenderer.cs` (+37 -14) </details> ### 📄 Description ## Type of change - [X] Bug fix - [X] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective <!--Describe what the purpose of this PR is. For example: what bug you're fixing or what new feature you're adding--> Fix update on the toolbar item for the avatar icon color ## Code changes <!--Explain the changes you've made to each file or major component. This should help the reviewer understand your changes--> <!--Also refer to any related changes or PRs in other repositories--> * **CustomNavigationRenderer:** Here we have some **HACKS** because of how inaccessible is the `NavigationRenderer` of Xamarin Forms for extension. So here are a couple of hacks in order to make this work. Essentially we subscribe to the `PropertyChanged` of the `ToolbarItem` and update the rendering mode to display the icon accordingly (by default `UIBarButtonItem` uses `AlwaysTemplate` and we need to change that to `AlwaysOriginal` to display the icon successfully) The problem with this is correctly subscribing/unsubscribing the event, and given that we don't have access to all places where the `NavigationRenderer` disposes ToolbarItem objects, then I added some helper methods on the `ExtendedToolbarItem` to make this possible from the pages lifecycle. * **ExtendedToolbarItem.cs:** Added helper methods to help subscribing/unsubscribing for the hack on the `CustomNavigationRenderer` using the lifecycle methods of each page `OnAppearing/OnDisappearing` * **....Page.xaml.cs:** Called helper methods to indirectly subscribe/unsubscribe the hack. ### Xamarin Forms code links: [NavigationRenderer -> UpdateToolbarItems](https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs#L1407) [ToolbarItemExtensions](https://github.com/xamarin/Xamarin.Forms/blob/8f765bd87a2968bef9c86122d88c9c47be9196d2/Xamarin.Forms.Platform.iOS/Extensions/ToolbarItemExtensions.cs) ## Testing requirements <!--What functionality requires testing by QA? This includes testing new behavior and regression testing--> The icon for the account avatar should be updated accordingly depending on the account that is being shown. ## Before you submit - [ ] I have added **unit tests** where it makes sense to do so (encouraged but not required) - [ ] This change requires a **documentation update** (notify the documentation team) - [ ] This change has particular **deployment requirements** (notify the DevOps team) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-01 14:59:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/android#51299