Mastering Xamarin UI Development Table of Contents
Total Page:16
File Type:pdf, Size:1020Kb
Mastering Xamarin UI Development Table of Contents Mastering Xamarin UI Development Credits About the Author Acknowledgments About the Reviewers www.PacktPub.com Why subscribe? Customer Feedback Dedication Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions 1. Creating the TrackMyWalks Native App Creating the TrackMyWalks solution Updating the TrackMyWalks solution packages Creating the TrackMyWalks model Creating the walks main page Creating the new walk entry content page Creating the walk trail content page Adding the Xamarin.Forms.Maps NuGet package Creating the DistanceTravelledPage content page Creating the Splash screen content page Updating the Xamarin.Forms App class Differences between Xamarin Studio and Visual Studio Running the TrackMyWalks app using the simulator Summary 2. MVVM and Data Binding Understanding the MVVM pattern architecture Implementing the MVVM ViewModels within your app Creating the WalkBaseViewModel for the TrackMyWalks app Implementing the WalksPageViewModel Updating the walks main page to use the MVVM model Implementing the walks entry page ViewModel Updating the WalksEntryPage to use the MVVM model Implementing the walk trail page ViewModel Updating the WalksTrailPage to use the MVVM model Implementing the DistanceTravelledViewModel Updating the DistanceTravelledPage to use the MVVM model Summary 3. Navigating within the MVVM Model - The Xamarin.Forms Way Understanding the Xamarin.Forms Navigation API Differences between the navigation and ViewModel approaches Implementing the navigation service within your app Creating the navigation service interface for the TrackMyWalks app Creating a navigation service to navigate within our ViewModels Updating the WalkBaseViewModel to use our navigation service Updating the walks main page ViewModel and navigation service Updating the walks main page to use the updated ViewModel Updating the walks entry page ViewModel and navigation service Updating the WalksEntryPage to use the updated ViewModel Updating the walks trail page ViewModel and navigation service Updating the WalksTrailPage to use the updated ViewModel Updating the distance travelled ViewModel and navigation service Updating the DistanceTravelledPage to use the updated ViewModel Updating the Xamarin.Forms.App class to use the navigation service Summary 4. Adding Location-Based Features within Your App Creating and using platform-specific services Creating the Location Service Interface for the TrackMyWalks app Creating the Location Service class for the Android platform Creating the Location Service class for the iOS platform Enabling background updates and getting the user's current location Updating the WalkEntryViewModel to use the location service Updating the DistanceTravelledViewModel to use the location service Updating the SplashPage to register our ViewModels Updating the MainActivity class to use Xamarin.Forms.Maps Updating the Xamarin.Forms App class to use platform specifics Summary 5. Customizing the User Interface Creating the DataTemplate class for the TrackMyWalks app Updating the walks main page to use the data template Creating a TableView EntryCell custom picker for the iOS platform Creating the custom picker renderer class for the iOS platform Updating the WalksEntryPage to use the custom picker renderer Creating PlatformEffects using the Effects API for the iOS platform Creating PlatformEffects using the Effects API for the Android platform Implementing value converters within the TrackMyWalks app Updating the WalkBaseViewModel to use our Boolean converter Updating the WalksPageViewModel to use our Boolean converter Updating the walks main page to use the updated ViewModel Updating the WalksTrailPage to use the updated ViewModel Updating the DistanceTravelledPage to use the updated ViewModel Updating the WalkCellDataTemplate class to use PlatformEffects Summary 6. Working with Razor Templates Understanding the Razor template engine Creating and implementing Razor templates within Xamarin Studio Adding the SQLite.Net package to the BookLibrary solution Creating and implementing the book library database model Creating and implementing the book database wrapper Creating and implementing the BookLibrary database wrapper Creating and implementing the book listing main page Creating and implementing the BookLibraryAdd Razor template Creating and implementing the BookLibraryEdit Razor template Creating and implementing the WebViewController class Updating the book library Cascading Style Sheet (CSS) Summary 7. Incorporating API Data Access Using Microsoft Azure App Services Setting up our TrackMyWalks app using Microsoft Azure Adding the Json.Net NuGet package to the TrackMyWalks app Adding the HttpClient NuGet package to the TrackMyWalks app Updating the WalkEntries model to use the Json.Net framework Creating the HTTP web service class for the TrackMyWalks app Creating the DataService API for the TrackMyWalks app Creating the DataService API class for the TrackMyWalks app Updating the WalkBaseViewModel to use our DataService API Updating the WalkEntryViewModel to use our DataService API Updating the WalksPageViewModel to use our DataService API Updating the WalksPage to use the updated ViewModel Updating the custom picker renderer class for the iOS platform Updating the WalksEntryPage to use the updated custom picker Summary 8. Making Our App Social - Using the Facebook API Setting up and registering the TrackMyWalks app with Facebook Adding the Xamarin.Auth NuGet package to the TrackMyWalks app Adding the FaceBook SDK library to the TrackMyWalks app Creating a Facebook user model for the TrackMyWalks app Creating a FacebookCredentials class for the TrackMyWalks app Creating the Facebook Sign In to use within our TrackMyWalks app Creating the Facebook Sign In Class for TrackMyWalks (iOS) app Updating the NavigationService Interface for the TrackMyWalks app Updating the NavigationService class for the TrackMyWalks app Updating the WalksPage to properly handle Facebook Sign In Updating the WalksPage ViewModel to use our FaceBookApiUser Updating the DistanceTravelledPage for the TrackMyWalks app Updating the Xamarin.Forms App class to handle Facebook Sign In Enabling Facebook functionality within the TrackMyWalks app Summary 9. Unit Testing Your Xamarin.Forms Apps Using the NUnit and UITest Frameworks Creating a unit test solution folder using Xamarin Studio Creating a unit test project using Xamarin Studio Adding the Moq NuGet package to the unit test project Adding the TrackMyWalks project to TrackMyWalks.UnitTests Creating and implementing the WalksTrailViewModel NUnit test class Creating and implementing the WalkEntryViewModel NUnit test class Running the TrackMyWalks.UnitTests using Xamarin Studio Creating a UI test project using Xamarin Studio Understanding the commonly used UITest methods Setting up and initializing our TrackMyWalks app for UITest Implementing the CreateNewWalkEntry using the UITest.Framework Adding the Xamarin Test Cloud Agent to the iOS project Updating the TrackMyWalks AppDelegate class to handle Xamarin Test Cloud Agent Running the TrackMyWalks UITests using Xamarin Studio Summary 10. Packaging and Deploying Your Xamarin.Forms Applications Creating and setting up your iOS development team Creating the TrackMyWalks iOS development certificate Obtaining the iOS development certificate from Apple Creating the App ID for the TrackMyWalks (iOS) application Creating the TrackMyWalks development provisioning profile Preparing the TrackMyWalks (iOS) app for submission Submitting the TrackMyWalks (iOS) app to iTunes Connect using Xamarin Studio Summary Mastering Xamarin UI Development Mastering Xamarin UI Development Copyright © 2017 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: January 2017 Production reference: 1130117 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78646-200-8 www.packtpub.com Credits Author Copy Editor Steven F. Daniel Safis Editing Reviewers Project Coordinator Lance McCarthy Izzat Contractor Engin Polat Commissioning Editor Proofreader Amarabha Banerjee Safis Editing Acquisition Editor Indexer Shweta Pant Tejal Daruwale Soni Content Development Editor Graphics Priyanka Mehta Abhinash Sahu Technical Editor Production Coordinator Abhishek Sharma Deepika Naik About the Author Steven F. Daniel is the CEO and founder of GENIESOFT STUDIOS, a software development company based in Melbourne, Victoria, that focuses primarily on developing games and business applications for the iOS, Android,