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
9cd30b33
Commit
9cd30b33
authored
Aug 07, 2018
by
Orkhan Alikhanov
Committed by
OrkhanAlikhanov
Aug 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added divider to Editor
parent
f172f0fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
1 deletions
+53
-1
Sources/iOS/Editor.swift
+53
-1
No files found.
Sources/iOS/Editor.swift
View file @
9cd30b33
...
@@ -97,6 +97,38 @@ open class Editor: View {
...
@@ -97,6 +97,38 @@ open class Editor: View {
@IBInspectable
@IBInspectable
open
var
placeholderHorizontalOffset
:
CGFloat
=
0
open
var
placeholderHorizontalOffset
:
CGFloat
=
0
/// Divider normal height.
@IBInspectable
open
var
dividerNormalHeight
:
CGFloat
=
1
{
didSet
{
updateDividerHeight
()
}
}
/// Divider active height.
@IBInspectable
open
var
dividerActiveHeight
:
CGFloat
=
2
{
didSet
{
updateDividerHeight
()
}
}
/// Divider normal color.
@IBInspectable
open
var
dividerNormalColor
=
Color
.
grey
.
lighten2
{
didSet
{
updateDividerColor
()
}
}
/// Divider active color.
@IBInspectable
open
var
dividerActiveColor
=
Color
.
blue
.
base
{
didSet
{
updateDividerColor
()
}
}
/// A reference to titleLabel.textAlignment observation.
/// A reference to titleLabel.textAlignment observation.
private
var
placeholderLabelTextObserver
:
NSKeyValueObservation
!
private
var
placeholderLabelTextObserver
:
NSKeyValueObservation
!
...
@@ -108,6 +140,7 @@ open class Editor: View {
...
@@ -108,6 +140,7 @@ open class Editor: View {
open
override
func
prepare
()
{
open
override
func
prepare
()
{
super
.
prepare
()
super
.
prepare
()
prepareDivider
()
prepareTextView
()
prepareTextView
()
preparePlaceholderLabel
()
preparePlaceholderLabel
()
prepareNotificationHandlers
()
prepareNotificationHandlers
()
...
@@ -116,11 +149,17 @@ open class Editor: View {
...
@@ -116,11 +149,17 @@ open class Editor: View {
open
override
func
layoutSubviews
()
{
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
layoutPlaceholderLabel
()
layoutPlaceholderLabel
()
layoutDivider
()
}
}
}
}
private
extension
Editor
{
private
extension
Editor
{
/// Prepares the divider.
func
prepareDivider
()
{
dividerColor
=
dividerNormalColor
}
/// Prepares the textView.
/// Prepares the textView.
func
prepareTextView
()
{
func
prepareTextView
()
{
layout
(
textView
)
.
edges
()
layout
(
textView
)
.
edges
()
...
@@ -164,6 +203,16 @@ private extension Editor {
...
@@ -164,6 +203,16 @@ private extension Editor {
placeholderLabel
.
isHidden
=
.
hidden
==
placeholderAnimation
placeholderLabel
.
isHidden
=
.
hidden
==
placeholderAnimation
}
}
/// Updates the dividerColor.
func
updateDividerColor
()
{
dividerColor
=
isEditing
?
dividerActiveColor
:
dividerNormalColor
}
/// Updates the dividerThickness.
func
updateDividerHeight
()
{
dividerThickness
=
isEditing
?
dividerActiveHeight
:
dividerNormalHeight
}
}
}
private
extension
Editor
{
private
extension
Editor
{
...
@@ -216,11 +265,14 @@ private extension Editor {
...
@@ -216,11 +265,14 @@ private extension Editor {
updateEditorState
(
animated
:
true
)
updateEditorState
(
animated
:
true
)
}
}
/// Updates editor.
func
updateEditorState
(
animated
:
Bool
=
false
)
{
func
updateEditorState
(
animated
:
Bool
=
false
)
{
updatePlaceholderVisibility
()
updatePlaceholderVisibility
()
updatePlaceholderLabelColor
()
updatePlaceholderLabelColor
()
updateDividerHeight
()
updateDividerColor
()
guard
isPlaceholderAnimated
else
{
guard
animated
&&
isPlaceholderAnimated
else
{
layoutPlaceholderLabel
()
layoutPlaceholderLabel
()
return
return
}
}
...
...
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