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
62f29b52
Unverified
Commit
62f29b52
authored
Jan 03, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updated FABMenuController handler for FABButton user interactions
parent
3724bbd3
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
105 additions
and
59 deletions
+105
-59
Sources/iOS/Capture/Capture.swift
+1
-1
Sources/iOS/Divider.swift
+1
-1
Sources/iOS/FABMenu.swift
+56
-12
Sources/iOS/FABMenuController.swift
+24
-22
Sources/iOS/Grid.swift
+1
-1
Sources/iOS/Layout.swift
+1
-1
Sources/iOS/NavigationItem.swift
+2
-2
Sources/iOS/PageTabBarController.swift
+1
-1
Sources/iOS/Switch.swift
+16
-16
Sources/iOS/TabBar.swift
+1
-1
Sources/iOS/Toolbar.swift
+1
-1
No files found.
Sources/iOS/Capture/Capture.swift
View file @
62f29b52
...
...
@@ -37,7 +37,7 @@ public enum CaptureMode: Int {
case
video
}
private
var
CaptureAdjustingExposureContext
:
UInt8
=
0
file
private
var
CaptureAdjustingExposureContext
:
UInt8
=
0
@objc(CapturePreset)
public
enum
CapturePreset
:
Int
{
...
...
Sources/iOS/Divider.swift
View file @
62f29b52
...
...
@@ -135,7 +135,7 @@ public struct Divider {
}
/// A memory reference to the Divider instance.
private
var
DividerKey
:
UInt8
=
0
file
private
var
DividerKey
:
UInt8
=
0
extension
UIView
{
/// TabBarItem reference.
...
...
Sources/iOS/FABMenu.swift
View file @
62f29b52
...
...
@@ -214,10 +214,13 @@ open class FABMenu: View {
}
addSubview
(
v
)
v
.
addTarget
(
self
,
action
:
#selector(
handle
ToggleMenu
(button:)
)
,
for
:
.
touchUpInside
)
v
.
addTarget
(
self
,
action
:
#selector(
handle
FABButton
(button:)
)
,
for
:
.
touchUpInside
)
}
}
/// An internal handler for the FABButton.
internal
var
handleFABButtonCallback
:
((
UIButton
)
->
Void
)?
/// Size of FABMenuItems.
open
var
fabMenuItemSize
:
CGSize
{
get
{
...
...
@@ -314,16 +317,34 @@ extension FABMenu {
- 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
)
{
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
open
(
isTriggeredByUserInteraction
:
false
,
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
}
/**
Open the Menu component with animation options.
- Parameter isTriggeredByUserInteraction: A boolean indicating whether the
state was changed by a user interaction, true if yes, false otherwise.
- Parameter duration: The time for each view's animation.
- Parameter delay: A delay time for each view's animation.
- Parameter usingSpringWithDamping: A damping ratio for the animation.
- Parameter initialSpringVelocity: The initial velocity for the animation.
- Parameter options: Options to pass to the 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.
*/
internal
func
open
(
isTriggeredByUserInteraction
:
Bool
,
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
if
isTriggeredByUserInteraction
{
delegate
?
.
fabMenuWillOpen
?(
fabMenu
:
self
)
}
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
completion
=
completion
]
(
view
)
in
spring
.
expand
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
completion
=
completion
]
(
view
)
in
guard
let
s
=
self
else
{
return
}
(
view
as?
FABMenuItem
)?
.
showTitleLabel
()
if
view
==
s
.
fabMenuItems
.
last
{
if
isTriggeredByUserInteraction
&&
view
==
s
.
fabMenuItems
.
last
{
s
.
delegate
?
.
fabMenuDidOpen
?(
fabMenu
:
s
)
}
...
...
@@ -342,16 +363,34 @@ extension FABMenu {
- 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
)
{
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
close
(
isTriggeredByUserInteraction
:
false
,
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
,
completion
:
completion
)
}
/**
Close the Menu component with animation options.
- Parameter isTriggeredByUserInteraction: A boolean indicating whether the
state was changed by a user interaction, true if yes, false otherwise.
- Parameter duration: The time for each view's animation.
- Parameter delay: A delay time for each view's animation.
- Parameter usingSpringWithDamping: A damping ratio for the animation.
- Parameter initialSpringVelocity: The initial velocity for the animation.
- Parameter options: Options to pass to the 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.
*/
internal
func
close
(
isTriggeredByUserInteraction
:
Bool
,
duration
:
TimeInterval
=
0.15
,
delay
:
TimeInterval
=
0
,
usingSpringWithDamping
:
CGFloat
=
0.5
,
initialSpringVelocity
:
CGFloat
=
0
,
options
:
UIViewAnimationOptions
=
[],
animations
:
((
UIView
)
->
Void
)?
=
nil
,
completion
:
((
UIView
)
->
Void
)?
=
nil
)
{
if
isTriggeredByUserInteraction
{
delegate
?
.
fabMenuWillClose
?(
fabMenu
:
self
)
}
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
completion
=
completion
]
(
view
)
in
spring
.
contract
(
duration
:
duration
,
delay
:
delay
,
usingSpringWithDamping
:
usingSpringWithDamping
,
initialSpringVelocity
:
initialSpringVelocity
,
options
:
options
,
animations
:
animations
)
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
completion
=
completion
]
(
view
)
in
guard
let
s
=
self
else
{
return
}
(
view
as?
FABMenuItem
)?
.
hideTitleLabel
()
if
view
==
s
.
fabMenuItems
.
last
{
if
isTriggeredByUserInteraction
&&
view
==
s
.
fabMenuItems
.
last
{
s
.
delegate
?
.
fabMenuDidClose
?(
fabMenu
:
s
)
}
...
...
@@ -382,9 +421,9 @@ extension FABMenu {
delegate
?
.
fabMenu
?(
fabMenu
:
self
,
tappedAt
:
point
,
isOutside
:
true
)
close
()
close
(
isTriggeredByUserInteraction
:
true
)
return
s
elf
.
hitTest
(
point
,
with
:
event
)
return
s
uper
.
hitTest
(
point
,
with
:
event
)
}
}
...
...
@@ -394,12 +433,17 @@ extension FABMenu {
- Parameter button: A UIButton.
*/
@objc
fileprivate
func
handleToggleMenu
(
button
:
UIButton
)
{
fileprivate
func
handleFABButton
(
button
:
UIButton
)
{
guard
nil
==
handleFABButtonCallback
else
{
handleFABButtonCallback
?(
button
)
return
}
guard
isOpened
else
{
open
()
open
(
isTriggeredByUserInteraction
:
true
)
return
}
close
()
close
(
isTriggeredByUserInteraction
:
true
)
}
}
Sources/iOS/FABMenuController.swift
View file @
62f29b52
...
...
@@ -86,11 +86,14 @@ open class FABMenuController: RootController {
}
}
extension
FABMenuController
:
FABMenuDelegate
{}
extension
FABMenuController
{
/// Prepares the fabMenu.
fileprivate
func
prepareFABMenu
()
{
fabMenu
.
delegate
=
self
fabMenu
.
zPosition
=
1000
fabMenu
.
handleFABButtonCallback
=
handleFABButton
view
.
addSubview
(
fabMenu
)
}
}
...
...
@@ -174,33 +177,32 @@ extension FABMenuController {
}
}
extension
FABMenuController
:
FABMenuDelegate
{
@objc
open
func
fabMenuWillOpen
(
fabMenu
:
FABMenu
)
{
isUserInteractionEnabled
=
false
showFabMenuBacking
()
}
@objc
open
func
fabMenuDidOpen
(
fabMenu
:
FABMenu
)
{
isUserInteractionEnabled
=
true
}
extension
FABMenuController
{
/**
Handler to toggle the FABMenu opened or closed.
- Parameter button: A UIButton.
*/
@objc
open
func
fabMenuWillClose
(
fabMenu
:
FABMenu
)
{
fileprivate
func
handleFABButton
(
button
:
UIButton
)
{
guard
fabMenu
.
isOpened
else
{
isUserInteractionEnabled
=
false
showFabMenuBacking
()
fabMenu
.
open
(
isTriggeredByUserInteraction
:
true
,
completion
:
handleCompletion
)
return
}
isUserInteractionEnabled
=
false
hideFabMenuBacking
()
fabMenu
.
close
(
isTriggeredByUserInteraction
:
true
,
completion
:
handleCompletion
)
}
@objc
open
func
fabMenuDidClose
(
fabMenu
:
FABMenu
)
{
isUserInteractionEnabled
=
true
}
@objc
open
func
fabMenu
(
fabMenu
:
FABMenu
,
tappedAt
point
:
CGPoint
,
isOutside
:
Bool
)
{
guard
isOutside
else
{
return
/**
Completion handler for FABMenu open and close calls.
- Parameter view: A UIView.
*/
fileprivate
func
handleCompletion
(
view
:
UIView
)
{
if
view
==
fabMenu
.
fabMenuItems
.
last
{
isUserInteractionEnabled
=
true
}
}
}
Sources/iOS/Grid.swift
View file @
62f29b52
...
...
@@ -266,7 +266,7 @@ public struct Grid {
}
/// A memory reference to the Grid instance for UIView extensions.
private
var
GridKey
:
UInt8
=
0
file
private
var
GridKey
:
UInt8
=
0
/// Grid extension for UIView.
extension
UIView
{
...
...
Sources/iOS/Layout.swift
View file @
62f29b52
...
...
@@ -961,7 +961,7 @@ extension Layout {
}
/// A memory reference to the LayoutKey instance for UIView extensions.
private
var
LayoutKey
:
UInt8
=
0
file
private
var
LayoutKey
:
UInt8
=
0
/// Layout extension for UIView.
extension
UIView
{
...
...
Sources/iOS/NavigationItem.swift
View file @
62f29b52
...
...
@@ -31,8 +31,8 @@
import
UIKit
/// A memory reference to the NavigationItem instance.
private
var
NavigationItemKey
:
UInt8
=
0
private
var
NavigationItemContext
:
UInt8
=
0
file
private
var
NavigationItemKey
:
UInt8
=
0
file
private
var
NavigationItemContext
:
UInt8
=
0
public
class
NavigationItem
:
NSObject
{
/// Should center the contentView.
...
...
Sources/iOS/PageTabBarController.swift
View file @
62f29b52
...
...
@@ -31,7 +31,7 @@
import
UIKit
/// A memory reference to the PageTabBarItem instance for UIViewController extensions.
private
var
PageTabBarItemKey
:
UInt8
=
0
file
private
var
PageTabBarItemKey
:
UInt8
=
0
open
class
PageTabBarItem
:
FlatButton
{
open
override
func
prepare
()
{
...
...
Sources/iOS/Switch.swift
View file @
62f29b52
...
...
@@ -388,7 +388,7 @@ extension Switch {
internalSwitchState
=
state
if
animated
{
animateToState
(
state
:
state
)
{
[
weak
self
]
_
in
animateToState
(
state
:
state
)
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
]
_
in
guard
isTriggeredByUserInteraction
else
{
return
}
...
...
@@ -467,23 +467,23 @@ extension Switch {
fileprivate
func
animateToState
(
state
:
SwitchState
,
completion
:
((
Switch
)
->
Void
)?
=
nil
)
{
isUserInteractionEnabled
=
false
UIView
.
animate
(
withDuration
:
0.15
,
delay
:
0.05
,
options
:
[
.
curveEaseIn
,
.
curveEaseOut
],
animations
:
{
[
weak
self
]
in
guard
let
s
=
self
else
{
return
}
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
styleForState
(
state
:
state
)
delay
:
0.05
,
options
:
[
.
curveEaseIn
,
.
curveEaseOut
],
animations
:
{
[
weak
self
]
in
guard
let
s
=
self
else
{
return
}
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
+
s
.
bounceOffset
:
s
.
offPosition
-
s
.
bounceOffset
s
.
styleForState
(
state
:
state
)
})
{
[
weak
self
]
_
in
UIView
.
animate
(
withDuration
:
0.15
,
animations
:
{
[
weak
self
]
in
guard
let
s
=
self
else
{
return
}
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
animations
:
{
[
weak
self
]
in
guard
let
s
=
self
else
{
return
}
s
.
button
.
x
=
.
on
==
state
?
s
.
onPosition
:
s
.
offPosition
})
{
[
weak
self
]
_
in
guard
let
s
=
self
else
{
return
...
...
Sources/iOS/TabBar.swift
View file @
62f29b52
...
...
@@ -254,7 +254,7 @@ extension TabBar {
s
.
line
.
center
.
x
=
button
.
center
.
x
s
.
line
.
width
=
button
.
width
})
{
[
weak
self
,
button
=
button
,
completion
=
completion
]
_
in
})
{
[
weak
self
,
isTriggeredByUserInteraction
=
isTriggeredByUserInteraction
,
button
=
button
,
completion
=
completion
]
_
in
guard
let
s
=
self
else
{
return
}
...
...
Sources/iOS/Toolbar.swift
View file @
62f29b52
...
...
@@ -30,7 +30,7 @@
import
UIKit
private
var
ToolbarContext
:
UInt8
=
0
file
private
var
ToolbarContext
:
UInt8
=
0
open
class
Toolbar
:
Bar
{
/// A convenience property to set the titleLabel.text.
...
...
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