dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

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

Open PureWeen opened 1 year ago

PureWeen commented 1 year ago

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 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

Still to investigate

(Public) API Changes

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

Usage Scenarios

Window Attached Property

Window property (maybe)

    window.WindowSoftInputModeAdjust="AdjustPan"

Non-Shell Scenarios (also should work if using shell)

<ContentPage Window.WindowSoftInputModeAdjust="AdjustPan">

Shell property

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

<ContentPage Shell.WindowSoftInputModeAdjust="AdjustPan">

TextInput property?

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

<Entry Window.WindowSoftInputModeAdjust="AdjustPan">

Backward Compatibility

N/A

Difficulty

Medium

PureWeen commented 1 year ago

Related https://github.com/dotnet/maui/issues/16398

tj-devel709 commented 3 weeks ago

One way we can do this, in the case where we have a non-scrollView at the top of the ContentPage, is to replace the ContentPage's Subview with a scrollview that has the size of the original ContentPage's Subview minus the size of the keyboard. In my example, the animations may be able to be improved as it looks pretty choppy, but functional:

https://github.com/user-attachments/assets/f81f021a-34d1-4570-921c-d7c34ea74207

By doing this, we are able to still access the full page including that top label and still access things below the editor.

Branch with these changes - https://github.com/dotnet/maui/tree/dev/TJ/keyboardScroll-Inset-Improvements_1_AdjustResize