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