Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
5a438b88
Unverified
Commit
5a438b88
authored
Dec 26, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added blur and fade backing types for FABMenuController
parent
42b6d525
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
66 deletions
+132
-66
Sources/iOS/FABButton.swift
+1
-0
Sources/iOS/FABMenu.swift
+19
-17
Sources/iOS/FABMenuController.swift
+112
-49
No files found.
Sources/iOS/FABButton.swift
View file @
5a438b88
...
@@ -42,6 +42,7 @@ open class FABButton: Button {
...
@@ -42,6 +42,7 @@ open class FABButton: Button {
super
.
prepare
()
super
.
prepare
()
depthPreset
=
.
depth1
depthPreset
=
.
depth1
shapePreset
=
.
circle
shapePreset
=
.
circle
pulseAnimation
=
.
centerWithBacking
backgroundColor
=
.
white
backgroundColor
=
.
white
}
}
}
}
Sources/iOS/FABMenu.swift
View file @
5a438b88
...
@@ -41,17 +41,6 @@ public enum FABMenuDirection: Int {
...
@@ -41,17 +41,6 @@ public enum FABMenuDirection: Int {
@objc(FABMenuDelegate)
@objc(FABMenuDelegate)
public
protocol
FABMenuDelegate
{
public
protocol
FABMenuDelegate
{
/**
/**
A delegation method that is executed when the user taps while
the menu is opened.
- Parameter fabMenu: A FABMenu.
- Parameter tappedAt point: A CGPoint.
- Parameter isOutside: A boolean indicating whether the tap
was outside the menu button area.
*/
@objc
optional
func
fabMenu
(
fabMenu
:
FABMenu
,
tappedAt
point
:
CGPoint
,
isOutside
:
Bool
)
/**
A delegation method that is execited when the menu will open.
A delegation method that is execited when the menu will open.
- Parameter fabMenu: A FABMenu.
- Parameter fabMenu: A FABMenu.
*/
*/
...
@@ -78,6 +67,17 @@ public protocol FABMenuDelegate {
...
@@ -78,6 +67,17 @@ public protocol FABMenuDelegate {
*/
*/
@objc
@objc
optional
func
fabMenuDidClose
(
fabMenu
:
FABMenu
)
optional
func
fabMenuDidClose
(
fabMenu
:
FABMenu
)
/**
A delegation method that is executed when the user taps while
the menu is opened.
- Parameter fabMenu: A FABMenu.
- Parameter tappedAt point: A CGPoint.
- Parameter isOutside: A boolean indicating whether the tap
was outside the menu button area.
*/
@objc
optional
func
fabMenu
(
fabMenu
:
FABMenu
,
tappedAt
point
:
CGPoint
,
isOutside
:
Bool
)
}
}
...
@@ -148,7 +148,7 @@ open class FABMenu: View, SpringableMotion {
...
@@ -148,7 +148,7 @@ open class FABMenu: View, SpringableMotion {
}
}
/// A boolean indicating if the menu is enabled.
/// A boolean indicating if the menu is enabled.
open
var
isEnable
:
Bool
{
open
var
isEnable
d
:
Bool
{
get
{
get
{
return
spring
.
isEnabled
return
spring
.
isEnabled
}
}
...
@@ -202,7 +202,7 @@ extension FABMenu {
...
@@ -202,7 +202,7 @@ extension FABMenu {
- Parameter animations: An animation block to execute on each view's animation.
- Parameter animations: An animation block to execute on each view's animation.
- Parameter completion: A completion block to execute on each view's animation.
- Parameter completion: A completion block to execute on each view's animation.
*/
*/
open
func
open
(
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
fileprivate
func
open
(
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
}
}
...
@@ -216,7 +216,7 @@ extension FABMenu {
...
@@ -216,7 +216,7 @@ extension FABMenu {
- Parameter animations: An animation block to execute on each view's animation.
- Parameter animations: An animation block to execute on each view's animation.
- Parameter completion: A completion block to execute on each view's animation.
- Parameter completion: A completion block to execute on each view's animation.
*/
*/
open
func
close
(
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
fileprivate
func
close
(
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
}
}
}
}
...
@@ -229,7 +229,7 @@ extension FABMenu {
...
@@ -229,7 +229,7 @@ extension FABMenu {
- Returns: An optional UIView.
- Returns: An optional UIView.
*/
*/
open
override
func
hitTest
(
_
point
:
CGPoint
,
with
event
:
UIEvent
?)
->
UIView
?
{
open
override
func
hitTest
(
_
point
:
CGPoint
,
with
event
:
UIEvent
?)
->
UIView
?
{
guard
spring
.
isOpened
,
spring
.
isEnabled
else
{
guard
isOpened
,
isEnabled
else
{
return
super
.
hitTest
(
point
,
with
:
event
)
return
super
.
hitTest
(
point
,
with
:
event
)
}
}
...
@@ -267,8 +267,9 @@ extension FABMenu {
...
@@ -267,8 +267,9 @@ extension FABMenu {
extension
FABMenu
{
extension
FABMenu
{
/// Opens the menu and reveals the FABMenuItems.
/// Opens the menu and reveals the FABMenuItems.
fileprivate
func
openMenu
()
{
open
func
openMenu
()
{
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
open
{
[
weak
self
]
(
view
)
in
open
{
[
weak
self
]
(
view
)
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
...
@@ -283,8 +284,9 @@ extension FABMenu {
...
@@ -283,8 +284,9 @@ extension FABMenu {
}
}
/// Closes the menu and hides the FABMenuItems.
/// Closes the menu and hides the FABMenuItems.
fileprivate
func
closeMenu
()
{
open
func
closeMenu
()
{
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
close
{
[
weak
self
]
(
view
)
in
close
{
[
weak
self
]
(
view
)
in
guard
let
s
=
self
else
{
guard
let
s
=
self
else
{
return
return
...
...
Sources/iOS/FABMenuController.swift
View file @
5a438b88
...
@@ -30,6 +30,11 @@
...
@@ -30,6 +30,11 @@
import
UIKit
import
UIKit
public
enum
FABMenuBacking
{
case
fade
case
blur
}
extension
UIViewController
{
extension
UIViewController
{
/**
/**
A convenience property that provides access to the FABMenuController.
A convenience property that provides access to the FABMenuController.
...
@@ -53,6 +58,15 @@ open class FABMenuController: RootController {
...
@@ -53,6 +58,15 @@ open class FABMenuController: RootController {
@IBInspectable
@IBInspectable
open
let
fabMenu
=
FABMenu
()
open
let
fabMenu
=
FABMenu
()
/// A FABMenuBacking value type.
open
var
fabMenuBacking
=
FABMenuBacking
.
blur
/// The fabMenuBacking UIBlurEffectStyle.
open
var
fabMenuBackingBlurEffectStyle
=
UIBlurEffectStyle
.
light
/// A reference to the blurView.
open
fileprivate
(
set
)
var
blurView
:
UIView
?
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
rootViewController
.
view
.
frame
=
view
.
bounds
rootViewController
.
view
.
frame
=
view
.
bounds
...
@@ -80,55 +94,104 @@ extension FABMenuController {
...
@@ -80,55 +94,104 @@ extension FABMenuController {
}
}
}
}
extension
FABMenuController
{
/// Shows the fabMenuBacking.
fileprivate
func
showFabMenuBacking
()
{
showFade
()
showBlurView
()
}
/// Hides the fabMenuBacking.
fileprivate
func
hideFabMenuBacking
()
{
hideFade
()
hideBlurView
()
}
/// Shows the blurView.
fileprivate
func
showBlurView
()
{
guard
.
blur
==
fabMenuBacking
else
{
return
}
guard
!
fabMenu
.
isOpened
,
fabMenu
.
isEnabled
else
{
return
}
guard
nil
==
blurView
else
{
return
}
let
blur
=
UIVisualEffectView
(
effect
:
UIBlurEffect
(
style
:
fabMenuBackingBlurEffectStyle
))
blurView
=
UIView
()
blurView
?
.
layout
(
blur
)
.
edges
()
view
.
layout
(
blurView
!
)
.
edges
()
view
.
bringSubview
(
toFront
:
fabMenu
)
}
/// Hides the blurView.
fileprivate
func
hideBlurView
()
{
guard
fabMenu
.
isOpened
,
fabMenu
.
isEnabled
else
{
return
}
blurView
?
.
removeFromSuperview
()
blurView
=
nil
}
/// Shows the fade.
fileprivate
func
showFade
()
{
guard
.
fade
==
fabMenuBacking
else
{
return
}
guard
!
fabMenu
.
isOpened
,
fabMenu
.
isEnabled
else
{
return
}
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
self
?
.
rootViewController
.
view
.
alpha
=
0.15
})
}
/// Hides the fade.
fileprivate
func
hideFade
()
{
guard
fabMenu
.
isOpened
,
fabMenu
.
isEnabled
else
{
return
}
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
self
?
.
rootViewController
.
view
.
alpha
=
1
})
}
}
extension
FABMenuController
:
FABMenuDelegate
{
extension
FABMenuController
:
FABMenuDelegate
{
@objc
open
func
fabMenuWillOpen
(
fabMenu
:
FABMenu
)
{
isUserInteractionEnabled
=
false
showFabMenuBacking
()
}
// /**
@objc
// Opens the menu with a callback.
open
func
fabMenuDidOpen
(
fabMenu
:
FABMenu
)
{
// - Parameter completion: An Optional callback that is executed when
isUserInteractionEnabled
=
true
// all menu items have been opened.
}
// */
// open func openMenu(completion: ((UIView) -> Void)? = nil) {
@objc
// if true == isUserInteractionEnabled {
open
func
fabMenuWillClose
(
fabMenu
:
FABMenu
)
{
// isUserInteractionEnabled = false
isUserInteractionEnabled
=
false
//
hideFabMenuBacking
()
// UIView.animate(withDuration: 0.15, animations: { [weak self] in
}
// guard let s = self else {
// return
@objc
// }
open
func
fabMenuDidClose
(
fabMenu
:
FABMenu
)
{
// s.rootViewController.view.alpha = 0.15
isUserInteractionEnabled
=
true
// })
}
//
// fabMenu.open { [completion = completion] (view) in
@objc
// completion?(view)
open
func
fabMenu
(
fabMenu
:
FABMenu
,
tappedAt
point
:
CGPoint
,
isOutside
:
Bool
)
{
// }
guard
isOutside
else
{
// }
return
// }
}
//
}
// /**
// Opens the menu with a callback.
// - Parameter completion: An Optional callback that is executed when
// all menu items have been closed.
// */
// open func closeMenu(completion: ((UIView) -> Void)? = nil) {
// if false == isUserInteractionEnabled {
// UIView.animate(withDuration: 0.15, animations: { [weak self] in
// guard let s = self else {
// return
// }
// s.rootViewController.view.alpha = 1
// })
//
// fabMenu.close { [weak self] (view) in
// guard let s = self else {
// return
// }
//
// completion?(view)
//
// if view == s.fabMenu.items.last {
// s.isUserInteractionEnabled = true
// }
// }
// }
// }
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment