mirror of
https://github.com/bitwarden/mobile
synced 2025-12-23 19:53:50 +00:00
Moved add/edit pages to use custom form cells. Moved navigation of vault to modals. Created custom renderer for left modal dismiss button on navigation pages. refresh for edit site UI.
This commit is contained in:
68
src/iOS/Controls/ContentPageRenderer.cs
Normal file
68
src/iOS/Controls/ContentPageRenderer.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Bit.iOS.Controls;
|
||||
using UIKit;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.iOS;
|
||||
|
||||
[assembly: ExportRenderer(typeof(ContentPage), typeof(ContentPageRenderer))]
|
||||
namespace Bit.iOS.Controls
|
||||
{
|
||||
public class ContentPageRenderer : PageRenderer
|
||||
{
|
||||
public override void ViewWillAppear(bool animated)
|
||||
{
|
||||
base.ViewWillAppear(animated);
|
||||
|
||||
var contentPage = Element as ContentPage;
|
||||
if(contentPage == null || NavigationController == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var itemsInfo = contentPage.ToolbarItems;
|
||||
|
||||
var navigationItem = NavigationController.TopViewController.NavigationItem;
|
||||
var leftNativeButtons = (navigationItem.LeftBarButtonItems ?? new UIBarButtonItem[] { }).ToList();
|
||||
var rightNativeButtons = (navigationItem.RightBarButtonItems ?? new UIBarButtonItem[] { }).ToList();
|
||||
|
||||
var newLeftButtons = new List<UIBarButtonItem>();
|
||||
var newRightButtons = new List<UIBarButtonItem>();
|
||||
|
||||
rightNativeButtons.ForEach(nativeItem =>
|
||||
{
|
||||
// Use reflection to get Xamarin private field "_item"
|
||||
var field = nativeItem.GetType().GetField("_item", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if(field == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var info = field.GetValue(nativeItem) as ToolbarItem;
|
||||
if(info == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(info.Priority < 0)
|
||||
{
|
||||
newLeftButtons.Add(nativeItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
newRightButtons.Add(nativeItem);
|
||||
}
|
||||
});
|
||||
|
||||
leftNativeButtons.ForEach(nativeItem =>
|
||||
{
|
||||
newLeftButtons.Add(nativeItem);
|
||||
});
|
||||
|
||||
navigationItem.RightBarButtonItems = newRightButtons.ToArray();
|
||||
navigationItem.LeftBarButtonItems = newLeftButtons.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user