0%

Book Description

Learn to build cross-platform mobile apps using the latest features in Xamarin.Forms 4 with the help of a series of projects including apps for real-time chatting, AR games, location-tracking, weather, photo galleries, and much more

Key Features

  • Develop mobile apps, AR games, and chatbots of varying complexity with the help of real-world examples
  • Explore the important features of Xamarin.Forms 4 such as Shell, CollectionView, and CarouselView
  • Get to grips with advanced concepts such as AR and VR and machine learning for mobile development

Book Description

Xamarin.Forms is a lightweight cross-platform development toolkit for building apps with a rich user interface. Improved and updated to cover the latest features of Xamarin.Forms, this second edition covers CollectionView and Shell, along with interesting concepts such as augmented reality (AR) and machine learning.

Starting with an introduction to Xamarin and how it works, this book shares tips for choosing the type of development environment you should strive for when planning cross-platform mobile apps. You'll build your first Xamarin.Forms app and learn how to use Shell to implement the app architecture. The book gradually increases the level of complexity of the projects, guiding you through creating apps ranging from a location tracker and weather map to an AR game and face recognition. As you advance, the book will take you through modern mobile development frameworks such as SQLite, .NET Core Mono, ARKit, and ARCore. You'll be able to customize your apps for both Android and iOS platforms to achieve native-like performance and speed. The book is filled with engaging examples, so you can grasp essential concepts by writing code instead of reading through endless theory.

By the end of this book, you'll be ready to develop your own native apps with Xamarin.Forms and its associated technologies, such as .NET Core, Visual Studio 2019, and C#.

What you will learn

  • Set up Xamarin.Forms to build native apps with code-sharing capabilities
  • Understand the core aspects of developing a mobile app, such as its layout, UX, and rendering
  • Use custom renderers to gain platform-specific access
  • Discover how to create custom layouts for your apps with Xamarin.Forms Shell
  • Use Azure SignalR to implement serverless services in your Xamarin apps
  • Create an augmented reality (AR) game for Android and iOS using ARCore and ARKit, respectively
  • Build and train machine learning models using CoreML, TensorFlow, and Azure Cognitive Services

Who this book is for

