mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
all editor to be scrollable
This commit is contained in:
parent
c205e0da1b
commit
e4c96dc6d8
1 changed files with 34 additions and 0 deletions
|
@ -4,6 +4,8 @@ using Bit.Android.Controls;
|
||||||
using Bit.App.Controls;
|
using Bit.App.Controls;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Platform.Android;
|
using Xamarin.Forms.Platform.Android;
|
||||||
|
using Android.Text.Method;
|
||||||
|
using Android.Views;
|
||||||
|
|
||||||
[assembly: ExportRenderer(typeof(ExtendedEditor), typeof(ExtendedEditorRenderer))]
|
[assembly: ExportRenderer(typeof(ExtendedEditor), typeof(ExtendedEditorRenderer))]
|
||||||
namespace Bit.Android.Controls
|
namespace Bit.Android.Controls
|
||||||
|
@ -17,6 +19,7 @@ namespace Bit.Android.Controls
|
||||||
var view = (ExtendedEditor)Element;
|
var view = (ExtendedEditor)Element;
|
||||||
|
|
||||||
SetBorder(view);
|
SetBorder(view);
|
||||||
|
SetScrollable();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
@ -44,5 +47,36 @@ namespace Bit.Android.Controls
|
||||||
Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue