-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Enhancement] Left-aligned ToolbarItems on Android & iOS #1719
Comments
Hi, i would like to see if i can deal with this issue |
@samhouts will this allow both left and right toolbar items? we need the ability to have both. below is exactly what forms needs to allow |
@dhaligas Yes, that's the idea. |
@netapau you still working on this? |
@jassmith
For the first time I look in this code I can not advance anymore. |
The answers are no and no to both, though the second would be ideally a yes for an optimal implementation. I have moved this back to the available for implementation column |
@jassmith i need this .. do I have to modify the NavigationPageRenderer (Android) to make this work? |
@dhaligas the implementation of this for iOS is straightforward and similar on Android
and the start list would basically be a duplicate of that line of code, but instead calling This is such an easy issue it will surely be picked up by the team or myself very soon now that its in the F100 list which gives us approval to do it. |
@jassmith the iOS one seems simple and I am able to do it without modifying the core. But android seems like you have to get into the internals of NavigationPageRenderer to support this |
For Android it's basically the same as @jassmith describes, but then here I guess?
edit: I have taken a quick look at it, but I can't see any way to achieve this on Android? Besides building a custom toolbar, but I figure that will open up some kind of Pandora's box with current (backwards) compatibility |
@jfversluis on android there is the Toolbar.NavigationIcon that can be used to set the Left Toolbar Item but that is buried in the NavigationPageRenderer. This only allows one item which is fine for left Left Toolbar Items the majority of the time |
@dhaligas I didn't really look into it, but NavigationIcon sounds like it can hold just one? |
Upon further review I was too hasty with my statements about Android. The API will need to be modified to only allow one icon for Android and to make it clear its an override for the back button. |
@jassmith I have to do this now. is there a way to hack this in on Android with a renderer or effect? |
If there is a custom renderer we can write to do this, it would be optimal. i am in desperate need for it. |
Is it possible to add options to set the Toolbaricon? Left, Middle, Right ? It would be more easy to set an image icon of a company in the center of the Navbar or align it to the left Controlbutton (Back or Hamburger) |
their is a custom renderer for ContentPage in order to move toolbar items to the left [iOS only], when the app first lunch, every thing is fine, but when navigate to other tab, the items on left duplicate on the right, and till now I can't fix this issue, and I think the problem in these lines Xamarin.Forms/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs Lines 172 to 176 in 8ed7a28
I don't know exactly but please keep this in mind when implementing this feature |
Learnings from the shell branch are that this will 100% not work as specced. We need to take the API back to the drawing board here and make sure it reflects the actual capabilities of the platforms. |
any update for this enhancement? |
Would love it if this can be made to happen, or at least if anyone has the CustomRenderer code for Android. I've got pages where I need Save and Cancel buttons, and if the user, clicks Cancel, I need to show a confirmation that they really want to leave and lose unsaved data... |
@Osmosis311 did you try TitleView? |
they are difference things @Shaboo |
yea I think these different things, toolbar position is very important to release it as soon as possible |
Any Idea if this will be implemented? |
Any luck? |
Pls implementation! |
1 similar comment
Pls implementation! |
I think UWP should also be supported: https://www.rudyhuyn.com/blog/2015/12/23/display-an-appbarbutton-on-the-left-side-of-a-commandbar/ |
I'm just in the need of it again :( Any updates on this one? |
Sorry to hear that @winterdouglas! I'm afraid not. Although the initial spec still states this as easy, I don't think it is. From what I remember looking into it, iOS for example only allows 1 button on the left. And from Jasons comments it looks like it's not that easy on Android as well. Maybe the APIs changed meanwhile, that would be awesome, I'm happy to be proven wrong in this case :) That would mean, in order to achieve this, we would have to create a fully customized Navigation bar/page ourselves which is a huge investment to get right. One alternative could be to use the TitleView as suggested. Or if you have any other suggestions to make this happen, I'm all ears. |
it's works for me [assembly: ExportRenderer(typeof(CustomBackButtonPage), typeof(CustomContentPageRenderer))]
|
Hey everyone, thanks for all the input and effort here. This won't be able to make it into Xamarin.Forms anymore unfortunately. If it's something you're still interested in, make sure to see if it's on the roadmap for .NET MAUI or open an issue with a feature request and add all the details. Thanks! |
@jfversluis Given up on the native toolbar renderer completely. It's only useful for basic scenarios. On the last 4 commercials apps I've been involved with, we rolled out own toolbar as it was the way we could realize the designs. Allowing drawing like Flutter is the way to go. |
Thanks @mackayn! That seems definitely be the thing holding us back here and something we're keeping in mind. |
Rationale
ToolbarItem
s currently display aligned to the right on all platforms. There is no way to display aToolbarItem
on the left. This is useful for many designs, including completely customizing the back button on aNavigationPage
.Implementation
Add new platform specific properties to
ToolbarItem
:Renderers will need to be updated accordingly.
Expected Result
Android
ToolbarItemPosition
will default toEnd
.ToolbarItemPosition
is set toStart
,ToolbarItem
will be displayed on the left side of the screen when in LTR mode and on the right side of the screen when in RTL mode.iOS
See Android
UWP
No change. This is not a supported paradigm for UWP, so it will not be affected.
Implications for CSS
None
Backward Compatibility
Since we are adding new properties, there should be no compatibility problems as long as:
ToolbarItem
's Position defaults to the right side of the screen, as is the expected behavior now.Third party renderers will need to be updated to ensure that this functionality is officially supported.
Difficulty : Easy
See https://forums.xamarin.com/discussion/85097/left-toolbaritems-in-xamarin-forms for original proposal.
The text was updated successfully, but these errors were encountered: