1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-10 01:08:23 +02:00

all editor to be scrollable

This commit is contained in:
Kyle Spearrin 2017-09-12 15:41:18 -04:00
parent c205e0da1b
commit e4c96dc6d8

View File

@ -4,6 +4,8 @@ using Bit.Android.Controls;
using Bit.App.Controls;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Android.Text.Method;
using Android.Views;
[assembly: ExportRenderer(typeof(ExtendedEditor), typeof(ExtendedEditorRenderer))]
namespace Bit.Android.Controls
@ -17,6 +19,7 @@ namespace Bit.Android.Controls
var view = (ExtendedEditor)Element;
SetBorder(view);
SetScrollable();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
@ -44,5 +47,36 @@ namespace Bit.Android.Controls
Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
}
}
private void SetScrollable()
{
// While scrolling inside Editor stop scrolling parent view.
Control.OverScrollMode = OverScrollMode.Always;
Control.ScrollBarStyle = ScrollbarStyles.InsideInset;
Control.SetOnTouchListener(new EditorTouchListener());
// For Scrolling in Editor innner area
Control.VerticalScrollBarEnabled = true;
Control.MovementMethod = ScrollingMovementMethod.Instance;
Control.ScrollBarStyle = ScrollbarStyles.InsideInset;
// Force scrollbars to be displayed
var arr = Control.Context.Theme.ObtainStyledAttributes(new int[0]);
InitializeScrollbars(arr);
arr.Recycle();
}
public class EditorTouchListener : Java.Lang.Object, IOnTouchListener
{
public bool OnTouch(global::Android.Views.View v, MotionEvent e)
{
v.Parent?.RequestDisallowInterceptTouchEvent(true);
if((e.Action & MotionEventActions.Up) != 0 && (e.ActionMasked & MotionEventActions.Up) != 0)
{
v.Parent?.RequestDisallowInterceptTouchEvent(false);
}
return false;
}
}
}
}