Adding badge to TabbedPage ToolBarItems from shared code - xamarin

How can I add a badge to one of TabbedPage ToolBarItems? I create all my pages and tabs in shared code (forms) and I see no way of doing it there (I can just set name, icon). Probably I'll have to do it specifically for each platform (let's say iOS is enough), but in a way that I can control badge value from shared code- I need the badge to have value of count of list items (list is inside that tab), so I'll need to update it as the list is changing.
Any suggestions? Thanks!

Only things that exists on both iOS and Android platforms are implemented in Xamarin.Forms. And it seems like there are no badges out of the box for Android.
But you still can implement a custom renderer for your TabBarItem which will use the iOS badge and some Android library for this.

Related

How to make Sure Keyboard is not placed over an Entry when it is focused in Xamarin?

I have an Entry which is placed in a ContentView, and this ContentView is placed in a Grid. When this Entry is Focused, the Keyboard is placed over the ContentView preventing the user from seeing the Entry.
I would like to know if there is a way to determine if a View is Visible and if not make sure it is (prevent the Keyboard from being placed over it).
Any thoughts on how I could do this.
I would need this to work on iOS specifically, Android and Windows seem not to have this issue in my use-case.
On Android platform, the official document provides Soft Keyboard Input Mode. Refer to https://learn.microsoft.com/en-us/xamarin/xamarin-forms/platform/android/soft-keyboard-input-mode for details.
On IOS platform, you can query KeyboardOverlap installation in IOS's nuget, and then add KeyboardOverlapRenderer.Init (); in AppDelegate to achieve the effect in IOS.

Can I make a Xamarin.Form app (iOS) support Apple Dynamic Type?

In Apple iOS Settings > Display & Brightness there is the ability to change the size of text for applications that use Dynamic Type.
Is it possible to do this with Xamarin.Forms app (iOS custom rendere maybe). If so can someone give an example of how to do this for something like a TableSection Heading and a Label?
For iOS you need for XF TableView TableViewRenderer with native control of UITableView. More here:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/renderers/
To avoid duplicated answer I will just provide a link
With a custom renderer can I make a TableSection.Title appear in small mixed case?

Difficulty while writing custom renderer for navigation drawer(MasterDetailPage) xamarin.forms

I am using xamarin.forms mvvm light architecture and targeting Android & iOS.
I am currently writing custom renderer for navigation drawer(MasterDetailPage).
I am currently writing custom renderer for Android and i have tried many things.
Currently my MasterDetail Page renders according to OS's default behaviour i.e. in Android master page starts below the app bar but i wanted my master page to popover app bar or start above the app bar like gmail,stack exchange android app etc
use this theme Theme.AppCompat.Light.NoActionBar for the expected behaviour
There exists one already, as of this writing it is out of date though (not targeting Xamarin Forms 2): https://github.com/nativecode-dev/oss-xamarin. Perhaps you can use that?

Is possible to do sliding drawer in xamarin cross platform?

I am working in xamarin pcl project , I am trying to keep sliding drawer in my pcl project but i dont know how to do that .
Are you using Xamarin.Forms?
If not, i would advice to use a framework like MvvmCross (https://github.com/MvvmCross/MvvmCross)
This would enable you to split the actual implementation of the drawer / hamburger menu into the different UI projects like iOS and Android(maybe WP8 too).
Since those platforms all behave differently, for example Android uses Fragments which are replaced inside the activity containing your navigation drawer, you should use a custom presenter to determine where you want the specific platform to navigate to. You can find more information on that topic here: http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html

Custom Navigation with Xamarin.Forms

I’m working on an application for Android and iOS, which requires a certain flexibility for one or two views. That’s why we created & implemented a service that translated a basic list of objects into a user interface for both iOS & Android. But now that Xamarin.Forms is released, we decided to replace our service by the one Xamarin provides. I did succeed in creating the views with Xamarin.Forms, resulting in better looking & smoother running pages. But my problem lies in the navigation of it. Here is a little drawing on what I would like to achieve:
I would like my app to start an activity that starts with a custom fragment. After clicking a button on this fragment, I would like the page I created with the Xamarin.Forms api to be added to my current navigation stack! Once the user is finished with the Xamarin.Forms page, it navigates to a second custom fragment, all that without breaking the navigation cycle. Does anybody have an idea on how I can achieve this?
For the iOS developpers: replace Activity with NavigationController & Fragment with ViewController
Take a look at CarouselPage for Xamarin.Forms' own approach. It doesn't look like that's what you need but you can also look at its source code and maybe make a custom renderer yourself.
You may also want to take a look at MVVM
As for the easier/hackier way you'd want to make a button on each page and when the button is tapped execute Navigation.PushModalAsync(nextPage) - there won't be a "< Back" button any more, you may need to implement that yourself if you need it.
If by your meaning of 'current navigation stack' is for using the native Navigation of each platform, then remember that you don't have to use Xamarin.Forms' Navigation Model and functions such like PushAsync.
If you prefer to do Navigation with code specific to each platform then you can do this the same as normal. Just create your stub pages in each platform specific project and set the Xamarin.Forms content for each page from the shared project.
From each platform specific stub page (Activity / UIView / PhoneApplicationPage) you could then execute an Action<> call setting on the shared Xamarin.Forms page to help with the navigation, or alternatively, hook into a custom-event that is raised from the Xamarin.Forms** page back to the platform specific stub page to allow you to do navigation from there.
Like Sten mentioned there won't be any 'Back' button so you will most likely have to do that yourself.

Resources