Skip to content

Commit

Permalink
Improvements & Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
enisn committed Aug 8, 2018
1 parent d02c27f commit ff92d3f
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 22 deletions.
17 changes: 15 additions & 2 deletions InputKit.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<id>Xamarin.Forms.InputKit</id>

<!-- The package version number that is used when resolving dependencies -->
<version>2.2.1</version>
<version>2.2.2</version>

<!-- Authors contain text that appears directly on the gallery -->
<authors>Enis Necipoglu</authors>
Expand All @@ -26,14 +26,27 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>

<!-- Any details about this particular release -->
<releaseNotes>CheckBox Color property fixed, CheckBox CommandParameter added. Some SelectionView improvements.</releaseNotes>
<releaseNotes>Highly dropdown bug fixed</releaseNotes>

<title>Common controls mostly required</title>
<summary>
Checkbox, Radio Button,Dropdown, Advanced Entry, Advanced Slider included this package
</summary>

<description>

v.2.2.2
Dropdown BidnableProperties added,
Dropdown selectedIndex bug fixed.
CanExecute check added all commands
CommandParameter added in AdvancedEntry
CommandParameter added in RadioButton
Checkbox unwanted shadow bug fixed
SelectionView TextColor fixed
iOS Dropdown improvements.

Dropdown will be popover on iOS

v.2.2.0
Controls in this package are fully bindable and ready to use.
AdvancedEntry Completed event added,
Expand Down
9 changes: 4 additions & 5 deletions InputKit/Platforms/iOS/MenuEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ void OnPopupRequest(View view)

RootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController;

UIAlertController actionSheetAlert = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet);
UIAlertController actionSheetAlert = UIAlertController.Create(null, null, UIAlertControllerStyle.Alert);

int i = 0;
foreach (var item in Effect.Parent.ItemsSource)
//int i = 0;
for (int i = 0; i < Effect.Parent.ItemsSource.Count; i++)
{
actionSheetAlert.AddAction(UIAlertAction.Create(item.ToString(), UIAlertActionStyle.Default, (action) => Effect.Parent.InvokeItemSelected(item.ToString(),i)));
i++;
actionSheetAlert.AddAction(UIAlertAction.Create(Effect.Parent.ItemsSource[i].ToString(), UIAlertActionStyle.Default, (action) => Effect.Parent.InvokeItemSelected(Effect.Parent.ItemsSource[i].ToString(),i)));
}

actionSheetAlert.AddAction(UIAlertAction.Create(UIAlertControllerCancelText, UIAlertActionStyle.Destructive, null));
Expand Down
13 changes: 11 additions & 2 deletions InputKit/Shared/Controls/AdvancedEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Input;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
Expand Down Expand Up @@ -60,9 +59,14 @@ public AdvancedEntry()
};

txtInput.TextChanged += TxtInput_TextChanged;
txtInput.Completed += (s, args) => { CompletedCommand?.Execute(s); Completed?.Invoke(this, new EventArgs()); FocusNext(); };
txtInput.Completed += (s, args) => { ExecuteCommand(); Completed?.Invoke(this, new EventArgs()); FocusNext(); };
imgWarning.IsVisible = this.IsRequired;
}
void ExecuteCommand()
{
if (CompletedCommand?.CanExecute(CommandParameter ?? this) ?? false)
CompletedCommand?.Execute(CommandParameter ?? this);
}
#region Not Implemented
public bool IsSelected { get => false; set { } }
public object Value { get; set; }
Expand Down Expand Up @@ -300,6 +304,10 @@ public bool IsAnnotated
/// Executed when entry completed.
/// </summary>
public ICommand CompletedCommand { get; set; }
/// <summary>
/// Parameter to send with CompletedCommand
/// </summary>
public object CommandParameter { get => GetValue(CommandParameterProperty); set => SetValue(CommandParameterProperty, value); }
//--------------------------------------------------------------------------------------------------------------------------------------------------
#region BindableProperties
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
Expand All @@ -317,6 +325,7 @@ public bool IsAnnotated
public static readonly BindableProperty IgnoreValidationMessageProperty = BindableProperty.Create(nameof(IgnoreValidationMessage), typeof(bool), typeof(AdvancedEntry), false, propertyChanged: (bo, ov, nv) => (bo as AdvancedEntry).DisplayValidation());
public static readonly BindableProperty IsRequiredProperty = BindableProperty.Create(nameof(IsRequired), typeof(bool), typeof(AdvancedEntry), false, propertyChanged: (bo, ov, nv) => (bo as AdvancedEntry).UpdateWarning());
public static readonly BindableProperty PlaceholderColorProperty = BindableProperty.Create(nameof(PlaceholderColor), typeof(Color), typeof(AdvancedEntry), Color.LightGray, propertyChanged: (bo, ov, nv) => (bo as AdvancedEntry).PlaceholderColor = (Color)nv);
public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create(nameof(CommandParameter), typeof(object), typeof(AdvancedEntry), propertyChanged: (bo, ov, nv) => (bo as AdvancedEntry).CommandParameter = nv);
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
#endregion
//--------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
12 changes: 9 additions & 3 deletions InputKit/Shared/Controls/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class CheckBox : StackLayout, IValidatable
};


Frame boxBackground = new Frame { Padding = 0, CornerRadius = GlobalSetting.CornerRadius, InputTransparent = true, HeightRequest = GlobalSetting.Size, WidthRequest = GlobalSetting.Size, BackgroundColor = GlobalSetting.BackgroundColor, MinimumWidthRequest = 35, BorderColor = GlobalSetting.BorderColor, VerticalOptions = LayoutOptions.CenterAndExpand };
Frame boxBackground = new Frame { Padding = 0, CornerRadius = GlobalSetting.CornerRadius, InputTransparent = true, HeightRequest = GlobalSetting.Size, WidthRequest = GlobalSetting.Size, BackgroundColor = GlobalSetting.BackgroundColor, MinimumWidthRequest = 35, BorderColor = GlobalSetting.BorderColor, VerticalOptions = LayoutOptions.CenterAndExpand, HasShadow = false };
BoxView boxSelected = new BoxView { IsVisible = false, HeightRequest = GlobalSetting.Size * .60, WidthRequest = GlobalSetting.Size * .60, Color = GlobalSetting.Color, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center };
Label lblSelected = new Label { Text = "✓", Margin = new Thickness(0, -1, 0, 0), FontSize = GlobalSetting.Size * .72, FontAttributes = FontAttributes.Bold, IsVisible = false, TextColor = GlobalSetting.Color, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand };
Label lblOption = new Label { VerticalOptions = LayoutOptions.CenterAndExpand, FontSize = GlobalSetting.FontSize, TextColor = GlobalSetting.TextColor, FontFamily = GlobalSetting.FontFamily };
Expand All @@ -44,9 +44,15 @@ public CheckBox()
this.Children.Add(lblOption);
this.GestureRecognizers.Add(new TapGestureRecognizer
{
Command = new Command(() => { if (IsDisabled) return; IsChecked = !IsChecked; CheckChanged?.Invoke(this, new EventArgs()); CheckChangedCommand?.Execute(CommandParameter ?? this); ValidationChanged?.Invoke(this, new EventArgs()); }),
Command = new Command(() => { if (IsDisabled) return; IsChecked = !IsChecked; ExecuteCommand(); CheckChanged?.Invoke(this, new EventArgs()); ValidationChanged?.Invoke(this, new EventArgs()); }),
});
}

