From 1f197d29797cf94c6f5ab318e89e1449cc5020d7 Mon Sep 17 00:00:00 2001 From: Allan Ritchie Date: Thu, 25 May 2017 19:50:51 -0400 Subject: [PATCH] toast example --- .../Samples.UI.XamarinForms/ToastsPage.xaml | 9 +++++---- .../Samples/ViewModels/ToastsViewModel.cs | 20 +++++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Samples/Samples.UI.XamarinForms/ToastsPage.xaml b/src/Samples/Samples.UI.XamarinForms/ToastsPage.xaml index 3cae09c9..5b01c13e 100644 --- a/src/Samples/Samples.UI.XamarinForms/ToastsPage.xaml +++ b/src/Samples/Samples.UI.XamarinForms/ToastsPage.xaml @@ -1,4 +1,4 @@ - + - + - + - + + diff --git a/src/Samples/Samples/ViewModels/ToastsViewModel.cs b/src/Samples/Samples/ViewModels/ToastsViewModel.cs index 9edc7f7d..8c98c3e4 100644 --- a/src/Samples/Samples/ViewModels/ToastsViewModel.cs +++ b/src/Samples/Samples/ViewModels/ToastsViewModel.cs @@ -20,7 +20,7 @@ public ToastsViewModel(IUserDialogs dialogs) : base(dialogs) this.MessageTextColor = ToHex(Color.White); this.BackgroundColor = ToHex(Color.Blue); - this.Open = new Command(async () => + this.Open = new Command(() => { // var icon = await BitmapLoader.Current.LoadFromResource("emoji_cool_small.png", null, null); @@ -35,11 +35,12 @@ public ToastsViewModel(IUserDialogs dialogs) : base(dialogs) //.SetBackgroundColor(bgColor) //.SetMessageTextColor(msgColor) .SetDuration(TimeSpan.FromSeconds(this.SecondsDuration)) + .SetPosition(this.ShowOnTop ? ToastPosition.Top : ToastPosition.Bottom) //.SetIcon(icon) .SetAction(x => x .SetText(this.ActionText) //.SetTextColor(actionColor) - .SetAction(() => dialogs.Alert("You clicked the primary button")) + .SetAction(() => dialogs.Alert("You clicked the primary toast button")) ) ); }); @@ -98,6 +99,21 @@ public int SecondsDuration } + bool showOnTop; + public bool ShowOnTop + { + get => this.showOnTop; + set + { + if (this.showOnTop == value) + return; + + this.showOnTop = true; + this.OnPropertyChanged(); + } + } + + string actionText; public string ActionText {