Skip to content

Commit

Permalink
fix some uwp things and release
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed May 7, 2016
1 parent a7c5fe1 commit e1a671e
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 59 deletions.
5 changes: 4 additions & 1 deletion nuspec/Acr.UserDialogs.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Acr.UserDialogs</id>
<version>5.0.1</version>
<version>5.1.0</version>
<title>ACR User Dialogs Plugin for Xamarin and Windows</title>
<summary>Allows for messagebox style dialogs to be called from your shared/PCL/MVVM code</summary>
<description>
Expand Down Expand Up @@ -64,6 +64,9 @@ Supported Platforms
5.1
[feature] date and time dialogs
[feature] using BTProgressHUD and AndHUD from nuget (at last)!
[fix][droid] launch on uithread
[fix][ios] showsuccess/error now properly masks the background
[fix][uwp] several bugfixes and improvements

5.0.1
[fix][ios] incorrect prompt result
Expand Down
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ Supports Android, iOS, and Unified Windows Platform (UWP, UAP)
* Action Sheet (multiple choice menu)
* Alert
* Confirm
* Date
* Loading
* Login
* Progress
* Prompt
* Toasts
* Time
* [examples](https://github.com/aritchie/userdialogs/blob/master/src/Samples/Samples/MainPage.cs)

## Support Platforms
Expand Down Expand Up @@ -62,6 +64,9 @@ All config objects contain static vars that contain defaults which are basically
- DefaultNo
- DefaultOkText
- DefaultCancelText
- DatePromptConfig
- DefaultOkText
- DefaultCancelText
- LoginConfig
- DefaultTitle
- DefaultOkText
Expand Down Expand Up @@ -89,7 +94,10 @@ All config objects contain static vars that contain defaults which are basically
- ErrorBackgroundColor
- ErrorTextColor
- DefaultDuration

- TimePromptConfig
- DefaultOkText
- DefaultCancelText
- DefaultMinuteInterval

## FAQ

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<Compile Include="PromptConfig.cs" />
<Compile Include="PromptResult.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TimeConfig.cs" />
<Compile Include="TimeResult.cs" />
<Compile Include="ToastConfig.cs" />
</ItemGroup>
Expand Down
12 changes: 0 additions & 12 deletions src/Acr.UserDialogs.Interface/TimeConfig.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Acr.UserDialogs.Uwp/ProgressContentDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<ContentDialog.Content>
<StackPanel>
<TextBlock Text="{Binding Title}" FontSize="17" Foreground="White" HorizontalAlignment="Center" />
<TextBlock Text="{Binding Title}" FontSize="17" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
<ProgressBar x:Name="ProgressBar" Value="{Binding PercentComplete}" HorizontalAlignment="Stretch" IsIndeterminate="{Binding IsIndeterministic}" />
<TextBlock Text="{Binding PercentComplete}" HorizontalAlignment="Center" FontSize="17" Foreground="White" Visibility="{Binding TextPercentVisibility}" />
<Button Visibility="{Binding CancelVisibility}" HorizontalAlignment="Center" Content="{Binding CancelText}" Command="{Binding Cancel}" />
Expand Down
70 changes: 44 additions & 26 deletions src/Acr.UserDialogs.Uwp/ProgressDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.Xaml;


namespace Acr.UserDialogs {

public class ProgressDialog : IProgressDialog, INotifyPropertyChanged {
namespace Acr.UserDialogs
{
public class ProgressDialog : IProgressDialog, INotifyPropertyChanged
{
readonly ProgressContentDialog dialog;
Action cancelAction;


public ProgressDialog() {
public ProgressDialog()
{
this.CancelVisibility = Visibility.Collapsed;
this.IsIndeterministic = true;
this.dialog = new ProgressContentDialog { DataContext = this };
Expand All @@ -24,9 +27,11 @@ public ProgressDialog() {
public bool IsIndeterministic { get; private set; }

bool deter;
public bool IsDeterministic {
public bool IsDeterministic
{
get { return this.deter; }
set {
set
{
this.deter = value;
this.IsIndeterministic = !value;
this.TextPercentVisibility = value
Expand All @@ -45,9 +50,11 @@ public bool IsDeterministic {


int percent;
public int PercentComplete {
public int PercentComplete
{
get { return this.percent; }
set {
set
{
if (value > 100)
this.percent = 100;
else if (value < 0)
Expand All @@ -60,31 +67,37 @@ public int PercentComplete {


Visibility textVis;
public Visibility TextPercentVisibility {
public Visibility TextPercentVisibility
{
get { return this.textVis; }
private set {
private set
{
this.textVis = value;
this.Change();
}
}


string title;
public string Title {
public string Title
{
get { return this.title; }
set {
set
{
this.title = value;
this.Change();
}
}


public void Dispose() {
public void Dispose()
{
this.Hide();
}


public void Hide() {
public void Hide()
{
if (!this.IsShowing)
return;

Expand All @@ -93,14 +106,16 @@ public void Hide() {
}


public void SetCancel(Action onCancel, string cancelText = "Cancel") {
public void SetCancel(Action onCancel, string cancelText = "Cancel")
{
this.CancelVisibility = Visibility.Visible;
this.cancelAction = onCancel;
this.CancelText = cancelText;
}


public void Show() {
public void Show()
{
if (this.IsShowing)
return;

Expand All @@ -109,7 +124,8 @@ public void Show() {
}


void Change([CallerMemberName] string property = null) {
void Change([CallerMemberName] string property = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
}

Expand All @@ -118,19 +134,23 @@ void Change([CallerMemberName] string property = null) {


string cancelText;
public string CancelText {
public string CancelText
{
get { return this.cancelText; }
set {
set
{
this.cancelText = value;
this.Change();
}
}


Visibility cancelVisible;
public Visibility CancelVisibility {
public Visibility CancelVisibility
{
get { return this.cancelVisible; }
private set {
private set
{
this.cancelVisible = value;
this.Change();
}
Expand All @@ -140,11 +160,9 @@ private set {
public event PropertyChangedEventHandler PropertyChanged;


protected virtual void Dispatch(Action action) {
CoreWindow
.GetForCurrentThread()
.Dispatcher
.RunAsync(CoreDispatcherPriority.Normal, () => action());
protected virtual void Dispatch(Action action)
{
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
}
}
}
47 changes: 30 additions & 17 deletions src/Acr.UserDialogs.Uwp/UserDialogsImpl.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using Windows.Foundation.Collections;
using Windows.ApplicationModel.Core;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.UI.Text;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
Expand All @@ -18,7 +19,6 @@ namespace Acr.UserDialogs
{
public class UserDialogsImpl : AbstractUserDialogs
{

public override void Alert(AlertConfig config)
{
var dialog = new MessageDialog(config.Message, config.Title ?? String.Empty);
Expand Down Expand Up @@ -219,7 +219,7 @@ public override void Prompt(PromptConfig config)

public override void ShowImage(IBitmap image, string message, int timeoutMillis)
{
this.Show(null, message, ToastConfig.SuccessBackgroundColor, timeoutMillis);
this.Show(image, message, ToastConfig.SuccessBackgroundColor, timeoutMillis);
}


Expand Down Expand Up @@ -319,21 +319,36 @@ protected virtual void SetDefaultPrompt(ContentDialog dialog, StackPanel stack,

protected virtual void Show(IBitmap image, string message, Color bgColor, int timeoutMillis)
{
var stack = new StackPanel
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Opacity = 0.7
};
if (image != null)
{
var source = image.ToNative();
stack.Children.Add(new Image { Source = source });
}
stack.Children.Add(new TextBlock
{
Text = message,
FontSize = 24f,
TextAlignment = TextAlignment.Center,
FontWeight = FontWeights.Bold
});

var cd = new ContentDialog
{
Background = new SolidColorBrush(bgColor.ToNative()),
Content = new TextBlock { Text = message }
BorderBrush = new SolidColorBrush(bgColor.ToNative()),
Content = stack
};
stack.Tapped += (sender, args) => cd.Hide();

this.Dispatch(() => cd.ShowAsync());
Task.Delay(TimeSpan.FromMilliseconds(timeoutMillis))
.ContinueWith(x =>
{
try
{
this.Dispatch(() => cd.Hide());
}
catch { }
});
.ContinueWith(x => this.Dispatch(cd.Hide));
}


Expand All @@ -345,10 +360,8 @@ protected override IProgressDialog CreateDialogInstance()

protected virtual void Dispatch(Action action)
{
CoreWindow
.GetForCurrentThread()
.Dispatcher
.RunAsync(CoreDispatcherPriority.Normal, () => action());
//this.UiDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => action());
}

#endregion
Expand Down

0 comments on commit e1a671e

Please sign in to comment.