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
dbf37c44
Commit
dbf37c44
authored
Aug 08, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added detailLabel to Editor
parent
93dd75be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
Sources/iOS/Editor.swift
+57
-0
No files found.
Sources/iOS/Editor.swift
View file @
dbf37c44
...
@@ -129,6 +129,38 @@ open class Editor: View {
...
@@ -129,6 +129,38 @@ open class Editor: View {
}
}
}
}
/// The detailLabel UILabel that is displayed.
@IBInspectable
public
let
detailLabel
=
UILabel
()
/// The detailLabel text value.
@IBInspectable
open
var
detail
:
String
?
{
get
{
return
detailLabel
.
text
}
set
(
value
)
{
detailLabel
.
text
=
value
layoutSubviews
()
}
}
/// The detailLabel text color.
@IBInspectable
open
var
detailColor
=
Color
.
darkText
.
others
{
didSet
{
updateDetailLabelColor
()
}
}
/// Vertical distance for the detailLabel from the divider.
@IBInspectable
open
var
detailVerticalOffset
:
CGFloat
=
8
{
didSet
{
layoutSubviews
()
}
}
/// A reference to titleLabel.textAlignment observation.
/// A reference to titleLabel.textAlignment observation.
private
var
placeholderLabelTextObserver
:
NSKeyValueObservation
!
private
var
placeholderLabelTextObserver
:
NSKeyValueObservation
!
...
@@ -143,6 +175,7 @@ open class Editor: View {
...
@@ -143,6 +175,7 @@ open class Editor: View {
prepareDivider
()
prepareDivider
()
prepareTextView
()
prepareTextView
()
preparePlaceholderLabel
()
preparePlaceholderLabel
()
prepareDetailLabel
()
prepareNotificationHandlers
()
prepareNotificationHandlers
()
}
}
...
@@ -150,6 +183,7 @@ open class Editor: View {
...
@@ -150,6 +183,7 @@ open class Editor: View {
super
.
layoutSubviews
()
super
.
layoutSubviews
()
layoutPlaceholderLabel
()
layoutPlaceholderLabel
()
layoutDivider
()
layoutDivider
()
layoutBottomLabel
(
label
:
detailLabel
,
verticalOffset
:
detailVerticalOffset
)
}
}
@discardableResult
@discardableResult
...
@@ -197,6 +231,14 @@ private extension Editor {
...
@@ -197,6 +231,14 @@ private extension Editor {
}
}
}
}
/// Prepares the detailLabel.
func
prepareDetailLabel
()
{
detailLabel
.
font
=
RobotoFont
.
regular
(
with
:
12
)
detailLabel
.
numberOfLines
=
0
detailColor
=
Color
.
darkText
.
others
addSubview
(
detailLabel
)
}
/// Prepares the Notification handlers.
/// Prepares the Notification handlers.
func
prepareNotificationHandlers
()
{
func
prepareNotificationHandlers
()
{
let
center
=
NotificationCenter
.
default
let
center
=
NotificationCenter
.
default
...
@@ -232,6 +274,11 @@ private extension Editor {
...
@@ -232,6 +274,11 @@ private extension Editor {
func
updateDividerHeight
()
{
func
updateDividerHeight
()
{
dividerThickness
=
isEditing
?
dividerActiveHeight
:
dividerNormalHeight
dividerThickness
=
isEditing
?
dividerActiveHeight
:
dividerNormalHeight
}
}
/// Updates the detailLabel text color.
func
updateDetailLabelColor
()
{
detailLabel
.
textColor
=
detailColor
}
}
}
private
extension
Editor
{
private
extension
Editor
{
...
@@ -265,6 +312,15 @@ private extension Editor {
...
@@ -265,6 +312,15 @@ private extension Editor {
default
:
break
default
:
break
}
}
}
}
/// Layout given label at the bottom with the vertical offset provided.
func
layoutBottomLabel
(
label
:
UILabel
,
verticalOffset
:
CGFloat
)
{
let
c
=
dividerContentEdgeInsets
label
.
frame
.
origin
.
x
=
c
.
left
label
.
frame
.
origin
.
y
=
bounds
.
height
+
verticalOffset
label
.
frame
.
size
.
width
=
bounds
.
width
-
c
.
left
-
c
.
right
label
.
frame
.
size
.
height
=
label
.
sizeThatFits
(
CGSize
(
width
:
label
.
bounds
.
width
,
height
:
.
greatestFiniteMagnitude
))
.
height
}
}
}
private
extension
Editor
{
private
extension
Editor
{
...
@@ -340,6 +396,7 @@ public extension Editor {
...
@@ -340,6 +396,7 @@ public extension Editor {
}
}
set
(
value
)
{
set
(
value
)
{
textView
.
textAlignment
=
value
textView
.
textAlignment
=
value
detailLabel
.
textAlignment
=
value
}
}
}
}
}
}
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