Book Image

Mastering Xamarin UI Development - Second Edition

By : Steven F. Daniel
Book Image

Mastering Xamarin UI Development - Second Edition

By: Steven F. Daniel

Overview of this book

This book will provide you with the knowledge and practical skills that are required to develop real-world Xamarin and Xamarin.Forms applications. You’ll learn how to create native Android app that will interact with the device camera and photo gallery, and then create a native iOS sliding tiles game. You will learn how to implement complex UI layouts and create customizable control elements based on the platform, using XAML and C# 7 code to interact with control elements within your XAML ContentPages. You’ll learn how to add location-based features by to your apps by creating a LocationService class and using the Xam.Plugin.Geolocator cross-platform library, that will be used to obtain the current device location. Next, you’ll learn how to work with and implement animations and visual effects within your UI using the PlatformEffects API, using C# code. At the end of this book, you’ll learn how to integrate Microsoft Azure App Services and use the Twitter APIs within your app. You will work with the Razor Templating Engine to build a book library HTML5 solution that will use a SQLite.net library to store, update, retrieve, and delete information within a local SQLite database. Finally, you will learn how to write unit tests using the NUnit and UITest frameworks.
Table of Contents (15 chapters)

Creating and implementing the LocationService class

In this section, we will take a look at how to create the LocationService class that will inherit from our ILocationService interface, and implement the underlying instance methods that we declared within our interface class. We did this to help us retrieve and continually listen for changes within the GPS location coordinates which will be used by our ViewModels and ContentPages (Views).

Let's start by creating the LocationService class for our TrackMyWalks app by performing the following steps:

  1. Ensure that the TrackMyWalks solution is open within the Visual Studio for Mac IDE.
  2. Next, right-click on the Services folder and choose Add|New File... from the pop-up menu.
  3. Then, choose the Empty Class option under the General section and enter LocationService for the name of the class to be created, as shown in the following...