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
091d4306
Unverified
Commit
091d4306
authored
Oct 26, 2018
by
Daniel Jonathan
Committed by
GitHub
Oct 26, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1183 from OrkhanAlikhanov/global-font
Global font and navigationItem.backButton issue
parents
0b1d7707
0cd62140
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
96 additions
and
35 deletions
+96
-35
Sources/iOS/Button.swift
+1
-0
Sources/iOS/DialogView.swift
+3
-2
Sources/iOS/Editor.swift
+1
-1
Sources/iOS/ErrorTextField.swift
+1
-1
Sources/iOS/FABMenu.swift
+1
-1
Sources/iOS/Font.swift
+22
-1
Sources/iOS/NavigationController.swift
+56
-22
Sources/iOS/SearchBar.swift
+1
-1
Sources/iOS/Snackbar.swift
+1
-1
Sources/iOS/TextField.swift
+2
-2
Sources/iOS/TextView.swift
+1
-1
Sources/iOS/Theme.swift
+3
-0
Sources/iOS/Toolbar.swift
+2
-2
Sources/iOS/ViewController.swift
+1
-0
No files found.
Sources/iOS/Button.swift
View file @
091d4306
...
@@ -279,6 +279,7 @@ open class Button: UIButton, Pulseable, PulseableLayer, Themeable {
...
@@ -279,6 +279,7 @@ open class Button: UIButton, Pulseable, PulseableLayer, Themeable {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
contentScaleFactor
=
Screen
.
scale
contentScaleFactor
=
Screen
.
scale
titleLabel
?
.
font
=
Theme
.
font
.
regular
(
with
:
fontSize
)
prepareVisualLayer
()
prepareVisualLayer
()
preparePulse
()
preparePulse
()
applyCurrentTheme
()
applyCurrentTheme
()
...
...
Sources/iOS/DialogView.swift
View file @
091d4306
...
@@ -233,7 +233,7 @@ private extension DialogView {
...
@@ -233,7 +233,7 @@ private extension DialogView {
/// Prepares titleTitle.
/// Prepares titleTitle.
func
prepareTitleLabel
()
{
func
prepareTitleLabel
()
{
titleArea
.
addSubview
(
titleLabel
)
titleArea
.
addSubview
(
titleLabel
)
titleLabel
.
font
=
RobotoF
ont
.
bold
(
with
:
20
)
titleLabel
.
font
=
Theme
.
f
ont
.
bold
(
with
:
20
)
titleLabel
.
textColor
=
Color
.
darkText
.
primary
titleLabel
.
textColor
=
Color
.
darkText
.
primary
titleLabel
.
numberOfLines
=
0
titleLabel
.
numberOfLines
=
0
}
}
...
@@ -250,7 +250,7 @@ private extension DialogView {
...
@@ -250,7 +250,7 @@ private extension DialogView {
func
prepareButtons
()
{
func
prepareButtons
()
{
[
positiveButton
,
negativeButton
,
neutralButton
]
.
forEach
{
[
positiveButton
,
negativeButton
,
neutralButton
]
.
forEach
{
buttonArea
.
addSubview
(
$0
)
buttonArea
.
addSubview
(
$0
)
$0
.
titleLabel
?
.
font
=
RobotoF
ont
.
medium
(
with
:
14
)
$0
.
titleLabel
?
.
font
=
Theme
.
f
ont
.
medium
(
with
:
14
)
$0
.
contentEdgeInsets
=
Constants
.
button
.
insets
$0
.
contentEdgeInsets
=
Constants
.
button
.
insets
$0
.
cornerRadiusPreset
=
.
cornerRadius1
$0
.
cornerRadiusPreset
=
.
cornerRadius1
}
}
...
@@ -270,6 +270,7 @@ private extension DialogView {
...
@@ -270,6 +270,7 @@ private extension DialogView {
/// Prepares detailsLabel.
/// Prepares detailsLabel.
func
prepareDetailsLabel
()
{
func
prepareDetailsLabel
()
{
contentArea
.
addSubview
(
detailsLabel
)
contentArea
.
addSubview
(
detailsLabel
)
detailsLabel
.
font
=
Theme
.
font
.
regular
(
with
:
detailsLabel
.
fontSize
)
detailsLabel
.
numberOfLines
=
0
detailsLabel
.
numberOfLines
=
0
detailsLabel
.
textColor
=
Color
.
darkText
.
secondary
detailsLabel
.
textColor
=
Color
.
darkText
.
secondary
}
}
...
...
Sources/iOS/Editor.swift
View file @
091d4306
...
@@ -251,7 +251,7 @@ private extension Editor {
...
@@ -251,7 +251,7 @@ private extension Editor {
/// Prepares the detailLabel.
/// Prepares the detailLabel.
func
prepareDetailLabel
()
{
func
prepareDetailLabel
()
{
detailLabel
.
font
=
RobotoF
ont
.
regular
(
with
:
12
)
detailLabel
.
font
=
Theme
.
f
ont
.
regular
(
with
:
12
)
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
detailColor
=
Color
.
darkText
.
others
detailColor
=
Color
.
darkText
.
others
addSubview
(
detailLabel
)
addSubview
(
detailLabel
)
...
...
Sources/iOS/ErrorTextField.swift
View file @
091d4306
...
@@ -83,7 +83,7 @@ open class ErrorTextField: TextField {
...
@@ -83,7 +83,7 @@ open class ErrorTextField: TextField {
/// Prepares the errorLabel.
/// Prepares the errorLabel.
func
prepareErrorLabel
()
{
func
prepareErrorLabel
()
{
errorLabel
.
font
=
RobotoF
ont
.
regular
(
with
:
12
)
errorLabel
.
font
=
Theme
.
f
ont
.
regular
(
with
:
12
)
errorLabel
.
numberOfLines
=
0
errorLabel
.
numberOfLines
=
0
errorColor
=
{
errorColor
}()
// call didSet
errorColor
=
{
errorColor
}()
// call didSet
addSubview
(
errorLabel
)
addSubview
(
errorLabel
)
...
...
Sources/iOS/FABMenu.swift
View file @
091d4306
...
@@ -129,7 +129,7 @@ extension FABMenuItem {
...
@@ -129,7 +129,7 @@ extension FABMenuItem {
/// Prepares the titleLabel.
/// Prepares the titleLabel.
fileprivate
func
prepareTitleLabel
()
{
fileprivate
func
prepareTitleLabel
()
{
titleLabel
.
font
=
RobotoF
ont
.
regular
(
with
:
14
)
titleLabel
.
font
=
Theme
.
f
ont
.
regular
(
with
:
14
)
titleLabel
.
textAlignment
=
.
center
titleLabel
.
textAlignment
=
.
center
titleLabel
.
backgroundColor
=
.
white
titleLabel
.
backgroundColor
=
.
white
titleLabel
.
depthPreset
=
fabButton
.
depthPreset
titleLabel
.
depthPreset
=
fabButton
.
depthPreset
...
...
Sources/iOS/Font.swift
View file @
091d4306
...
@@ -30,7 +30,28 @@
...
@@ -30,7 +30,28 @@
import
UIKit
import
UIKit
public
protocol
FontType
{}
public
protocol
FontType
{
/**
Regular with size font.
- Parameter with size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
static
func
regular
(
with
size
:
CGFloat
)
->
UIFont
/**
Medium with size font.
- Parameter with size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
static
func
medium
(
with
size
:
CGFloat
)
->
UIFont
/**
Bold with size font.
- Parameter with size: A CGFLoat for the font size.
- Returns: A UIFont.
*/
static
func
bold
(
with
size
:
CGFloat
)
->
UIFont
}
public
struct
Font
{
public
struct
Font
{
/// Size of font.
/// Size of font.
...
...
Sources/iOS/NavigationController.swift
View file @
091d4306
...
@@ -146,6 +146,22 @@ open class NavigationController: UINavigationController {
...
@@ -146,6 +146,22 @@ open class NavigationController: UINavigationController {
navigationBar
.
setNeedsLayout
()
navigationBar
.
setNeedsLayout
()
navigationBar
.
layoutIfNeeded
()
navigationBar
.
layoutIfNeeded
()
}
}
/**
Sets whether the navigation bar is hidden.
- Parameter _ hidden: Specify true to hide the navigation bar or false to show it.
- Parameter animated: Specify true if you want to animate the change in visibility or false if you want the navigation bar to appear immediately.
*/
open
override
func
setNavigationBarHidden
(
_
hidden
:
Bool
,
animated
:
Bool
)
{
super
.
setNavigationBarHidden
(
hidden
,
animated
:
animated
)
guard
let
items
=
navigationBar
.
items
,
items
.
count
>
1
else
{
return
}
items
.
forEach
{
prepareBackButton
(
for
:
$0
,
in
:
navigationBar
)
}
}
}
}
extension
NavigationController
:
UINavigationBarDelegate
{
extension
NavigationController
:
UINavigationBarDelegate
{
...
@@ -158,32 +174,12 @@ extension NavigationController: UINavigationBarDelegate {
...
@@ -158,32 +174,12 @@ extension NavigationController: UINavigationBarDelegate {
True is yes, false is no.
True is yes, false is no.
*/
*/
public
func
navigationBar
(
_
navigationBar
:
UINavigationBar
,
shouldPush
item
:
UINavigationItem
)
->
Bool
{
public
func
navigationBar
(
_
navigationBar
:
UINavigationBar
,
shouldPush
item
:
UINavigationItem
)
->
Bool
{
if
let
v
=
navigationBar
as?
NavigationBar
{
prepareBackButton
(
for
:
item
,
in
:
navigationBar
)
if
nil
==
item
.
backButton
.
image
&&
nil
==
item
.
backButton
.
title
{
item
.
backButton
.
image
=
v
.
backButtonImage
}
if
!
item
.
backButton
.
isHidden
{
item
.
leftViews
.
insert
(
item
.
backButton
,
at
:
0
)
}
item
.
backButton
.
addTarget
(
self
,
action
:
#selector(
handle(backButton:)
)
,
for
:
.
touchUpInside
)
item
.
hidesBackButton
=
false
item
.
setHidesBackButton
(
true
,
animated
:
false
)
v
.
layoutNavigationItem
(
item
:
item
)
}
return
true
return
true
}
}
public
func
navigationBar
(
_
navigationBar
:
UINavigationBar
,
didPop
item
:
UINavigationItem
)
{
public
func
navigationBar
(
_
navigationBar
:
UINavigationBar
,
didPop
item
:
UINavigationItem
)
{
if
let
index
=
item
.
leftViews
.
index
(
of
:
item
.
backButton
)
{
removeBackButton
(
from
:
item
)
item
.
leftViews
.
remove
(
at
:
index
)
}
item
.
backButton
.
removeTarget
(
self
,
action
:
#selector(
handle(backButton:)
)
,
for
:
.
touchUpInside
)
}
}
}
}
...
@@ -193,6 +189,44 @@ internal extension NavigationController {
...
@@ -193,6 +189,44 @@ internal extension NavigationController {
func
handle
(
backButton
:
UIButton
)
{
func
handle
(
backButton
:
UIButton
)
{
popViewController
(
animated
:
true
)
popViewController
(
animated
:
true
)
}
}
/**
Prepares back button of the navigation item in navigation bar.
- Parameter for item: A UINavigationItem.
- Parameter in navigationBar: A UINavigationBar.
*/
func
prepareBackButton
(
for
item
:
UINavigationItem
,
in
navigationBar
:
UINavigationBar
)
{
guard
let
v
=
navigationBar
as?
NavigationBar
else
{
return
}
if
nil
==
item
.
backButton
.
image
&&
nil
==
item
.
backButton
.
title
{
item
.
backButton
.
image
=
v
.
backButtonImage
}
if
!
item
.
backButton
.
isHidden
&&
!
item
.
leftViews
.
contains
(
item
.
backButton
)
{
item
.
leftViews
.
insert
(
item
.
backButton
,
at
:
0
)
}
item
.
backButton
.
addTarget
(
self
,
action
:
#selector(
handle(backButton:)
)
,
for
:
.
touchUpInside
)
item
.
hidesBackButton
=
false
item
.
setHidesBackButton
(
true
,
animated
:
false
)
v
.
layoutNavigationItem
(
item
:
item
)
}
/**
Removes back button of the navigation item.
- Parameter from item: A UINavigationItem.
*/
func
removeBackButton
(
from
item
:
UINavigationItem
)
{
if
let
index
=
item
.
leftViews
.
index
(
of
:
item
.
backButton
)
{
item
.
leftViews
.
remove
(
at
:
index
)
}
item
.
backButton
.
removeTarget
(
self
,
action
:
#selector(
handle(backButton:)
)
,
for
:
.
touchUpInside
)
}
}
}
extension
NavigationController
:
UIGestureRecognizerDelegate
{
extension
NavigationController
:
UIGestureRecognizerDelegate
{
...
...
Sources/iOS/SearchBar.swift
View file @
091d4306
...
@@ -213,7 +213,7 @@ fileprivate extension SearchBar {
...
@@ -213,7 +213,7 @@ fileprivate extension SearchBar {
/// Prepares the textField.
/// Prepares the textField.
func
prepareTextField
()
{
func
prepareTextField
()
{
textField
.
contentScaleFactor
=
Screen
.
scale
textField
.
contentScaleFactor
=
Screen
.
scale
textField
.
font
=
RobotoF
ont
.
regular
(
with
:
17
)
textField
.
font
=
Theme
.
f
ont
.
regular
(
with
:
17
)
textField
.
backgroundColor
=
Color
.
clear
textField
.
backgroundColor
=
Color
.
clear
textField
.
clearButtonMode
=
.
whileEditing
textField
.
clearButtonMode
=
.
whileEditing
textField
.
addTarget
(
self
,
action
:
#selector(
handleEditingChanged(textField:)
)
,
for
:
.
editingChanged
)
textField
.
addTarget
(
self
,
action
:
#selector(
handleEditingChanged(textField:)
)
,
for
:
.
editingChanged
)
...
...
Sources/iOS/Snackbar.swift
View file @
091d4306
...
@@ -104,7 +104,7 @@ open class Snackbar: Bar {
...
@@ -104,7 +104,7 @@ open class Snackbar: Bar {
/// Prepares the textLabel.
/// Prepares the textLabel.
private
func
prepareTextLabel
()
{
private
func
prepareTextLabel
()
{
textLabel
.
contentScaleFactor
=
Screen
.
scale
textLabel
.
contentScaleFactor
=
Screen
.
scale
textLabel
.
font
=
RobotoF
ont
.
medium
(
with
:
14
)
textLabel
.
font
=
Theme
.
f
ont
.
medium
(
with
:
14
)
textLabel
.
textAlignment
=
.
left
textLabel
.
textAlignment
=
.
left
textLabel
.
textColor
=
.
white
textLabel
.
textColor
=
.
white
textLabel
.
numberOfLines
=
0
textLabel
.
numberOfLines
=
0
...
...
Sources/iOS/TextField.swift
View file @
091d4306
...
@@ -450,7 +450,7 @@ open class TextField: UITextField, Themeable {
...
@@ -450,7 +450,7 @@ open class TextField: UITextField, Themeable {
borderStyle
=
.
none
borderStyle
=
.
none
backgroundColor
=
nil
backgroundColor
=
nil
contentScaleFactor
=
Screen
.
scale
contentScaleFactor
=
Screen
.
scale
font
=
RobotoF
ont
.
regular
(
with
:
16
)
font
=
Theme
.
f
ont
.
regular
(
with
:
16
)
textColor
=
Color
.
darkText
.
primary
textColor
=
Color
.
darkText
.
primary
prepareDivider
()
prepareDivider
()
...
@@ -496,7 +496,7 @@ fileprivate extension TextField {
...
@@ -496,7 +496,7 @@ fileprivate extension TextField {
/// Prepares the detailLabel.
/// Prepares the detailLabel.
func
prepareDetailLabel
()
{
func
prepareDetailLabel
()
{
detailLabel
.
font
=
RobotoF
ont
.
regular
(
with
:
12
)
detailLabel
.
font
=
Theme
.
f
ont
.
regular
(
with
:
12
)
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
detailColor
=
Color
.
darkText
.
others
detailColor
=
Color
.
darkText
.
others
addSubview
(
detailLabel
)
addSubview
(
detailLabel
)
...
...
Sources/iOS/TextView.swift
View file @
091d4306
...
@@ -283,7 +283,7 @@ open class TextView: UITextView, Themeable {
...
@@ -283,7 +283,7 @@ open class TextView: UITextView, Themeable {
contentScaleFactor
=
Screen
.
scale
contentScaleFactor
=
Screen
.
scale
textContainerInset
=
.
zero
textContainerInset
=
.
zero
backgroundColor
=
nil
backgroundColor
=
nil
font
=
RobotoF
ont
.
regular
(
with
:
16
)
font
=
Theme
.
f
ont
.
regular
(
with
:
16
)
textColor
=
Color
.
darkText
.
primary
textColor
=
Color
.
darkText
.
primary
prepareNotificationHandlers
()
prepareNotificationHandlers
()
...
...
Sources/iOS/Theme.swift
View file @
091d4306
...
@@ -77,6 +77,9 @@ public struct Theme: Hashable {
...
@@ -77,6 +77,9 @@ public struct Theme: Hashable {
/// A boolean indicating if theming is enabled globally.
/// A boolean indicating if theming is enabled globally.
public
static
var
isEnabled
=
true
public
static
var
isEnabled
=
true
/// Global font for app.
public
static
var
font
:
FontType
.
Type
=
RobotoFont
.
self
/// An initializer.
/// An initializer.
public
init
()
{
}
public
init
()
{
}
}
}
...
...
Sources/iOS/Toolbar.swift
View file @
091d4306
...
@@ -184,7 +184,7 @@ private extension Toolbar {
...
@@ -184,7 +184,7 @@ private extension Toolbar {
func
prepareTitleLabel
()
{
func
prepareTitleLabel
()
{
titleLabel
.
textAlignment
=
.
center
titleLabel
.
textAlignment
=
.
center
titleLabel
.
contentScaleFactor
=
Screen
.
scale
titleLabel
.
contentScaleFactor
=
Screen
.
scale
titleLabel
.
font
=
RobotoF
ont
.
medium
(
with
:
17
)
titleLabel
.
font
=
Theme
.
f
ont
.
medium
(
with
:
17
)
titleLabel
.
textColor
=
Color
.
darkText
.
primary
titleLabel
.
textColor
=
Color
.
darkText
.
primary
titleLabelTextAlignmentObserver
=
titleLabel
.
observe
(
\
.
textAlignment
)
{
[
weak
self
]
titleLabel
,
_
in
titleLabelTextAlignmentObserver
=
titleLabel
.
observe
(
\
.
textAlignment
)
{
[
weak
self
]
titleLabel
,
_
in
self
?
.
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
self
?
.
contentViewAlignment
=
.
center
==
titleLabel
.
textAlignment
?
.
center
:
.
full
...
@@ -195,7 +195,7 @@ private extension Toolbar {
...
@@ -195,7 +195,7 @@ private extension Toolbar {
func
prepareDetailLabel
()
{
func
prepareDetailLabel
()
{
detailLabel
.
textAlignment
=
.
center
detailLabel
.
textAlignment
=
.
center
detailLabel
.
contentScaleFactor
=
Screen
.
scale
detailLabel
.
contentScaleFactor
=
Screen
.
scale
detailLabel
.
font
=
RobotoF
ont
.
regular
(
with
:
12
)
detailLabel
.
font
=
Theme
.
f
ont
.
regular
(
with
:
12
)
detailLabel
.
textColor
=
Color
.
darkText
.
secondary
detailLabel
.
textColor
=
Color
.
darkText
.
secondary
}
}
...
...
Sources/iOS/ViewController.swift
View file @
091d4306
...
@@ -45,6 +45,7 @@ open class ViewController: UIViewController, Themeable {
...
@@ -45,6 +45,7 @@ open class ViewController: UIViewController, Themeable {
*/
*/
open
func
prepare
()
{
open
func
prepare
()
{
view
.
clipsToBounds
=
true
view
.
clipsToBounds
=
true
view
.
backgroundColor
=
.
white
view
.
contentScaleFactor
=
Screen
.
scale
view
.
contentScaleFactor
=
Screen
.
scale
applyCurrentTheme
()
applyCurrentTheme
()
}
}
...
...
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