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
9efac5ec
Unverified
Commit
9efac5ec
authored
Aug 28, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: updates to RootController types and Snackbar
parent
e1fd6014
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
231 additions
and
174 deletions
+231
-174
Sources/iOS/MenuController.swift
+1
-1
Sources/iOS/NavigationItem.swift
+2
-2
Sources/iOS/PageTabBarController.swift
+22
-23
Sources/iOS/RobotoFont.swift
+15
-15
Sources/iOS/SearchBar.swift
+17
-12
Sources/iOS/SearchBarController.swift
+8
-14
Sources/iOS/Snackbar.swift
+44
-38
Sources/iOS/SnackbarController.swift
+96
-36
Sources/iOS/StatusBarController.swift
+4
-5
Sources/iOS/TextField.swift
+2
-2
Sources/iOS/Toolbar.swift
+9
-9
Sources/iOS/ToolbarController.swift
+11
-17
No files found.
Sources/iOS/MenuController.swift
View file @
9efac5ec
...
@@ -51,7 +51,7 @@ extension UIViewController {
...
@@ -51,7 +51,7 @@ extension UIViewController {
@IBDesignable
@IBDesignable
public
class
MenuController
:
RootController
{
public
class
MenuController
:
RootController
{
/// Reference to the MenuView.
/// Reference to the MenuView.
public
private(set)
lazy
var
menuView
:
MenuView
=
MenuView
()
public
private(set)
lazy
var
menuView
:
MenuView
=
MenuView
()
/**
/**
Opens the menu with a callback.
Opens the menu with a callback.
...
...
Sources/iOS/NavigationItem.swift
View file @
9efac5ec
...
@@ -75,14 +75,14 @@ public class NavigationItem {
...
@@ -75,14 +75,14 @@ public class NavigationItem {
/// Prepares the titleLabel.
/// Prepares the titleLabel.
private
func
prepareTitleLabel
()
{
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
=
UILabel
()
titleLabel
.
font
=
RobotoFont
.
medium
WithSize
(
size
:
17
)
titleLabel
.
font
=
RobotoFont
.
medium
(
with
:
17
)
titleLabel
.
textAlignment
=
.
center
titleLabel
.
textAlignment
=
.
center
}
}
/// Prepares the detailLabel.
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
=
UILabel
()
detailLabel
.
font
=
RobotoFont
.
regular
WithSize
(
size
:
12
)
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
detailLabel
.
textAlignment
=
.
center
detailLabel
.
textAlignment
=
.
center
}
}
}
}
...
...
Sources/iOS/PageTabBarController.swift
View file @
9efac5ec
...
@@ -110,7 +110,7 @@ open class PageTabBarController: RootController {
...
@@ -110,7 +110,7 @@ open class PageTabBarController: RootController {
open
var
pageTabBarAlignment
=
PageTabBarAlignment
.
bottom
open
var
pageTabBarAlignment
=
PageTabBarAlignment
.
bottom
/// Reference to the PageTabBar.
/// Reference to the PageTabBar.
open
internal(set)
var
pageTabBar
:
PageTabBar
!
open
internal(set)
lazy
var
pageTabBar
:
PageTabBar
=
PageTabBar
()
/// Delegation handler.
/// Delegation handler.
open
weak
var
delegate
:
PageTabBarControllerDelegate
?
open
weak
var
delegate
:
PageTabBarControllerDelegate
?
...
@@ -147,30 +147,39 @@ open class PageTabBarController: RootController {
...
@@ -147,30 +147,39 @@ open class PageTabBarController: RootController {
*/
*/
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
guard
let
v
=
pageTabBar
else
{
return
}
let
w
=
view
.
width
let
w
=
view
.
width
let
h
=
view
.
height
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
let
p
=
pageTabBar
.
intrinsicContentSize
.
height
+
pageTabBar
.
grid
.
layoutEdgeInsets
.
top
+
pageTabBar
.
grid
.
layoutEdgeInsets
.
bottom
let
y
=
h
-
p
let
y
=
h
-
p
v
.
height
=
p
pageTabBar
.
height
=
p
v
.
width
=
w
+
v
.
grid
.
layoutEdgeInsets
.
left
+
v
.
grid
.
layoutEdgeInsets
.
right
pageTabBar
.
width
=
w
+
pageTabBar
.
grid
.
layoutEdgeInsets
.
left
+
pageTabBar
.
grid
.
layoutEdgeInsets
.
right
rootViewController
.
view
.
height
=
y
rootViewController
.
view
.
height
=
y
switch
pageTabBarAlignment
{
switch
pageTabBarAlignment
{
case
.
top
:
case
.
top
:
v
.
y
=
0
pageTabBar
.
y
=
0
rootViewController
.
view
.
y
=
p
rootViewController
.
view
.
y
=
p
case
.
bottom
:
case
.
bottom
:
v
.
y
=
y
pageTabBar
.
y
=
y
rootViewController
.
view
.
y
=
0
rootViewController
.
view
.
y
=
0
}
}
v
.
divider
.
reload
()
pageTabBar
.
divider
.
reload
()
}
/**
Sets the view controllers.
- Parameter _ viewController: An Array of UIViewControllers.
- Parameter direction: A UIPageViewControllerNavigationDirection enum value.
- Parameter animated: A boolean indicating to include animation.
- Parameter completion: An optional completion block.
*/
open
func
setViewControllers
(
_
viewControllers
:
[
UIViewController
],
direction
:
UIPageViewControllerNavigationDirection
,
animated
:
Bool
,
completion
:
(
@escaping
(
Bool
)
->
Void
)?
=
nil
)
{
pageViewController
?
.
setViewControllers
(
viewControllers
,
direction
:
direction
,
animated
:
animated
,
completion
:
completion
)
preparePageTabBarItems
()
}
}
/**
/**
...
@@ -248,19 +257,9 @@ open class PageTabBarController: RootController {
...
@@ -248,19 +257,9 @@ open class PageTabBarController: RootController {
/// Prepares the pageTabBar.
/// Prepares the pageTabBar.
private
func
preparePageTabBar
()
{
private
func
preparePageTabBar
()
{
if
nil
==
pageTabBar
{
pageTabBar
.
zPosition
=
1000
pageTabBar
=
PageTabBar
()
view
.
addSubview
(
pageTabBar
)
pageTabBar
.
zPosition
=
1000
pageTabBar
.
select
(
at
:
selectedIndex
)
view
.
addSubview
(
pageTabBar
)
pageTabBar
.
select
(
at
:
selectedIndex
)
}
}
}
extension
PageTabBarController
{
open
func
setViewControllers
(
_
viewControllers
:
[
UIViewController
]?,
direction
:
UIPageViewControllerNavigationDirection
,
animated
:
Bool
,
completion
:
(
@escaping
(
Bool
)
->
Void
)?
=
nil
)
{
pageViewController
?
.
setViewControllers
(
viewControllers
,
direction
:
direction
,
animated
:
animated
,
completion
:
completion
)
preparePageTabBarItems
()
}
}
}
}
...
...
Sources/iOS/RobotoFont.swift
View file @
9efac5ec
...
@@ -38,35 +38,35 @@ public struct RobotoFont: FontType {
...
@@ -38,35 +38,35 @@ public struct RobotoFont: FontType {
/// Thin font.
/// Thin font.
public
static
var
thin
:
UIFont
{
public
static
var
thin
:
UIFont
{
return
thin
WithSize
(
size
:
Font
.
pointSize
)
return
thin
(
with
:
Font
.
pointSize
)
}
}
/// Light font.
/// Light font.
public
static
var
light
:
UIFont
{
public
static
var
light
:
UIFont
{
return
light
WithSize
(
size
:
Font
.
pointSize
)
return
light
(
with
:
Font
.
pointSize
)
}
}
/// Regular font.
/// Regular font.
public
static
var
regular
:
UIFont
{
public
static
var
regular
:
UIFont
{
return
regular
WithSize
(
size
:
Font
.
pointSize
)
return
regular
(
with
:
Font
.
pointSize
)
}
}
/// Medium font.
/// Medium font.
public
static
var
medium
:
UIFont
{
public
static
var
medium
:
UIFont
{
return
medium
WithSize
(
size
:
Font
.
pointSize
)
return
medium
(
with
:
Font
.
pointSize
)
}
}
/// Bold font.
/// Bold font.
public
static
var
bold
:
UIFont
{
public
static
var
bold
:
UIFont
{
return
bold
WithSize
(
size
:
Font
.
pointSize
)
return
bold
(
with
:
Font
.
pointSize
)
}
}
/**
/**
Thin with size font.
Thin with size font.
- Parameter size: A CGFLoat for the font size.
- Parameter
with
size: A CGFLoat for the font size.
- Returns: A UIFont.
- Returns: A UIFont.
*/
*/
public
static
func
thin
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
thin
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Thin"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Thin"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Thin"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Thin"
,
size
:
size
)
{
return
f
return
f
...
@@ -76,10 +76,10 @@ public struct RobotoFont: FontType {
...
@@ -76,10 +76,10 @@ public struct RobotoFont: FontType {
/**
/**
Light with size font.
Light with size font.
- Parameter size: A CGFLoat for the font size.
- Parameter
with
size: A CGFLoat for the font size.
- Returns: A UIFont.
- Returns: A UIFont.
*/
*/
public
static
func
light
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
light
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Light"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Light"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Light"
,
size
:
size
)
{
return
f
return
f
...
@@ -89,10 +89,10 @@ public struct RobotoFont: FontType {
...
@@ -89,10 +89,10 @@ public struct RobotoFont: FontType {
/**
/**
Regular with size font.
Regular with size font.
- Parameter size: A CGFLoat for the font size.
- Parameter
with
size: A CGFLoat for the font size.
- Returns: A UIFont.
- Returns: A UIFont.
*/
*/
public
static
func
regular
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
regular
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Regular"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Regular"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Regular"
,
size
:
size
)
{
return
f
return
f
...
@@ -102,10 +102,10 @@ public struct RobotoFont: FontType {
...
@@ -102,10 +102,10 @@ public struct RobotoFont: FontType {
/**
/**
Medium with size font.
Medium with size font.
- Parameter size: A CGFLoat for the font size.
- Parameter
with
size: A CGFLoat for the font size.
- Returns: A UIFont.
- Returns: A UIFont.
*/
*/
public
static
func
medium
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
medium
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Medium"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Medium"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Medium"
,
size
:
size
)
{
return
f
return
f
...
@@ -115,10 +115,10 @@ public struct RobotoFont: FontType {
...
@@ -115,10 +115,10 @@ public struct RobotoFont: FontType {
/**
/**
Bold with size font.
Bold with size font.
- Parameter size: A CGFLoat for the font size.
- Parameter
with
size: A CGFLoat for the font size.
- Returns: A UIFont.
- Returns: A UIFont.
*/
*/
public
static
func
bold
WithSize
(
size
:
CGFloat
)
->
UIFont
{
public
static
func
bold
(
with
size
:
CGFloat
)
->
UIFont
{
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Bold"
)
Font
.
loadFontIfNeeded
(
name
:
"Roboto-Bold"
)
if
let
f
=
UIFont
(
name
:
"Roboto-Bold"
,
size
:
size
)
{
if
let
f
=
UIFont
(
name
:
"Roboto-Bold"
,
size
:
size
)
{
return
f
return
f
...
...
Sources/iOS/SearchBar.swift
View file @
9efac5ec
...
@@ -30,15 +30,16 @@
...
@@ -30,15 +30,16 @@
import
UIKit
import
UIKit
public
class
SearchBar
:
BarView
{
open
class
SearchBar
:
BarView
{
/// The UITextField for the searchBar.
/// The UITextField for the searchBar.
public
private(set)
var
textField
:
UITextField
!
open
private(set)
var
textField
:
UITextField
!
/// Reference to the clearButton.
/// Reference to the clearButton.
public
private(set)
var
clearButton
:
IconButton
!
open
private(set)
var
clearButton
:
IconButton
!
/// Handle the clearButton manually.
/// Handle the clearButton manually.
@IBInspectable
public
var
clearButtonAutoHandleEnabled
:
Bool
=
true
{
@IBInspectable
open
var
clearButtonAutoHandleEnabled
:
Bool
=
true
{
didSet
{
didSet
{
clearButton
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
touchUpInside
)
clearButton
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
for
:
.
touchUpInside
)
if
clearButtonAutoHandleEnabled
{
if
clearButtonAutoHandleEnabled
{
...
@@ -48,7 +49,8 @@ public class SearchBar: BarView {
...
@@ -48,7 +49,8 @@ public class SearchBar: BarView {
}
}
/// TintColor for searchBar.
/// TintColor for searchBar.
@IBInspectable
public
override
var
tintColor
:
UIColor
?
{
@IBInspectable
open
override
var
tintColor
:
UIColor
?
{
get
{
get
{
return
textField
.
tintColor
return
textField
.
tintColor
}
}
...
@@ -58,7 +60,8 @@ public class SearchBar: BarView {
...
@@ -58,7 +60,8 @@ public class SearchBar: BarView {
}
}
/// TextColor for searchBar.
/// TextColor for searchBar.
@IBInspectable
public
var
textColor
:
UIColor
?
{
@IBInspectable
open
var
textColor
:
UIColor
?
{
get
{
get
{
return
textField
.
textColor
return
textField
.
textColor
}
}
...
@@ -68,7 +71,8 @@ public class SearchBar: BarView {
...
@@ -68,7 +71,8 @@ public class SearchBar: BarView {
}
}
/// Sets the textField placeholder value.
/// Sets the textField placeholder value.
@IBInspectable
public
var
placeholder
:
String
?
{
@IBInspectable
open
var
placeholder
:
String
?
{
didSet
{
didSet
{
if
let
v
:
String
=
placeholder
{
if
let
v
:
String
=
placeholder
{
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
...
@@ -77,7 +81,8 @@ public class SearchBar: BarView {
...
@@ -77,7 +81,8 @@ public class SearchBar: BarView {
}
}
/// Placeholder textColor.
/// Placeholder textColor.
@IBInspectable
public
var
placeholderColor
:
UIColor
=
Color
.
darkText
.
others
{
@IBInspectable
open
var
placeholderColor
:
UIColor
=
Color
.
darkText
.
others
{
didSet
{
didSet
{
if
let
v
:
String
=
placeholder
{
if
let
v
:
String
=
placeholder
{
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
textField
.
attributedPlaceholder
=
NSAttributedString
(
string
:
v
,
attributes
:
[
NSForegroundColorAttributeName
:
placeholderColor
])
...
@@ -85,7 +90,7 @@ public class SearchBar: BarView {
...
@@ -85,7 +90,7 @@ public class SearchBar: BarView {
}
}
}
}
public
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
if
willRenderView
{
if
willRenderView
{
textField
.
frame
=
contentView
.
bounds
textField
.
frame
=
contentView
.
bounds
...
@@ -127,14 +132,14 @@ public class SearchBar: BarView {
...
@@ -127,14 +132,14 @@ public class SearchBar: BarView {
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
prepareTextField
()
prepareTextField
()
prepareClearButton
()
prepareClearButton
()
}
}
/// Layout the clearButton.
/// Layout the clearButton.
public
func
layoutClearButton
()
{
open
func
layoutClearButton
()
{
let
h
:
CGFloat
=
textField
.
frame
.
height
let
h
:
CGFloat
=
textField
.
frame
.
height
clearButton
.
frame
=
CGRect
(
x
:
textField
.
frame
.
width
-
h
,
y
:
0
,
width
:
h
,
height
:
h
)
clearButton
.
frame
=
CGRect
(
x
:
textField
.
frame
.
width
-
h
,
y
:
0
,
width
:
h
,
height
:
h
)
}
}
...
@@ -148,7 +153,7 @@ public class SearchBar: BarView {
...
@@ -148,7 +153,7 @@ public class SearchBar: BarView {
private
func
prepareTextField
()
{
private
func
prepareTextField
()
{
textField
=
UITextField
()
textField
=
UITextField
()
textField
.
contentScaleFactor
=
Device
.
scale
textField
.
contentScaleFactor
=
Device
.
scale
textField
.
font
=
RobotoFont
.
regular
WithSize
(
size
:
17
)
textField
.
font
=
RobotoFont
.
regular
(
with
:
17
)
textField
.
backgroundColor
=
Color
.
clear
textField
.
backgroundColor
=
Color
.
clear
textField
.
clearButtonMode
=
.
whileEditing
textField
.
clearButtonMode
=
.
whileEditing
tintColor
=
placeholderColor
tintColor
=
placeholderColor
...
...
Sources/iOS/SearchBarController.swift
View file @
9efac5ec
...
@@ -50,7 +50,7 @@ extension UIViewController {
...
@@ -50,7 +50,7 @@ extension UIViewController {
open
class
SearchBarController
:
RootController
{
open
class
SearchBarController
:
RootController
{
/// Reference to the SearchBar.
/// Reference to the SearchBar.
open
internal(set)
var
searchBar
:
SearchBar
!
open
internal(set)
lazy
var
searchBar
:
SearchBar
=
SearchBar
()
/**
/**
To execute in the order of the layout chain, override this
To execute in the order of the layout chain, override this
...
@@ -59,23 +59,20 @@ open class SearchBarController: RootController {
...
@@ -59,23 +59,20 @@ open class SearchBarController: RootController {
*/
*/
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
guard
let
v
=
searchBar
else
{
return
}
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
searchBar
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
let
w
=
view
.
width
let
w
=
view
.
width
let
h
=
view
.
height
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
let
p
=
searchBar
.
intrinsicContentSize
.
height
+
searchBar
.
grid
.
layoutEdgeInsets
.
top
+
searchBar
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
+
v
.
grid
.
layoutEdgeInsets
.
left
+
v
.
grid
.
layoutEdgeInsets
.
right
searchBar
.
width
=
w
+
searchBar
.
grid
.
layoutEdgeInsets
.
left
+
searchBar
.
grid
.
layoutEdgeInsets
.
right
v
.
height
=
p
searchBar
.
height
=
p
rootViewController
.
view
.
y
=
p
rootViewController
.
view
.
y
=
p
rootViewController
.
view
.
height
=
h
-
p
rootViewController
.
view
.
height
=
h
-
p
v
.
divider
.
reload
()
searchBar
.
divider
.
reload
()
}
}
/**
/**
...
@@ -92,10 +89,7 @@ open class SearchBarController: RootController {
...
@@ -92,10 +89,7 @@ open class SearchBarController: RootController {
/// Prepares the searchBar.
/// Prepares the searchBar.
private
func
prepareSearchBar
()
{
private
func
prepareSearchBar
()
{
if
nil
==
searchBar
{
searchBar
.
zPosition
=
1000
searchBar
=
SearchBar
()
view
.
addSubview
(
searchBar
)
searchBar
.
zPosition
=
1000
view
.
addSubview
(
searchBar
)
}
}
}
}
}
Sources/iOS/Snackbar.swift
View file @
9efac5ec
...
@@ -30,55 +30,49 @@
...
@@ -30,55 +30,49 @@
import
UIKit
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(SnackbarStatus)
@objc(SnackbarStatus)
public
enum
SnackbarStatus
:
Int
{
public
enum
SnackbarStatus
:
Int
{
case
visible
case
visible
case
notVisible
case
notVisible
case
animating
}
}
@objc(Snackbar)
open
class
Snackbar
:
BarView
{
open
class
Snackbar
:
BarView
{
/// Delegation handler.
/// A convenience property to set the titleLabel text.
open
weak
var
delegate
:
SnackbarDelegate
?
public
var
text
:
String
?
{
get
{
return
textLabel
?
.
text
}
set
(
value
)
{
textLabel
?
.
text
=
value
layoutSubviews
()
}
}
/// Text label.
public
private(set)
var
textLabel
:
UILabel
!
open
override
var
intrinsicContentSize
:
CGSize
{
open
override
var
intrinsicContentSize
:
CGSize
{
return
CGSize
(
width
:
width
,
height
:
4
8
)
return
CGSize
(
width
:
width
,
height
:
4
9
)
}
}
/// The status of the snackbar.
/// The status of the snackbar.
open
internal(set)
var
status
=
SnackbarStatus
.
visible
open
internal(set)
var
status
=
SnackbarStatus
.
notVisible
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
if
willRenderView
{
if
nil
!=
text
&&
""
!=
text
{
if
nil
==
textLabel
.
superview
{
contentView
.
addSubview
(
textLabel
)
}
textLabel
.
frame
=
contentView
.
bounds
}
else
{
textLabel
.
removeFromSuperview
()
}
contentView
.
grid
.
reload
()
}
}
/**
/**
Prepares the view instance when intialized. When subclassing,
Prepares the view instance when intialized. When subclassing,
...
@@ -89,6 +83,18 @@ open class Snackbar: BarView {
...
@@ -89,6 +83,18 @@ open class Snackbar: BarView {
*/
*/
open
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
backgroundColor
=
Color
.
grey
.
darken4
backgroundColor
=
Color
.
grey
.
darken3
grid
.
contentEdgeInsets
=
EdgeInsets
(
top
:
0
,
left
:
24
,
bottom
:
0
,
right
:
24
)
grid
.
interimSpace
=
24
prepareTextLabel
()
}
/// Prepares the textLabel.
private
func
prepareTextLabel
()
{
textLabel
=
UILabel
()
textLabel
.
contentScaleFactor
=
Device
.
scale
textLabel
.
font
=
RobotoFont
.
medium
(
with
:
14
)
textLabel
.
textAlignment
=
.
left
textLabel
.
textColor
=
Color
.
white
}
}
}
}
Sources/iOS/SnackbarController.swift
View file @
9efac5ec
...
@@ -30,6 +30,37 @@
...
@@ -30,6 +30,37 @@
import
UIKit
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)
//}
extension
UIViewController
{
extension
UIViewController
{
/**
/**
A convenience property that provides access to the SnackbarController.
A convenience property that provides access to the SnackbarController.
...
@@ -49,14 +80,35 @@ extension UIViewController {
...
@@ -49,14 +80,35 @@ extension UIViewController {
}
}
open
class
SnackbarController
:
RootController
{
open
class
SnackbarController
:
RootController
{
/**
/// A boolean indicating if the Snacbar is animating.
A boolean that indicates whether to move the view controller
open
internal(set)
var
isAnimating
=
false
when the Snackbar animates.
*/
open
var
isSnackbarAttachedToController
=
false
/// Reference to the Snackbar.
/// Reference to the Snackbar.
open
internal(set)
var
snackbar
:
Snackbar
!
open
internal(set)
lazy
var
snackbar
:
Snackbar
=
Snackbar
()
/**
Animates to a SnackbarStatus.
- Parameter status: A SnackbarStatus enum value.
*/
open
func
animate
(
snackbar
status
:
SnackbarStatus
,
animations
:
(
@escaping
(
Snackbar
)
->
Void
)?
=
nil
,
completion
:
(
@escaping
(
Snackbar
)
->
Void
)?
=
nil
)
{
isAnimating
=
true
UIView
.
animate
(
withDuration
:
0.25
,
animations
:
{
[
weak
self
,
status
=
status
,
animations
=
animations
]
in
guard
let
s
=
self
else
{
return
}
s
.
layoutSnackbar
(
status
:
status
)
animations
?(
s
.
snackbar
)
})
{
[
weak
self
,
status
=
status
,
completion
=
completion
]
_
in
guard
let
s
=
self
else
{
return
}
s
.
isAnimating
=
false
s
.
snackbar
.
status
=
status
completion
?(
s
.
snackbar
)
}
}
/**
/**
To execute in the order of the layout chain, override this
To execute in the order of the layout chain, override this
...
@@ -65,35 +117,11 @@ open class SnackbarController: RootController {
...
@@ -65,35 +117,11 @@ open class SnackbarController: RootController {
*/
*/
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
guard
let
v
=
snackbar
else
{
guard
!
isAnimating
else
{
return
return
}
}
let
w
=
view
.
width
layoutSnackbar
(
status
:
snackbar
.
status
)
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
v
.
height
=
p
rootViewController
.
view
.
x
=
0
rootViewController
.
view
.
y
=
0
rootViewController
.
view
.
width
=
w
switch
v
.
status
{
case
.
visible
:
let
y
=
h
-
p
v
.
y
=
y
v
.
isHidden
=
false
rootViewController
.
view
.
height
=
y
case
.
notVisible
:
v
.
y
=
h
v
.
isHidden
=
true
rootViewController
.
view
.
height
=
h
case
.
animating
:
break
}
v
.
divider
.
reload
()
}
}
/**
/**
...
@@ -110,10 +138,42 @@ open class SnackbarController: RootController {
...
@@ -110,10 +138,42 @@ open class SnackbarController: RootController {
/// Prepares the snackbar.
/// Prepares the snackbar.
private
func
prepareSnackbar
()
{
private
func
prepareSnackbar
()
{
if
nil
==
snackbar
{
snackbar
.
zPosition
=
10000
snackbar
=
Snackbar
()
view
.
addSubview
(
snackbar
)
snackbar
.
zPosition
=
10000
}
view
.
addSubview
(
snackbar
)
/**
Lays out the Snackbar.
- Parameter status: A SnackbarStatus enum value.
*/
private
func
layoutSnackbar
(
status
:
SnackbarStatus
)
{
guard
let
vc
=
rootViewController
else
{
return
}
}
let
w
=
view
.
width
let
h
=
view
.
height
let
p
=
snackbar
.
intrinsicContentSize
.
height
+
snackbar
.
grid
.
layoutEdgeInsets
.
top
+
snackbar
.
grid
.
layoutEdgeInsets
.
bottom
snackbar
.
width
=
w
snackbar
.
height
=
p
vc
.
view
.
x
=
0
vc
.
view
.
y
=
0
vc
.
view
.
width
=
w
switch
status
{
case
.
visible
:
let
y
=
h
-
p
snackbar
.
y
=
y
snackbar
.
isHidden
=
false
vc
.
view
.
height
=
y
case
.
notVisible
:
snackbar
.
y
=
h
snackbar
.
isHidden
=
true
vc
.
view
.
height
=
h
}
snackbar
.
divider
.
reload
()
}
}
}
}
Sources/iOS/StatusBarController.swift
View file @
9efac5ec
...
@@ -49,16 +49,16 @@ extension UIViewController {
...
@@ -49,16 +49,16 @@ extension UIViewController {
}
}
@IBDesignable
@IBDesignable
public
class
StatusBarController
:
RootController
{
open
class
StatusBarController
:
RootController
{
/// A reference to the statusBarView.
/// A reference to the statusBarView.
public
private(set)
var
statusBarView
:
View
!
open
internal(set)
lazy
var
statusBarView
=
View
()
/**
/**
To execute in the order of the layout chain, override this
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
method. LayoutSubviews should be called immediately, unless you
have a certain need.
have a certain need.
*/
*/
public
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
statusBarView
.
isHidden
=
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
statusBarView
.
isHidden
=
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
rootViewController
.
view
.
frame
=
view
.
bounds
rootViewController
.
view
.
frame
=
view
.
bounds
...
@@ -71,14 +71,13 @@ public class StatusBarController: RootController {
...
@@ -71,14 +71,13 @@ public class StatusBarController: RootController {
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
prepareStatusBarView
()
prepareStatusBarView
()
}
}
/// Prepares the statusBarView.
/// Prepares the statusBarView.
private
func
prepareStatusBarView
()
{
private
func
prepareStatusBarView
()
{
statusBarView
=
View
()
statusBarView
.
zPosition
=
3000
statusBarView
.
zPosition
=
3000
statusBarView
.
backgroundColor
=
Color
.
black
.
withAlphaComponent
(
0.12
)
statusBarView
.
backgroundColor
=
Color
.
black
.
withAlphaComponent
(
0.12
)
_
=
view
.
layout
(
statusBarView
)
.
top
(
0
)
.
horizontally
()
.
height
(
20
)
_
=
view
.
layout
(
statusBarView
)
.
top
(
0
)
.
horizontally
()
.
height
(
20
)
...
...
Sources/iOS/TextField.swift
View file @
9efac5ec
...
@@ -509,13 +509,13 @@ open class TextField: UITextField {
...
@@ -509,13 +509,13 @@ open class TextField: UITextField {
private
func
preparePlaceholderLabel
()
{
private
func
preparePlaceholderLabel
()
{
placeholderLabel
=
UILabel
(
frame
:
.
zero
)
placeholderLabel
=
UILabel
(
frame
:
.
zero
)
placeholderColor
=
Color
.
darkText
.
others
placeholderColor
=
Color
.
darkText
.
others
font
=
RobotoFont
.
regular
WithSize
(
size
:
16
)
font
=
RobotoFont
.
regular
(
with
:
16
)
addSubview
(
placeholderLabel
)
addSubview
(
placeholderLabel
)
}
}
/// Prepares the detailLabel.
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
private
func
prepareDetailLabel
()
{
detailLabel
.
font
=
RobotoFont
.
regular
WithSize
(
size
:
12
)
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
detailColor
=
Color
.
darkText
.
others
detailColor
=
Color
.
darkText
.
others
addSubview
(
detailLabel
)
addSubview
(
detailLabel
)
}
}
...
...
Sources/iOS/Toolbar.swift
View file @
9efac5ec
...
@@ -30,9 +30,9 @@
...
@@ -30,9 +30,9 @@
import
UIKit
import
UIKit
public
class
Toolbar
:
BarView
{
open
class
Toolbar
:
BarView
{
/// A convenience property to set the titleLabel text.
/// A convenience property to set the titleLabel text.
public
var
title
:
String
?
{
open
var
title
:
String
?
{
get
{
get
{
return
titleLabel
?
.
text
return
titleLabel
?
.
text
}
}
...
@@ -43,10 +43,10 @@ public class Toolbar: BarView {
...
@@ -43,10 +43,10 @@ public class Toolbar: BarView {
}
}
/// Title label.
/// Title label.
public
private(set)
var
titleLabel
:
UILabel
!
open
private(set)
var
titleLabel
:
UILabel
!
/// A convenience property to set the detailLabel text.
/// A convenience property to set the detailLabel text.
public
var
detail
:
String
?
{
open
var
detail
:
String
?
{
get
{
get
{
return
detailLabel
?
.
text
return
detailLabel
?
.
text
}
}
...
@@ -57,9 +57,9 @@ public class Toolbar: BarView {
...
@@ -57,9 +57,9 @@ public class Toolbar: BarView {
}
}
/// Detail label.
/// Detail label.
public
private(set)
var
detailLabel
:
UILabel
!
open
private(set)
var
detailLabel
:
UILabel
!
public
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
if
willRenderView
{
if
willRenderView
{
...
@@ -134,7 +134,7 @@ public class Toolbar: BarView {
...
@@ -134,7 +134,7 @@ public class Toolbar: BarView {
The super.prepareView method should always be called immediately
The super.prepareView method should always be called immediately
when subclassing.
when subclassing.
*/
*/
public
override
func
prepareView
()
{
open
override
func
prepareView
()
{
super
.
prepareView
()
super
.
prepareView
()
prepareTitleLabel
()
prepareTitleLabel
()
prepareDetailLabel
()
prepareDetailLabel
()
...
@@ -144,7 +144,7 @@ public class Toolbar: BarView {
...
@@ -144,7 +144,7 @@ public class Toolbar: BarView {
private
func
prepareTitleLabel
()
{
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
=
UILabel
()
titleLabel
.
contentScaleFactor
=
Device
.
scale
titleLabel
.
contentScaleFactor
=
Device
.
scale
titleLabel
.
font
=
RobotoFont
.
medium
WithSize
(
size
:
17
)
titleLabel
.
font
=
RobotoFont
.
medium
(
with
:
17
)
titleLabel
.
textAlignment
=
.
left
titleLabel
.
textAlignment
=
.
left
}
}
...
@@ -152,7 +152,7 @@ public class Toolbar: BarView {
...
@@ -152,7 +152,7 @@ public class Toolbar: BarView {
private
func
prepareDetailLabel
()
{
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
=
UILabel
()
detailLabel
.
contentScaleFactor
=
Device
.
scale
detailLabel
.
contentScaleFactor
=
Device
.
scale
detailLabel
.
font
=
RobotoFont
.
regular
WithSize
(
size
:
12
)
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
detailLabel
.
textAlignment
=
.
left
detailLabel
.
textAlignment
=
.
left
}
}
}
}
Sources/iOS/ToolbarController.swift
View file @
9efac5ec
...
@@ -73,7 +73,7 @@ open class ToolbarController: RootController {
...
@@ -73,7 +73,7 @@ open class ToolbarController: RootController {
private
var
internalFloatingViewController
:
UIViewController
?
private
var
internalFloatingViewController
:
UIViewController
?
/// Reference to the Toolbar.
/// Reference to the Toolbar.
open
internal(set)
var
toolbar
:
Toolbar
!
open
internal(set)
lazy
var
toolbar
:
Toolbar
=
Toolbar
()
/// Delegation handler.
/// Delegation handler.
open
weak
var
delegate
:
ToolbarControllerDelegate
?
open
weak
var
delegate
:
ToolbarControllerDelegate
?
...
@@ -84,7 +84,7 @@ open class ToolbarController: RootController {
...
@@ -84,7 +84,7 @@ open class ToolbarController: RootController {
return
internalFloatingViewController
return
internalFloatingViewController
}
}
set
(
value
)
{
set
(
value
)
{
if
let
v
:
UIViewController
=
internalFloatingViewController
{
if
let
v
=
internalFloatingViewController
{
v
.
view
.
layer
.
rasterizationScale
=
Device
.
scale
v
.
view
.
layer
.
rasterizationScale
=
Device
.
scale
v
.
view
.
layer
.
shouldRasterize
=
true
v
.
view
.
layer
.
shouldRasterize
=
true
delegate
?
.
toolbarControllerWillCloseFloatingViewController
?(
toolbarController
:
self
)
delegate
?
.
toolbarControllerWillCloseFloatingViewController
?(
toolbarController
:
self
)
...
@@ -113,7 +113,7 @@ open class ToolbarController: RootController {
...
@@ -113,7 +113,7 @@ open class ToolbarController: RootController {
}
}
}
}
if
let
v
:
UIViewController
=
value
{
if
let
v
=
value
{
// Add the noteViewController! to the view.
// Add the noteViewController! to the view.
addChildViewController
(
v
)
addChildViewController
(
v
)
v
.
view
.
frame
=
view
.
bounds
v
.
view
.
frame
=
view
.
bounds
...
@@ -162,23 +162,20 @@ open class ToolbarController: RootController {
...
@@ -162,23 +162,20 @@ open class ToolbarController: RootController {
*/
*/
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
guard
let
v
=
toolbar
else
{
return
toolbar
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
}
v
.
grid
.
layoutEdgeInsets
.
top
=
.
phone
==
Device
.
userInterfaceIdiom
&&
Device
.
isLandscape
?
0
:
20
let
w
=
view
.
width
let
w
=
view
.
width
let
h
=
view
.
height
let
h
=
view
.
height
let
p
=
v
.
intrinsicContentSize
.
height
+
v
.
grid
.
layoutEdgeInsets
.
top
+
v
.
grid
.
layoutEdgeInsets
.
bottom
let
p
=
toolbar
.
intrinsicContentSize
.
height
+
toolbar
.
grid
.
layoutEdgeInsets
.
top
+
toolbar
.
grid
.
layoutEdgeInsets
.
bottom
v
.
width
=
w
+
v
.
grid
.
layoutEdgeInsets
.
left
+
v
.
grid
.
layoutEdgeInsets
.
right
toolbar
.
width
=
w
+
toolbar
.
grid
.
layoutEdgeInsets
.
left
+
toolbar
.
grid
.
layoutEdgeInsets
.
right
v
.
height
=
p
toolbar
.
height
=
p
rootViewController
.
view
.
y
=
p
rootViewController
.
view
.
y
=
p
rootViewController
.
view
.
height
=
h
-
p
rootViewController
.
view
.
height
=
h
-
p
v
.
divider
.
reload
()
toolbar
.
divider
.
reload
()
}
}
/**
/**
...
@@ -195,10 +192,7 @@ open class ToolbarController: RootController {
...
@@ -195,10 +192,7 @@ open class ToolbarController: RootController {
/// Prepares the toolbar.
/// Prepares the toolbar.
private
func
prepareToolbar
()
{
private
func
prepareToolbar
()
{
if
nil
==
toolbar
{
toolbar
.
zPosition
=
1000
toolbar
=
Toolbar
()
view
.
addSubview
(
toolbar
)
toolbar
.
zPosition
=
1000
view
.
addSubview
(
toolbar
)
}
}
}
}
}
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