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
4d2a95fb
Unverified
Commit
4d2a95fb
authored
Aug 31, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: added Snackbar alignment to top and bottom with delegation
parent
15a0e382
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
35 deletions
+60
-35
Sources/iOS/SnackbarController.swift
+60
-35
No files found.
Sources/iOS/SnackbarController.swift
View file @
4d2a95fb
...
...
@@ -30,36 +30,42 @@
import
UIKit
//@objc(SnackbarDelegate)
//public protocol SnackbarDelegate {
// /**
// A delegation method that is executed when a Snackbar will show.
// - Parameter snackbar: A Snackbar.
// */
// @objc
// optional func snackbarWillShow(snackbar: Snackbar)
//
// /**
// A delegation method that is executed when a Snackbar did show.
// - Parameter snackbar: A Snackbar.
// */
// @objc
// optional func snackbarDidShow(snackbar: Snackbar)
//
// /**
// A delegation method that is executed when a Snackbar will hide.
// - Parameter snackbar: A Snackbar.
// */
// @objc
// optional func snackbarWillHide(snackbar: Snackbar)
//
// /**
// A delegation method that is executed when a Snackbar did hide.
// - Parameter snackbar: A Snackbar.
// */
// @objc
// optional func snackbarDidHide(snackbar: Snackbar)
//}
@objc(SnackbarControllerDelegate)
public
protocol
SnackbarControllerDelegate
{
/**
A delegation method that is executed when a Snackbar will show.
- Parameter snackbarController: A SnackbarController.
*/
@objc
optional
func
snackbarControllerWillShow
(
snackbarController
:
SnackbarController
)
/**
A delegation method that is executed when a Snackbar did show.
- Parameter snackbarController: A SnackbarController.
*/
@objc
optional
func
snackbarControllerDidShow
(
snackbarController
:
SnackbarController
)
/**
A delegation method that is executed when a Snackbar will hide.
- Parameter snackbarController: A SnackbarController.
*/
@objc
optional
func
snackbarControllerWillHide
(
snackbarController
:
SnackbarController
)
/**
A delegation method that is executed when a Snackbar did hide.
- Parameter snackbarController: A SnackbarController.
*/
@objc
optional
func
snackbarControllerDidHide
(
snackbarController
:
SnackbarController
)
}
@objc(SnackbarAlignment)
public
enum
SnackbarAlignment
:
Int
{
case
top
case
bottom
}
extension
UIViewController
{
/**
...
...
@@ -86,6 +92,12 @@ open class SnackbarController: RootController {
/// Reference to the Snackbar.
open
internal(set)
lazy
var
snackbar
:
Snackbar
=
Snackbar
()
/// Delegation handler.
open
weak
var
delegate
:
SnackbarControllerDelegate
?
/// Snackbar alignment setting.
open
var
snackbarAlignment
=
SnackbarAlignment
.
bottom
/**
Animates to a SnackbarStatus.
- Parameter status: A SnackbarStatus enum value.
...
...
@@ -96,6 +108,12 @@ open class SnackbarController: RootController {
return
}
if
.
visible
==
status
{
s
.
delegate
?
.
snackbarControllerWillShow
?(
snackbarController
:
s
)
}
else
{
s
.
delegate
?
.
snackbarControllerWillHide
?(
snackbarController
:
s
)
}
s
.
isAnimating
=
true
s
.
isUserInteractionEnabled
=
false
...
...
@@ -116,6 +134,12 @@ open class SnackbarController: RootController {
s
.
isUserInteractionEnabled
=
true
s
.
snackbar
.
status
=
status
if
.
visible
==
status
{
s
.
delegate
?
.
snackbarControllerDidShow
?(
snackbarController
:
s
)
}
else
{
s
.
delegate
?
.
snackbarControllerDidHide
?(
snackbarController
:
s
)
}
completion
?(
s
.
snackbar
)
}
}
...
...
@@ -162,7 +186,11 @@ open class SnackbarController: RootController {
let
p
=
snackbar
.
intrinsicContentSize
.
height
+
snackbar
.
grid
.
layoutEdgeInsets
.
top
+
snackbar
.
grid
.
layoutEdgeInsets
.
bottom
snackbar
.
width
=
view
.
width
snackbar
.
height
=
p
snackbar
.
y
=
.
visible
==
status
?
view
.
height
-
p
:
view
.
height
if
.
bottom
==
snackbarAlignment
{
snackbar
.
y
=
.
visible
==
status
?
view
.
height
-
p
:
view
.
height
}
else
{
snackbar
.
y
=
.
visible
==
status
?
0
:
-
snackbar
.
height
}
snackbar
.
divider
.
reload
()
}
...
...
@@ -175,9 +203,6 @@ open class SnackbarController: RootController {
return
}
vc
.
view
.
x
=
0
vc
.
view
.
y
=
0
vc
.
view
.
width
=
view
.
width
vc
.
view
.
height
=
.
visible
==
status
?
view
.
height
-
snackbar
.
height
:
view
.
height
vc
.
view
.
frame
=
view
.
bounds
}
}
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