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
f3398a3b
Commit
f3398a3b
authored
Oct 10, 2018
by
Orkhan Alikhanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made TextView and Editor Themeable
parent
0e02f6ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
Sources/iOS/Editor.swift
+15
-1
Sources/iOS/TextView.swift
+7
-1
No files found.
Sources/iOS/Editor.swift
View file @
f3398a3b
...
...
@@ -35,7 +35,7 @@ public enum EditorPlaceholderAnimation {
case
hidden
}
open
class
Editor
:
View
{
open
class
Editor
:
View
,
Themeable
{
/// Reference to textView.
public
let
textView
=
TextView
()
...
...
@@ -173,11 +173,14 @@ open class Editor: View {
open
override
func
prepare
()
{
super
.
prepare
()
backgroundColor
=
nil
prepareDivider
()
prepareTextView
()
preparePlaceholderLabel
()
prepareDetailLabel
()
prepareNotificationHandlers
()
applyCurrentTheme
()
}
open
override
func
layoutSubviews
()
{
...
...
@@ -187,6 +190,17 @@ open class Editor: View {
layoutBottomLabel
(
label
:
detailLabel
,
verticalOffset
:
detailVerticalOffset
)
}
open
func
apply
(
theme
:
Theme
)
{
placeholderActiveColor
=
theme
.
secondary
placeholderNormalColor
=
theme
.
onSurface
.
withAlphaComponent
(
0.38
)
dividerActiveColor
=
theme
.
secondary
dividerNormalColor
=
theme
.
onSurface
.
withAlphaComponent
(
0.12
)
detailColor
=
theme
.
onSurface
.
withAlphaComponent
(
0.38
)
textView
.
tintColor
=
theme
.
secondary
}
@discardableResult
open
override
func
becomeFirstResponder
()
->
Bool
{
return
textView
.
becomeFirstResponder
()
...
...
Sources/iOS/TextView.swift
View file @
f3398a3b
...
...
@@ -87,7 +87,7 @@ public protocol TextViewDelegate : UITextViewDelegate {
optional
func
textView
(
textView
:
TextView
,
didProcessEditing
textStorage
:
TextStorage
,
text
:
String
,
range
:
NSRange
)
}
open
class
TextView
:
UITextView
{
open
class
TextView
:
UITextView
,
Themeable
{
/// A boolean indicating whether the text is empty.
open
var
isEmpty
:
Bool
{
return
0
==
text
?
.
utf16
.
count
...
...
@@ -289,6 +289,7 @@ open class TextView: UITextView {
prepareNotificationHandlers
()
prepareRegularExpression
()
preparePlaceholderLabel
()
applyCurrentTheme
()
}
open
override
var
contentSize
:
CGSize
{
...
...
@@ -354,6 +355,11 @@ open class TextView: UITextView {
super
.
paste
(
sender
)
fixTypingFont
()
}
open
func
apply
(
theme
:
Theme
)
{
textColor
=
theme
.
onSurface
.
withAlphaComponent
(
0.87
)
placeholderColor
=
theme
.
onSurface
.
withAlphaComponent
(
0.38
)
}
}
fileprivate
extension
TextView
{
...
...
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