Skip to content

Commit

Permalink
Merge pull request #76 from DarthRamone/master
Browse files Browse the repository at this point in the history
ShadowOpacity, ShadowRadius and ShadowColor varying
  • Loading branch information
jdehlin authored Oct 3, 2017
2 parents 00315f1 + 300ba23 commit 861b3fa
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 9 deletions.
15 changes: 15 additions & 0 deletions Xamarin-Sidebar/Sidebar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ public bool DisablePanGesture

public float GestureActiveArea { get; set; }

public float ShadowOpacity {
get { return _sidebarContentArea.ShadowOpacity; }
set { _sidebarContentArea.ShadowOpacity = value; }
}

public float ShadowRadius {
get { return _sidebarContentArea.ShadowRadius; }
set { _sidebarContentArea.ShadowRadius = value; }
}

public UIColor ShadowColor {
get { return _sidebarContentArea.ShadowColor; }
set { _sidebarContentArea.ShadowColor = value; }
}

public bool HasShadowing { get; set; }

public bool HasDarkOverlay { get; set; }
Expand Down
19 changes: 13 additions & 6 deletions Xamarin-Sidebar/SidebarContentArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ internal class SidebarContentArea
public UIViewController ContentViewController { get; set; }


public float ShadowRadius { get; set; } = 4.0f;

public float ShadowOpacity { get; set; } = 0.5f;

public UIColor ShadowColor { get; set; } = UIColor.Black;


public SidebarContentArea(UIViewController viewController) {
ContentViewController = viewController;

Expand All @@ -41,9 +48,9 @@ public SidebarContentArea(UIViewController viewController) {
public void DisplayShadow(float position) {
ContentViewController.View.Layer.ShadowOffset = new SizeF(position, 0);
ContentViewController.View.Layer.ShadowPath = UIBezierPath.FromRect(ContentViewController.View.Bounds).CGPath;
ContentViewController.View.Layer.ShadowRadius = 4.0f;
ContentViewController.View.Layer.ShadowOpacity = 0.5f;
ContentViewController.View.Layer.ShadowColor = UIColor.Black.CGColor;
ContentViewController.View.Layer.ShadowRadius = ShadowRadius;
ContentViewController.View.Layer.ShadowOpacity = ShadowOpacity;
ContentViewController.View.Layer.ShadowColor = ShadowColor.CGColor;
}

public void HideShadow() {
Expand Down Expand Up @@ -213,9 +220,9 @@ private void ShowShadowWhileDragging(bool hasShadowing, MenuLocations menuLocati
var xOffset = (menuLocation == MenuLocations.Left) ? -5 : 5;
ContentViewController.View.Layer.ShadowOffset = new SizeF(xOffset, 0);
ContentViewController.View.Layer.ShadowPath = UIBezierPath.FromRect (ContentViewController.View.Bounds).CGPath;
ContentViewController.View.Layer.ShadowRadius = 4.0f;
ContentViewController.View.Layer.ShadowOpacity = 0.5f;
ContentViewController.View.Layer.ShadowColor = UIColor.Black.CGColor;
ContentViewController.View.Layer.ShadowRadius = ShadowRadius;
ContentViewController.View.Layer.ShadowOpacity = ShadowOpacity;
ContentViewController.View.Layer.ShadowColor = ShadowColor.CGColor;
}
}
}
Expand Down
32 changes: 29 additions & 3 deletions Xamarin-Sidebar/SidebarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ public SidebarController(
public UIViewController MenuAreaController { get { return _sidebar.MenuViewController; } }


/// <summary>
/// <summary>
/// Determines the percent of width to complete slide action.
/// </summary>
public float FlingPercentage {
get { return _sidebar.FlingPercentage; }
set { _sidebar.FlingPercentage = value; }
}

/// <summary>
/// <summary>
/// Determines the minimum velocity considered a "fling" to complete slide action.
/// </summary>
public float FlingVelocity {
Expand All @@ -115,6 +115,32 @@ public bool HasShadowing {
set { _sidebar.HasShadowing = value; }
}

/// <summary>
/// Gets or sets the shadow opacity.
/// </summary>
public float ShadowOpacity {
get { return _sidebar.ShadowOpacity; }
set { _sidebar.ShadowOpacity = value; }
}

/// <summary>
/// Gets or sets the color of the shadow.
/// </summary>
public UIColor ShadowColor {
get { return _sidebar.ShadowColor; }
set { _sidebar.ShadowColor = value; }
}

/// <summary>
/// Gets or sets the shadow radius.
/// </summary>
/// <value>The shadow radius.</value>
public float ShadowRadius
{
get { return _sidebar.ShadowRadius; }
set { _sidebar.ShadowRadius = value; }
}

/// <summary>
/// Gets or sets a value indicating whether there should be a dark overlay effect on the content view.
/// </summary>
Expand Down Expand Up @@ -281,7 +307,7 @@ private void SetMenuViewPosition() {
var menuFrame = MenuAreaController.View.Frame;
menuFrame.X = MenuLocation == MenuLocations.Left ? 0 : View.Frame.Width - MenuWidth;
menuFrame.Width = MenuWidth;
menuFrame.Height = View.Frame.Height;
menuFrame.Height = View.Frame.Height;
MenuAreaController.View.Frame = menuFrame;
}

Expand Down

0 comments on commit 861b3fa

Please sign in to comment.