The document discusses cross-platform mobile development using Xamarin. It highlights features like sharing C# code across platforms, using 100% native APIs, and building user interfaces with Xamarin.Forms. It also covers testing with Xamarin Test Cloud, monitoring with Xamarin Insights, and training through Xamarin University. The document provides examples of building an app with shared business logic, UI code, and navigation using Xamarin.Forms.
4. xamarin.com/testcloud
✓ Automated UI testing
✓ Thousands of real devices
✓ Integration with CI systems
✓ Test any mobile app
✓ Find bugs before your
customers do
14. Traditional Xamarin Approach With Xamarin.Forms:
Share UI code, all native
iOS C# UI Windows C# UIAndroid C# UI
Shared C# Business Logic
Shared UI Code
Shared C# Business Logic
15. ✓ 40+ Pages, layouts, and controls
(Build with C# or XAML)
✓ Two-way data binding
✓ Navigation
✓ Animation API
✓ Dependency Service
✓ Messaging Center
✓ Styles, Converters, Behaviors
Shared C# Business Logic
Shared UI Code
21. Sport
Development goals:
• Provide a way for colleagues to
challenge and rank up
• Gain a deeperunderstanding of
Forms – capabilities/limitations
• Learn Azure Mobile Services
(WebAPI, EF, push)
22. Application Design Goals
• Simplified registration/authentication
• Athlete’s can join multiple leagues
• View current rank within ladder
• Athlete stats & challenge history
• Facilitate challenge flow (accept, nudge, post results)
26. Absolute Layout
• Used to control size and position of child elements
• LayoutBounds is based on LayoutFlags value
• SizeProportional, PositionProportional, All
• Element’s LayoutBounds are proportional to the
AbsoluteLayout’s bounds
• The x and y anchor points are interpolated as the child
elements position changes
27. SimpleAuth
• SimpleAuth – stupid simple
• github.com/clancey/simpleauth
var scopes = new[] {
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
};
var api = new GoogleApi("google", "clientid", "clientsecret") {
Scopes = scopes,
};
var account = await api.Authenticate();
29. Providers
• Use an interface to define intent
• Implement on each platform
• Use the Dependency Service to get a platform-specific
implementation at runtime
• Smaller utilities can use the same namespace/class without
the need for an interface
30. ToastNotifier Provider
public interface IToastNotifier
{
Task<bool> Notify(ToastNotificationType type, string title, string description,TimeSpan duration, object context = null);
void HideAll();
}
define
[assembly: Dependency(typeof(Sport.Android.ToastNotifier))]
...
public class ToastNotifier : IToastNotifier
{
public Task<bool> Notify(ToastNotificationType type, string title, string description,
TimeSpan duration, object context = null)
{
var taskCompletionSource = new TaskCompletionSource<bool>();
Toast.MakeText(Forms.Context, description, ToastLength.Short).Show();
return taskCompletionSource.Task;
}
public void HideAll()
{
}
}
implement
var toaster = DependencyService.Get<IToastNotifier>();
toaster.Notify(type, title ?? type.ToString().ToUpper(), message, TimeSpan.FromSeconds(2.5f));
use
31. Custom, Reusable Controls
• Equivalent to a WPF/ASP.NET User
Control
• Use Bindable Properties to allow
consumers to bind values
• Templated controls can allow for inner
content
• Subclass ContentView
32. Little Tricks
• Use layers for precise layout - position and size
• Use opacity on controls to handle a user event
• Examples
• ImageButton
• Styled Date and Time pickers
• Use VectorImages instead of bitmaps
• Reduce application footprint by including a single .svg file
• Control tint color and size dynamically
• Use an IsBusy flag to trigger progress
• Use a Busy : IDisposable to ensure flag always gets set to false
• Use static converters – less code, fewer objects
• Run tasks safely using a proxy task-runner
Let’s check out some code!
33. Vector Image
• Control size and tint color dynamically
• Reduce footprint by resourcing a single .svg file
34. Animations
• Super easy to use
• Basic animations are supported
• Scale
• Translate
• Fade
• Rotate
• Easing (Bounce, Cubic, Linear, Sin)
36. Animations
var speed = (uint)App.AnimationSpeed;
var ease = Easing.SinIn;
var pushRect = new Rectangle(Content.Width, btnPush.Bounds.Y, btnPush.Bounds.Width, btnPush.Height);
btnPush.FadeTo(0, speed, ease);
await btnPush.LayoutTo(pushRect, speed, ease);
var contRect = new Rectangle(Content.Width, btnCont.Bounds.Y, btnCont.Bounds.Width, btnCont.Height);
btnCont.FadeTo(0, speed, ease);
await btnCont.LayoutTo(contRect, speed, ease);
37. Parallax Effect
void Parallax()
{
if(_imageHeight <= 0)
_imageHeight = photoImage.Height;
var y = scrollView.ScrollY * .4;
if(y >= 0)
{
//Move the Image's Y coordinate a fraction
//of the ScrollView's Y position
photoImage.Scale = 1;
photoImage.TranslationY = y;
}
else
{
//Calculate a scale that equalizes the height vs scroll
double newHeight = _imageHeight + (scrollView.ScrollY * -1);
photoImage.Scale = newHeight / _imageHeight;
photoImage.TranslationY = scrollView.ScrollY / 2;
}
}
38. Insights & UITest
• Add custom events or implement at a base level
• Use StyleID to store the element identifier
• Share UITest code between iOS and Android