Shared Components In Xamarin Forms

Xamarin has several cross-platform libraries available for you to use that we have  unified API for accessing platform specific features from iOS Windows Phone and Android .These are all open source and available through github which you can then use or modify however you like.

There are several components that xamarin supports. The first is Xamarin social which provides some social networking capabilities to your application it has support for example for posting to Facebook and Twitter.

We also have Xamarin.Auth which is used for OAuth. It’s support is to securely connect to web services. And then we have the Xamarin.Mobile component which has location camera and photo access .

As an example here we have some code to take a picture using Xamarin.Mobile this code works on iOS Android and Windows apps .The media picker that you see here provides access to the photo as a file or as a streams . So then you can load it into whatever the platform specific representation of an image might be. Now you could of course write this code using platform-specific api's but then you have to write a three separate times.And in fact you might still choose to use the native API .If you need some special capability that's unique to the platform but more often than not you just want to take a photo.

Another area to look at is the dotnet foundation this is an open source consortium of Microsoft. And Microsoft  partners that has a ton of open source dot net code that you can use.

Another great place to look is a github. Xamarin maintains a list of open source plugins github/xamarin/plugins .These have all been produced by different authors and they're not officially supported by Xamarin. But each provides an abstraction over some specific feature with implementations for each platform . So you can access that feature from shared code. All of these are open source and most of them can be used either in source form or as a binary which you can add using nougat.

 You likely have already used nougat if you've done any Microsoft development but nougat is a package manager for .NET development that supports downloading and installing both binary and source elements in project. There's a large public repository at which you can use to search for available components by name or by functionality. You can also create your own private repositories using a folder network share or even a web URL.

You can add remove and update components directly from your IDE, it's supported in both visual studio and Xamarin studio through the references note on the project.

 It also supports auto package restore automatically which means you don't need to include the nuget packages directly in your source control . And Microsoft is moving towards this as their primary vehicle of code updates and component distribution including frameworks such as and Xamarin.Forms.

Another option for Xamarin specific components is the Xamarin component store this is an older distribution channel that was created before nugget .However there are still a lot of great components here.

It's accessible through the components folder in each of your projects. It supports a commercial pricing model. And Xamarin manages this store so that every component is validated and tested.

 You can use either nugget or the component store and often components are published in both. But generally if that's the case you should prefer nugget as it's fully supported by both Microsoft and the Xamarin tools.

No comments:

Post a Comment

Set Up Android Device for Xamarin Android Development

There are two different options of debugging the xamarin forms and xamarin android application.            Debugging through Real Mob...