Skip to content

Commit

Permalink
toast example
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed May 25, 2017
1 parent 48da9a0 commit 1f197d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/Samples/Samples.UI.XamarinForms/ToastsPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Samples.ToastsPage"
Expand All @@ -8,14 +8,15 @@
<TableRoot>
<TableSection Title="Message">
<EntryCell Label="Value" Text="{Binding Message}" />
<EntryCell Label="Text Color" Text="{Binding MessageTextColor}" />
<!-- <EntryCell Label="Text Color" Text="{Binding MessageTextColor}" />-->
</TableSection>
<TableSection Title="Action Color">
<EntryCell Label="Value" Text="{Binding ActionText}" />
<EntryCell Label="Text Color" Text="{Binding ActionTextColor}" />
<!-- <EntryCell Label="Text Color" Text="{Binding ActionTextColor}" />-->
</TableSection>
<TableSection>
<EntryCell Label="Background Color" Text="{Binding BackgroundColor}" />
<SwitchCell Text="Show on Top" On="{Binding ShowOnTop}" />
<!-- <EntryCell Label="Background Color" Text="{Binding BackgroundColor}" />-->
<EntryCell Label="Duration (sec)" Text="{Binding SecondsDuration}" Keyboard="Numeric" />
<TextCell Text="Open Toast" Command="{Binding Open}" />
</TableSection>
Expand Down
20 changes: 18 additions & 2 deletions src/Samples/Samples/ViewModels/ToastsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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"))
)
);
});
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 1f197d2

Please sign in to comment.