Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
masonyc committed Apr 23, 2019
2 parents 283782a + 2cb1897 commit 0982a16
Showing 1 changed file with 47 additions and 10 deletions.
57 changes: 47 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
# Xamarin.KeyboardHelper

This plugin includes:
- Xamarin.EnableKeyboardEffect -- allows user to show/hide softkeyboard on Android/iOS platform in Xamarin.Forms
- KeyboardEnableEffect -- allows user to show/hide softkeyboard on Android/iOS platform in Xamarin.Forms
- SoftKeyboardService -- check entry's IsAcceptingText status

Note: This repo had a name change from Xamarin.EnableKeyboardEffect to Xamarin.KeyboardHelper. Please download a new version of nuget below.

# Building Status

<img src="https://ci.appveyor.com/api/projects/status/github/masonyc/Xamarin.EnableKeyboardEffect?svg=true" width="100">
<img src="https://ci.appveyor.com/api/projects/status/github/masonyc/Xamarin.KeyboardHelper?svg=true" width="100">

# Setup

- Need Xamarin.Forms version 3 or above
- `Xamarin.EnableKeyboardEffect` Available on NuGet: https://www.nuget.org/packages/Xamarin.EnableKeyboardEffect
- `Xamarin.KeyboardHelper` Available on NuGet: https://www.nuget.org/packages/Xamarin.KeyboardHelper/2.0.0
- Install into your platform-specific projects (iOS/Android), and any .NET Standard 2.0 projects required for your app.
- Add ```
xmlns:effects="clr-namespace:Xamarin.EnableKeyboardEffect;assembly=Xamarin.EnableKeyboardEffect" ```at the top of the xaml file
xmlns:effects="clr-namespace:Xamarin.KeyboardHelper;assembly=Xamarin.KeyboardHelper" ```at the top of the xaml file

## Platform Support

Expand All @@ -25,6 +27,8 @@ This plugin includes:
|Xamarin.iOS|Yes|iOS 8+| |
|Xamarin.Android|Yes|API 16+|Project should [target Android framework 9.0+](https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/android-api-levels?tabs=vswin#framework)|

# KeyboardEnableEffect

## For Android

```csharp
Expand All @@ -34,7 +38,7 @@ This plugin includes:
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

//need this line to init effect in android
Xamarin.EnableKeyboardEffect.Platform.Droid.Effects.Init(this);
Xamarin.KeyboardHelper.Platform.Droid.Effects.Init(this);

LoadApplication(new App());
}
Expand All @@ -48,19 +52,19 @@ This plugin includes:
global::Xamarin.Forms.Forms.Init();

//need this line to init effect in iOS
Xamarin.EnableKeyboardEffect.Platform.iOS.Effects.Init();
Xamarin.KeyboardHelper.Platform.iOS.Effects.Init();

LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
```

# Usage
## Usage

### Show soft keyboard

```csharp
<Entry Text="Show Keyboard" effects:EnableKeyboardEffect.EnableKeyboard="True">
<Entry Text="Show Keyboard" effects:KeyboardEffect.EnableKeyboard="True">
<Entry.Effects>
<effects:KeyboardEnableEffect/>
</Entry.Effects>
Expand All @@ -70,7 +74,7 @@ This plugin includes:
### Hide soft keyboard

```csharp
<Entry Text="Hide Keyboard" effects:EnableKeyboardEffect.EnableKeyboard="False">
<Entry Text="Hide Keyboard" effects:KeyboardEffect.EnableKeyboard="False">
<Entry.Effects>
<effects:KeyboardEnableEffect/>
</Entry.Effects>
Expand All @@ -80,13 +84,46 @@ This plugin includes:
### Bind boolean property to effect

```csharp
<Entry Text="Toggle Keyboard" effects:EnableKeyboardEffect.EnableKeyboard="{Binding BooleanBinding}">
<Entry Text="Toggle Keyboard" effects:KeyboardEffect.EnableKeyboard="{Binding BooleanBinding}">
<Entry.Effects>
<effects:KeyboardEnableEffect/>
</Entry.Effects>
</Entry>
```

# SoftKeyboardService

## Under Page.xaml.cs or view model
```csharp
public MainPage()
{
InitializeComponent();

this.Appearing += MainPage_Appearing;
this.Disappearing += MainPage_Disappearing;
}

private void MainPage_Disappearing(object sender, EventArgs e)
{
SoftKeyboard.Current.VisibilityChanged -= Current_VisibilityChanged;
}

private void MainPage_Appearing(object sender, EventArgs e)
{
SoftKeyboard.Current.VisibilityChanged += Current_VisibilityChanged;
}

private void Current_VisibilityChanged(SoftKeyboardEventArgs e)
{
if(e.IsVisible){
// do your things
}
else{
// do your things
}
}
```

# Demo

### Android
Expand Down

0 comments on commit 0982a16

Please sign in to comment.