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
34e53600
Unverified
Commit
34e53600
authored
Oct 21, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: rework on cards
parent
5b66bcf0
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
83 additions
and
127 deletions
+83
-127
README.md
+1
-1
Sources/Info.plist
+1
-1
Sources/iOS/Bar.swift
+1
-1
Sources/iOS/Card.swift
+7
-6
Sources/iOS/CollectionView.swift
+3
-3
Sources/iOS/CollectionViewDataSource.swift
+4
-4
Sources/iOS/CollectionViewLayout.swift
+6
-5
Sources/iOS/ImageCard.swift
+2
-1
Sources/iOS/Material+CALayer.swift
+2
-8
Sources/iOS/PresenterCard.swift
+40
-77
Sources/iOS/SearchBar.swift
+0
-1
Sources/iOS/StatusBarController.swift
+15
-16
Sources/iOS/TabBar.swift
+0
-1
Sources/iOS/Toolbar.swift
+0
-1
Sources/iOS/ToolbarController.swift
+1
-1
No files found.
README.md
View file @
34e53600
...
...
@@ -107,7 +107,7 @@ A button is used to trigger an action through a touch event. Material comes with

*
Download the complete
[
Button sample
](
https://github.com/CosmicMind/Samples/tree/master/Material/Programmatic/Button
)
.
*
Learn more about
[
TextField
](
http://cosmicmind.io/material/button
)
.
*
Learn more about
[
Button
](
http://cosmicmind.io/material/button
)
.
## Switch
...
...
Sources/Info.plist
View file @
34e53600
...
...
@@ -15,7 +15,7 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
FMWK
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
2.2.
1
<
/string
>
<
string
>
2.2.
3
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
...
...
Sources/iOS/Bar.swift
View file @
34e53600
...
...
@@ -259,7 +259,7 @@ open class Bar: View {
*/
open
override
func
prepare
()
{
super
.
prepare
()
heightPreset
=
.
default
heightPreset
=
.
normal
autoresizingMask
=
.
flexibleWidth
interimSpacePreset
=
.
interimSpace3
contentEdgeInsetsPreset
=
.
square1
...
...
Sources/iOS/Card.swift
View file @
34e53600
...
...
@@ -70,6 +70,7 @@ open class Card: PulseView {
@IBInspectable
open
var
toolbar
:
Toolbar
?
{
didSet
{
oldValue
?
.
removeFromSuperview
()
layoutSubviews
()
}
}
...
...
@@ -93,6 +94,7 @@ open class Card: PulseView {
@IBInspectable
open
var
contentView
:
UIView
?
{
didSet
{
oldValue
?
.
removeFromSuperview
()
layoutSubviews
()
}
}
...
...
@@ -116,6 +118,7 @@ open class Card: PulseView {
@IBInspectable
open
var
bottomBar
:
Bar
?
{
didSet
{
oldValue
?
.
removeFromSuperview
()
layoutSubviews
()
}
}
...
...
@@ -193,7 +196,7 @@ open class Card: PulseView {
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
views
[
"toolbar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
}
if
let
v
=
contentView
{
...
...
@@ -215,8 +218,6 @@ open class Card: PulseView {
}
if
let
v
=
bottomBar
{
metrics
[
"bottomBarBottom"
]
=
bottomBarEdgeInsets
.
bottom
if
nil
!=
contentView
{
metrics
[
"contentViewBottom"
]
=
(
metrics
[
"contentViewBottom"
]
as!
CGFloat
)
+
bottomBarEdgeInsets
.
top
format
+=
"-[bottomBar]-(bottomBarBottom)"
...
...
@@ -225,18 +226,18 @@ open class Card: PulseView {
format
+=
"-[bottomBar]-(bottomBarBottom)"
}
else
{
metrics
[
"bottomBarTop"
]
=
bottomBarEdgeInsets
.
top
format
+=
"-(bottomBarTop)-[bottomBar]
-(bottomBarBottom)
"
format
+=
"-(bottomBarTop)-[bottomBar]"
}
views
[
"bottomBar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
.
bottom
(
bottomBarEdgeInsets
.
bottom
)
}
guard
0
<
views
.
count
else
{
return
}
container
.
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-
|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
container
.
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
}
/**
...
...
Sources/iOS/CollectionView.swift
View file @
34e53600
...
...
@@ -32,12 +32,12 @@ import UIKit
open
class
CollectionView
:
UICollectionView
{
/// A preset wrapper around contentEdgeInsets.
open
var
contentEdgeInsetsPreset
:
EdgeInsets
{
open
var
contentEdgeInsetsPreset
:
EdgeInsets
Preset
{
get
{
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
contentEdgeInsets
return
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
contentEdgeInsets
Preset
}
set
(
value
)
{
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
contentEdgeInsets
=
value
(
collectionViewLayout
as?
CollectionViewLayout
)
!.
contentEdgeInsets
Preset
=
value
}
}
...
...
Sources/iOS/CollectionViewDataSource.swift
View file @
34e53600
...
...
@@ -32,8 +32,8 @@ import UIKit
public
protocol
CollectionViewDataSource
:
UICollectionViewDataSource
{
/**
Retrieves th
e items for the collectionView.
- Returns: An Array of CollectionDataSourceItem objects.
*/
func
items
()
->
[
CollectionDataSourceItem
]
Retrieves the data sourc
e items for the collectionView.
- Returns: An Array of CollectionDataSourceItem objects.
*/
var
dataSourceItems
:
[
CollectionDataSourceItem
]
{
get
}
}
Sources/iOS/CollectionViewLayout.swift
View file @
34e53600
...
...
@@ -38,7 +38,7 @@ open class CollectionViewLayout: UICollectionViewLayout {
open
var
itemSize
=
CGSize
.
zero
/// A preset wrapper around contentEdgeInsets.
open
var
contentEdgeInsetsPreset
:
EdgeInsetsPreset
=
.
none
{
open
var
contentEdgeInsetsPreset
=
EdgeInsetsPreset
.
none
{
didSet
{
contentEdgeInsets
=
EdgeInsetsPresetToValue
(
preset
:
contentEdgeInsetsPreset
)
}
...
...
@@ -79,7 +79,7 @@ open class CollectionViewLayout: UICollectionViewLayout {
- Returns: An Array of NSIndexPath objects.
*/
open
func
indexPathsOfItemsInRect
(
rect
:
CGRect
)
->
[
NSIndexPath
]
{
var
paths
:
Array
<
NSIndexPath
>
=
Array
<
NSIndexPath
>
()
var
paths
=
[
NSIndexPath
]
()
for
(
attribute
,
indexPath
)
in
layoutItems
{
if
rect
.
intersects
(
attribute
.
frame
)
{
paths
.
append
(
indexPath
)
...
...
@@ -104,7 +104,7 @@ open class CollectionViewLayout: UICollectionViewLayout {
}
open
override
func
layoutAttributesForElements
(
in
rect
:
CGRect
)
->
[
UICollectionViewLayoutAttributes
]?
{
var
layoutAttributes
:
Array
<
UICollectionViewLayoutAttributes
>
=
Array
<
UICollectionViewLayoutAttributes
>
()
var
layoutAttributes
=
[
UICollectionViewLayoutAttributes
]
()
for
(
attribute
,
_
)
in
layoutItems
{
if
rect
.
intersects
(
attribute
.
frame
)
{
layoutAttributes
.
append
(
attribute
)
...
...
@@ -118,9 +118,10 @@ open class CollectionViewLayout: UICollectionViewLayout {
}
open
override
func
prepare
()
{
if
let
dataSource
:
CollectionViewDataSource
=
collectionView
?
.
dataSource
as?
CollectionViewDataSourc
e
{
prepareLayoutForItems
(
dataSourceItems
:
dataSource
.
items
())
guard
let
dataSource
=
collectionView
?
.
dataSource
as?
CollectionViewDataSource
els
e
{
return
}
prepareLayoutForItems
(
dataSourceItems
:
dataSource
.
dataSourceItems
)
}
open
override
func
targetContentOffset
(
forProposedContentOffset
proposedContentOffset
:
CGPoint
)
->
CGPoint
{
...
...
Sources/iOS/ImageCard.swift
View file @
34e53600
...
...
@@ -99,6 +99,7 @@ open class ImageCard: Card {
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
.
top
(
.
top
==
toolbarAlignment
?
toolbarEdgeInsets
.
top
:
iv
.
height
-
v
.
height
-
toolbarEdgeInsets
.
bottom
)
.
height
(
v
.
height
)
}
if
let
v
=
contentView
{
...
...
@@ -125,7 +126,7 @@ open class ImageCard: Card {
}
views
[
"bottomBar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
.
height
(
v
.
height
)
}
guard
0
<
views
.
count
else
{
...
...
Sources/iOS/Material+CALayer.swift
View file @
34e53600
...
...
@@ -83,7 +83,7 @@ internal class MaterialLayer {
}
/// Enables automatic shadowPath sizing.
internal
var
isShadowPathAutoSizing
=
fals
e
internal
var
isShadowPathAutoSizing
=
tru
e
/**
Initializer that takes in a CALayer.
...
...
@@ -316,12 +316,6 @@ extension CALayer {
return
}
if
.
none
==
depthPreset
{
shadowPath
=
nil
}
else
if
nil
==
shadowPath
{
shadowPath
=
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
else
{
animate
(
animation
:
Animation
.
shadowPath
(
path
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
,
duration
:
0
))
}
shadowPath
=
.
none
==
depthPreset
?
nil
:
UIBezierPath
(
roundedRect
:
bounds
,
cornerRadius
:
cornerRadius
)
.
cgPath
}
}
Sources/iOS/PresenterCard.swift
View file @
34e53600
...
...
@@ -30,6 +30,7 @@
import
UIKit
@available(iOS 9.0, *)
open
class
PresenterCard
:
Card
{
/// A preset wrapper around presenterViewEdgeInsets.
open
var
presenterViewEdgeInsetsPreset
=
EdgeInsetsPreset
.
none
{
...
...
@@ -50,94 +51,56 @@ open class PresenterCard: Card {
@IBInspectable
open
var
presenterView
:
UIView
?
{
didSet
{
oldValue
?
.
removeFromSuperview
()
layoutSubviews
()
}
}
open
override
func
reload
()
{
// Clear constraints so new ones do not conflict.
container
.
removeConstraints
(
container
.
constraints
)
for
v
in
container
.
subviews
{
v
.
removeFromSuperview
()
}
var
top
:
CGFloat
=
0
var
bottom
:
CGFloat
=
0
var
format
=
"V:|"
var
views
=
[
String
:
Any
]()
var
metrics
=
[
String
:
Any
]()
container
.
removeConstraints
(
container
.
constraints
)
if
let
v
=
toolbar
{
metrics
[
"toolbarTop"
]
=
toolbarEdgeInsets
.
top
metrics
[
"toolbarBottom"
]
=
toolbarEdgeInsets
.
bottom
format
+=
"-(toolbarTop)-[toolbar]-(toolbarBottom)"
views
[
"toolbar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
toolbarEdgeInsets
.
left
,
right
:
toolbarEdgeInsets
.
right
)
top
+=
toolbarEdgeInsets
.
top
container
.
layout
(
v
)
.
top
(
top
)
.
left
(
toolbarEdgeInsets
.
left
)
.
right
(
toolbarEdgeInsets
.
right
)
.
height
(
v
.
height
)
top
+=
v
.
height
+
toolbarEdgeInsets
.
bottom
}
if
let
v
=
presenterView
{
metrics
[
"presenterViewBottom"
]
=
presenterViewEdgeInsets
.
bottom
if
nil
!=
toolbar
{
metrics
[
"toolbarBottom"
]
=
(
metrics
[
"toolbarBottom"
]
as!
CGFloat
)
+
presenterViewEdgeInsets
.
top
format
+=
"-[presenterView]-(presenterViewBottom)"
}
else
{
metrics
[
"presenterViewTop"
]
=
presenterViewEdgeInsets
.
top
format
+=
"-(presenterViewTop)-[presenterView]-(presenterViewBottom)"
}
views
[
"presenterView"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
presenterViewEdgeInsets
.
left
,
right
:
presenterViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
}
if
let
v
=
contentView
{
metrics
[
"contentViewBottom"
]
=
contentViewEdgeInsets
.
bottom
if
nil
!=
presenterView
{
metrics
[
"presenterViewBottom"
]
=
(
metrics
[
"presenterViewBottom"
]
as!
CGFloat
)
+
contentViewEdgeInsets
.
top
format
+=
"-[contentView]-(contentViewBottom)"
}
else
if
nil
!=
toolbar
{
metrics
[
"toolbarBottom"
]
=
(
metrics
[
"toolbarBottom"
]
as!
CGFloat
)
+
contentViewEdgeInsets
.
top
format
+=
"-[contentView]-(contentViewBottom)"
}
else
{
metrics
[
"contentViewTop"
]
=
contentViewEdgeInsets
.
top
format
+=
"-(contentViewTop)-[contentView]-(contentViewBottom)"
}
views
[
"contentView"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
contentViewEdgeInsets
.
left
,
right
:
contentViewEdgeInsets
.
right
)
v
.
grid
.
reload
()
v
.
divider
.
reload
()
top
+=
presenterViewEdgeInsets
.
top
container
.
layout
(
v
)
.
top
(
top
)
.
left
(
presenterViewEdgeInsets
.
left
)
.
right
(
presenterViewEdgeInsets
.
right
)
top
+=
v
.
height
+
presenterViewEdgeInsets
.
bottom
}
if
let
v
=
bottomBar
{
metrics
[
"bottomBarBottom"
]
=
bottomBarEdgeInsets
.
bottom
if
nil
!=
contentView
{
metrics
[
"contentViewBottom"
]
=
(
metrics
[
"contentViewBottom"
]
as!
CGFloat
)
+
bottomBarEdgeInsets
.
top
format
+=
"-[bottomBar]-(bottomBarBottom)"
}
else
if
nil
!=
presenterView
{
metrics
[
"presenterViewBottom"
]
=
(
metrics
[
"presenterViewBottom"
]
as!
CGFloat
)
+
bottomBarEdgeInsets
.
top
format
+=
"-[bottomBar]-(bottomBarBottom)"
}
else
if
nil
!=
toolbar
{
metrics
[
"toolbarBottom"
]
=
(
metrics
[
"toolbarBottom"
]
as!
CGFloat
)
+
bottomBarEdgeInsets
.
top
format
+=
"-[bottomBar]-(bottomBarBottom)"
}
else
{
metrics
[
"bottomBarTop"
]
=
bottomBarEdgeInsets
.
top
format
+=
"-(bottomBarTop)-[bottomBar]-(bottomBarBottom)"
}
views
[
"bottomBar"
]
=
v
container
.
layout
(
v
)
.
horizontally
(
left
:
bottomBarEdgeInsets
.
left
,
right
:
bottomBarEdgeInsets
.
right
)
}
guard
0
<
views
.
count
else
{
return
}
container
.
addConstraints
(
Layout
.
constraint
(
format
:
"
\(
format
)
-|"
,
options
:
[],
metrics
:
metrics
,
views
:
views
))
//
// if let v = contentView {
// top += contentViewEdgeInsets.top
// container.layout(v).top(top).left(contentViewEdgeInsets.left).right(contentViewEdgeInsets.right)
// top += v.height + contentViewEdgeInsets.bottom
// }
//
// if let v = bottomBar {
// top += bottomBarEdgeInsets.top
// container.layout(v).top(top).left(bottomBarEdgeInsets.left).right(bottomBarEdgeInsets.right).bottom(bottomBarEdgeInsets.bottom)
// bottom += v.height + bottomBarEdgeInsets.top + bottomBarEdgeInsets.bottom
// }
//
// if let v = contentView {
// bottom += contentViewEdgeInsets.bottom
// container.layout(v).bottom(bottom)
// bottom += v.height + contentViewEdgeInsets.top
// }
//
// if let v = presenterView {
// bottom += presenterViewEdgeInsets.bottom
// container.layout(v).bottom(bottom)
// bottom += v.height + presenterViewEdgeInsets.top
// }
//
// if let v = toolbar {
// bottom += toolbarEdgeInsets.bottom
// container.layout(v).bottom(bottom)
// }
}
}
Sources/iOS/SearchBar.swift
View file @
34e53600
...
...
@@ -170,7 +170,6 @@ open class SearchBar: Bar {
*/
open
override
func
prepare
()
{
super
.
prepare
()
heightPreset
=
.
normal
prepareTextField
()
prepareClearButton
()
}
...
...
Sources/iOS/StatusBarController.swift
View file @
34e53600
...
...
@@ -32,10 +32,10 @@ import UIKit
extension
UIViewController
{
/**
A convenience property that provides access to the StatusBarController.
This is the recommended method of accessing the StatusBarController
through child UIViewControllers.
*/
A convenience property that provides access to the StatusBarController.
This is the recommended method of accessing the StatusBarController
through child UIViewControllers.
*/
public
var
statusBarController
:
StatusBarController
?
{
var
viewController
:
UIViewController
?
=
self
while
nil
!=
viewController
{
...
...
@@ -53,23 +53,23 @@ open class StatusBarController: RootController {
open
private(set)
lazy
var
statusBar
=
View
()
/**
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
To execute in the order of the layout chain, override this
method. LayoutSubviews should be called immediately, unless you
have a certain need.
*/
open
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
statusBar
.
isHidden
=
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
statusBar
.
zPosition
=
Device
.
isLandscape
&&
.
phone
==
Device
.
userInterfaceIdiom
?
0
:
3000
rootViewController
.
view
.
frame
=
view
.
bounds
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepare method
to initialize property values and other setup operations.
The super.prepare method should always be called immediately
when subclassing.
*/
open
override
func
prepare
()
{
super
.
prepare
()
prepareStatusBar
()
...
...
@@ -77,7 +77,6 @@ open class StatusBarController: RootController {
/// Prepares the statusBar.
private
func
prepareStatusBar
()
{
statusBar
.
zPosition
=
3000
statusBar
.
backgroundColor
=
.
white
view
.
layout
(
statusBar
)
.
top
()
.
horizontally
()
.
height
(
20
)
}
...
...
Sources/iOS/TabBar.swift
View file @
34e53600
...
...
@@ -202,7 +202,6 @@ open class TabBar: Bar {
*/
open
override
func
prepare
()
{
super
.
prepare
()
heightPreset
=
.
normal
contentEdgeInsetsPreset
=
.
none
interimSpacePreset
=
.
none
prepareLine
()
...
...
Sources/iOS/Toolbar.swift
View file @
34e53600
...
...
@@ -148,7 +148,6 @@ open class Toolbar: Bar {
*/
open
override
func
prepare
()
{
super
.
prepare
()
heightPreset
=
.
normal
contentViewAlignment
=
.
center
prepareTitleLabel
()
prepareDetailLabel
()
...
...
Sources/iOS/ToolbarController.swift
View file @
34e53600
...
...
@@ -173,7 +173,7 @@ open class ToolbarController: StatusBarController {
super
.
layoutSubviews
()
statusBar
.
layoutIfNeeded
()
let
y
=
statusBar
.
isHidde
n
?
0
:
statusBar
.
height
let
y
=
0
==
statusBar
.
zPositio
n
?
0
:
statusBar
.
height
let
p
=
y
+
toolbar
.
height
toolbar
.
y
=
y
...
...
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