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
e6e03bef
Commit
e6e03bef
authored
May 30, 2016
by
danieldahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updating MaterialCollectionViews, progressive commit
parent
27e11c4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
+1
-1
Sources/iOS/MaterialCollectionViewLayout.swift
+11
-12
No files found.
Examples/Programmatic/MaterialCollectionView/MaterialCollectionView/ViewController.swift
View file @
e6e03bef
...
@@ -107,7 +107,7 @@ extension ViewController: MaterialCollectionViewDataSource {
...
@@ -107,7 +107,7 @@ extension ViewController: MaterialCollectionViewDataSource {
return
1
return
1
}
}
/// Prepares the cells within the
table
View.
/// Prepares the cells within the
collection
View.
func
collectionView
(
collectionView
:
UICollectionView
,
cellForItemAtIndexPath
indexPath
:
NSIndexPath
)
->
UICollectionViewCell
{
func
collectionView
(
collectionView
:
UICollectionView
,
cellForItemAtIndexPath
indexPath
:
NSIndexPath
)
->
UICollectionViewCell
{
let
cell
:
MaterialCollectionViewCell
=
collectionView
.
dequeueReusableCellWithReuseIdentifier
(
"MaterialCollectionViewCell"
,
forIndexPath
:
indexPath
)
as!
MaterialCollectionViewCell
let
cell
:
MaterialCollectionViewCell
=
collectionView
.
dequeueReusableCellWithReuseIdentifier
(
"MaterialCollectionViewCell"
,
forIndexPath
:
indexPath
)
as!
MaterialCollectionViewCell
let
item
:
MaterialDataSourceItem
=
dataSourceItems
[
indexPath
.
item
]
let
item
:
MaterialDataSourceItem
=
dataSourceItems
[
indexPath
.
item
]
...
...
Sources/iOS/MaterialCollectionViewLayout.swift
View file @
e6e03bef
...
@@ -53,8 +53,8 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
...
@@ -53,8 +53,8 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
/// Layout attribute items.
/// Layout attribute items.
public
private(set)
var
layoutItems
:
Array
<
(
UICollectionViewLayoutAttributes
,
NSIndexPath
)
>
=
Array
<
(
UICollectionViewLayoutAttributes
,
NSIndexPath
)
>
()
public
private(set)
var
layoutItems
:
Array
<
(
UICollectionViewLayoutAttributes
,
NSIndexPath
)
>
=
Array
<
(
UICollectionViewLayoutAttributes
,
NSIndexPath
)
>
()
/// Cell items.
/// Cell
data source
items.
public
private(set)
var
i
tems
:
Array
<
MaterialDataSourceItem
>
?
public
private(set)
var
dataSourceI
tems
:
Array
<
MaterialDataSourceItem
>
?
/// Scroll direction.
/// Scroll direction.
public
var
scrollDirection
:
UICollectionViewScrollDirection
=
.
Vertical
public
var
scrollDirection
:
UICollectionViewScrollDirection
=
.
Vertical
...
@@ -86,7 +86,7 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
...
@@ -86,7 +86,7 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
public
override
func
layoutAttributesForItemAtIndexPath
(
indexPath
:
NSIndexPath
)
->
UICollectionViewLayoutAttributes
?
{
public
override
func
layoutAttributesForItemAtIndexPath
(
indexPath
:
NSIndexPath
)
->
UICollectionViewLayoutAttributes
?
{
let
attributes
:
UICollectionViewLayoutAttributes
=
UICollectionViewLayoutAttributes
(
forCellWithIndexPath
:
indexPath
)
let
attributes
:
UICollectionViewLayoutAttributes
=
UICollectionViewLayoutAttributes
(
forCellWithIndexPath
:
indexPath
)
let
item
:
MaterialDataSourceItem
=
i
tems
!
[
indexPath
.
item
]
let
item
:
MaterialDataSourceItem
=
dataSourceI
tems
!
[
indexPath
.
item
]
if
0
<
itemSize
.
width
&&
0
<
itemSize
.
height
{
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
)
attributes
.
frame
=
CGRectMake
(
offset
.
x
,
offset
.
y
,
itemSize
.
width
-
contentInset
.
left
-
contentInset
.
right
,
itemSize
.
height
-
contentInset
.
top
-
contentInset
.
bottom
)
...
@@ -123,8 +123,12 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
...
@@ -123,8 +123,12 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
}
}
}
}
public
func
prepareLayoutForItems
(
items
:
Array
<
MaterialDataSourceItem
>
)
{
public
override
func
targetContentOffsetForProposedContentOffset
(
proposedContentOffset
:
CGPoint
)
->
CGPoint
{
self
.
items
=
items
return
proposedContentOffset
}
private
func
prepareLayoutForItems
(
dataSourceItems
:
Array
<
MaterialDataSourceItem
>
)
{
self
.
dataSourceItems
=
dataSourceItems
layoutItems
.
removeAll
()
layoutItems
.
removeAll
()
offset
.
x
=
contentInset
.
left
offset
.
x
=
contentInset
.
left
...
@@ -132,8 +136,8 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
...
@@ -132,8 +136,8 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
var
indexPath
:
NSIndexPath
?
var
indexPath
:
NSIndexPath
?
for
i
in
0
..<
i
tems
.
count
{
for
i
in
0
..<
dataSourceI
tems
.
count
{
let
item
:
MaterialDataSourceItem
=
i
tems
[
i
]
let
item
:
MaterialDataSourceItem
=
dataSourceI
tems
[
i
]
indexPath
=
NSIndexPath
(
forItem
:
i
,
inSection
:
0
)
indexPath
=
NSIndexPath
(
forItem
:
i
,
inSection
:
0
)
layoutItems
.
append
((
layoutAttributesForItemAtIndexPath
(
indexPath
!
)
!
,
indexPath
!
))
layoutItems
.
append
((
layoutAttributesForItemAtIndexPath
(
indexPath
!
)
!
,
indexPath
!
))
...
@@ -155,8 +159,4 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
...
@@ -155,8 +159,4 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
contentSize
=
CGSizeMake
(
offset
.
x
,
collectionView
!.
bounds
.
height
)
contentSize
=
CGSizeMake
(
offset
.
x
,
collectionView
!.
bounds
.
height
)
}
}
}
}
public
override
func
targetContentOffsetForProposedContentOffset
(
proposedContentOffset
:
CGPoint
)
->
CGPoint
{
return
proposedContentOffset
}
}
}
\ 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