Mastering Xamarin.Forms - Third Edition

Book description

New edition of the bestselling guide to building an effective mobile app architecture with Xamarin.Forms 4 that maximizes the overall quality of apps.

Key Features

  • Updated for Xamarin.Forms 4
  • Packed with real-world scenarios and solutions to help you build professional grade mobile apps with Xamarin.Forms
  • Includes design patterns and best practice techniques that every mobile developer should know

Book Description

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.

What you will learn

  • Find out how, when, and why to use architecture patterns and best practices with Xamarin.Forms
  • Implement the Model-View-ViewModel (MVVM) pattern and data binding in Xamarin.Forms mobile apps
  • Incorporate client-side validation in Xamarin.Forms mobile apps
  • Extend the Xamarin.Forms navigation API with a custom ViewModel-centric navigation service
  • Leverage the inversion of control and dependency injection patterns in Xamarin.Forms mobile apps
  • Work with online and offline data in Xamarin.Forms mobile apps
  • Use platform-specific APIs to build rich custom user interfaces in Xamarin.Forms mobile apps
  • Explore how to monitor mobile app quality using Visual Studio App Center

Who this book is for

This book is intended for .NET developers who are familiar with Xamarin mobile application development and the open source Xamarin.Forms toolkit. If you have already started working with Xamarin.Forms and want to take your app to the next level, making it more maintainable, testable and flexible, then this book is for you.

Table of contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  2. Getting Started
    1. Introducing the app idea
      1. Defining features
    2. Creating the initial app
      1. Setting up the solution
        1. Updating the Xamarin.Forms packages
      2. Creating the main page
      3. Creating the new entry page
      4. Creating the entry detail page
    3. Summary
  3. MVVM and Data Binding
    1. Understanding the MVVM pattern
    2. Adding MVVM to the app
      1. Setting up the app structure
      2. Adding ViewModels
        1. Adding MainViewModel
        2. Adding DetailViewModel
        3. Adding NewEntryViewModel
    3. Validation
      1. Adding a base validation ViewModel
      2. Adding validation to the New Entry Page
    4. Summary
  4. Navigation
    1. The Xamarin.Forms navigation API
    2. Navigation and MVVM
      1. ViewModel-centric navigation
    3. Creating a navigation service
      1. Updating the TripLog app
        1. Updating BaseViewModel
        2. Updating MainViewModel
        3. Updating NewEntryViewModel
        4. Updating DetailPage
    4. Summary
  5. Platform-Specific Services and Dependency Injection
    1. Inversion of control and dependency injection in mobile apps
    2. Xamarin.Forms DependencyService versus third-party alternatives
    3. Creating and using platform-specific services
      1. Creating a location service
      2. Using the location service on the New Entry Page
      3. Adding the location service implementation
    4. Registering dependencies
      1. Registering the platform-service implementations
      2. Registering the ViewModels
      3. Registering the navigation service
      4. Updating the TripLog app
      5. Updating the navigation service to handle ViewModel creation and dependency injection
    5. Summary
  6. User Interface
    1. Custom renderers
      1. Creating a TableView DatePicker
    2. Value converters
      1. Creating a reverse visibility value converter
      2. Creating an integer-to-image value converter
    3. Adding pull-to-refresh
    4. Accessibility
      1. Supporting screen readers
    5. Summary
  7. API Data Access
    1. Creating an API with Azure Functions
      1. Creating an Azure Function App
      2. Creating an Azure Function
      3. Browsing and adding data
    2. Creating a base HTTP service
    3. Creating an API data service
      1. Updating the TripLog app ViewModels
    4. Offline data caching
      1. Adding the Akavache library
      2. Maintaining an offline data cache
    5. Summary
  8. Authentication
    1. Adding authentication to Azure Functions
      1. Setting up an identity provider
    2. Creating an authentication service
    3. Adding a sign-in page
    4. Adding a sign-out button
    5. Summary
  9. Testing
    1. Unit testing
      1. Testing ViewModels
      2. Running unit tests in Visual Studio
    2. Summary
  10. App Monitoring
    1. Mobile app analytics
      1. Crash reporting
    2. Visual Studio App Center
      1. Setting up Visual Studio App Center
      2. Creating an analytics service
      3. Tracking exceptions and events
    3. Summary
  11. Other Books You May Enjoy
  12. Index

Product information

  • Title: Mastering Xamarin.Forms - Third Edition
  • Author(s): Ed Snider
  • Release date: December 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781839213380