Back in October RedBit had an opportunity to participate in a weekend hack to try and leverage technology to find missing children. It was a collaboration with Missing Children Society of Canada, City of Calgary, Calgary Police Service, Microsoft and RedBit.
The system consisted of the following
- Visual Studio – This was our development environment
- GitHub – our source code repository for the system
- Xamarin Forms – our cross-platform solution to target iOS, Android & Windows with one code base
- Hockey App – Distribution of the application
Although multiple people worked on the application and this article focuses on the development of the Xamarin app, here is a high level architecture of the system which should give an idea of all the parts involved in the system
Mobile App Design Session
With any project, at RedBit we start with a design session to figure out what exactly needs to be built. We had an idea of the users that were going to use the mobile app (personas) and this was officers investigating a case.
After an hour of a design session we came up with the following white board drawing
It was a simple application that consisted of
- Login Page
- List of Cases Page
- Case Details Page
- Map of social content page
Each page consisted of various actions that the user could do on each page. At this point we defined the APIs that were required by the backend NodeJS REST API and the data models that will be sent from device to REST API. For more details on the NodeJS application and backend see the following articles Cloud4Good: Setting up Infrastructure as code on behalf of Missing Children Society of Canada and Cloud4Good: Extracting Data from the Twitter API through Azure Functions.
Overview of the App
The application written for the hack is a Xamarin Forms based application using a Shared Project which allowed us to share code across iOS, Android and Windows. The solution consisted of four projects
- IRIS – Shared Project where about 95% of the code exists
- IRIS.Droid – the android version of the project
- IRIS.iOS – the iOS version of the project
- IRIS.Windows – the Windows UWP version of the project. We did not build for older versions of Windows
We determined we have about 95% code sharing by running Code Metrics within Visual Studio (you require Enterprise version to run Code Metrics) as you can see from the following
Since we are using a shared project and these lines go within the platform specific projects, so if we assume MCS.IRIS.Droid is the lowest and MCS.IRIS.UWP is the highest, we are looking at about 95% code coverage.
Code metrics works much better with Portable Class Libraries (PCL) but I tend to work with Shared Projects unless it’s something that can be leveraged in multiple projects not just one project.
This projects contains the main items
- Models – These are the models we defined during design such as Case, Social Account, Registered Account etc. This is the first M of MVVM.
- Services – This basically contains the service to connect to the backend API system. Currently just authenticates and retrieves data
- ViewModels – This is the VM part of MVVM and contains the logic on who the views should behave
- Views – This is the first V of MVVM and is the UI that is presented to the user and databound to the appropriate viewmodels.
Some things to note
- SimpleIoC – We pulled in some classes from MVVMLight open source project. This was done more for simplicity and to help accelerate things with some people who were not familiar with MVVM
- cs – this is where we register all our ViewModels using SimpleIoC
MCS.IRIS.Droid & iOS & Windows Project
The platform specific projects, has very minimal custom code. We added the following to help enhance some of the experience but didn’t focus too much on this with the limited amount of time
- Added a custom renderer for the Entry fields to remove the auto complete etc
- Added nuget project references
- Added support for Android theming by adding a custom style for titlebar and added code to MainActivity.cs
- Nothing was done here
As you can see very minimal code on the platform specific implementations and sharing about 95% of code on three platforms natively.
This is the first in a series of articles to get the project up and running