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
f89ce814
Commit
f89ce814
authored
Dec 17, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial code for TextField
parent
4619f96b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
1 deletions
+122
-1
Examples/Programmatic/TextField/TextField/ViewController.swift
+10
-1
MaterialKit.xcodeproj/project.pbxproj
+12
-0
Sources/TextField.swift
+100
-0
No files found.
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
f89ce814
...
@@ -24,11 +24,20 @@ class ViewController: UIViewController {
...
@@ -24,11 +24,20 @@ class ViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareView
()
prepareView
()
prepareTextField
()
}
}
private
func
prepareView
()
{
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
white
view
.
backgroundColor
=
MaterialColor
.
white
}
}
private
func
prepareTextField
()
{
let
textField
:
TextField
=
TextField
(
frame
:
CGRectMake
(
100
,
100
,
200
,
35
))
textField
.
placeholder
=
"Title"
textField
.
textColor
=
MaterialColor
.
grey
.
base
textField
.
titleLabel
=
UILabel
()
view
.
addSubview
(
textField
)
}
}
}
MaterialKit.xcodeproj/project.pbxproj
View file @
f89ce814
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
963832421B88DFD80015F710
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832361B88DFD80015F710
/* MaterialKit.framework */
;
};
963832421B88DFD80015F710
/* MaterialKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832361B88DFD80015F710
/* MaterialKit.framework */
;
};
9638325A1B88E31A0015F710
/* MaterialKitTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832581B88E31A0015F710
/* MaterialKitTests.swift */
;
};
9638325A1B88E31A0015F710
/* MaterialKitTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832581B88E31A0015F710
/* MaterialKitTests.swift */
;
};
966F57B81C226D75009185B7
/* TextField.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966F57B71C226D75009185B7
/* TextField.swift */
;
};
96D88C1E1C1328D800B91418
/* CaptureView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88BF51C1328D800B91418
/* CaptureView.swift */
;
};
96D88C1E1C1328D800B91418
/* CaptureView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88BF51C1328D800B91418
/* CaptureView.swift */
;
};
96D88C1F1C1328D800B91418
/* CardView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88BF61C1328D800B91418
/* CardView.swift */
;
};
96D88C1F1C1328D800B91418
/* CardView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88BF61C1328D800B91418
/* CardView.swift */
;
};
96D88C201C1328D800B91418
/* CapturePreviewView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88BF71C1328D800B91418
/* CapturePreviewView.swift */
;
};
96D88C201C1328D800B91418
/* CapturePreviewView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88BF71C1328D800B91418
/* CapturePreviewView.swift */
;
};
...
@@ -96,6 +97,7 @@
...
@@ -96,6 +97,7 @@
963832411B88DFD80015F710
/* MaterialKitTests.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
MaterialKitTests.xctest
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832411B88DFD80015F710
/* MaterialKitTests.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
MaterialKitTests.xctest
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832581B88E31A0015F710
/* MaterialKitTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKitTests.swift
;
sourceTree
=
"<group>"
;
};
963832581B88E31A0015F710
/* MaterialKitTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialKitTests.swift
;
sourceTree
=
"<group>"
;
};
963832591B88E31A0015F710
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
963832591B88E31A0015F710
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
966F57B71C226D75009185B7
/* TextField.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
TextField.swift
;
sourceTree
=
"<group>"
;
};
96D88BF51C1328D800B91418
/* CaptureView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CaptureView.swift
;
sourceTree
=
"<group>"
;
};
96D88BF51C1328D800B91418
/* CaptureView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CaptureView.swift
;
sourceTree
=
"<group>"
;
};
96D88BF61C1328D800B91418
/* CardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CardView.swift
;
sourceTree
=
"<group>"
;
};
96D88BF61C1328D800B91418
/* CardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CardView.swift
;
sourceTree
=
"<group>"
;
};
96D88BF71C1328D800B91418
/* CapturePreviewView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CapturePreviewView.swift
;
sourceTree
=
"<group>"
;
};
96D88BF71C1328D800B91418
/* CapturePreviewView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CapturePreviewView.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -184,6 +186,14 @@
...
@@ -184,6 +186,14 @@
path
=
Tests
;
path
=
Tests
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
966F57B61C226D65009185B7
/* Text */
=
{
isa
=
PBXGroup
;
children
=
(
966F57B71C226D75009185B7
/* TextField.swift */
,
);
name
=
Text
;
sourceTree
=
"<group>"
;
};
96D88BF41C1328D800B91418
/* Sources */
=
{
96D88BF41C1328D800B91418
/* Sources */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -204,6 +214,7 @@
...
@@ -204,6 +214,7 @@
96D88C4A1C13294200B91418
/* Type */
,
96D88C4A1C13294200B91418
/* Type */
,
96D88C491C13292700B91418
/* Capture */
,
96D88C491C13292700B91418
/* Capture */
,
96D88C471C1328F500B91418
/* Font */
,
96D88C471C1328F500B91418
/* Font */
,
966F57B61C226D65009185B7
/* Text */
,
);
);
path
=
Sources
;
path
=
Sources
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -509,6 +520,7 @@
...
@@ -509,6 +520,7 @@
96D88C351C1328D800B91418
/* MaterialLayout.swift in Sources */
,
96D88C351C1328D800B91418
/* MaterialLayout.swift in Sources */
,
96D88C2F1C1328D800B91418
/* MaterialGravity.swift in Sources */
,
96D88C2F1C1328D800B91418
/* MaterialGravity.swift in Sources */
,
96D88C231C1328D800B91418
/* FlatButton.swift in Sources */
,
96D88C231C1328D800B91418
/* FlatButton.swift in Sources */
,
966F57B81C226D75009185B7
/* TextField.swift in Sources */
,
96D88C201C1328D800B91418
/* CapturePreviewView.swift in Sources */
,
96D88C201C1328D800B91418
/* CapturePreviewView.swift in Sources */
,
96D88C3E1C1328D800B91418
/* NavigationBarView.swift in Sources */
,
96D88C3E1C1328D800B91418
/* NavigationBarView.swift in Sources */
,
96D88C221C1328D800B91418
/* FabButton.swift in Sources */
,
96D88C221C1328D800B91418
/* FabButton.swift in Sources */
,
...
...
Sources/TextField.swift
0 → 100644
View file @
f89ce814
//
// Copyright (C) 2015 CosmicMind, Inc. <http://cosmicmind.io> and other CosmicMind 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
class
TextField
:
UITextField
{
/**
:name: bottomBorderLayer
*/
public
private(set)
lazy
var
bottomBorderLayer
:
MaterialLayer
=
MaterialLayer
()
/**
:name: titleLabel
*/
public
var
titleLabel
:
UILabel
?
{
didSet
{
prepareTitleLabel
()
}
}
/**
:name: bottomBorderEnabled
*/
public
var
bottomBorderEnabled
:
Bool
=
true
/**
:name: init
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
:name: init
*/
public
override
init
(
frame
:
CGRect
)
{
super
.
init
(
frame
:
frame
)
prepareView
()
}
/**
:name: init
*/
public
convenience
init
()
{
self
.
init
(
frame
:
CGRectNull
)
}
/**
:name: layoutSubviews
*/
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
bottomBorderLayer
.
frame
=
CGRectMake
(
0
,
bounds
.
height
-
bottomBorderLayer
.
height
,
bounds
.
width
,
bottomBorderLayer
.
height
)
}
/**
:name: prepareView
*/
public
func
prepareView
()
{
prepareBottomBorderLayer
()
}
/**
:name: prepareBottomBorderLayer
*/
private
func
prepareBottomBorderLayer
()
{
bottomBorderLayer
.
frame
=
CGRectMake
(
0
,
bounds
.
height
-
1
,
bounds
.
width
,
1
)
bottomBorderLayer
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
.
CGColor
layer
.
addSublayer
(
bottomBorderLayer
)
}
/**
:name: prepareTitleLabel
*/
private
func
prepareTitleLabel
()
{
if
let
v
:
UILabel
=
titleLabel
{
v
.
frame
=
bounds
v
.
text
=
placeholder
v
.
textColor
=
textColor
addSubview
(
v
)
}
}
}
\ No newline at end of file
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