mirror of
https://github.com/bitwarden/mobile
synced 2025-12-14 23:33:34 +00:00
* Fixed long secure notes edition scrolling when focused issue (#1257) * Improved fix long secure notes edition scrolling when focused issue to not use a new editor custom renderer but an effect (#1257) * Fixed long editor, on text and notes on send when scrolling when focused issue (#1257)
This commit is contained in:
committed by
GitHub
parent
a07ef1a1d6
commit
b8c1107c94
@@ -0,0 +1,43 @@
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Behaviors
|
||||
{
|
||||
/// <summary>
|
||||
/// This behavior prevents the Editor to be automatically scrolled to the bottom on focus.
|
||||
/// This is needed due to this Xamarin Forms issue: https://github.com/xamarin/Xamarin.Forms/issues/2233
|
||||
/// </summary>
|
||||
public class EditorPreventAutoBottomScrollingOnFocusedBehavior : Behavior<Editor>
|
||||
{
|
||||
public static readonly BindableProperty ParentScrollViewProperty
|
||||
= BindableProperty.Create(nameof(ParentScrollView), typeof(ScrollView), typeof(EditorPreventAutoBottomScrollingOnFocusedBehavior));
|
||||
|
||||
public ScrollView ParentScrollView
|
||||
{
|
||||
get => (ScrollView)GetValue(ParentScrollViewProperty);
|
||||
set => SetValue(ParentScrollViewProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnAttachedTo(Editor bindable)
|
||||
{
|
||||
base.OnAttachedTo(bindable);
|
||||
|
||||
bindable.Focused += OnFocused;
|
||||
}
|
||||
|
||||
private void OnFocused(object sender, FocusEventArgs e)
|
||||
{
|
||||
if (DeviceInfo.Platform.Equals(DevicePlatform.iOS) && ParentScrollView != null)
|
||||
{
|
||||
ParentScrollView.ScrollToAsync(ParentScrollView.ScrollX, ParentScrollView.ScrollY, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(Editor bindable)
|
||||
{
|
||||
bindable.Focused -= OnFocused;
|
||||
|
||||
base.OnDetachingFrom(bindable);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user