Open PureWeen opened 1 year 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
Description
Currently we have a platform specific for
WindowSoftInputModeAdjust
that maps directly toAndroid
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 whyAdjustResize
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.Still to investigate
This property is a bit more relevant on
Android
becauseAdjustPan
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 aScrollView
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 toScrollView
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
Window Attached Property
Window property (maybe)
Non-Shell Scenarios (also should work if using shell)
Shell property
Shell has these types of properties already so for consistency we should expose this through a shell attached property as well
TextInput property?
Maybe this is a property you'd want to configure on each input field?
Backward Compatibility
N/A
Difficulty
Medium