summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-08-30 10:46:14 -0700
committerJason Smith <jason.smith@xamarin.com>2016-08-30 10:46:14 -0700
commit5e553f6195e66e48688b8ab324f1bab1e9251f0a (patch)
treef8843e5e9e8afe89a05a1cc91c3b7fa05588bac7 /Xamarin.Forms.Platform.iOS
parentf551654b1cfe654c579ca50978445e7cb93f287d (diff)
downloadxamarin-forms-5e553f6195e66e48688b8ab324f1bab1e9251f0a.tar.gz
xamarin-forms-5e553f6195e66e48688b8ab324f1bab1e9251f0a.tar.bz2
xamarin-forms-5e553f6195e66e48688b8ab324f1bab1e9251f0a.zip
Platform Specifics (#301)
* Playing around with how the platform specifics interfaces etc. might work * Sample implementation of iOS navigation translucency * Very slightly reduced code * Better vendor stuff * Drop single-implemenation interfaces * Generics on NavigationPage * On-demand vendor stuff * Remove functionally duplicate classes and make ControlGallery work again * Namespace all the things. XAML test. * Can use Effect to attach platform specific * Attach Effect on PropertyChanging for XAML support! * Rename IConfigPlatform interfaces for readability * Some renaming to match the documents * Split class files * Clear out test-only code * Re-namespace * Added On method to rendered Elements * Allow for removal of platform suffix, convenience methods on specific platforms * Creating a gallery page for specifics * Add rudimentary Platform Specifics gallery; make CollapseStyle work on UWP; Add CollapsedPaneWidth specific property * Toolbar now working with both collapse styles * MDP now displaying Content title; toolbar routing around title * Add a gallery for the iOS NavigationPage stuff * Add Navigation Page as detail page to verify it works with new Toolbar options * Make titlebar/toolbar background colors consistent * ToolbarPlacement now working on NavigationPage * Toolbar Placement working for tabbed and nav pages * Fix bug where phone doesn't get default toolbar placement on start * [Core] Add PS WindowSoftInputModeAdjust [Core] Make Application extendable * Toolbar placement now working on Nav, Tabbed, and Master pages on desktop/phone Remove unnecessary style indirection Fix build errors * [A] Add PlatformConfigurationExtensions * SetSoftInputMode test page * [A] SetSoftInputMode Known issue: Status bar color does not work in AdjustResize mode * [Core] Add PS Blur * [iOS] Configure renderer for blur * Add test page * Move to blur VisualElement for broader support * Move test pages to gallery * Update docs * Use lazy initializer for PlatformConfigurationRegistry
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Extensions/PlatformConfigurationExtensions.cs11
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs30
-rw-r--r--Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs60
-rw-r--r--Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj1
-rw-r--r--Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj1
6 files changed, 98 insertions, 7 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Extensions/PlatformConfigurationExtensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/PlatformConfigurationExtensions.cs
new file mode 100644
index 00000000..f61837f2
--- /dev/null
+++ b/Xamarin.Forms.Platform.iOS/Extensions/PlatformConfigurationExtensions.cs
@@ -0,0 +1,11 @@
+namespace Xamarin.Forms.Platform.iOS
+{
+ public static class PlatformConfigurationExtensions
+ {
+ public static IPlatformElementConfiguration<PlatformConfiguration.iOS, T> OnThisPlatform<T>(this T element)
+ where T : Element, IElementConfiguration<T>
+ {
+ return (element).On<PlatformConfiguration.iOS>();
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs
index ad408c1f..20e9c38b 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/BoxRenderer.cs
@@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Drawing;
+using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
#if __UNIFIED__
using UIKit;
using CoreGraphics;
@@ -23,7 +24,6 @@ namespace Xamarin.Forms.Platform.iOS
public class BoxRenderer : VisualElementRenderer<BoxView>
{
UIColor _colorToRenderer;
-
SizeF _previousSize;
public override void Draw(RectangleF rect)
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
index 271291d6..c4186880 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
@@ -7,7 +7,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xamarin.Forms.Internals;
-
+using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
#if __UNIFIED__
using UIKit;
using CoreGraphics;
@@ -21,9 +21,9 @@ using SizeF = CoreGraphics.CGSize;
using PointF = CoreGraphics.CGPoint;
#else
-using nfloat=System.Single;
-using nint=System.Int32;
-using nuint=System.UInt32;
+using nfloat = System.Single;
+using nint = System.Int32;
+using nuint = System.UInt32;
#endif
namespace Xamarin.Forms.Platform.iOS
@@ -49,6 +49,8 @@ namespace Xamarin.Forms.Platform.iOS
var parentingViewController = (ParentingViewController)ViewControllers.Last();
UpdateLeftBarButtonItem(parentingViewController);
});
+
+
}
Page Current { get; set; }
@@ -181,7 +183,10 @@ namespace Xamarin.Forms.Platform.iOS
base.ViewDidLoad();
if (Forms.IsiOS7OrNewer)
- NavigationBar.Translucent = false;
+ {
+
+ UpdateTranslucent();
+ }
else
WantsFullScreenLayout = false;
@@ -437,6 +442,18 @@ namespace Xamarin.Forms.Platform.iOS
UpdateBackgroundColor();
else if (e.PropertyName == NavigationPage.CurrentPageProperty.PropertyName)
Current = ((NavigationPage)Element).CurrentPage;
+ else if (e.PropertyName == PlatformConfiguration.iOSSpecific.NavigationPage.IsNavigationBarTranslucentProperty.PropertyName)
+ UpdateTranslucent();
+ }
+
+ void UpdateTranslucent()
+ {
+ if (!Forms.IsiOS7OrNewer)
+ {
+ return;
+ }
+
+ NavigationBar.Translucent = ((NavigationPage)Element).OnThisPlatform().IsNavigationBarTranslucent();
}
void InsertPageBefore(Page page, Page before)
@@ -481,7 +498,7 @@ namespace Xamarin.Forms.Platform.iOS
if (page == null)
throw new ArgumentNullException("page");
if (page == Current)
- throw new NotSupportedException(); // should never happen as NavPage protecs against this
+ throw new NotSupportedException(); // should never happen as NavPage protects against this
var target = Platform.GetRenderer(page).ViewController.ParentViewController;
@@ -807,6 +824,7 @@ namespace Xamarin.Forms.Platform.iOS
public override void ViewWillAppear(bool animated)
{
UpdateNavigationBarVisibility(animated);
+ EdgesForExtendedLayout = UIRectEdge.None;
base.ViewWillAppear(animated);
}
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
index ab212b21..d4da0930 100644
--- a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs
@@ -4,6 +4,8 @@ using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Drawing;
using System.ComponentModel;
+using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
+
#if __UNIFIED__
using UIKit;
#else
@@ -13,6 +15,7 @@ using MonoTouch.UIKit;
using RectangleF = CoreGraphics.CGRect;
using SizeF = CoreGraphics.CGSize;
using PointF = CoreGraphics.CGPoint;
+using CoreGraphics;
#else
using nfloat=System.Single;
@@ -44,6 +47,9 @@ namespace Xamarin.Forms.Platform.iOS
VisualElementPackager _packager;
VisualElementTracker _tracker;
+ UIVisualEffectView _blur;
+ BlurEffectStyle _previousBlur;
+
protected VisualElementRenderer() : base(RectangleF.Empty)
{
_propertyChangedHandler = OnElementPropertyChanged;
@@ -180,6 +186,17 @@ namespace Xamarin.Forms.Platform.iOS
return new SizeF(0, 0);
}
+ public override void Draw(RectangleF rect)
+ {
+ base.Draw(rect);
+ if (_blur != null)
+ {
+ _blur.Frame = rect;
+ if (_blur.Superview == null)
+ Superview.Add(_blur);
+ }
+ }
+
protected override void Dispose(bool disposing)
{
if ((_flags & VisualElementRendererFlags.Disposed) != 0)
@@ -220,6 +237,9 @@ namespace Xamarin.Forms.Platform.iOS
var changed = ElementChanged;
if (changed != null)
changed(this, e);
+
+ if (e.NewElement != null)
+ SetBlur((BlurEffectStyle)e.NewElement.GetValue(PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty));
}
protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -228,6 +248,8 @@ namespace Xamarin.Forms.Platform.iOS
SetBackgroundColor(Element.BackgroundColor);
else if (e.PropertyName == Layout.IsClippedToBoundsProperty.PropertyName)
UpdateClipToBounds();
+ else if (e.PropertyName == PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty.PropertyName)
+ SetBlur((BlurEffectStyle)Element.GetValue(PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty));
}
protected virtual void OnRegisterEffect(PlatformEffect effect)
@@ -248,6 +270,44 @@ namespace Xamarin.Forms.Platform.iOS
BackgroundColor = color.ToUIColor();
}
+ protected virtual void SetBlur(BlurEffectStyle blur)
+ {
+ if (_previousBlur == blur)
+ return;
+
+ _previousBlur = blur;
+
+ if (_blur != null)
+ {
+ _blur.RemoveFromSuperview();
+ _blur = null;
+ }
+
+ if (blur == BlurEffectStyle.None)
+ {
+ SetNeedsDisplay();
+ return;
+ }
+
+ UIBlurEffect blurEffect;
+ switch (blur)
+ {
+ default:
+ case BlurEffectStyle.ExtraLight:
+ blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.ExtraLight);
+ break;
+ case BlurEffectStyle.Light:
+ blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);
+ break;
+ case BlurEffectStyle.Dark:
+ blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark);
+ break;
+ }
+
+ _blur = new UIVisualEffectView(blurEffect);
+ SetNeedsDisplay();
+ }
+
protected virtual void UpdateNativeWidget()
{
}
diff --git a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj
index 285660e6..5b705d01 100644
--- a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj
+++ b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj
@@ -69,6 +69,7 @@
<Compile Include="ContextScrollViewDelegate.cs" />
<Compile Include="EffectUtilities.cs" />
<Compile Include="Extensions\CellExtensions.cs" />
+ <Compile Include="Extensions\PlatformConfigurationExtensions.cs" />
<Compile Include="Forms.cs" />
<Compile Include="GlobalCloseContextGestureRecognizer.cs" />
<Compile Include="Extensions\ArrayExtensions.cs" />
diff --git a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj
index 3ed36e7f..d2364175 100644
--- a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj
+++ b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj
@@ -133,6 +133,7 @@
<Compile Include="ExportImageSourceHandlerAttribute.cs" />
<Compile Include="ExportRendererAttribute.cs" />
<Compile Include="Extensions\ArrayExtensions.cs" />
+ <Compile Include="Extensions\PlatformConfigurationExtensions.cs" />
<Compile Include="NativeViewWrapper.cs" />
<Compile Include="NativeViewWrapperRenderer.cs" />
<Compile Include="PlatformEffect.cs" />