Skip to content

Commit

Permalink
Merge pull request #19 from muak/PlaceholderFix
Browse files Browse the repository at this point in the history
Fixed placeholder
  • Loading branch information
muak authored Aug 29, 2017
2 parents 43385ef + 141917f commit 2e43870
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
5 changes: 4 additions & 1 deletion AiForms.Effects.iOS/PlaceholderPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override void OnAttached()
_placeholderLabel.Alpha = 1;
}

_textView.Changed += _textView_Changed;
_textView.Changed += _textView_Changed;
}

protected override void OnDetached()
Expand All @@ -60,6 +60,9 @@ protected override void OnElementPropertyChanged(System.ComponentModel.PropertyC

if (e.PropertyName == Placeholder.TextProperty.PropertyName) {
UpdateText();
//avoid breaking change.
//There exists same property in attached element's property. I should have named TextProperty other name.
_textView_Changed(_textView,EventArgs.Empty);
}
else if (e.PropertyName == Placeholder.ColorProperty.PropertyName) {
UpdateColor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class PlaceholderPageViewModel
public ReactiveProperty<Color> PlaceColor { get; } = new ReactiveProperty<Color>();
public ReactiveProperty<bool> ColorToggle { get; } = new ReactiveProperty<bool>();
public ReactiveProperty<bool> TextToggle { get; } = new ReactiveProperty<bool>();
public ReactiveProperty<string> EditText { get; } = new ReactiveProperty<string>();

public ReactiveCommand ChangeTextCommand { get; } = new ReactiveCommand();

public PlaceholderPageViewModel()
{
Expand All @@ -28,6 +31,16 @@ public PlaceholderPageViewModel()

ColorToggle.Value = true;
TextToggle.Value = true;

ChangeTextCommand.Subscribe(_=>{
if(string.IsNullOrEmpty(EditText.Value)){
EditText.Value = "Abcdef";
}
else{
EditText.Value = "";
}

});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@
<Label Text="Text" VerticalOptions="Center" />
<Switch IsToggled="{Binding TextToggle.Value}" VerticalOptions="Center" />
</StackLayout>
<StackLayout Orientation="Horizontal" VerticalOptions="Start" BackgroundColor="White">
<Button Text="ChText" VerticalOptions="Center" Command="{Binding ChangeTextCommand}" />
</StackLayout>
<Editor HeightRequest="150" BackgroundColor="#F0F0F0"
ef:Placeholder.On="{Binding EffectOn.Value}"
ef:Placeholder.Text="{Binding PlaceText.Value}"
ef:Placeholder.Color="{Binding PlaceColor.Value}"
Text="{Binding EditText.Value}"
/>

<Entry Placeholder="Entry Placeholder" PlaceholderColor="{Binding PlaceColor.Value}"
ef:Placeholder.On="{Binding EffectOn.Value}"
ef:Placeholder.Text="{Binding PlaceText.Value}"
ef:Placeholder.Color="{Binding PlaceColor.Value}"
Text="{Binding EditText.Value}"
/>
</StackLayout>
</ContentPage>
10 changes: 3 additions & 7 deletions nuget/AiEffects_mac.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>AiForms.Effects</id>
<version>1.0.0</version>
<version>1.0.1</version>
<title>AiForms.Effects for Xamarin.Forms</title>
<authors>kamu</authors>
<owners>kamu</owners>
Expand All @@ -12,13 +12,9 @@
<description>Xamarin.Forms Effects(add Border/add placeholder/add Text/add Command/add NumberPicker, TimePicker and DatePicker/alter color for switch and slider/alter LineHeight of Label and Editor/Button to flat) for iOS/Android</description>
<summary></summary>
<releaseNotes>
## NewFeatures
## BugFix

[Border] add border to a view.
[Placeholder] show placeholder on Editor.
[AddTimePicker] add TimePicker to a view.
[AddDatePicker] add DatePicker to a view.
[AlterColor] alter accent color for slider, switch and so on.
[Placeholder][iOS] When binded Editor.Text Property, Placeholder isn't hidden.
</releaseNotes>
<tags>Xamarin.Forms Effects Command NumberPikcer LineHeight LineSpacing FlatButton Validation SoundEffect Border TimePicker DatePicker Placeholder Color</tags>
<language>en-US</language>
Expand Down

0 comments on commit 2e43870

Please sign in to comment.