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
7c2198ec
Unverified
Commit
7c2198ec
authored
Oct 16, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: progression with TextField
parent
dfcc3fbd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
24 deletions
+46
-24
Examples/Programmatic/TextField/TextField.xcodeproj/project.pbxproj
+3
-2
Examples/Programmatic/TextField/TextField/ViewController.swift
+28
-21
Sources/iOS/SearchBar.swift
+15
-1
Sources/iOS/TextField.swift
+0
-0
No files found.
Examples/Programmatic/TextField/TextField.xcodeproj/project.pbxproj
View file @
7c2198ec
...
...
@@ -107,6 +107,7 @@
TargetAttributes
=
{
96090AE31D9CDD2E00709CA6
=
{
CreatedOnToolsVersion
=
8.0
;
DevelopmentTeam
=
9Z76XCNLGL
;
ProvisioningStyle
=
Automatic
;
};
};
...
...
@@ -262,7 +263,7 @@
isa
=
XCBuildConfiguration
;
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
DEVELOPMENT_TEAM
=
""
;
DEVELOPMENT_TEAM
=
9Z76XCNLGL
;
INFOPLIST_FILE
=
TextField/Info.plist
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
io.cosmicmind.TextField
;
...
...
@@ -275,7 +276,7 @@
isa
=
XCBuildConfiguration
;
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
DEVELOPMENT_TEAM
=
""
;
DEVELOPMENT_TEAM
=
9Z76XCNLGL
;
INFOPLIST_FILE
=
TextField/Info.plist
;
LD_RUNPATH_SEARCH_PATHS
=
"$(inherited) @executable_path/Frameworks"
;
PRODUCT_BUNDLE_IDENTIFIER
=
io.cosmicmind.TextField
;
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
7c2198ec
...
...
@@ -40,9 +40,9 @@ class ViewController: UIViewController {
super
.
viewDidLoad
()
view
.
backgroundColor
=
.
white
//
prepareNameField()
prepareNameField
()
prepareEmailField
()
//
preparePasswordField()
preparePasswordField
()
prepareResignResponderButton
()
}
...
...
@@ -68,36 +68,39 @@ class ViewController: UIViewController {
}
private
func
prepareNameField
()
{
let
d
:
CGFloat
=
40
let
d
:
CGFloat
=
32
nameField
=
TextField
()
nameField
.
text
=
"Daniel Dahan"
nameField
.
placeholder
=
"Name"
nameField
.
detail
=
"Your given name"
nameField
.
detail
Label
.
text
=
"Your given name"
nameField
.
textAlignment
=
.
center
nameField
.
clearButtonMode
=
.
whileEditing
// Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 40 pixels.
view
.
layout
(
nameField
)
.
top
(
d
)
.
horizontally
(
left
:
d
,
right
:
d
)
let
leftView
=
UIImageView
()
leftView
.
image
=
Icon
.
email
?
.
tint
(
with
:
Color
.
cyan
.
base
)
nameField
.
leftView
=
leftView
nameField
.
leftViewMode
=
.
always
view
.
layout
(
nameField
)
.
top
(
100
)
.
horizontally
(
left
:
d
,
right
:
d
)
.
height
(
d
)
}
private
func
prepareEmailField
()
{
let
d
:
CGFloat
=
32
let
leftView
=
UIImageView
(
frame
:
CGRect
(
x
:
0
,
y
:
0
,
width
:
d
,
height
:
d
))
leftView
.
image
=
Icon
.
email
?
.
tint
(
with
:
Color
.
cyan
.
base
)
leftView
.
contentMode
=
.
center
emailField
=
ErrorTextField
(
frame
:
CGRect
(
x
:
40
,
y
:
120
,
width
:
view
.
width
-
80
,
height
:
d
))
emailField
.
placeholder
=
"Email"
emailField
.
detail
=
"Error, incorrect email"
emailField
=
ErrorTextField
(
frame
:
CGRect
(
x
:
d
,
y
:
200
,
width
:
view
.
width
-
(
2
*
d
),
height
:
d
))
emailField
.
placeholderLabel
.
text
=
"Email"
emailField
.
detailLabel
.
text
=
"Error, incorrect email"
emailField
.
isClearIconButtonEnabled
=
true
emailField
.
delegate
=
self
let
leftView
=
UIImageView
()
leftView
.
image
=
Icon
.
email
?
.
tint
(
with
:
Color
.
cyan
.
base
)
emailField
.
leftView
=
leftView
emailField
.
leftViewMode
=
.
always
emailField
.
divider
.
contentEdgeInsets
.
left
=
d
// emailField.placeholderNormalColor = Color.amber.darken4
// emailField.placeholderActiveColor = Color.pink.base
...
...
@@ -107,20 +110,24 @@ class ViewController: UIViewController {
}
private
func
preparePasswordField
()
{
let
d
:
CGFloat
=
40
let
d
:
CGFloat
=
32
passwordField
=
TextField
()
passwordField
.
placeholder
=
"Password"
passwordField
.
detail
=
"At least 8 characters"
passwordField
.
placeholder
Label
.
text
=
"Password"
passwordField
.
detail
Label
.
text
=
"At least 8 characters"
passwordField
.
clearButtonMode
=
.
whileEditing
passwordField
.
isVisibilityIconButtonEnabled
=
true
let
leftView
=
UIImageView
()
leftView
.
image
=
Icon
.
email
?
.
tint
(
with
:
Color
.
cyan
.
base
)
passwordField
.
leftView
=
leftView
passwordField
.
leftViewMode
=
.
always
// Setting the visibilityIconButton color.
passwordField
.
visibilityIconButton
?
.
tintColor
=
Color
.
green
.
base
.
withAlphaComponent
(
passwordField
.
isSecureTextEntry
?
0.38
:
0.54
)
// Size the TextField to the maximum width, less 40 pixels on either side
// with a top margin of 200 pixels.
view
.
layout
(
passwordField
)
.
top
(
200
)
.
horizontally
(
left
:
d
,
right
:
d
)
view
.
layout
(
passwordField
)
.
top
(
300
)
.
horizontally
(
left
:
d
,
right
:
d
)
.
height
(
d
)
}
}
...
...
Sources/iOS/SearchBar.swift
View file @
7c2198ec
...
...
@@ -42,6 +42,15 @@ public protocol SearchBarDelegate {
optional
func
searchBar
(
searchBar
:
SearchBar
,
didChange
textField
:
UITextField
,
with
text
:
String
?)
/**
A delegation method that is executed when the textField will clear.
- Parameter searchBar: A SearchBar.
- Parameter willClear textField: A UITextField.
- Parameter with text: An optional String.
*/
@objc
optional
func
searchBar
(
searchBar
:
SearchBar
,
willClear
textField
:
UITextField
,
with
text
:
String
?)
/**
A delegation method that is executed when the textField is cleared.
- Parameter searchBar: A SearchBar.
- Parameter didClear textField: A UITextField.
...
...
@@ -175,8 +184,13 @@ open class SearchBar: Bar {
/// Clears the textField text.
@objc
internal
func
handleClearButton
()
{
delegate
?
.
searchBar
?(
searchBar
:
self
,
didClear
:
textField
,
with
:
textField
.
text
)
let
text
=
textField
.
text
delegate
?
.
searchBar
?(
searchBar
:
self
,
willClear
:
textField
,
with
:
text
)
textField
.
text
=
nil
delegate
?
.
searchBar
?(
searchBar
:
self
,
didClear
:
textField
,
with
:
text
)
}
// Live updates the search results.
...
...
Sources/iOS/TextField.swift
View file @
7c2198ec
This diff is collapsed.
Click to expand it.
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