mirror of
https://github.com/bitwarden/android.git
synced 2024-12-19 07:41:52 +03:00
Added reflection service to handle sizerequest for extendedtableview. Remove footer spacing on uitableview ios renderer.
This commit is contained in:
parent
ec419a2306
commit
b9c823b0aa
12 changed files with 121 additions and 3 deletions
|
@ -259,6 +259,7 @@
|
||||||
<Compile Include="Services\KeyStoreStorageService.cs" />
|
<Compile Include="Services\KeyStoreStorageService.cs" />
|
||||||
<Compile Include="MainActivity.cs" />
|
<Compile Include="MainActivity.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Services\ReflectionService.cs" />
|
||||||
<Compile Include="Services\SqlService.cs" />
|
<Compile Include="Services\SqlService.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -122,6 +122,7 @@ namespace Bit.Android
|
||||||
.RegisterType<IPushNotificationListener, PushNotificationListener>(new ContainerControlledLifetimeManager())
|
.RegisterType<IPushNotificationListener, PushNotificationListener>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IAppIdService, AppIdService>(new ContainerControlledLifetimeManager())
|
.RegisterType<IAppIdService, AppIdService>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IPasswordGenerationService, PasswordGenerationService>(new ContainerControlledLifetimeManager())
|
.RegisterType<IPasswordGenerationService, PasswordGenerationService>(new ContainerControlledLifetimeManager())
|
||||||
|
.RegisterType<IReflectionService, ReflectionService>(new ContainerControlledLifetimeManager())
|
||||||
// Repositories
|
// Repositories
|
||||||
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
||||||
|
|
34
src/Android/Services/ReflectionService.cs
Normal file
34
src/Android/Services/ReflectionService.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Bit.App.Abstractions;
|
||||||
|
using Bit.App.Controls;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.Android.Services
|
||||||
|
{
|
||||||
|
public class ReflectionService : IReflectionService
|
||||||
|
{
|
||||||
|
public Func<double, double, SizeRequest> GetVisualElementOnSizeRequest(ExtendedTableView tableView)
|
||||||
|
{
|
||||||
|
var handle = typeof(VisualElement).GetMethod(
|
||||||
|
"OnSizeRequest",
|
||||||
|
BindingFlags.Instance | BindingFlags.NonPublic,
|
||||||
|
null,
|
||||||
|
new Type[] { typeof(double), typeof(double) },
|
||||||
|
null)?.MethodHandle;
|
||||||
|
|
||||||
|
if(!handle.HasValue)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("handle could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var pointer = handle.Value.GetFunctionPointer();
|
||||||
|
if(pointer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("pointer could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Func<double, double, SizeRequest>)Activator.CreateInstance(typeof(Func<double, double, SizeRequest>), tableView, pointer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
src/App/Abstractions/Services/IReflectionService.cs
Normal file
11
src/App/Abstractions/Services/IReflectionService.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using Bit.App.Controls;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Abstractions
|
||||||
|
{
|
||||||
|
public interface IReflectionService
|
||||||
|
{
|
||||||
|
Func<double, double, SizeRequest> GetVisualElementOnSizeRequest(ExtendedTableView tableView);
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,6 +40,7 @@
|
||||||
<Compile Include="Abstractions\Services\IAppIdService.cs" />
|
<Compile Include="Abstractions\Services\IAppIdService.cs" />
|
||||||
<Compile Include="Abstractions\Services\IAuthService.cs" />
|
<Compile Include="Abstractions\Services\IAuthService.cs" />
|
||||||
<Compile Include="Abstractions\Services\IClipboardService.cs" />
|
<Compile Include="Abstractions\Services\IClipboardService.cs" />
|
||||||
|
<Compile Include="Abstractions\Services\IReflectionService.cs" />
|
||||||
<Compile Include="Abstractions\Services\ISiteService.cs" />
|
<Compile Include="Abstractions\Services\ISiteService.cs" />
|
||||||
<Compile Include="Abstractions\Services\IFolderService.cs" />
|
<Compile Include="Abstractions\Services\IFolderService.cs" />
|
||||||
<Compile Include="App.cs" />
|
<Compile Include="App.cs" />
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
using System;
|
using System;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Reflection.Emit;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using XLabs.Ioc;
|
||||||
|
using Bit.App.Abstractions;
|
||||||
|
|
||||||
namespace Bit.App.Controls
|
namespace Bit.App.Controls
|
||||||
{
|
{
|
||||||
public class ExtendedTableView : TableView
|
public class ExtendedTableView : TableView
|
||||||
{
|
{
|
||||||
|
public ExtendedTableView()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
VerticalOptions = LayoutOptions.Start;
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly BindableProperty EnableScrollingProperty =
|
public static readonly BindableProperty EnableScrollingProperty =
|
||||||
BindableProperty.Create(nameof(EnableScrolling), typeof(bool), typeof(ExtendedTableView), true);
|
BindableProperty.Create(nameof(EnableScrolling), typeof(bool), typeof(ExtendedTableView), true);
|
||||||
|
|
||||||
|
@ -33,5 +44,17 @@ namespace Bit.App.Controls
|
||||||
}
|
}
|
||||||
|
|
||||||
public int EstimatedRowHeight { get; set; }
|
public int EstimatedRowHeight { get; set; }
|
||||||
|
|
||||||
|
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
|
||||||
|
{
|
||||||
|
if(Device.OS == TargetPlatform.iOS && VerticalOptions.Alignment != LayoutAlignment.Fill)
|
||||||
|
{
|
||||||
|
var reflectionService = Resolver.Resolve<IReflectionService>();
|
||||||
|
var baseBaseOnSizeRequest = reflectionService.GetVisualElementOnSizeRequest(this);
|
||||||
|
return baseBaseOnSizeRequest(widthConstraint, heightConstraint);
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OnSizeRequest(widthConstraint, heightConstraint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,9 @@ namespace Bit.App.Pages
|
||||||
EnableScrolling = false,
|
EnableScrolling = false,
|
||||||
EnableSelection = false,
|
EnableSelection = false,
|
||||||
HasUnevenRows = true,
|
HasUnevenRows = true,
|
||||||
|
VerticalOptions = LayoutOptions.Start,
|
||||||
|
BackgroundColor = Color.Gray,
|
||||||
|
Margin = new Thickness(0, -1),
|
||||||
Root = new TableRoot
|
Root = new TableRoot
|
||||||
{
|
{
|
||||||
new TableSection()
|
new TableSection()
|
||||||
|
@ -67,6 +70,9 @@ namespace Bit.App.Pages
|
||||||
Intent = TableIntent.Settings,
|
Intent = TableIntent.Settings,
|
||||||
EnableScrolling = false,
|
EnableScrolling = false,
|
||||||
EnableSelection = true,
|
EnableSelection = true,
|
||||||
|
VerticalOptions = LayoutOptions.End,
|
||||||
|
BackgroundColor = Color.Yellow,
|
||||||
|
Margin = new Thickness(0, -1),
|
||||||
Root = new TableRoot
|
Root = new TableRoot
|
||||||
{
|
{
|
||||||
new TableSection()
|
new TableSection()
|
||||||
|
@ -102,7 +108,7 @@ namespace Bit.App.Pages
|
||||||
}, ToolbarItemOrder.Default, 0);
|
}, ToolbarItemOrder.Default, 0);
|
||||||
|
|
||||||
Title = "Edit Folder";
|
Title = "Edit Folder";
|
||||||
Content = new StackLayout { Children = { mainTable, deleteTable } };
|
Content = new ScrollView { Content = new StackLayout { Children = { mainTable, deleteTable } } };
|
||||||
ToolbarItems.Add(saveToolBarItem);
|
ToolbarItems.Add(saveToolBarItem);
|
||||||
if(Device.OS == TargetPlatform.iOS)
|
if(Device.OS == TargetPlatform.iOS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,8 @@ namespace Bit.App.Pages
|
||||||
Margin = new Thickness(15, 40, 15, 0),
|
Margin = new Thickness(15, 40, 15, 0),
|
||||||
HorizontalTextAlignment = TextAlignment.Center,
|
HorizontalTextAlignment = TextAlignment.Center,
|
||||||
FontFamily = "Courier",
|
FontFamily = "Courier",
|
||||||
LineBreakMode = LineBreakMode.TailTruncation
|
LineBreakMode = LineBreakMode.TailTruncation,
|
||||||
|
VerticalOptions = LayoutOptions.Start
|
||||||
};
|
};
|
||||||
|
|
||||||
var tgr = new TapGestureRecognizer();
|
var tgr = new TapGestureRecognizer();
|
||||||
|
@ -64,6 +65,7 @@ namespace Bit.App.Pages
|
||||||
EnableScrolling = false,
|
EnableScrolling = false,
|
||||||
Intent = TableIntent.Menu,
|
Intent = TableIntent.Menu,
|
||||||
HasUnevenRows = true,
|
HasUnevenRows = true,
|
||||||
|
VerticalOptions = LayoutOptions.End,
|
||||||
Root = new TableRoot
|
Root = new TableRoot
|
||||||
{
|
{
|
||||||
new TableSection
|
new TableSection
|
||||||
|
|
|
@ -200,6 +200,7 @@ namespace Bit.iOS
|
||||||
.RegisterType<IPushNotificationListener, PushNotificationListener>(new ContainerControlledLifetimeManager())
|
.RegisterType<IPushNotificationListener, PushNotificationListener>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IAppIdService, AppIdService>(new ContainerControlledLifetimeManager())
|
.RegisterType<IAppIdService, AppIdService>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IPasswordGenerationService, PasswordGenerationService>(new ContainerControlledLifetimeManager())
|
.RegisterType<IPasswordGenerationService, PasswordGenerationService>(new ContainerControlledLifetimeManager())
|
||||||
|
.RegisterType<IReflectionService, ReflectionService>(new ContainerControlledLifetimeManager())
|
||||||
// Repositories
|
// Repositories
|
||||||
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
.RegisterType<IFolderRepository, FolderRepository>(new ContainerControlledLifetimeManager())
|
||||||
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
.RegisterType<IFolderApiRepository, FolderApiRepository>(new ContainerControlledLifetimeManager())
|
||||||
|
|
|
@ -23,9 +23,12 @@ namespace Bit.iOS.Controls
|
||||||
UpdateRowHeight(view);
|
UpdateRowHeight(view);
|
||||||
UpdateEstimatedRowHeight(view);
|
UpdateEstimatedRowHeight(view);
|
||||||
UpdateSeparatorColor(view);
|
UpdateSeparatorColor(view);
|
||||||
|
|
||||||
|
Control.SectionFooterHeight = 0.01f;
|
||||||
|
Control.EstimatedSectionFooterHeight = 1f;
|
||||||
|
Control.ContentInset = new UIEdgeInsets(0, 0, -35, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnElementPropertyChanged(sender, e);
|
base.OnElementPropertyChanged(sender, e);
|
||||||
|
|
34
src/iOS/Services/ReflectionService.cs
Normal file
34
src/iOS/Services/ReflectionService.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using Bit.App.Abstractions;
|
||||||
|
using Bit.App.Controls;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.iOS.Services
|
||||||
|
{
|
||||||
|
public class ReflectionService : IReflectionService
|
||||||
|
{
|
||||||
|
public Func<double, double, SizeRequest> GetVisualElementOnSizeRequest(ExtendedTableView tableView)
|
||||||
|
{
|
||||||
|
var handle = typeof(VisualElement).GetMethod(
|
||||||
|
"OnSizeRequest",
|
||||||
|
BindingFlags.Instance | BindingFlags.NonPublic,
|
||||||
|
null,
|
||||||
|
new Type[] { typeof(double), typeof(double) },
|
||||||
|
null)?.MethodHandle;
|
||||||
|
|
||||||
|
if(!handle.HasValue)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("handle could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var pointer = handle.Value.GetFunctionPointer();
|
||||||
|
if(pointer == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("pointer could not be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Func<double, double, SizeRequest>)Activator.CreateInstance(typeof(Func<double, double, SizeRequest>), tableView, pointer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -115,6 +115,7 @@
|
||||||
<Compile Include="Services\ClipboardService.cs" />
|
<Compile Include="Services\ClipboardService.cs" />
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="AppDelegate.cs" />
|
<Compile Include="AppDelegate.cs" />
|
||||||
|
<Compile Include="Services\ReflectionService.cs" />
|
||||||
<None Include="Entitlements.plist" />
|
<None Include="Entitlements.plist" />
|
||||||
<None Include="Info.plist" />
|
<None Include="Info.plist" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
Loading…
Reference in a new issue