Book Image

Mastering Xamarin.Forms - Third Edition

By : Ed Snider
Book Image

Mastering Xamarin.Forms - Third Edition

By: Ed Snider

Overview of this book

Discover how to extend and build upon the components of the most recent version of Xamarin.Forms to develop an effective, robust mobile app architecture. This new edition features Xamarin.Forms 4 updates, including CollectionView and RefreshView, new coverage of client-side validation, and updates on how to implement user authentication. Mastering Xamarin.Forms, Third Edition is one of the few Xamarin books structured around the development of a simple app from start to finish, beginning with a basic Xamarin.Forms app and going step by step through several advanced topics to create a solution architecture rich with the benefits of good design patterns and best practices. This book introduces a core separation between the app's user interface and the app's business logic by applying the MVVM pattern and data binding, and then focuses on building a layer of plugin-like services that handle platform-specific utilities such as navigation and geo-location, as well as how to loosely use these services in the app with inversion of control and dependency injection. You’ll connect the app to a live web-based API and set up offline synchronization before testing the app logic through unit testing. Finally, you will learn how to add monitoring to your Xamarin.Forms projects to track crashes and analytics and gain a proactive edge on quality.
Table of Contents (12 chapters)

What this book covers

Chapter 1, Getting Started, will start off by quickly reviewing the basics of the Xamarin.Forms toolkit. We will then walk through building a simple app with Xamarin.Forms, called TripLog. The TripLog app will serve as the foundation that we build upon throughout the rest of the book by applying new techniques and concepts in each subsequent chapter.

Chapter 2, MVVM and Data Binding, will introduce the Model-View-ViewModel (MVVM) pattern and the benefits of using it in a mobile app architecture. We will then walk through updating the TripLog app with ViewModels that provide data context for the app's pages through data binding. We will then build client-side validation that leverages the MVVM pattern put in place.

Chapter 3, Navigation, will explain how navigation works in Xamarin.Forms and some approaches to navigation related to MVVM. We will build a custom navigation service for the TripLog app that extends the one provided by Xamarin.Forms to provide a navigation model that occurs solely at the ViewModel level, decoupled from the pages themselves.

Chapter 4, Platform-Specific Services and Dependency Injection, will discuss the power of the inversion of control (IoC) and the dependency injection pattern, specific to multi-platform mobile app development. We will discuss the Xamarin.Forms Dependency Service and some of its shortcomings. We will add a third-party dependency injection library to the TripLog app to be used instead of Xamarin.Forms's default Dependency Service. We will then build some services that are dependent on platform-specific APIs and use them within the TripLog app through dependency injection.

Chapter 5, User Interface, will explain how to tap into platform-specific user interface APIs using custom renderers in Xamarin.Forms. We will also discuss the use of value converters to customize the appearance of data at the time of binding.

Chapter 6, API Data Access, will explain how to set up a new RESTful API using a Microsoft Azure Function App. We will then walk through how to connect the TripLog app to the API to get its data and how to set up caching for offline use.

Chapter 7, Authentication, will explain how to set up authentication on the API created in Chapter 6, API Data Access, and then how to add sign-in, sign-out, and authentication to the TripLog app.

Chapter 8, Testing, will discuss the importance of testing in mobile apps. We will walk through how to take advantage of the patterns introduced throughout the book to easily unit test the ViewModels within the TripLog app.

Chapter 9, App Monitoring, will explain the importance of crash reporting and collecting analytical data in mobile apps. We will then integrate the Visual Studio App Center SDK into the TripLog app using the service dependency pattern implemented in Chapter 4, Platform-Specific Services and Dependency Injection.