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
6a42c8f2
Commit
6a42c8f2
authored
May 26, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverted changes to MaterialCollection*
parent
ef45d307
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
77 deletions
+40
-77
Examples/Storyboards/Toolbar/Toolbar/Base.lproj/Main.storyboard
+1
-1
Sources/iOS/BarView.swift
+3
-3
Sources/iOS/MaterialCollectionView.swift
+8
-23
Sources/iOS/MaterialCollectionViewLayout.swift
+22
-44
Sources/iOS/SearchBar.swift
+3
-3
Sources/iOS/Toolbar.swift
+3
-3
No files found.
Examples/Storyboards/Toolbar/Toolbar/Base.lproj/Main.storyboard
View file @
6a42c8f2
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"1011
6"
systemVersion=
"15E65
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
initialViewController=
"BYZ-38-t0r"
>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"1011
7"
systemVersion=
"15F34
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
initialViewController=
"BYZ-38-t0r"
>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"10085"
/>
...
...
Sources/iOS/BarView.swift
View file @
6a42c8f2
...
...
@@ -59,9 +59,9 @@ public class BarView : ControlView {
super
.
init
(
frame
:
frame
)
}
///
Basic
initializer.
public
overrid
e
init
()
{
s
uper
.
init
(
leftControls
:
nil
,
rightControls
:
nil
)
///
Convenience
initializer.
public
convenienc
e
init
()
{
s
elf
.
init
(
frame
:
CGRectZero
)
}
/**
...
...
Sources/iOS/MaterialCollectionView.swift
View file @
6a42c8f2
...
...
@@ -75,7 +75,7 @@ public class MaterialCollectionView : UICollectionView {
/// A preset wrapper around contentInset.
public
var
contentInsetPreset
:
MaterialEdgeInset
{
get
{
return
(
collectionViewLayout
as
!
MaterialCollectionViewLayout
)
.
contentInsetPreset
return
(
collectionViewLayout
as
?
MaterialCollectionViewLayout
)
!
.
contentInsetPreset
}
set
(
value
)
{
(
collectionViewLayout
as?
MaterialCollectionViewLayout
)
!.
contentInsetPreset
=
value
...
...
@@ -84,20 +84,20 @@ public class MaterialCollectionView : UICollectionView {
public
override
var
contentInset
:
UIEdgeInsets
{
get
{
return
(
collectionViewLayout
as
!
MaterialCollectionViewLayout
)
.
contentInset
return
(
collectionViewLayout
as
?
MaterialCollectionViewLayout
)
!
.
contentInset
}
set
(
value
)
{
(
collectionViewLayout
as
!
MaterialCollectionViewLayout
)
.
contentInset
=
value
(
collectionViewLayout
as
?
MaterialCollectionViewLayout
)
!
.
contentInset
=
value
}
}
/// Scroll direction.
public
var
scrollDirection
:
UICollectionViewScrollDirection
{
get
{
return
(
collectionViewLayout
as
!
MaterialCollectionViewLayout
)
.
scrollDirection
return
(
collectionViewLayout
as
?
MaterialCollectionViewLayout
)
!
.
scrollDirection
}
set
(
value
)
{
(
collectionViewLayout
as
!
MaterialCollectionViewLayout
)
.
scrollDirection
=
value
(
collectionViewLayout
as
?
MaterialCollectionViewLayout
)
!
.
scrollDirection
=
value
}
}
...
...
@@ -111,20 +111,10 @@ public class MaterialCollectionView : UICollectionView {
/// Spacing between items.
@IBInspectable
public
var
spacing
:
CGFloat
{
get
{
return
(
collectionViewLayout
as
!
MaterialCollectionViewLayout
)
.
spacing
return
(
collectionViewLayout
as
?
MaterialCollectionViewLayout
)
!
.
spacing
}
set
(
value
)
{
(
collectionViewLayout
as!
MaterialCollectionViewLayout
)
.
spacing
=
value
}
}
/// The layout alignment direction.
public
var
alignmentDirection
:
MaterialAlignmentDirection
{
get
{
return
(
collectionViewLayout
as!
MaterialCollectionViewLayout
)
.
alignmentDirection
}
set
(
value
)
{
(
collectionViewLayout
as!
MaterialCollectionViewLayout
)
.
alignmentDirection
=
value
(
collectionViewLayout
as?
MaterialCollectionViewLayout
)
!.
spacing
=
value
}
}
...
...
@@ -142,10 +132,7 @@ public class MaterialCollectionView : UICollectionView {
- Parameter collectionViewLayout: A UICollectionViewLayout reference.
*/
public
override
init
(
frame
:
CGRect
,
collectionViewLayout
layout
:
UICollectionViewLayout
)
{
guard
let
l
=
layout
as?
MaterialCollectionViewLayout
else
{
assert
(
false
,
"[MaterialCollectionView Error: Must use a class that subclasses MaterialCollectionViewLayout]"
)
}
super
.
init
(
frame
:
frame
,
collectionViewLayout
:
l
)
super
.
init
(
frame
:
frame
,
collectionViewLayout
:
layout
)
prepareView
()
}
...
...
@@ -174,6 +161,5 @@ public class MaterialCollectionView : UICollectionView {
contentScaleFactor
=
MaterialDevice
.
scale
backgroundColor
=
MaterialColor
.
clear
contentInset
=
UIEdgeInsetsZero
alignmentDirection
=
.
None
}
}
\ No newline at end of file
Sources/iOS/MaterialCollectionViewLayout.swift
View file @
6a42c8f2
...
...
@@ -30,16 +30,13 @@
import
UIKit
public
enum
MaterialAlignmentDirection
{
case
None
case
Vertical
case
Horizontal
}
public
class
MaterialCollectionViewLayout
:
UICollectionViewFlowLayout
{
public
class
MaterialCollectionViewLayout
:
UICollectionViewLayout
{
/// Used to calculate the dimensions of the cells.
internal
var
offset
:
CGPoint
=
CGPointZero
/// The size of items.
public
var
itemSize
:
CGSize
=
CGSizeZero
/// A preset wrapper around contentInset.
public
var
contentInsetPreset
:
MaterialEdgeInset
=
.
None
{
didSet
{
...
...
@@ -59,8 +56,8 @@ public class MaterialCollectionViewLayout : UICollectionViewFlowLayout {
/// Cell items.
public
private(set)
var
items
:
Array
<
MaterialDataSourceItem
>
?
///
Alignment
direction.
public
var
alignmentDirection
:
MaterialAlignmentDirection
=
.
None
///
Scroll
direction.
public
var
scrollDirection
:
UICollectionViewScrollDirection
=
.
Vertical
/// A preset wrapper around spacing.
public
var
spacingPreset
:
MaterialSpacing
=
.
None
{
...
...
@@ -88,50 +85,32 @@ public class MaterialCollectionViewLayout : UICollectionViewFlowLayout {
}
public
override
func
layoutAttributesForItemAtIndexPath
(
indexPath
:
NSIndexPath
)
->
UICollectionViewLayoutAttributes
?
{
let
attributes
:
UICollectionViewLayoutAttributes
=
super
.
layoutAttributesForItemAtIndexPath
(
indexPath
)
!
let
attributes
:
UICollectionViewLayoutAttributes
=
UICollectionViewLayoutAttributes
(
forCellWithIndexPath
:
indexPath
)
let
item
:
MaterialDataSourceItem
=
items
!
[
indexPath
.
item
]
switch
alignmentDirection
{
case
.
Vertical
:
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
offset
.
y
,
itemSize
.
width
-
contentInset
.
left
-
contentInset
.
right
,
itemSize
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
}
else
if
.
Vertical
==
scrollDirection
{
attributes
.
frame
=
CGRectMake
(
contentInset
.
left
,
offset
.
y
,
collectionView
!.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
,
nil
==
item
.
height
?
collectionView
!.
bounds
.
height
:
item
.
height
!
)
case
.
Horizontal
:
}
else
{
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
contentInset
.
top
,
nil
==
item
.
width
?
collectionView
!.
bounds
.
width
:
item
.
width
!
,
collectionView
!.
bounds
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
case
.
None
:
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
offset
.
y
,
itemSize
.
width
-
contentInset
.
left
-
contentInset
.
right
,
itemSize
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
}
return
attributes
}
public
override
func
layoutAttributesForSupplementaryViewOfKind
(
elementKind
:
String
,
atIndexPath
indexPath
:
NSIndexPath
)
->
UICollectionViewLayoutAttributes
?
{
let
attributes
:
UICollectionViewLayoutAttributes
=
super
.
layoutAttributesForSupplementaryViewOfKind
(
elementKind
,
atIndexPath
:
indexPath
)
!
let
item
:
MaterialDataSourceItem
=
items
!
[
indexPath
.
item
]
switch
alignmentDirection
{
case
.
Vertical
:
attributes
.
frame
=
CGRectMake
(
contentInset
.
left
,
offset
.
y
,
collectionView
!.
bounds
.
width
-
contentInset
.
left
-
contentInset
.
right
,
44
)
case
.
Horizontal
:
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
contentInset
.
top
,
nil
==
item
.
width
?
collectionView
!.
bounds
.
width
:
item
.
width
!
,
44
)
case
.
None
:
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
offset
.
y
,
itemSize
.
width
-
contentInset
.
left
-
contentInset
.
right
,
headerReferenceSize
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
}
return
attributes
}
public
override
func
layoutAttributesForElementsInRect
(
rect
:
CGRect
)
->
[
UICollectionViewLayoutAttributes
]?
{
let
attributes
:
Array
<
UICollectionViewLayoutAttributes
>
=
super
.
layoutAttributesForElementsInRect
(
rect
)
!
return
attributes
var
layoutAttributes
:
Array
<
UICollectionViewLayoutAttributes
>
=
Array
<
UICollectionViewLayoutAttributes
>
()
for
(
attribute
,
_
)
in
layoutItems
{
if
CGRectIntersectsRect
(
rect
,
attribute
.
frame
)
{
layoutAttributes
.
append
(
attribute
)
}
public
override
func
layoutAttributesForDecorationViewOfKind
(
elementKind
:
String
,
atIndexPath
indexPath
:
NSIndexPath
)
->
UICollectionViewLayoutAttributes
?
{
let
attributes
:
UICollectionViewLayoutAttributes
=
super
.
layoutAttributesForDecorationViewOfKind
(
elementKind
,
atIndexPath
:
indexPath
)
!
return
attributes
}
return
layoutAttributes
}
public
override
func
shouldInvalidateLayoutForBoundsChange
(
newBounds
:
CGRect
)
->
Bool
{
return
.
Vertical
==
scrollDirection
?
newBounds
.
width
!=
collectionView
?
.
bounds
.
width
:
newBounds
.
height
!=
collectionView
?
.
bounds
.
height
return
.
Vertical
==
scrollDirection
?
newBounds
.
width
!=
collectionView
!.
bounds
.
width
:
newBounds
.
height
!=
collectionView
!
.
bounds
.
height
}
public
override
func
collectionViewContentSize
()
->
CGSize
{
...
...
@@ -168,13 +147,12 @@ public class MaterialCollectionViewLayout : UICollectionViewFlowLayout {
offset
.
x
+=
contentInset
.
right
-
spacing
offset
.
y
+=
contentInset
.
bottom
-
spacing
switch
alignmentDirection
{
case
.
Vertical
:
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
contentSize
=
CGSizeMake
(
offset
.
x
,
offset
.
y
)
}
else
if
.
Vertical
==
scrollDirection
{
contentSize
=
CGSizeMake
(
collectionView
!.
bounds
.
width
,
offset
.
y
)
case
.
Horizontal
:
}
else
{
contentSize
=
CGSizeMake
(
offset
.
x
,
collectionView
!.
bounds
.
height
)
case
.
None
:
contentSize
=
CGSizeMake
(
offset
.
x
,
offset
.
y
)
}
}
...
...
Sources/iOS/SearchBar.swift
View file @
6a42c8f2
...
...
@@ -111,9 +111,9 @@ public class SearchBar : BarView {
super
.
init
(
frame
:
frame
)
}
///
Basic
initializer.
public
overrid
e
init
()
{
s
uper
.
init
(
)
///
Convenience
initializer.
public
convenienc
e
init
()
{
s
elf
.
init
(
frame
:
CGRectZero
)
}
/**
...
...
Sources/iOS/Toolbar.swift
View file @
6a42c8f2
...
...
@@ -74,9 +74,9 @@ public class Toolbar : BarView {
super
.
init
(
frame
:
frame
)
}
///
Basic
initializer.
public
overrid
e
init
()
{
s
uper
.
init
(
)
///
Convenience
initializer.
public
convenienc
e
init
()
{
s
elf
.
init
(
frame
:
CGRectZero
)
}
/**
...
...
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