mirror of
https://github.com/bitwarden/mobile.git
synced 2024-11-25 12:05:59 +01: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:
parent
a07ef1a1d6
commit
b8c1107c94
@ -124,6 +124,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Resources\" />
|
<Folder Include="Resources\" />
|
||||||
|
<Folder Include="Behaviors\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -411,4 +412,7 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Behaviors\" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/App/Effects/ScrollEnabledEffect.cs
Normal file
25
src/App/Effects/ScrollEnabledEffect.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Effects
|
||||||
|
{
|
||||||
|
public class ScrollEnabledEffect : RoutingEffect
|
||||||
|
{
|
||||||
|
public static readonly BindableProperty IsScrollEnabledProperty =
|
||||||
|
BindableProperty.CreateAttached("IsScrollEnabled", typeof(bool), typeof(ScrollEnabledEffect), true);
|
||||||
|
|
||||||
|
public static bool GetIsScrollEnabled(BindableObject view)
|
||||||
|
{
|
||||||
|
return (bool)view.GetValue(IsScrollEnabledProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetIsScrollEnabled(BindableObject view, bool value)
|
||||||
|
{
|
||||||
|
view.SetValue(IsScrollEnabledProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScrollEnabledEffect()
|
||||||
|
: base("Bitwarden.ScrollEnabledEffect")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,8 @@
|
|||||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
xmlns:u="clr-namespace:Bit.App.Utilities"
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
xmlns:controls="clr-namespace:Bit.App.Controls"
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
|
xmlns:behaviors="clr-namespace:Bit.App.Behaviors"
|
||||||
|
xmlns:effects="clr-namespace:Bit.App.Effects"
|
||||||
x:DataType="pages:SendAddEditPageViewModel"
|
x:DataType="pages:SendAddEditPageViewModel"
|
||||||
x:Name="_page"
|
x:Name="_page"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
@ -201,7 +203,15 @@
|
|||||||
Text="{Binding Send.Text.Text}"
|
Text="{Binding Send.Text.Text}"
|
||||||
IsEnabled="{Binding SendEnabled}"
|
IsEnabled="{Binding SendEnabled}"
|
||||||
StyleClass="box-value"
|
StyleClass="box-value"
|
||||||
Margin="{Binding EditorMargins}" />
|
Margin="{Binding EditorMargins}"
|
||||||
|
effects:ScrollEnabledEffect.IsScrollEnabled="false" >
|
||||||
|
<Editor.Behaviors>
|
||||||
|
<behaviors:EditorPreventAutoBottomScrollingOnFocusedBehavior ParentScrollView="{x:Reference _scrollView}" />
|
||||||
|
</Editor.Behaviors>
|
||||||
|
<Editor.Effects>
|
||||||
|
<effects:ScrollEnabledEffect />
|
||||||
|
</Editor.Effects>
|
||||||
|
</Editor>
|
||||||
<BoxView
|
<BoxView
|
||||||
StyleClass="box-row-separator"
|
StyleClass="box-row-separator"
|
||||||
IsVisible="{Binding ShowEditorSeparators}" />
|
IsVisible="{Binding ShowEditorSeparators}" />
|
||||||
@ -443,7 +453,15 @@
|
|||||||
Text="{Binding Send.Notes}"
|
Text="{Binding Send.Notes}"
|
||||||
IsEnabled="{Binding SendEnabled}"
|
IsEnabled="{Binding SendEnabled}"
|
||||||
StyleClass="box-value"
|
StyleClass="box-value"
|
||||||
Margin="{Binding EditorMargins}" />
|
Margin="{Binding EditorMargins}"
|
||||||
|
effects:ScrollEnabledEffect.IsScrollEnabled="false" >
|
||||||
|
<Editor.Behaviors>
|
||||||
|
<behaviors:EditorPreventAutoBottomScrollingOnFocusedBehavior ParentScrollView="{x:Reference _scrollView}" />
|
||||||
|
</Editor.Behaviors>
|
||||||
|
<Editor.Effects>
|
||||||
|
<effects:ScrollEnabledEffect />
|
||||||
|
</Editor.Effects>
|
||||||
|
</Editor>
|
||||||
<BoxView
|
<BoxView
|
||||||
StyleClass="box-row-separator"
|
StyleClass="box-row-separator"
|
||||||
IsVisible="{Binding ShowEditorSeparators}" />
|
IsVisible="{Binding ShowEditorSeparators}" />
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
xmlns:u="clr-namespace:Bit.App.Utilities"
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
xmlns:controls="clr-namespace:Bit.App.Controls"
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
|
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
|
||||||
|
xmlns:behaviors="clr-namespace:Bit.App.Behaviors"
|
||||||
|
xmlns:effects="clr-namespace:Bit.App.Effects"
|
||||||
x:DataType="pages:AddEditPageViewModel"
|
x:DataType="pages:AddEditPageViewModel"
|
||||||
x:Name="_page"
|
x:Name="_page"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
@ -584,8 +586,16 @@
|
|||||||
<Editor
|
<Editor
|
||||||
x:Name="_notesEditor"
|
x:Name="_notesEditor"
|
||||||
AutoSize="TextChanges"
|
AutoSize="TextChanges"
|
||||||
Text="{Binding Cipher.Notes}"
|
StyleClass="box-value"
|
||||||
StyleClass="box-value" />
|
effects:ScrollEnabledEffect.IsScrollEnabled="false"
|
||||||
|
Text="{Binding Cipher.Notes}">
|
||||||
|
<Editor.Behaviors>
|
||||||
|
<behaviors:EditorPreventAutoBottomScrollingOnFocusedBehavior ParentScrollView="{x:Reference _scrollView}" />
|
||||||
|
</Editor.Behaviors>
|
||||||
|
<Editor.Effects>
|
||||||
|
<effects:ScrollEnabledEffect />
|
||||||
|
</Editor.Effects>
|
||||||
|
</Editor>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowNotesSeparator}" />
|
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowNotesSeparator}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
25
src/iOS.Core/Effects/ScrollEnabledEffect.cs
Normal file
25
src/iOS.Core/Effects/ScrollEnabledEffect.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Bit.iOS.Core.Effects;
|
||||||
|
using UIKit;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
using Xamarin.Forms.Platform.iOS;
|
||||||
|
|
||||||
|
[assembly: ResolutionGroupName("Bitwarden")]
|
||||||
|
[assembly: ExportEffect(typeof(ScrollEnabledEffect), "ScrollEnabledEffect")]
|
||||||
|
namespace Bit.iOS.Core.Effects
|
||||||
|
{
|
||||||
|
public class ScrollEnabledEffect : PlatformEffect
|
||||||
|
{
|
||||||
|
protected override void OnAttached()
|
||||||
|
{
|
||||||
|
// this can be for any view that inherits from UIScrollView like UITextView.
|
||||||
|
if (Element != null && Control is UIScrollView scrollView)
|
||||||
|
{
|
||||||
|
scrollView.ScrollEnabled = App.Effects.ScrollEnabledEffect.GetIsScrollEnabled(Element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDetached()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -137,6 +137,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Resources\" />
|
<Folder Include="Resources\" />
|
||||||
|
<Folder Include="Effects\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Constants.cs" />
|
<Compile Include="Constants.cs" />
|
||||||
@ -189,6 +190,7 @@
|
|||||||
<Compile Include="Views\SwitchTableViewCell.cs" />
|
<Compile Include="Views\SwitchTableViewCell.cs" />
|
||||||
<Compile Include="Views\Toast.cs" />
|
<Compile Include="Views\Toast.cs" />
|
||||||
<Compile Include="Renderers\SelectableLabelRenderer.cs" />
|
<Compile Include="Renderers\SelectableLabelRenderer.cs" />
|
||||||
|
<Compile Include="Effects\ScrollEnabledEffect.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\App\App.csproj">
|
<ProjectReference Include="..\App\App.csproj">
|
||||||
|
Loading…
Reference in New Issue
Block a user