Skip to content

Commit

Permalink
FormView and IValidatable Update
Browse files Browse the repository at this point in the history
  • Loading branch information
enisn committed Jul 15, 2018
1 parent 87cd1c4 commit 45ceea1
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<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.0.0.5</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainActivity.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.1.0.637273" />
<PackageReference Include="Xamarin.Forms.InputKit">
<Version>2.0.0.5</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
Expand Down
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.0.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
35 changes: 32 additions & 3 deletions FormViewSample.InputKit/FormViewSample.InputKit/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,64 @@
x:Class="FormViewSample.InputKit.MainPage"
BackgroundColor="WhiteSmoke">

<ContentPage.BindingContext>
<local:MainViewModel/>
</ContentPage.BindingContext>
<ContentPage.Content>
<StackLayout Padding="30">
<Label Text="You can see FormView Below:"/>
<input:FormView>
<BoxView HeightRequest="1" Color="LightGray" />
<input:FormView IsValidated="{Binding IsValidated}">

<input:AdvancedEntry
Text="{Binding Email}"
IsRequired="True"
Title="Place your email below:"
Annotation="Email"
Placeholder="[email protected]"
AnnotationColor="Accent"
ValidationMessage="Please type a valid email address"
IsRequired="True"
IconImage="ic_email_black_24dp.png"
MinLength="10"
MaxLength="50"
/>

<input:AdvancedEntry
Text="{Binding NameSurname}"
IsRequired="True"
Title="Place your name below:"
Annotation="NameSurname"
Placeholder="John Doe"
AnnotationColor="Accent"
ValidationMessage="Please type your name correctly"
IsRequired="True"
IconImage="ic_account_circle_black_24dp.png"
MinLength="5"
MaxLength="30"
/>

<input:AdvancedEntry
Text="{Binding Phone}"
IsRequired="True"
Title="Place your phone number below:"
Annotation="Phone"
Placeholder="5439998877"
AnnotationColor="Accent"
ValidationMessage="Please type your phone number correctly"
IconImage="ic_account_circle_black_24dp.png"
MaxLength="10"
/>

<input:CheckBox IsRequired="True" Type="Check" Text="I Accept User Agreement" />

<Label Text="Choose your subscription type:" />
<input:RadioButtonGroupView IsRequired="True" SelectedItemChanged="RadioButtonGroupView_SelectedItemChanged">
<input:RadioButton Text="Free" />
<input:RadioButton Text="Bronze" />
<input:RadioButton Text="Gold" />
<input:RadioButton Text="Platinium" />
</input:RadioButtonGroupView>

<Button Command="{Binding SubmitCommand}" Margin="0,20" Text="Submit" BackgroundColor="Accent" CornerRadius="20" TextColor="White" />
</input:FormView>
</StackLayout>
</ContentPage.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ public MainPage()
{
InitializeComponent();
}
}

private void RadioButtonGroupView_SelectedItemChanged(object sender, EventArgs e)
{

}
}
}
42 changes: 42 additions & 0 deletions FormViewSample.InputKit/FormViewSample.InputKit/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;
using Xamarin.Forms;

namespace FormViewSample.InputKit
{
public class MainViewModel : INotifyPropertyChanged
{
private string _nameSurname;
private string _email;
private string _phone;

public MainViewModel()
{
SubmitCommand = new Command(Submit);
}
public Command SubmitCommand { get; set; }
public bool IsValidated { get; set; }
public string NameSurname { get => _nameSurname; set { _nameSurname = value; OnPropertyChanged(); } }
public string Email { get => _email; set { _email = value; OnPropertyChanged(); } }
public string Phone { get => _phone; set { _phone = value; OnPropertyChanged(); } }

async void Submit()
{
if (!IsValidated)
{
await Application.Current.MainPage.DisplayAlert("", "You must fill all areas correctly!", "OK");
}

//DO SOME STUFFS HERE
}


#region INotifyPropertyChanged Implementation
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName]string propName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
#endregion
}
}
3 changes: 2 additions & 1 deletion 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.0.0.2</version>
<version>2.0.0.6</version>

<!-- Authors contain text that appears directly on the gallery -->
<authors>Enis Necipoglu</authors>
Expand Down Expand Up @@ -125,5 +125,6 @@
<file src="InputKit\bin\Release\xamarin.watchos10\Plugin.InputKit.dll" target="lib\xamarin.watchos10\Plugin.InputKit.dll" />
<file src="InputKit\bin\Release\xamarin.watchos10\Plugin.InputKit.xml" target="lib\xamarin.watchos10\Plugin.InputKit.xml" />


</files>
</package>
3 changes: 2 additions & 1 deletion InputKit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugin", "Plugin", "{12D598
ProjectSection(SolutionItems) = preProject
InputKit.nuspec = InputKit.nuspec
Pack.bat = Pack.bat
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.InputKit.Android", "Sample.InputKit\Sample.InputKit.Android\Sample.InputKit.Android.csproj", "{BB4B11C4-B014-4D02-A014-5A29F694A392}"
Expand All @@ -23,7 +24,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormViewSample.InputKit.And
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormViewSample.InputKit.iOS", "FormViewSample.InputKit\FormViewSample.InputKit.iOS\FormViewSample.InputKit.iOS.csproj", "{7266B8FF-71CB-4EC5-9F2C-891BF323DA63}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormViewSample.InputKit", "FormViewSample.InputKit\FormViewSample.InputKit\FormViewSample.InputKit.csproj", "{15D16C2C-2F95-467B-B466-6CA34F6FCF70}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FormViewSample.InputKit", "FormViewSample.InputKit\FormViewSample.InputKit\FormViewSample.InputKit.csproj", "{15D16C2C-2F95-467B-B466-6CA34F6FCF70}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1 change: 1 addition & 0 deletions InputKit/InputKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<None Remove="Shared\Controls\AdvancedEntry.cs" />
<None Remove="Shared\Controls\AdvancedSlider.cs" />
<None Remove="Shared\Controls\CheckBox.cs" />
<None Remove="Shared\Controls\EmptyEntry.cs" />
<None Remove="Shared\Controls\FormView.cs" />
<None Remove="Shared\Controls\IconView.cs" />
<None Remove="Shared\Controls\RadioButton.cs" />
Expand Down
2 changes: 1 addition & 1 deletion InputKit/Shared/Configuration/GlobalSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class GlobalSetting : INotifyPropertyChanged
/// <summary>
/// If control has a corner radius, this is it.
/// </summary>
public double CornerRadius { get; set; }
public float CornerRadius { get; set; }
///------------------------------------------------------------------
/// <summary>
/// If control has fontsize, this is it.
Expand Down
Loading

0 comments on commit 45ceea1

Please sign in to comment.