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
5e8d2dec
Commit
5e8d2dec
authored
Aug 22, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit
parent
ebfbb737
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
179 additions
and
169 deletions
+179
-169
MaterialKit.podspec
+0
-0
MaterialKit.xcodeproj/project.pbxproj
+0
-0
Source/CapturePreview.swift
+18
-18
Source/FabButton.swift
+21
-15
Source/FlatButton.swift
+7
-7
Source/Layout.swift
+61
-0
Source/MaterialKit+UIView.swift
+0
-56
Source/RaisedButton.swift
+7
-7
Source/Text.swift
+15
-16
Source/TextStorage.swift
+12
-12
Source/TextView.swift
+38
-38
No files found.
Focus
Kit.podspec
→
Material
Kit.podspec
View file @
5e8d2dec
File moved
Focus
Kit.xcodeproj/project.pbxproj
→
Material
Kit.xcodeproj/project.pbxproj
View file @
5e8d2dec
This diff is collapsed.
Click to expand it.
Source/CapturePreview.swift
View file @
5e8d2dec
...
...
@@ -21,28 +21,28 @@ import AVFoundation
@objc(PreviewDelegate)
public
protocol
PreviewDelegate
{
optional
func
preview
(
preview
:
Preview
!
,
tappedToFocusAt
point
:
CGPoint
)
optional
func
preview
(
preview
:
Preview
!
,
tappedToExposeAt
point
:
CGPoint
)
optional
func
preview
(
preview
:
Preview
!
,
tappedToReset
focus
:
UIView
!
,
exposure
:
UIView
!
)
optional
func
preview
TappedToFocusAt
(
preview
:
Preview
,
point
:
CGPoint
)
optional
func
preview
TappedToExposeAt
(
preview
:
Preview
,
point
:
CGPoint
)
optional
func
preview
TappedToReset
(
preview
:
Preview
,
focus
:
UIView
,
exposure
:
UIView
)
}
public
class
Preview
:
UIView
{
/**
*
boxBounds
*
A static property that sets the initial size of the focusBox and exposureBox properties.
:name:
boxBounds
:description:
A static property that sets the initial size of the focusBox and exposureBox properties.
*/
static
public
var
boxBounds
:
CGRect
=
CGRectMake
(
0
,
0
,
150
,
150
)
/**
*
delegate
*
An optional instance of PreviewDelegate to handle events that are triggered during various
*
stages of engagement.
:name:
delegate
:description:
An optional instance of PreviewDelegate to handle events that are triggered during various
stages of engagement.
*/
public
weak
var
delegate
:
PreviewDelegate
?
/**
*
tapToFocusEnabled
*
A mutator and accessor that enables and disables tap to focus gesture.
:name:
tapToFocusEnabled
:description:
A mutator and accessor that enables and disables tap to focus gesture.
*/
public
var
tapToFocusEnabled
:
Bool
{
get
{
...
...
@@ -54,8 +54,8 @@ public class Preview: UIView {
}
/**
*
tapToExposeEnabled
*
A mutator and accessor that enables and disables tap to expose gesture.
:name:
tapToExposeEnabled
:description:
A mutator and accessor that enables and disables tap to expose gesture.
*/
public
var
tapToExposeEnabled
:
Bool
{
get
{
...
...
@@ -66,9 +66,9 @@ public class Preview: UIView {
}
}
/
**
*
override for layerClass
*
/
/
/
//
override for layerClass
/
/
override
public
class
func
layerClass
()
->
AnyClass
{
return
AVCaptureVideoPreviewLayer
.
self
}
...
...
@@ -142,7 +142,7 @@ public class Preview: UIView {
internal
func
handleSingleTap
(
recognizer
:
UIGestureRecognizer
)
{
let
point
:
CGPoint
=
recognizer
.
locationInView
(
self
)
runBoxAnimationOnView
(
focusBox
,
point
:
point
)
delegate
?
.
preview
?(
self
,
tappedToFocusA
t
:
captureDevicePointForPoint
(
point
))
delegate
?
.
preview
TappedToFocusAt
?(
self
,
poin
t
:
captureDevicePointForPoint
(
point
))
}
/**
...
...
@@ -153,7 +153,7 @@ public class Preview: UIView {
internal
func
handleDoubleTap
(
recognizer
:
UIGestureRecognizer
)
{
let
point
:
CGPoint
=
recognizer
.
locationInView
(
self
)
runBoxAnimationOnView
(
exposureBox
,
point
:
point
)
delegate
?
.
preview
?(
self
,
tappedToExposeA
t
:
captureDevicePointForPoint
(
point
))
delegate
?
.
preview
TappedToExposeAt
?(
self
,
poin
t
:
captureDevicePointForPoint
(
point
))
}
/**
...
...
@@ -270,7 +270,7 @@ public class Preview: UIView {
self
.
exposureBox
!.
hidden
=
true
self
.
focusBox
!.
transform
=
CGAffineTransformIdentity
self
.
exposureBox
!.
transform
=
CGAffineTransformIdentity
self
.
delegate
?
.
preview
?(
self
,
tappedToReset
:
self
.
focusBox
!
,
exposure
:
self
.
exposureBox
!
)
self
.
delegate
?
.
preview
TappedToReset
?(
self
,
focus
:
self
.
focusBox
!
,
exposure
:
self
.
exposureBox
!
)
}
}
}
...
...
Source/FabButton.swift
View file @
5e8d2dec
...
...
@@ -18,7 +18,7 @@
import
UIKit
class
FabButton
:
UIButton
{
public
class
FabButton
:
UIButton
{
var
lineWidth
:
CGFloat
=
2.0
...
...
@@ -29,20 +29,24 @@ class FabButton : UIButton {
private
var
hLine
:
UIView
?
private
var
backgroundColorView
:
UIView
?
private
var
pulseView
:
UIView
?
override
func
drawRect
(
rect
:
CGRect
)
{
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectZero
)
}
public
override
func
drawRect
(
rect
:
CGRect
)
{
setupContext
(
rect
)
setupBackgroundColorView
()
setupPlus
()
}
required
init
(
coder
aDecoder
:
NSCoder
)
{
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
initialize
()
applyShadow
()
}
required
override
init
(
frame
:
CGRect
)
{
public
required
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initialize
()
applyShadow
()
...
...
@@ -67,11 +71,11 @@ class FabButton : UIButton {
// so the pulse doesn't animate off the button
func
setupBackgroundColorView
()
{
backgroundColorView
=
UIView
()
backgroundColorView
!.
frame
=
self
.
bounds
backgroundColorView
!.
layer
.
cornerRadius
=
bounds
W
()
/
2.0
backgroundColorView
!.
frame
=
bounds
backgroundColorView
!.
layer
.
cornerRadius
=
bounds
.
width
/
2.0
backgroundColorView
!.
backgroundColor
=
color
backgroundColorView
!.
layer
.
masksToBounds
=
true
self
.
insertSubview
(
backgroundColorView
!
,
atIndex
:
0
)
insertSubview
(
backgroundColorView
!
,
atIndex
:
0
)
}
// I make the + with two views because
...
...
@@ -103,12 +107,14 @@ class FabButton : UIButton {
layer
.
shadowRadius
=
5
}
override
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
pulseTouches
(
touches
)
override
public
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
super
.
touchesBegan
(
touches
,
withEvent
:
event
)
pulseTouches
(
touches
)
}
override
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
shrink
()
override
public
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
shrink
()
removePulse
()
}
...
...
@@ -116,8 +122,8 @@ class FabButton : UIButton {
let
touch
=
touches
.
allObjects
.
last
as!
UITouch
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
bounds
W
(),
boundsH
()
)
pulseView
!.
layer
.
cornerRadius
=
bounds
W
()
/
2.0
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
bounds
.
width
,
bounds
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
.
width
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
!.
addSubview
(
pulseView
!
)
...
...
@@ -134,7 +140,7 @@ class FabButton : UIButton {
}
func
removePulse
()
{
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
()
->
Void
in
UIView
.
animateWithDuration
(
0.3
,
animations
:
{
_
in
self
.
pulseView
?
.
alpha
=
0.0
})
{
(
finished
)
->
Void
in
self
.
pulseView
?
.
removeFromSuperview
()
...
...
Source/FlatButton.swift
View file @
5e8d2dec
...
...
@@ -18,7 +18,7 @@
import
UIKit
class
FlatButton
:
UIButton
{
public
class
FlatButton
:
UIButton
{
var
textColor
:
UIColor
?
var
pulseColor
:
UIColor
?
...
...
@@ -28,18 +28,18 @@ class FlatButton : UIButton {
private
var
backgroundColorView
:
UIView
=
UIView
()
private
var
pulseView
:
UIView
?
override
func
drawRect
(
rect
:
CGRect
)
{
public
override
func
drawRect
(
rect
:
CGRect
)
{
setupContext
(
rect
)
setupBackgroundColorView
()
}
required
init
(
coder
aDecoder
:
NSCoder
)
{
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
initialize
()
applyShadow
()
}
required
override
init
(
frame
:
CGRect
)
{
public
required
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initialize
()
applyShadow
()
...
...
@@ -75,11 +75,11 @@ class FlatButton : UIButton {
layer
.
shadowRadius
=
5
}
override
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
public
override
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
pulseTouches
(
touches
)
}
override
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
public
override
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
shrink
()
removePulse
()
}
...
...
@@ -89,7 +89,7 @@ class FlatButton : UIButton {
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
height
,
self
.
bounds
.
size
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
H
()
/
2.0
pulseView
!.
layer
.
cornerRadius
=
bounds
.
height
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
!
)
...
...
Source/Layout.swift
0 → 100644
View file @
5e8d2dec
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
public
struct
Layout
{
public
static
func
topRight
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
,
height
:
CGFloat
,
top
:
CGFloat
,
right
:
CGFloat
)
{
parent
.
addSubview
(
child
)
var
metrics
=
[
"width"
:
width
,
"height"
:
height
,
"top"
:
top
,
"right"
:
right
]
var
views
=
[
"view"
:
child
]
var
viewBindingsDict
:
NSMutableDictionary
=
NSMutableDictionary
()
viewBindingsDict
.
setValue
(
child
,
forKey
:
"child"
)
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"H:[child(width)]-(right)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"V:|-(top)-[child(height)]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
}
public
static
func
topLeft
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
,
height
:
CGFloat
,
top
:
CGFloat
,
left
:
CGFloat
)
{
parent
.
addSubview
(
child
)
var
metrics
=
[
"width"
:
width
,
"height"
:
height
,
"top"
:
top
,
"left"
:
left
]
var
views
=
[
"view"
:
child
]
var
viewBindingsDict
:
NSMutableDictionary
=
NSMutableDictionary
()
viewBindingsDict
.
setValue
(
child
,
forKey
:
"child"
)
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"H:|-(left)-[child(width)]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"V:|-(top)-[child(height)]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
}
public
static
func
bottomRight
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
,
height
:
CGFloat
,
bottom
:
CGFloat
,
right
:
CGFloat
)
{
parent
.
addSubview
(
child
)
var
metrics
=
[
"width"
:
width
,
"height"
:
height
,
"bottom"
:
bottom
,
"right"
:
right
]
var
views
=
[
"view"
:
child
]
var
viewBindingsDict
:
NSMutableDictionary
=
NSMutableDictionary
()
viewBindingsDict
.
setValue
(
child
,
forKey
:
"child"
)
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"H:[child(width)]-(right)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"V:[child(height)]-(bottom)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
}
public
static
func
bottomLeft
(
parent
:
UIView
,
child
:
UIView
,
width
:
CGFloat
,
height
:
CGFloat
,
bottom
:
CGFloat
,
left
:
CGFloat
)
{
parent
.
addSubview
(
child
)
var
metrics
=
[
"width"
:
width
,
"height"
:
height
,
"bottom"
:
bottom
,
"left"
:
left
]
var
views
=
[
"view"
:
child
]
var
viewBindingsDict
:
NSMutableDictionary
=
NSMutableDictionary
()
viewBindingsDict
.
setValue
(
child
,
forKey
:
"child"
)
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"H:|-(left)-[child(width)]"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
parent
.
addConstraints
(
NSLayoutConstraint
.
constraintsWithVisualFormat
(
"V:[child(height)]-(bottom)-|"
,
options
:
nil
,
metrics
:
metrics
,
views
:
viewBindingsDict
as
[
NSObject
:
AnyObject
]))
}
}
Source/MaterialKit+UIView.swift
deleted
100644 → 0
View file @
ebfbb737
//
// Copyright (C) 2015 Adam Dahan <https://github.com/adamdahan>.
// Copyright (C) 2015 Daniel Dahan <https://github.com/danieldahan>.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
extension
UIView
{
func
frameW
()
->
CGFloat
{
return
self
.
frame
.
size
.
width
}
func
frameH
()
->
CGFloat
{
return
self
.
frame
.
size
.
height
}
func
frameX
()
->
CGFloat
{
return
self
.
frame
.
origin
.
x
}
func
frameY
()
->
CGFloat
{
return
self
.
frame
.
origin
.
y
}
func
boundsW
()
->
CGFloat
{
return
self
.
bounds
.
size
.
width
}
func
boundsH
()
->
CGFloat
{
return
self
.
bounds
.
size
.
height
}
func
boundsX
()
->
CGFloat
{
return
self
.
bounds
.
origin
.
x
}
func
boundsY
()
->
CGFloat
{
return
self
.
bounds
.
origin
.
y
}
}
Source/RaisedButton.swift
View file @
5e8d2dec
...
...
@@ -18,7 +18,7 @@
import
UIKit
class
RaisedButton
:
UIButton
{
public
class
RaisedButton
:
UIButton
{
var
color
:
UIColor
?
var
pulseColor
:
UIColor
?
...
...
@@ -28,18 +28,18 @@ class RaisedButton : UIButton {
private
var
backgroundColorView
:
UIView
=
UIView
()
private
var
pulseView
:
UIView
?
override
func
drawRect
(
rect
:
CGRect
)
{
public
override
func
drawRect
(
rect
:
CGRect
)
{
setupContext
(
rect
)
setupBackgroundColorView
()
}
required
init
(
coder
aDecoder
:
NSCoder
)
{
public
required
init
(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
initialize
()
applyShadow
()
}
required
override
init
(
frame
:
CGRect
)
{
public
required
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
initialize
()
applyShadow
()
...
...
@@ -76,11 +76,11 @@ class RaisedButton : UIButton {
layer
.
shadowRadius
=
5
}
override
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
public
override
func
touchesBegan
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
pulseTouches
(
touches
)
}
override
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
public
override
func
touchesEnded
(
touches
:
Set
<
NSObject
>
,
withEvent
event
:
UIEvent
)
{
shrink
()
removePulse
()
}
...
...
@@ -90,7 +90,7 @@ class RaisedButton : UIButton {
let
touchLocation
=
touch
.
locationInView
(
self
)
pulseView
=
UIView
()
pulseView
!.
frame
=
CGRectMake
(
0
,
0
,
self
.
bounds
.
size
.
height
,
self
.
bounds
.
size
.
height
)
pulseView
!.
layer
.
cornerRadius
=
bounds
H
()
/
2.0
pulseView
!.
layer
.
cornerRadius
=
bounds
.
height
/
2.0
pulseView
!.
center
=
touchLocation
pulseView
!.
backgroundColor
=
pulseColor
!.
colorWithAlphaComponent
(
0.5
)
backgroundColorView
.
addSubview
(
pulseView
!
)
...
...
Source/Text.swift
View file @
5e8d2dec
...
...
@@ -26,10 +26,10 @@ public protocol TextDelegate {
public
class
Text
:
NSObject
{
/**
*
searchPattern
*
A string representation of the regular expression that matches text within
* the TextStorage string property. By default, the search pattern recognizes
* words and emoji c
haracters beginning with hashtags.
:name:
searchPattern
:description:
A string representation of the regular expression that matches text within
the TextStorage string property. By default, the search pattern recognizes words and emoji
haracters beginning with hashtags.
*/
public
var
searchPattern
:
String
=
"(^|
\\
s)#[
\\
d
\\
w_
\u{203C}\u{2049}\u{20E3}\u{2122}\u{2139}\u{2194}
-
\u{2199}\u{21A9}
-
\u{21AA}\u{231A}
-
\u{231B}\u{23E9}
-
\u{23EC}\u{23F0}\u{23F3}\u{24C2}\u{25AA}
-
\u{25AB}\u{25B6}\u{25C0}\u{25FB}
-
\u{25FE}\u{2600}
-
\u{2601}\u{260E}\u{2611}\u{2614}
-
\u{2615}\u{261D}\u{263A}\u{2648}
-
\u{2653}\u{2660}\u{2663}\u{2665}
-
\u{2666}\u{2668}\u{267B}\u{267F}\u{2693}\u{26A0}
-
\u{26A1}\u{26AA}
-
\u{26AB}\u{26BD}
-
\u{26BE}\u{26C4}
-
\u{26C5}\u{26CE}\u{26D4}\u{26EA}\u{26F2}
-
\u{26F3}\u{26F5}\u{26FA}\u{26FD}\u{2702}\u{2705}\u{2708}
-
\u{270C}\u{270F}\u{2712}\u{2714}\u{2716}\u{2728}\u{2733}
-
\u{2734}\u{2744}\u{2747}\u{274C}\u{274E}\u{2753}
-
\u{2755}\u{2757}\u{2764}\u{2795}
-
\u{2797}\u{27A1}\u{27B0}\u{2934}
-
\u{2935}\u{2B05}
-
\u{2B07}\u{2B1B}
-
\u{2B1C}\u{2B50}\u{2B55}\u{3030}\u{303D}\u{3297}\u{3299}\u{1F004}\u{1F0CF}\u{1F170}
-
\u{1F171}\u{1F17E}
-
\u{1F17F}\u{1F18E}\u{1F191}
-
\u{1F19A}\u{1F1E7}
-
\u{1F1EC}\u{1F1EE}
-
\u{1F1F0}\u{1F1F3}\u{1F1F5}\u{1F1F7}
-
\u{1F1FA}\u{1F201}
-
\u{1F202}\u{1F21A}\u{1F22F}\u{1F232}
-
\u{1F23A}\u{1F250}
-
\u{1F251}\u{1F300}
-
\u{1F320}\u{1F330}
-
\u{1F335}\u{1F337}
-
\u{1F37C}\u{1F380}
-
\u{1F393}\u{1F3A0}
-
\u{1F3C4}\u{1F3C6}
-
\u{1F3CA}\u{1F3E0}
-
\u{1F3F0}\u{1F400}
-
\u{1F43E}\u{1F440}\u{1F442}
-
\u{1F4F7}\u{1F4F9}
-
\u{1F4FC}\u{1F500}
-
\u{1F507}\u{1F509}
-
\u{1F53D}\u{1F550}
-
\u{1F567}\u{1F5FB}
-
\u{1F640}\u{1F645}
-
\u{1F64F}\u{1F680}
-
\u{1F68A}
]+"
{
didSet
{
...
...
@@ -38,15 +38,14 @@ public class Text: NSObject {
}
/**
*
textStorage
*
Reference to wrapped NSTextStorage
:name:
textStorage
:description:
Reference to wrapped NSTextStorage
*/
public
let
textStorage
:
TextStorage
/**
* delegate
* An optional instance of TextDelegate to handle text processing events
*
:name: delegate
:description: An optional instance of TextDelegate to handle text processing events.
*/
public
weak
var
delegate
:
TextDelegate
?
...
...
@@ -63,8 +62,8 @@ public class Text: NSObject {
}
/**
*
string
*
Managed string value.
:name:
string
:description:
Managed string value.
*/
public
var
string
:
String
{
get
{
...
...
@@ -73,9 +72,9 @@ public class Text: NSObject {
}
/**
*
matches
*
An array of matches found in the TextStorage string property based on the
*
searchPattern property.
:name:
matches
:description:
An array of matches found in the TextStorage string property based on the
searchPattern property.
*/
public
var
matches
:
Array
<
String
>
{
get
{
...
...
@@ -85,8 +84,8 @@ public class Text: NSObject {
}
/**
*
unique
*
Ensures a unique value in the matches return array.
:name:
unique
:description:
Ensures a unique value in the matches return array.
*/
private
func
unique
<
S
:
SequenceType
,
E
:
Hashable
where
E
==
S
.
Generator
.
Element
>
(
source
:
S
)
->
[
E
]
{
var
seen
:
[
E
:
Bool
]
=
[:]
...
...
Source/TextStorage.swift
View file @
5e8d2dec
...
...
@@ -23,28 +23,28 @@ internal typealias TextStorageDidProcessEdit = (TextStorage!, NSTextCheckingResu
public
class
TextStorage
:
NSTextStorage
{
/**
*
store
*
Acts as the model, storing the string value.
:name:
store
:description:
Acts as the model, storing the string value.
*/
private
lazy
var
store
:
NSMutableAttributedString
=
NSMutableAttributedString
()
/**
*
searchExpression
*
Matches text within the TextStorage string property.
:name:
searchExpression
:description:
Matches text within the TextStorage string property.
*/
internal
var
searchExpression
:
NSRegularExpression
?
/**
*
textStorageWillProcessEdit
*
If set, this block callback executes when there is a change in the TextStorage
*
string value.
:name:
textStorageWillProcessEdit
:description:
If set, this block callback executes when there is a change in the TextStorage
string value.
*/
internal
var
textStorageWillProcessEdit
:
TextStorageWillProcessEdit
?
/**
*
textStorageDidProcessEdit
*
If set, this block callback executes when a match is detected after a change in
*
the TextStorage string value.
:name:
textStorageDidProcessEdit
:description:
If set, this block callback executes when a match is detected after a change in
the TextStorage string value.
*/
internal
var
textStorageDidProcessEdit
:
TextStorageDidProcessEdit
?
...
...
@@ -57,8 +57,8 @@ public class TextStorage: NSTextStorage {
}
/**
*
string
*
Managed string value.
:name:
string
:description:
Managed string value.
*/
override
public
var
string
:
String
{
get
{
...
...
Source/TextView.swift
View file @
5e8d2dec
...
...
@@ -22,16 +22,16 @@ private var defaultTextColor: UIColor = UIColor(red: 33/255, green: 33/255, blue
private
var
defaultPlaceholderColor
:
UIColor
=
UIColor
(
red
:
159
/
255
,
green
:
160
/
255
,
blue
:
164
/
255
,
alpha
:
1
)
public
class
TextView
:
UITextView
{
/
**
*
label
*
Placeholder label.
*
/
/
/
// :name:
label
// :description:
Placeholder label.
/
/
private
lazy
var
label
:
UILabel
=
UILabel
()
/
**
*
labelConstraints
*
Autoresize constraints for the placeholder label.
*
/
/
/
// :name:
labelConstraints
// :description:
Autoresize constraints for the placeholder label.
/
/
private
var
labelConstraints
:
Array
<
NSLayoutConstraint
>
?
required
public
init
(
coder
aDecoder
:
NSCoder
)
{
...
...
@@ -47,17 +47,17 @@ public class TextView: UITextView {
setupView
()
}
/
**
*
deinit
*
Notification observer removed from UITextView.
*/
/
/
// :name:
deinit
// :description:
Notification observer removed from UITextView.
//
deinit
{
NSNotificationCenter
.
defaultCenter
()
.
removeObserver
(
self
,
name
:
UITextViewTextDidChangeNotification
,
object
:
nil
)
}
/**
*
placeholder
*
The placeholder label string.
:name:
placeholder
:description:
The placeholder label string.
*/
public
var
placeholder
:
String
=
""
{
didSet
{
...
...
@@ -66,8 +66,8 @@ public class TextView: UITextView {
}
/**
*
placeholderColor
*
The placeholder color.
:name:
placeholderColor
:description:
The placeholder color.
*/
public
var
placeholderColor
:
UIColor
=
defaultPlaceholderColor
{
didSet
{
...
...
@@ -76,8 +76,8 @@ public class TextView: UITextView {
}
/**
*
font
*
Font to use for placeholder based on UITextView font.
:name:
font
:description:
Font to use for placeholder based on UITextView font.
*/
override
public
var
font
:
UIFont
!
{
didSet
{
...
...
@@ -86,8 +86,8 @@ public class TextView: UITextView {
}
/**
*
textAlignment
*
Sets placeholder textAlignment based on UITextView textAlignment.
:name:
textAlignment
:description:
Sets placeholder textAlignment based on UITextView textAlignment.
*/
override
public
var
textAlignment
:
NSTextAlignment
{
didSet
{
...
...
@@ -96,8 +96,8 @@ public class TextView: UITextView {
}
/**
*
text
*
When set, updates the placeholder text.
:name:
text
:description:
When set, updates the placeholder text.
*/
override
public
var
text
:
String
!
{
didSet
{
...
...
@@ -106,8 +106,8 @@ public class TextView: UITextView {
}
/**
*
attributedText
*
When set, updates the placeholder attributedText.
:name:
attributedText
:description:
When set, updates the placeholder attributedText.
*/
override
public
var
attributedText
:
NSAttributedString
!
{
didSet
{
...
...
@@ -116,8 +116,8 @@ public class TextView: UITextView {
}
/**
*
textContainerInset
*
When set, updates the placeholder constraints.
:name:
textContainerInset
:description:
When set, updates the placeholder constraints.
*/
override
public
var
textContainerInset
:
UIEdgeInsets
{
didSet
{
...
...
@@ -130,18 +130,18 @@ public class TextView: UITextView {
label
.
preferredMaxLayoutWidth
=
textContainer
.
size
.
width
-
textContainer
.
lineFragmentPadding
*
2.0
}
/
**
*
textViewTextDidChange
*
Updates the label visibility when text is empty or not.
*
/
/
/
// :name:
textViewTextDidChange
// :description:
Updates the label visibility when text is empty or not.
/
/
internal
func
textViewTextDidChange
()
{
label
.
hidden
=
!
text
.
isEmpty
}
/
**
*
setupView
*
Sets up the common initilized values.
*
/
/
/
// :name:
setupView
// :description:
Sets up the common initilized values.
/
/
private
func
setupView
()
{
backgroundColor
=
.
clearColor
()
textColor
=
defaultTextColor
...
...
@@ -162,10 +162,10 @@ public class TextView: UITextView {
updateLabelConstraints
()
}
/
**
*
updateLabelConstraints
*
Updates the placeholder constraints.
*/
/
/
// :name:
updateLabelConstraints
// :description:
Updates the placeholder constraints.
//
private
func
updateLabelConstraints
()
{
if
nil
!=
labelConstraints
{
removeConstraints
(
labelConstraints
!
)
...
...
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