void ExecuteCommand()
{
if (CheckChangedCommand?.CanExecute(CommandParameter ?? this) ?? false)
CheckChangedCommand?.Execute(CommandParameter ?? this);
}
async void Animate()
{
try
Expand Down Expand Up @@ -144,7 +150,7 @@ public Color Color
/// <summary>
/// Border color of around CheckBox
/// </summary>
public Color BorderColor { get => (Color)GetValue(BorderColorProperty); set => SetValue(BorderColorProperty,value); }
public Color BorderColor { get => (Color)GetValue(BorderColorProperty); set => SetValue(BorderColorProperty, value); }
/// <summary>
/// WARNING! : If you set this as required, user must set checked this control to be validated!
/// </summary>
Expand Down
11 changes: 9 additions & 2 deletions InputKit/Shared/Controls/Dropdown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ private void Menu_Requested(object sender, EventArgs e)
}
private void Menu_Item_Selected(string item, int index)
{
SelectedItem = ItemsSource[index];
try
{
SelectedItem = ItemsSource[index];
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
}
public IList ItemsSource
{
Expand Down Expand Up @@ -135,7 +142,7 @@ public void DisplayValidation()
public static readonly BindableProperty BorderColorProperty = BindableProperty.Create(nameof(BorderColor), typeof(Color), typeof(Dropdown), GlobalSetting.BorderColor, propertyChanged: (bo, ov, nv) => (bo as Dropdown).BorderColor = (Color)nv);
public static readonly BindableProperty PlaceholderProperty = BindableProperty.Create(nameof(Placeholder), typeof(string), typeof(Dropdown), null, propertyChanged: (bo, ov, nv) => (bo as Dropdown).Placeholder = (string)nv);
public static readonly BindableProperty IsRequiredProperty = BindableProperty.Create(nameof(IsRequired), typeof(bool), typeof(Dropdown), false, propertyChanged: (bo, ov, nv) => (bo as Dropdown).IsRequired = (bool)nv);
public static readonly BindableProperty ValidationMessageProperty = BindableProperty.Create(nameof(ValidationMessage), typeof(string), typeof(Dropdown), false, propertyChanged: (bo, ov, nv) => (bo as Dropdown).ValidationMessage = (string)nv);
public static readonly BindableProperty ValidationMessageProperty = BindableProperty.Create(nameof(ValidationMessage), typeof(string), typeof(Dropdown), null, propertyChanged: (bo, ov, nv) => (bo as Dropdown).ValidationMessage = (string)nv);
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
#endregion
}
Expand Down
7 changes: 6 additions & 1 deletion InputKit/Shared/Controls/RadioButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public RadioButtonGroupView()
/// Executes when tapped on RadioButton
/// </summary>
public ICommand SelectedItemChangedCommand { get; set; }
/// <summary>
/// Command Parameter will be sent in SelectedItemChangedCommand
/// </summary>
public object CommandParameter { get; set; }
private void RadioButtonGroupView_ChildrenReordered(object sender, EventArgs e)
{
UpdateAllEvent();
Expand Down Expand Up @@ -73,7 +77,8 @@ void UpdateSelected(object selected, EventArgs e)
SetValue(SelectedIndexProperty, this.SelectedIndex);
OnPropertyChanged(nameof(SelectedIndex));
SelectedItemChanged?.Invoke(this, new EventArgs());
SelectedItemChangedCommand?.Execute(this);
if (SelectedItemChangedCommand?.CanExecute(CommandParameter ?? this) ?? false) ;
SelectedItemChangedCommand?.Execute(CommandParameter ?? this);
ValidationChanged?.Invoke(this, new EventArgs());
}
/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion InputKit/Shared/Controls/SelectionView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Plugin.InputKit.Shared.Abstraction;
using Plugin.InputKit.Shared.Configuration;
using Plugin.InputKit.Shared.Helpers;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -400,7 +401,7 @@ private void UpdateColors()
if (IsSelected)
{
this.BackgroundColor = SelectionColor;
this.TextColor = Color.WhiteSmoke;
this.TextColor = SelectionColor.ToSurfaceColor();
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<td> <img src="http://enisnecipoglu.com/Plugins/inputkit.png" width="120" /></td>
<td>
<h1> Xamarin.Forms.InputKit </h1>
<p><a href="https://github.com/enisn/Xamarin.Forms.InputKit/wiki/CheckBox">CheckBox</a>, Radio Button, Advanced Slider, Dropdows etc. </p>
<p><a href="https://github.com/enisn/Xamarin.Forms.InputKit/wiki/CheckBox">CheckBox</a>, Radio Button, Advanced Entry, Advanced Slider, Dropdown etc. </p>
</td>
</tr>
</table>
Expand All @@ -15,7 +15,7 @@

[![Build status](https://ci.appveyor.com/api/projects/status/st6lcbts9bkhxqub?svg=true)](https://ci.appveyor.com/project/enisn/xamarin-forms-inputkit)
[![CodeFactor](https://www.codefactor.io/repository/github/enisn/xamarin.forms.inputkit/badge)](https://www.codefactor.io/repository/github/enisn/xamarin.forms.inputkit)
<a href="https://www.nuget.org/packages/Xamarin.Forms.InputKit/"><img src="https://img.shields.io/badge/Nuget-2.2.1-blue.svg" /></a>
<a href="https://www.nuget.org/packages/Xamarin.Forms.InputKit/"><img src="https://img.shields.io/badge/Nuget-2.2.2-blue.svg" /></a>
<a href="https://github.com/enisn/Xamarin.Forms.InputKit/wiki"> <img src="https://img.shields.io/badge/Visit-WiKi-orange.svg"/></a>
<p>
<b>Nuget Package Available: </b> : <a href="https://www.nuget.org/packages/Xamarin.Forms.InputKit/"><img source="http://enisnecipoglu.com/Plugins/inputkit.png" height="15" />Xamarin.Forms.InputKit on NuGet</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Plugin.CurrentActivity">
<Version>2.1.0.4</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="3.1.0.637273" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="27.0.2.1" />
<PackageReference Include="Xamarin.Forms.InputKit">
<Version>2.2.2</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.1.0.637273" />
<PackageReference Include="Xamarin.Forms.InputKit">
<Version>2.2.2</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Sample.InputKit/Sample.InputKit/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public partial class App : Application
public App()
{
InitializeComponent();

MainPage = new NavigationPage(new Sample.InputKit.MainPage());
}

Expand Down
4 changes: 1 addition & 3 deletions Sample.InputKit/Sample.InputKit/Sample.InputKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.1.0.637273" />
<PackageReference Include="Xamarin.Forms.InputKit" Version="2.2.2" />
</ItemGroup>

<ItemGroup>
Expand All @@ -22,7 +23,4 @@
<DependentUpon>*.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\InputKit\InputKit.csproj" />
</ItemGroup>
</Project>

0 comments on commit ff92d3f

Please sign in to comment.