Skip to content

Commit

Permalink
fixed AddCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
muak committed Dec 25, 2017
1 parent 10805bd commit 66aa676
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 47 deletions.
20 changes: 7 additions & 13 deletions AiForms.Effects.Droid/AddCommandPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ protected override void OnAttached()
_view.Touch += _view_Touch;

UpdateEnableRipple();


}

protected override void OnDetached()
Expand Down Expand Up @@ -300,12 +298,13 @@ void UpdateLongCommandParameter()

void UpdateEffectColor()
{
var color = AddCommand.GetEffectColor(Element);
if (color == Xamarin.Forms.Color.Default) {
return;
}

if (_useRipple) {
if (_useRipple)
{
var color = AddCommand.GetEffectColor(Element);
if (color == Xamarin.Forms.Color.Default) {
color = Xamarin.Forms.Color.Accent;
}

_ripple?.SetColor(getPressedColorSelector(color.ToAndroid()));
}

Expand All @@ -315,11 +314,6 @@ void UpdateEnableRipple()
{
_useRipple = AddCommand.GetEnableRipple(Element);

var color = AddCommand.GetEffectColor(Element);
if (color == Xamarin.Forms.Color.Default) {
return;
}

if (_useRipple) {
AddRipple();
}
Expand Down
6 changes: 3 additions & 3 deletions AiForms.Effects/AiForms.Effects.nuget.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/Users/kamu/Projects/AiForms.Effects/AiForms.Effects/project.lock.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kamu/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kamu/.nuget/packages/</NuGetPackageFolders>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/Users/kamusoft/Projects/AiForms.Effects/AiForms.Effects/project.lock.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kamusoft/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kamusoft/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">ProjectJson</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.3.1</NuGetToolVersion>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ There are properties of Command and Parameter for tap and long tap.
* LongCommandParameter
* Long Tap Command Parameter
* EffectColor
* background color when to tap.if it doesn't setting,nothing will occur.
* background color when to tap. if it doesn't setting,nothing will occur.
* EnableRipple
* Ripple Effect On/Off (default true,android only)<br>
If you don't have to use ripple effect,it make EnableRipple false.
If you don't have to use ripple effect, it make EnableRipple false.
* EnableSound
* When tapped, whether play system sound effect.(Default false)
* SyncCanExecute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@
<Reference Include="ReactiveProperty">
<HintPath>..\..\..\packages\ReactiveProperty.3.6.0\lib\MonoAndroid\ReactiveProperty.dll</HintPath>
</Reference>
<Reference Include="AiForms.Effects">
<HintPath>..\..\..\packages\AiForms.Effects.1.1.1\lib\MonoAndroid\AiForms.Effects.dll</HintPath>
</Reference>
<Reference Include="AiForms.Effects.Droid">
<HintPath>..\..\..\packages\AiForms.Effects.1.1.1\lib\MonoAndroid\AiForms.Effects.Droid.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AiEffects.Sample\AiEffects.Sample.csproj">
Expand All @@ -162,6 +156,14 @@
<Project>{02E2C54E-9A67-4255-BACC-C035A5529716}</Project>
<Name>AiEffects.TestApp</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\AiForms.Effects\AiForms.Effects.csproj">
<Project>{14FCC004-FC52-4028-A5AE-228AFD6F6222}</Project>
<Name>AiForms.Effects</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\AiForms.Effects.Droid\AiForms.Effects.Droid.csproj">
<Project>{49FC4DB1-A6EB-4670-A3A3-16E877E39D0C}</Project>
<Name>AiForms.Effects.Droid</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AiForms.Effects" version="1.1.1" targetFramework="monoandroid80" />
<package id="CommonServiceLocator" version="1.3" targetFramework="monoandroid70" />
<package id="Microsoft.NETCore.Platforms" version="1.0.1" targetFramework="monoandroid80" />
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="monoandroid80" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,6 @@
<Reference Include="ReactiveProperty.iOS">
<HintPath>..\..\..\packages\ReactiveProperty.3.6.0\lib\Xamarin.iOS10\ReactiveProperty.iOS.dll</HintPath>
</Reference>
<Reference Include="AiForms.Effects">
<HintPath>..\..\..\packages\AiForms.Effects.1.1.1\lib\Xamarin.iOS10\AiForms.Effects.dll</HintPath>
</Reference>
<Reference Include="AiForms.Effects.iOS">
<HintPath>..\..\..\packages\AiForms.Effects.1.1.1\lib\Xamarin.iOS10\AiForms.Effects.iOS.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AiEffects.Sample\AiEffects.Sample.csproj">
Expand All @@ -154,6 +148,14 @@
<Project>{02E2C54E-9A67-4255-BACC-C035A5529716}</Project>
<Name>AiEffects.TestApp</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\AiForms.Effects\AiForms.Effects.csproj">
<Project>{14FCC004-FC52-4028-A5AE-228AFD6F6222}</Project>
<Name>AiForms.Effects</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\AiForms.Effects.iOS\AiForms.Effects.iOS.csproj">
<Project>{7E1357E0-74E7-4FBF-B2AB-052C6A175A9F}</Project>
<Name>AiForms.Effects.iOS</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Contents.json" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AiForms.Effects" version="1.1.1" targetFramework="xamarinios10" />
<package id="CommonServiceLocator" version="1.3" targetFramework="xamarinios10" />
<package id="Microsoft.NETCore.Platforms" version="1.0.1" targetFramework="xamarinios10" />
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="xamarinios10" />
Expand Down
14 changes: 14 additions & 0 deletions Tests/AiEffects.TestApp/AiEffects.TestApp/AiEffects.TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
<DependentUpon>SizeToFitPage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\SizeToFitPageViewModel.cs" />
<Compile Include="Views\ViewCellPage.xaml.cs">
<DependentUpon>ViewCellPage.xaml</DependentUpon>
</Compile>
<Compile Include="ViewModels\ViewCellPageViewModel.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="App.xaml">
Expand Down Expand Up @@ -122,6 +126,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="Views\ViewCellPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Practices.ServiceLocation">
Expand All @@ -134,5 +142,11 @@
<ItemGroup>
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\AiForms.Effects\AiForms.Effects.csproj">
<Project>{14FCC004-FC52-4028-A5AE-228AFD6F6222}</Project>
<Name>AiForms.Effects</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/Users/kamu/Projects/AiForms.Effects/Tests/AiEffects.TestApp/AiEffects.TestApp/project.lock.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kamu/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kamu/.nuget/packages/</NuGetPackageFolders>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">/Users/kamusoft/Projects/AiForms.Effects/Tests/AiEffects.TestApp/AiEffects.TestApp/project.lock.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kamusoft/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kamusoft/.nuget/packages/</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">ProjectJson</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.3.1</NuGetToolVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using Reactive.Bindings;
using Prism.Services;
using System.Collections.ObjectModel;
namespace AiEffects.TestApp.ViewModels
{
public class ViewCellPageViewModel
{
public ReactiveCommand TestCommand { get; } = new ReactiveCommand();
public ObservableCollection<string> ItemsSource { get; } = new ObservableCollection<string>();

public ViewCellPageViewModel(IPageDialogService pageDlg)
{
for (var i = 0; i < 20;i++){
ItemsSource.Add("Name");
}

TestCommand.Subscribe(async _=>{
await pageDlg.DisplayAlertAsync("", "Tap", "OK");
});
}
}
}
5 changes: 5 additions & 0 deletions Tests/AiEffects.TestApp/AiEffects.TestApp/Views/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
</ContentPage.Resources>
<ScrollView>
<StackLayout Spacing="4" Padding="4">
<Label Text="ViewCell" HorizontalOptions="Center" />
<StackLayout Orientation="Horizontal">
<Button AutomationId="ViewCell" Text="ViewCell"
Command="{Binding GotoTestCommand}" CommandParameter="ViewCellPage" />
</StackLayout>
<Label Text="AddCommand" HorizontalOptions="Center" />
<StackLayout Orientation="Horizontal">
<Button AutomationId="AddCommandTapTest" Text="Tap"
Expand Down
29 changes: 29 additions & 0 deletions Tests/AiEffects.TestApp/AiEffects.TestApp/Views/ViewCellPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ef="clr-namespace:AiForms.Effects;assembly=AiForms.Effects"
x:Class="AiEffects.TestApp.Views.ViewCellPage">
<StackLayout Orientation="Vertical">
<ContentView BackgroundColor="Red" HeightRequest="30" VerticalOptions="Start"
ef:AddCommand.On="true"

ef:AddCommand.Command="{Binding TestCommand}"

/>
<ListView ItemsSource="{Binding ItemsSource}" x:Name="listview" VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding}" HorizontalOptions="StartAndExpand" />
<ContentView BackgroundColor="Red" HorizontalOptions="End" WidthRequest="30" HeightRequest="30"
ef:AddCommand.On="true" ef:AddCommand.Command="{Binding BindingContext.TestCommand,Source={x:Reference listview}}" ef:AddCommand.EnableRipple="true"
/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;

using Xamarin.Forms;

namespace AiEffects.TestApp.Views
{
public partial class ViewCellPage : ContentPage
{
public ViewCellPage()
{
InitializeComponent();
}
}
}
1 change: 0 additions & 1 deletion Tests/AiEffects.TestApp/AiEffects.TestApp/project.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"dependencies": {
"AiForms.Effects": "1.1.1",
"CommonServiceLocator": "1.3",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"NETStandard.Library": "1.6.0",
Expand Down
14 changes: 3 additions & 11 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.1.1</version>
<version>1.1.2</version>
<title>AiForms.Effects for Xamarin.Forms</title>
<authors>kamu</authors>
<owners>kamu</owners>
Expand All @@ -12,17 +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 / Size to fit for Label) for iOS/Android</description>
<summary></summary>
<releaseNotes>
## Notes
## Bug fix

Corresponded to Xamarin.Forms 2.5.0 And .NetStandard1.4

## New Feature

* SizeToFit ... Make font size adjusted to fit the Label size.

## Obsoleted

[AddCommand][Android] Done away with the simple effect that is invoked when EnableRipple is false.
* [AddCommand] Isn't executed command when EffectColor is default value on Android.
</releaseNotes>
<tags>Xamarin.Forms Effects Command NumberPikcer LineHeight LineSpacing FlatButton Validation SoundEffect Border TimePicker DatePicker Placeholder Color SizeToFit</tags>
<language>en-US</language>
Expand Down

0 comments on commit 66aa676

Please sign in to comment.