Skip to content

Commit

Permalink
Fix SyncCanExecute #53
Browse files Browse the repository at this point in the history
  • Loading branch information
Satoshi Nakamura committed Feb 4, 2020
1 parent abd3424 commit 33b994f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 33 deletions.
5 changes: 3 additions & 2 deletions AiForms.Effects.Droid/AddCommandPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ protected override void OnAttachedOverride()

_view.Clickable = true;
_view.LongClickable = true;

UpdateSyncCanExecute();
UpdateCommandParameter();
UpdateLongCommandParameter();
UpdateIsEnabled();

_view.Touch += _view_Touch;
_view.Touch += _view_Touch;
}

protected override void OnDetachedOverride()
Expand Down
2 changes: 1 addition & 1 deletion AiForms.Effects.Droid/FeedbackPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void UpdateEnableSound()
_enableSound = GetEnableSound();
}

void UpdateIsEnabled()
protected void UpdateIsEnabled()
{
if(!IsClickable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,27 @@ namespace AiEffects.TestApp.ViewModels
public class ForInvestigationViewModel
{
public ReactivePropertySlim<Color> BackColor { get; } = new ReactivePropertySlim<Color>();
public List<string> ItemsSource { get; set; } = new List<string>();


public ReactiveCommand GoCommand { get; set; } = new ReactiveCommand();

public ReactiveCommand CellCommand { get; set; } = new ReactiveCommand();
public ReactiveCommand HogeCommand { get; set; }

public ReactivePropertySlim<bool> CanExecute { get; } = new ReactivePropertySlim<bool>();

public ForInvestigationViewModel(INavigationService navigationService)
{
BackColor.Value = Color.Blue;

ItemsSource.Add("ABC");
ItemsSource.Add("CC");
ItemsSource.Add("DD");
ItemsSource.Add("EEE");
ItemsSource.Add("FFF");
ItemsSource.Add("GADSFS");
ItemsSource.Add("HDSGDG");
ItemsSource.Add("IGDG");
ItemsSource.Add("YYUY");
ItemsSource.Add("XXX");


var toggle = false;
GoCommand.Subscribe(async _ =>
{
//BackColor.Value = toggle ? Color.Blue : Color.Green;
//toggle = !toggle;
//await navigationService.NavigateAsync("MainPage",null,true);
await navigationService.GoBackAsync();
CanExecute.Value = !CanExecute.Value;
});

CellCommand.Subscribe(_ =>
HogeCommand = CanExecute.ToReactiveCommand();

HogeCommand.Subscribe(_ =>
{
Debug.WriteLine("Cell Tap!");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
x:Name="me">

<ContentPage.ToolbarItems>
<ToolbarItem Text="Go" Clicked="ToolbarItem_Clicked" />
<ToolbarItem Text="Go" Command="{Binding GoCommand}" />
</ContentPage.ToolbarItems>

<CollectionView ItemsSource="{Binding ItemsSource}">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="1" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="{Binding}" ef:AddCommand.Command="{Binding BindingContext.CellCommand,Source={x:Reference me}}" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<ContentView ef:AddCommand.Command="{Binding HogeCommand}"
ef:AddCommand.EffectColor="Red"
ef:AddCommand.SyncCanExecute="True"
BackgroundColor="Blue">
<Label Text="Hoge" />
</ContentView>
</ContentPage>
1 change: 1 addition & 0 deletions nuget/AzurePipelines.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

## Bug fixes

* AddCommand – Fixed AddCommand.SyncCanExecute does not work on Android #53
* Android – Fixed null exception when popping a page. #54
* AddText – Fixed the end of characters is sometimes omitted #48.
* Feedback – Fixed Android OnOverlayTouch crash #49.
Expand Down

0 comments on commit 33b994f

Please sign in to comment.