dotnet / dotnet/maui

Enable `AdjustPan` and `AdjustResize` behavior for iOS as well as Android

Open
#11,979 3 comments 4 reactions 0 assignees View on GitHub
area-keyboard platform/android platform/ios proposal/underconsideration
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
296

Description

### Description

Currently we have a platform specific for `WindowSoftInputModeAdjust` that maps directly to `Android` level properties.

For the most part, we replicate (or are in the process of replicating) a lot of the keyboard interaction that `Android` provides out of the box to iOS so this API will help round that out.

This will be a way to toggle between the behavior implemented here [here](https://github.com/dotnet/maui/issues/4792) that will "Scroll" your content into view vs just "resizing" the view window.

This property should be available at the Window/Shell level

`AdjustPan` example and why `AdjustResize` is relevant on Android. You'll notice I can't get back to the top Entry field. This is very annoying if you're trying to implement a chat app.

![2022-12-08_15-14-24](https://user-images.githubusercontent.com/5375137/206568968-2dde660a-be88-44bb-bbc7-0c60d4bc05b0.gif)

#### Still to investigate
- This property is a bit more relevant on `Android` because `AdjustPan` shifts the entire window up when the SoftKeyBoard opens. This makes it so fields at the top of your screen are unreachable. If you have content in a `ScrollView` and your window gets panned from the keyboard opening, then you are unable to reach any of the content at the top of your screen. Think about how annoying the current behavior is if someone is implementing a Chat App.

- On iOS we aren't going to be panning the entire window, so the relevance of this property does need to be investigated a little bit more. Is it useful on iOS to resize the view pane vs just scroll the scroll view? Is this scenario mainly relevant if the user doesn't have a ScrollView? What's our solution going to be on iOS if user doesn't have a ScrollView (currently on Xamarin.Forms scrolling the entry into view only works on iOS if your content is inside a ScrollView)

- Is there overlap here with Safe Areas? For example, when the soft keyboard opens does that influence safe area insets at all and we should more be approaching this from a Safe Area standpoint?

- Is this the wrong approach completely and we should just add some properties to `ScrollView`. We could add a property to `ScrollView` to indicate that it should just adjust its insets based on the presence of the keyboard.

### (Public) API Changes

Move current WindowSoftInputModeAdjust platform specific to an attached property that's available to everyone!

### Usage Scenarios

- keyboard + accessory view + dictionary

### Window Attached Property

#### Window property (maybe)

```C#
window.WindowSoftInputModeAdjust="AdjustPan"
```
#### Non-Shell Scenarios (also should work if using shell)

```XAML

```

#### Shell property
Shell has these types of properties already so for consistency we should expose this through a shell attached property as well

```XAML

```

#### TextInput property?
Maybe this is a property you'd want to configure on each input field?

```XAML

```

### Backward Compatibility

N/A

### Difficulty

Medium

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests; start by reviewing the existing platform-specific WindowSoftInputModeAdjust implementation and the behavior described in issue #4792. Resolve whether iOS should resize the view, adjust safe-area insets, or rely on ScrollView behavior, then define the supported Window/Shell attached-property API. Done means the design and implementation scope are settled for both iOS and Android.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.