using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Windows.Input;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
navPage.On<iOS>().SetPrefersLargeTitles(!navPage.On<iOS>().PrefersLargeTitles());
} )
},
+
+ new Button
+ {
+ Text = "UseLargeTitles on Navigation with safe Area",
+ Command = new Command( () =>{
+ var navPage = (Parent as NavigationPage);
+ navPage.On<iOS>().SetPrefersLargeTitles(true);
+ var page = new ContentPage { Title = "New Title", BackgroundColor = Color.Red };
+ page.On<iOS>().SetUseSafeArea(true);
+ var listView = new ListView(ListViewCachingStrategy.RecycleElementAndDataTemplate)
+ {
+ HasUnevenRows = true,
+ VerticalOptions = LayoutOptions.FillAndExpand
+ };
+
+ listView.ItemTemplate = new DataTemplate(()=>{
+ var cell = new ViewCell();
+ cell.View = new Label { Text ="Hello", FontSize = 30};
+ return cell;
+ });
+ listView.ItemsSource = Enumerable.Range(1, 40);
+ listView.Header = new Label { BackgroundColor = Color.Pink , Text = "I'm a header, background is red"};
+ listView.Footer = new Label { BackgroundColor = Color.Yellow , Text = "I'm a footer, you should see no white below me"};
+ page.Content = listView;
+ navPage.PushAsync(page);
+ } )
+ },
offscreenPageLimit
}
};
var restoreButton = new Button { Text = "Back To Gallery" };
- restoreButton.Clicked += async (sender, args) => await Navigation.PopAsync();
+ restoreButton.Clicked += async (sender, args) => await Navigation.PopAsync();
content.Children.Add(restoreButton);
Content = content;
public PlatformSpecificsGallery()
{
+ Title = "PlatformSpecificsGallery";
var mdpiOSButton = new Button { Text = "MasterDetailPage (iOS)" };
var mdpWindowsButton = new Button { Text = "MasterDetailPage (Windows)" };
var npiOSButton = new Button() { Text = "NavigationPage (iOS)" };
UIViewController[] _removeControllers;
UIToolbar _secondaryToolbar;
VisualElementTracker _tracker;
+ nfloat _navigationBottom = 0;
+
public NavigationRenderer()
{
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
+ if (Current == null)
+ return;
UpdateToolBarVisible();
- //var navBarFrameBotton = Forms.IsiOS11OrNewer ? View.SafeAreaInsets.Top : NavigationBar.Frame.Bottom;
- var navBarFrameBotton = NavigationBar.Frame.Bottom;
-
+ var navBarFrameBottom = Math.Min(NavigationBar.Frame.Bottom, 140);
+ _navigationBottom = (nfloat)navBarFrameBottom;
var toolbar = _secondaryToolbar;
// Use 0 if the NavBar is hidden or will be hidden
- var toolbarY = NavigationBarHidden || NavigationBar.Translucent || !NavigationPage.GetHasNavigationBar(Current) ? 0 : navBarFrameBotton;
+ var toolbarY = NavigationBarHidden || NavigationBar.Translucent || !NavigationPage.GetHasNavigationBar(Current) ? 0 : navBarFrameBottom;
toolbar.Frame = new RectangleF(0, toolbarY, View.Frame.Width, toolbar.Frame.Height);
double trueBottom = toolbar.Hidden ? toolbarY : toolbar.Frame.Bottom;
}
}
+ internal void ValidateInsets()
+ {
+ nfloat navBottom = NavigationBar.Frame.Bottom;
+
+ if (_navigationBottom != navBottom && Current != null)
+ ViewDidLayoutSubviews();
+ }
+
class SecondaryToolbar : UIToolbar
{
readonly List<UIView> _lines = new List<UIView>();
handler(this, EventArgs.Empty);
}
+ public override void ViewWillLayoutSubviews()
+ {
+ base.ViewWillLayoutSubviews();
+
+ NavigationRenderer n;
+ if (_navigation.TryGetTarget(out n))
+ n.ValidateInsets();
+ }
+
public override void ViewDidLayoutSubviews()
{
IVisualElementRenderer childRenderer;