This book is for C# and .NET developers who want to learn Xamarin.Forms and get started with native Xamarin mobile application development from the ground up. Working knowledge of Visual Studio will help you to get the most out of this book.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Xamarin.Forms Projects Second Edition
  3. Dedication
  4. About Packt
    1. Why subscribe?
  5. Foreword
  6. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  7. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  8. Introduction to Xamarin
    1. Native applications
    2. Xamarin and Mono
    3. Code sharing
    4. Using existing knowledge
    5. Xamarin platforms
    6. Xamarin.iOS
    7. Xamarin.Android
    8. Xamarin.Mac
    9. Xamarin.Forms
    10. <span class="TextRun SCXW211851927"><span class="NormalTextRun SCXW211851927">The architecture of&#160;<span class="TextRun SCXW211851927"><span class="SpellingError SCXW21185
    11. Defining a UI using XAML
    12. Defining a Label control
    13. Creating a page in XAML
    14. Creating a page in C#
    15. XAML or C#?
    16. Xamarin.Forms versus traditional Xamarin
    17. When to use Xamarin.Forms
    18. Setting up a development machine
    19. Setting up a Mac
    20. Installing Xcode
    21. Installing Visual Studio
    22. Configuring the Android emulator
    23. Setting up a Windows machine
    24. Installing Xamarin for Visual Studio
    25. Pairing Visual Studio with a Mac
    26. Configuring an Android emulator and hardware acceleration
    27. Configuring UWP developer mode
    28. Xamarin productivity tooling
    29. Xamarin Hot Restart
    30. Xamarin XAML Hot Reload
    31. Summary
  9. Building Our First Xamarin.Forms App
    1. Technical requirements
    2. An overview of the project
    3. Beginning the project
    4. Setting up the project
    5. Creating the new project
    6. Examining the files
    7. DoToo
    8. DoToo.Android
    9. DoToo.iOS
    10. DoToo.UWP
    11. Updating the Xamarin.Forms packages
    12. Removing the MainPage file
    13. Creating a repository and a TodoItem model
    14. Defining a to-do list item
    15. Creating a repository and its interface
    16. Connecting SQLite to persist data
    17. Adding the&#160;SQLite&#160;NuGet package
    18. Updating the TodoItem class
    19. Creating a connection to the SQLite database
    20. Implementing the GetItems(), AddItems(), and UpdateItems() methods
    21. Using MVVM – creating views and ViewModel
    22. Defining a ViewModel base class
    23. Introducing PropertyChanged.Fody&#160;
    24. Creating the MainViewModel
    25. Creating the TodoItemViewModel
    26. Creating the ItemViewModel class
    27. Creating the MainView view
    28. Creating the ItemView view
    29. Wiring up a dependency injection through Autofac
    30. Adding a reference to Autofac
    31. Creating the resolver
    32. Creating the bootstrapper
    33. Adding a bootstrapper on iOS
    34. Adding a bootstrapper in Android
    35. Adding a bootstrapper in UWP
    36. Making the app run
    37. Adding data bindings
    38. Navigating from MainView to ItemView to add a new item
    39. Adding new items to the list
    40. Binding ListView in MainView
    41. Creating a ValueConverter object for the item status
    42. Using ValueConverter
    43. Navigating to an item using a command
    44. Marking an item as complete using a command
    45. Creating the filter toggle function using a command
    46. Laying out the contents
    47. Setting an application-wide background color
    48. Laying out the MainView and ListView items
    49. The filter button
    50. Touching up ListView
    51. Summary
  10. Building a News App Using Xamarin.Forms Shell
    1. Technical requirements
    2. Project overview
    3. Getting started
    4. Building the news app
    5. Setting up the project
    6. Creating the new project
    7. Updating Xamarin.Forms packages
    8. Creating the structure of the app
    9. Creating the ViewModel base class
    10. Recapping on Quick PropertyChanged.Fody&#160;
    11. Implementing INotifyPropertyChanged
    12. Adding a reference to PropertyChanged.Fody
    13. Creating a FodyWeaver file
    14. Creating the HeadlinesViewModel class
    15. Creating the HeadlinesView
    16. Creating the ArticleItem
    17. Creating the ArticleView
    18. Creating the AboutView
    19. Wiring up dependency injection through Autofac
    20. Adding a reference to Autofac
    21. Creating the resolver
    22. Creating the bootstrapper
    23. Initializing the bootstrapper
    24. Downloading and configuring Font Awesome
    25. Downloading Font Awesome
    26. Adding Font Awesome to Info.plist on iOS
    27. Adding the font to a static resource
    28. Defining some icons in the resource dictionary
    29. Defining the shell
    30. Creating the MainShell file&#160;
    31. Defining the basic structure
    32. Adding the MainShell&#160;type to the container
    33. Making the app run
    34. Creating the news service
    35. Obtaining an API key
    36. Creating the models
    37. Creating a service class
    38. Creating the NewsScope enum
    39. Enabling C# 8
    40. Creating the NewsService class
    41. Wiring up the NewsService class
    42. Extending the HeadlinesViewModel class
    43. Extending the HeadlinesView
    44. Extending the ContentView of the ArticleItem
    45. Adding to the bootstrapper
    46. Adding a ContentTemplate attribute
    47. Handling navigation
    48. Creating the navigation service
    49. Creating the INavigation interface
    50. Implementing the INavigation interface using Shell
    51. Adding the INavigation interface to the ViewModel class
    52. Navigating using routes
    53. Finalizing the ItemSelected command
    54. Extending the ArticleView to receive query data
    55. Extending the ArticleView with a WebView
    56. Registering the route
    57. Summary
  11. A Matchmaking App with a Rich UX Using Animations
    1. Technical requirements
    2. Project overview
    3. Creating the matchmaking app
    4. Creating the project
    5. Creating the new project
    6. Updating the Xamarin.Forms NuGet packages
    7. Designing the MainPage file
    8. Creating the Swiper control
    9. Creating the control
    10. Defining the main grid
    11. Adding a content view for the photo
    12. Creating the DescriptionGenerator class
    13. Creating a picture class
    14. Binding the picture to the control
    15. Setting the source
    16. Controlling the loading label
    17. Handling pan gestures
    18. Testing the control
    19. Creating decision zones
    20. Extending the grid
    21. Adding the StackLayout for liking photos
    22. Adding the StackLayout for denying photos
    23. Determining the screen size
    24. Adding a clamp function
    25. Adding code to calculate the state
    26. Defining a method for calculating the state&#160;
    27. Wiring up the pan state check
    28. Adding exit logic
    29. Checking if the image should exit
    30. Removing the image
    31. Updating PanCompleted
    32. Adding events to the control
    33. Declaring two events
    34. Raising the events
    35. Wiring up the Swiper control
    36. Adding images
    37. Adding initial photos
    38. Making the call from the constructor
    39. Adding count labels
    40. Subscribing to events
    41. Adding methods to update the GUI and respond to events
    42. Wiring up events
    43. Summary
  12. Building a Photo Gallery App Using CollectionView and CarouselView
    1. Technical requirements
    2. Project overview
    3. Building the photo gallery app
    4. Importing photos
    5. Importing photos from the iOS photo gallery
    6. Importing photos from the Android photo gallery
    7. Writing the app-initializing code
    8. Creating a shell
    9. Creating a base view model
    10. Creating a bootstrapper and a resolver
    11. Creating the bootstrapper
    12. Creating the gallery view
    13. Creating the ViewModel
    14. Creating the view
    15. Loading photos incrementally
    16. Saving favorites
    17. Creating the carousels
    18. Creating the view model for the favorite photos
    19. Creating the view model for the latest photos
    20. Showing the favorites photos
    21. Summary
  13. Building a Location Tracking App Using GPS and Maps
    1. Technical requirements
    2. Project overview
    3. Building the MeTracker app
    4. Creating a repository to save the locations of our users
    5. Creating a model for the location data
    6. Creating the repository
    7. Xamarin.Essentials
    8. Creating a service for location tracking
    9. Setting up the app logic
    10. Creating a view with a map
    11. Creating a ViewModel
    12. Creating a resolver&#160;
    13. Creating the bootstrapper
    14. Creating the iOS bootstrapper
    15. Creating the Android bootstrapper
    16. Setting the MainPage
    17. Background location tracking on iOS
    18. Enabling location updates in the background
    19. Getting permissions to use the location of the user
    20. Subscribing to location updates
    21. Background location tracking with Android
    22. Adding the required permissions to use the location of the user
    23. Creating a background job
    24. Scheduling a background job
    25. Subscribing to location updates
    26. Creating a heat map
    27. Adding the GetAll method to LocationRepository
    28. Preparing the data for visualization
    29. Creating custom renderers
    30. Creating a custom control for the map
    31. Creating a custom renderer to extend the map in the iOS app
    32. Creating a custom renderer to extend the map in the Android app
    33. Refreshing the map when resuming the app
    34. Summary
  14. Building a Weather App for Multiple Form Factors
    1. Technical requirements
    2. Project overview
    3. Building the weather app
    4. Creating models for the weather data
    5. Adding the weather API models manually
    6. Adding the app-specific models
    7. Adding the ForecastItem model
    8. Adding the Forecast model
    9. Creating a service to fetch the weather data
    10. Configuring the applications so they use location services
    11. Configuring the iOS app so that it uses location services
    12. Configuring the Android app so that it uses location services
    13. Configuring the UWP app so that it uses location services
    14. Creating the ViewModel class
    15. Getting the weather data
    16. Grouping the weather data
    17. Creating a Resolver
    18. Creating a bootstrapper
    19. Creating the view for tablets and desktop computers
    20. Using FlexLayout
    21. Adding a toolbar item to refresh the weather data
    22. Adding a loading indicator
    23. Setting a background image
    24. Creating the view for phones
    25. Using a grouped CollectionView
    26. Adding pull to refresh functionality
    27. Navigating to different views based on the form factor
    28. Handling states with VisualStateManager
    29. Creating a behavior to set state changes
    30. Summary
  15. Setting Up a Backend for a Chat App Using Azure Services
    1. Technical requirements
    2. Understanding the different Azure serverless services
    3. Azure SignalR Service
    4. Azure Functions
    5. Azure Blob storage
    6. Azure Cognitive Services
    7. Project overview
    8. Building the serverless backend
    9. Creating a SignalR service
    10. Creating a storage account
    11. Creating an Azure&#160;Cognitive Service
    12. Using Azure Functions as an API
    13. Creating the Azure service for functions
    14. Creating a function to return the connection information for the SignalR service
    15. Creating a message library
    16. Creating a storage helper
    17. Creating a function for sending messages
    18. Using the Computer Vision API to scan photos for adult content
    19. Creating a scheduled job to clear photos from storage
    20. Deploying the functions to Azure
    21. Summary
  16. Building a Real-Time Chat Application
    1. Technical requirements
    2. Project overview
    3. Getting started
    4. Building the chat app
    5. Creating the chat service
    6. Initializing the app
    7. Creating a resolver
    8. Creating a Bootstrapper
    9. Creating a base ViewModel
    10. Creating the main view
    11. Creating&#160;MainViewModel
    12. Creating MainView
    13. Replacing MainPage
    14. Editing the XAML
    15. Fixing the code behind the view
    16. Setting the main view
    17. Creating ChatView
    18. Creating ChatViewModel
    19. Creating the class
    20. Adding the text property
    21. Receiving messages
    22. Creating the LocalSimpleTextMessage class
    23. Sending text messages
    24. Installing the Acr.UserDialogs plugin
    25. Installing the Media plugin
    26. Sending photos
    27. Creating the ChatView
    28. Creating Base64ToImageConverter
    29. Creating the skeleton ChatView&#160;
    30. Adding ResourceDictionary
    31. Adding CollectionView
    32. Adding templates
    33. Creating a template selector
    34. Adding the buttons and entry control
    35. Fixing the code behind
    36. Styling
    37. Styling with CSS
    38. Applying the style sheet
    39. Handling life cycle events
    40. Summary
  17. Creating an Augmented Reality Game
    1. Technical requirements
    2. Essential theory
    3. An overview of the project
    4. Setting up the project
    5. Creating the project
    6. Updating the Xamarin.Forms NuGet packages
    7. Setting the Android target framework version&#160;to 9.0
    8. Adding the camera permission to Android
    9. Adding a camera usage description for iOS
    10. Defining the user interface
    11. Creating the ARView control
    12. Modifying the MainPage
    13. Adding UrhoSharp
    14. Installing the UrhoSharp NuGet package for iOS and the .NET Standard project
    15. Installing the UrhoSharp.ARCore NuGet package for Android
    16. Adding the Android life cycle events
    17. Defining the PlaneNode class
    18. Adding custom renderers for the ARView control
    19. For iOS
    20. For Android
    21. Creating the game
    22. Adding the shared abstract Game class
    23. InitializeAR
    24. CreateSubPlane
    25. UpdateSubPlane
    26. FindNodeByPlaneId
    27. Adding platform-specific classes
    28. Adding the iOS-specific class
    29. Adding the Android-specific class
    30. Writing the ARKit-specific code
    31. Defining the ARKitComponent
    32. Writing handlers&#160;for adding and updating anchors
    33. SetPositionAndRotation
    34. UpdateOrAddPlaneNode
    35. OnAddAnchor
    36. OnUpdateAnchors
    37. Writing a handler for removing anchors
    38. OnRemoveAnchors
    39. Initializing ARKit
    40. Writing the ARCore-specific code
    41. Defining the ARCoreComponent
    42. SetPositionAndRotation
    43. Writing a handler for ARFrame updates
    44. Initializing ARCore
    45. OnConfigRequested
    46. InitializeAR
    47. Writing the game
    48. Adding a camera
    49. Configuring a renderer
    50. Adding lights
    51. Implementing the game startup
    52. Adding boxes
    53. AddBox()
    54. OnUpdate()
    55. Making boxes rotate
    56. Creating the rotate component
    57. Assigning the Rotator&#160;component
    58. Adding a box hit-test
    59. Adding a death animation
    60. DetermineHit()
    61. OnTouchBegin()
    62. Wiring up input
    63. Updating statistics
    64. Defining a statistics class
    65. Sending updates via MessagingCenter
    66. Wiring up events
    67. Updating the GUI&#160;
    68. Subscribing to the updates in the MainPage class
    69. Summary
  18. Hot Dog or Not Hot Dog Using Machine Learning
    1. Technical requirements
    2. Machine learning
    3. Azure Cognitive Services&#160;– Custom Vision
    4. Core ML
    5. TensorFlow
    6. Project overview
    7. Getting started
    8. Building the Hot Dog or Not Hot Dog application using machine learning
    9. Training a model
    10. Tagging images
    11. Training a model
    12. Exporting a model
    13. Building the app
    14. Classifying images with machine learning
    15. Using Core ML for image classification
    16. Using TensorFlow for image classification
    17. Creating a base ViewModel class
    18. Initializing the app
    19. Creating a Resolver class
    20. Creating a bootstrapper
    21. Creating the iOS bootstrapper
    22. Creating the Android bootstrapper
    23. Building the first view
    24. Building the ViewModel class
    25. Building the view
    26. Building the result view
    27. Building the ViewModel class
    28. Building the view
    29. Summary
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.145.97.248