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
415577d7
Commit
415577d7
authored
Sep 05, 2017
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup before merge from PRs
parent
87baa186
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
30 deletions
+50
-30
Sources/iOS/CollectionViewCell.swift
+1
-0
Sources/iOS/DynamicFontType.swift
+1
-1
Sources/iOS/EdgeInsets.swift
+23
-5
Sources/iOS/TextView.swift
+25
-24
No files found.
Sources/iOS/CollectionViewCell.swift
View file @
415577d7
...
@@ -252,6 +252,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable, PulseableLayer {
...
@@ -252,6 +252,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable, PulseableLayer {
open
func
prepare
()
{
open
func
prepare
()
{
backgroundColor
=
.
white
backgroundColor
=
.
white
contentScaleFactor
=
Screen
.
scale
contentScaleFactor
=
Screen
.
scale
prepareVisualLayer
()
prepareVisualLayer
()
preparePulse
()
preparePulse
()
}
}
...
...
Sources/iOS/DynamicFontType.swift
View file @
415577d7
...
@@ -63,6 +63,6 @@ open class DynamicFontType: NSObject {
...
@@ -63,6 +63,6 @@ open class DynamicFontType: NSObject {
/// Prepares observation for content size changes.
/// Prepares observation for content size changes.
private
func
prepareContentSizeObservation
()
{
private
func
prepareContentSizeObservation
()
{
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
handleContentSizeChange
)
,
name
:
NSNotification
.
Name
.
UIContentSizeCategoryDidChange
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
handleContentSizeChange
)
,
name
:
.
UIContentSizeCategoryDidChange
,
object
:
nil
)
}
}
}
}
Sources/iOS/EdgeInsets.swift
View file @
415577d7
...
@@ -44,6 +44,12 @@ public enum EdgeInsetsPreset: Int {
...
@@ -44,6 +44,12 @@ public enum EdgeInsetsPreset: Int {
case
square7
case
square7
case
square8
case
square8
case
square9
case
square9
case
square10
case
square11
case
square12
case
square13
case
square14
case
square15
// rectangle
// rectangle
case
wideRectangle1
case
wideRectangle1
...
@@ -98,16 +104,28 @@ public func EdgeInsetsPresetToValue(preset: EdgeInsetsPreset) -> EdgeInsets {
...
@@ -98,16 +104,28 @@ public func EdgeInsetsPresetToValue(preset: EdgeInsetsPreset) -> EdgeInsets {
case
.
square3
:
case
.
square3
:
return
EdgeInsets
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
return
EdgeInsets
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
case
.
square4
:
case
.
square4
:
return
EdgeInsets
(
top
:
2
4
,
left
:
24
,
bottom
:
24
,
right
:
24
)
return
EdgeInsets
(
top
:
2
0
,
left
:
20
,
bottom
:
20
,
right
:
20
)
case
.
square5
:
case
.
square5
:
return
EdgeInsets
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
return
EdgeInsets
(
top
:
24
,
left
:
24
,
bottom
:
24
,
right
:
24
)
case
.
square6
:
case
.
square6
:
return
EdgeInsets
(
top
:
40
,
left
:
40
,
bottom
:
40
,
right
:
40
)
return
EdgeInsets
(
top
:
28
,
left
:
28
,
bottom
:
28
,
right
:
28
)
case
.
square7
:
case
.
square7
:
return
EdgeInsets
(
top
:
48
,
left
:
48
,
bottom
:
48
,
right
:
48
)
return
EdgeInsets
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
case
.
square8
:
case
.
square8
:
return
EdgeInsets
(
top
:
56
,
left
:
56
,
bottom
:
56
,
right
:
5
6
)
return
EdgeInsets
(
top
:
36
,
left
:
36
,
bottom
:
36
,
right
:
3
6
)
case
.
square9
:
case
.
square9
:
return
EdgeInsets
(
top
:
40
,
left
:
40
,
bottom
:
40
,
right
:
40
)
case
.
square10
:
return
EdgeInsets
(
top
:
44
,
left
:
44
,
bottom
:
44
,
right
:
44
)
case
.
square11
:
return
EdgeInsets
(
top
:
48
,
left
:
48
,
bottom
:
48
,
right
:
48
)
case
.
square12
:
return
EdgeInsets
(
top
:
52
,
left
:
52
,
bottom
:
52
,
right
:
52
)
case
.
square13
:
return
EdgeInsets
(
top
:
56
,
left
:
56
,
bottom
:
56
,
right
:
56
)
case
.
square14
:
return
EdgeInsets
(
top
:
60
,
left
:
60
,
bottom
:
60
,
right
:
60
)
case
.
square15
:
return
EdgeInsets
(
top
:
64
,
left
:
64
,
bottom
:
64
,
right
:
64
)
return
EdgeInsets
(
top
:
64
,
left
:
64
,
bottom
:
64
,
right
:
64
)
// rectangle
// rectangle
...
...
Sources/iOS/TextView.swift
View file @
415577d7
...
@@ -279,32 +279,33 @@ open class TextView: UITextView {
...
@@ -279,32 +279,33 @@ open class TextView: UITextView {
backgroundColor
=
nil
backgroundColor
=
nil
font
=
RobotoFont
.
regular
(
with
:
16
)
font
=
RobotoFont
.
regular
(
with
:
16
)
textColor
=
Color
.
darkText
.
primary
textColor
=
Color
.
darkText
.
primary
prepareNotificationHandlers
()
prepareNotificationHandlers
()
prepareRegularExpression
()
prepareRegularExpression
()
preparePlaceholderLabel
()
preparePlaceholderLabel
()
}
}
}
}
extension
TextView
{
fileprivate
extension
TextView
{
/// Prepares the Notification handlers.
/// Prepares the Notification handlers.
f
ileprivate
f
unc
prepareNotificationHandlers
()
{
func
prepareNotificationHandlers
()
{
let
defaultCenter
=
NotificationCenter
.
default
let
defaultCenter
=
NotificationCenter
.
default
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardWillShow(notification:)
)
,
name
:
NSNotification
.
Name
.
UIKeyboardWillShow
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardWillShow(notification:)
)
,
name
:
.
UIKeyboardWillShow
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardWillHide(notification:)
)
,
name
:
NSNotification
.
Name
.
UIKeyboardWillHide
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardWillHide(notification:)
)
,
name
:
.
UIKeyboardWillHide
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardDidShow(notification:)
)
,
name
:
NSNotification
.
Name
.
UIKeyboardDidShow
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardDidShow(notification:)
)
,
name
:
.
UIKeyboardDidShow
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardDidHide(notification:)
)
,
name
:
NSNotification
.
Name
.
UIKeyboardDidHide
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleKeyboardDidHide(notification:)
)
,
name
:
.
UIKeyboardDidHide
,
object
:
nil
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidBegin
)
,
name
:
NSNotification
.
Name
.
UITextViewTextDidBeginEditing
,
object
:
self
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidBegin
)
,
name
:
.
UITextViewTextDidBeginEditing
,
object
:
self
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidChange
)
,
name
:
NSNotification
.
Name
.
UITextViewTextDidChange
,
object
:
self
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidChange
)
,
name
:
.
UITextViewTextDidChange
,
object
:
self
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidEnd
)
,
name
:
NSNotification
.
Name
.
UITextViewTextDidEndEditing
,
object
:
self
)
defaultCenter
.
addObserver
(
self
,
selector
:
#selector(
handleTextViewTextDidEnd
)
,
name
:
.
UITextViewTextDidEndEditing
,
object
:
self
)
}
}
/// Prepares the regular expression for matching.
/// Prepares the regular expression for matching.
f
ileprivate
f
unc
prepareRegularExpression
()
{
func
prepareRegularExpression
()
{
(
textStorage
as?
TextStorage
)?
.
expression
=
try
?
NSRegularExpression
(
pattern
:
pattern
,
options
:
[])
(
textStorage
as?
TextStorage
)?
.
expression
=
try
?
NSRegularExpression
(
pattern
:
pattern
,
options
:
[])
}
}
/// prepares the placeholderLabel property.
/// prepares the placeholderLabel property.
f
ileprivate
f
unc
preparePlaceholderLabel
()
{
func
preparePlaceholderLabel
()
{
placeholderLabel
.
textColor
=
Color
.
darkText
.
others
placeholderLabel
.
textColor
=
Color
.
darkText
.
others
placeholderLabel
.
textAlignment
=
textAlignment
placeholderLabel
.
textAlignment
=
textAlignment
placeholderLabel
.
numberOfLines
=
0
placeholderLabel
.
numberOfLines
=
0
...
@@ -313,22 +314,22 @@ extension TextView {
...
@@ -313,22 +314,22 @@ extension TextView {
}
}
}
}
extension
TextView
{
fileprivate
extension
TextView
{
/// Updates the placeholderLabel text color.
/// Updates the placeholderLabel text color.
f
ileprivate
f
unc
updatePlaceholderLabelColor
()
{
func
updatePlaceholderLabelColor
()
{
tintColor
=
placeholderActiveColor
tintColor
=
placeholderActiveColor
placeholderLabel
.
textColor
=
isEditing
?
placeholderActiveColor
:
placeholderNormalColor
placeholderLabel
.
textColor
=
isEditing
?
placeholderActiveColor
:
placeholderNormalColor
}
}
/// Updates the placeholderLabel visibility.
/// Updates the placeholderLabel visibility.
f
ileprivate
f
unc
updatePlaceholderVisibility
()
{
func
updatePlaceholderVisibility
()
{
placeholderLabel
.
isHidden
=
!
isEmpty
placeholderLabel
.
isHidden
=
!
isEmpty
}
}
}
}
extension
TextView
{
fileprivate
extension
TextView
{
/// Laysout the placeholder UILabel.
/// Laysout the placeholder UILabel.
f
ileprivate
f
unc
layoutPlaceholderLabel
()
{
func
layoutPlaceholderLabel
()
{
placeholderLabel
.
preferredMaxLayoutWidth
=
textContainer
.
size
.
width
-
textContainer
.
lineFragmentPadding
*
2
placeholderLabel
.
preferredMaxLayoutWidth
=
textContainer
.
size
.
width
-
textContainer
.
lineFragmentPadding
*
2
let
x
=
textContainerInset
.
left
+
textContainer
.
lineFragmentPadding
let
x
=
textContainerInset
.
left
+
textContainer
.
lineFragmentPadding
...
@@ -341,13 +342,13 @@ extension TextView {
...
@@ -341,13 +342,13 @@ extension TextView {
}
}
}
}
extension
TextView
{
fileprivate
extension
TextView
{
/**
/**
Handler for when the keyboard will open.
Handler for when the keyboard will open.
- Parameter notification: A Notification.
- Parameter notification: A Notification.
*/
*/
@objc
@objc
f
ileprivate
f
unc
handleKeyboardWillShow
(
notification
:
Notification
)
{
func
handleKeyboardWillShow
(
notification
:
Notification
)
{
guard
isKeyboardHidden
else
{
guard
isKeyboardHidden
else
{
return
return
}
}
...
@@ -364,7 +365,7 @@ extension TextView {
...
@@ -364,7 +365,7 @@ extension TextView {
- Parameter notification: A Notification.
- Parameter notification: A Notification.
*/
*/
@objc
@objc
f
ileprivate
f
unc
handleKeyboardDidShow
(
notification
:
Notification
)
{
func
handleKeyboardDidShow
(
notification
:
Notification
)
{
guard
isKeyboardHidden
else
{
guard
isKeyboardHidden
else
{
return
return
}
}
...
@@ -383,7 +384,7 @@ extension TextView {
...
@@ -383,7 +384,7 @@ extension TextView {
- Parameter notification: A Notification.
- Parameter notification: A Notification.
*/
*/
@objc
@objc
f
ileprivate
f
unc
handleKeyboardWillHide
(
notification
:
Notification
)
{
func
handleKeyboardWillHide
(
notification
:
Notification
)
{
guard
!
isKeyboardHidden
else
{
guard
!
isKeyboardHidden
else
{
return
return
}
}
...
@@ -400,7 +401,7 @@ extension TextView {
...
@@ -400,7 +401,7 @@ extension TextView {
- Parameter notification: A Notification.
- Parameter notification: A Notification.
*/
*/
@objc
@objc
f
ileprivate
f
unc
handleKeyboardDidHide
(
notification
:
Notification
)
{
func
handleKeyboardDidHide
(
notification
:
Notification
)
{
guard
!
isKeyboardHidden
else
{
guard
!
isKeyboardHidden
else
{
return
return
}
}
...
@@ -416,19 +417,19 @@ extension TextView {
...
@@ -416,19 +417,19 @@ extension TextView {
/// Notification handler for when text editing began.
/// Notification handler for when text editing began.
@objc
@objc
f
ileprivate
f
unc
handleTextViewTextDidBegin
()
{
func
handleTextViewTextDidBegin
()
{
isEditing
=
true
isEditing
=
true
}
}
/// Notification handler for when text changed.
/// Notification handler for when text changed.
@objc
@objc
f
ileprivate
f
unc
handleTextViewTextDidChange
()
{
func
handleTextViewTextDidChange
()
{
updatePlaceholderVisibility
()
updatePlaceholderVisibility
()
}
}
/// Notification handler for when text editing ended.
/// Notification handler for when text editing ended.
@objc
@objc
f
ileprivate
f
unc
handleTextViewTextDidEnd
()
{
func
handleTextViewTextDidEnd
()
{
isEditing
=
false
isEditing
=
false
updatePlaceholderVisibility
()
updatePlaceholderVisibility
()
}
}
...
...
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