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
59af6439
Unverified
Commit
59af6439
authored
Dec 14, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
development: initial rework of CollectionView
parent
f45e8ec6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
78 deletions
+118
-78
Material.xcodeproj/project.pbxproj
+0
-0
Sources/iOS/CollectionViewController.swift
+112
-0
Sources/iOS/CollectionViewDataSource.swift
+0
-39
Sources/iOS/CollectionViewDataSourceItem.swift
+1
-1
Sources/iOS/CollectionViewDelegate.swift
+0
-33
Sources/iOS/CollectionViewLayout.swift
+5
-5
No files found.
Material.xcodeproj/project.pbxproj
View file @
59af6439
This diff is collapsed.
Click to expand it.
Sources/iOS/CollectionViewController.swift
0 → 100644
View file @
59af6439
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
public
protocol
CollectionViewDelegate
:
UICollectionViewDelegate
{}
public
protocol
CollectionViewDataSource
:
UICollectionViewDataSource
{
/**
Retrieves the data source items for the collectionView.
- Returns: An Array of CollectionViewDataSourceItem objects.
*/
var
dataSourceItems
:
[
CollectionViewDataSourceItem
]
{
get
}
}
extension
UIViewController
{
/**
A convenience property that provides access to the CollectionViewController.
This is the recommended method of accessing the CollectionViewController
through child UIViewControllers.
*/
public
var
collectionViewController
:
CollectionViewController
?
{
var
viewController
:
UIViewController
?
=
self
while
nil
!=
viewController
{
if
viewController
is
CollectionViewController
{
return
viewController
as?
CollectionViewController
}
viewController
=
viewController
?
.
parent
}
return
nil
}
}
open
class
CollectionViewController
:
UIViewController
{
/// A reference to a Reminder.
open
let
collectionView
=
CollectionView
()
open
var
dataSourceItems
=
[
CollectionViewDataSourceItem
]()
open
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepare
()
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
open
func
prepare
()
{
view
.
clipsToBounds
=
true
view
.
backgroundColor
=
Color
.
white
view
.
contentScaleFactor
=
Screen
.
scale
prepareCollectionView
()
}
}
extension
CollectionViewController
{
/// Prepares the collectionView.
fileprivate
func
prepareCollectionView
()
{
collectionView
.
delegate
=
self
collectionView
.
dataSource
=
self
view
.
layout
(
collectionView
)
.
edges
()
}
}
extension
CollectionViewController
:
CollectionViewDelegate
{}
extension
CollectionViewController
:
CollectionViewDataSource
{
@objc
open
func
numberOfSections
(
in
collectionView
:
UICollectionView
)
->
Int
{
return
1
}
@objc
open
func
collectionView
(
_
collectionView
:
UICollectionView
,
numberOfItemsInSection
section
:
Int
)
->
Int
{
return
dataSourceItems
.
count
}
@objc
open
func
collectionView
(
_
collectionView
:
UICollectionView
,
cellForItemAt
indexPath
:
IndexPath
)
->
UICollectionViewCell
{
return
UICollectionViewCell
()
}
}
Sources/iOS/CollectionViewDataSource.swift
deleted
100644 → 0
View file @
f45e8ec6
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
public
protocol
CollectionViewDataSource
:
UICollectionViewDataSource
{
/**
Retrieves the data source items for the collectionView.
- Returns: An Array of CollectionDataSourceItem objects.
*/
var
dataSourceItems
:
[
CollectionDataSourceItem
]
{
get
}
}
Sources/iOS/CollectionDataSourceItem.swift
→
Sources/iOS/Collection
View
DataSourceItem.swift
View file @
59af6439
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
import
UIKit
import
UIKit
public
struct
CollectionDataSourceItem
{
public
struct
Collection
View
DataSourceItem
{
/// Stores an the data for the item.
/// Stores an the data for the item.
public
var
data
:
Any
?
public
var
data
:
Any
?
...
...
Sources/iOS/CollectionViewDelegate.swift
deleted
100644 → 0
View file @
f45e8ec6
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of CosmicMind nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
public
protocol
CollectionViewDelegate
:
UICollectionViewDelegate
{}
Sources/iOS/CollectionViewLayout.swift
View file @
59af6439
...
@@ -32,7 +32,7 @@ import UIKit
...
@@ -32,7 +32,7 @@ import UIKit
open
class
CollectionViewLayout
:
UICollectionViewLayout
{
open
class
CollectionViewLayout
:
UICollectionViewLayout
{
/// Used to calculate the dimensions of the cells.
/// Used to calculate the dimensions of the cells.
internal
var
offset
=
CGPoint
.
zero
open
var
offset
=
CGPoint
.
zero
/// The size of items.
/// The size of items.
open
var
itemSize
=
CGSize
.
zero
open
var
itemSize
=
CGSize
.
zero
...
@@ -48,13 +48,13 @@ open class CollectionViewLayout: UICollectionViewLayout {
...
@@ -48,13 +48,13 @@ open class CollectionViewLayout: UICollectionViewLayout {
open
var
contentEdgeInsets
=
EdgeInsets
.
zero
open
var
contentEdgeInsets
=
EdgeInsets
.
zero
/// Size of the content.
/// Size of the content.
open
internal
(set)
var
contentSize
=
CGSize
.
zero
open
fileprivate
(
set
)
var
contentSize
=
CGSize
.
zero
/// Layout attribute items.
/// Layout attribute items.
open
internal
(set)
lazy
var
layoutItems
=
[(
UICollectionViewLayoutAttributes
,
NSIndexPath
)]()
open
fileprivate
(
set
)
lazy
var
layoutItems
=
[(
UICollectionViewLayoutAttributes
,
NSIndexPath
)]()
/// Cell data source items.
/// Cell data source items.
open
internal(set)
var
dataSourceItems
:
[
Collection
DataSourceItem
]?
open
fileprivate
(
set
)
var
dataSourceItems
:
[
CollectionView
DataSourceItem
]?
/// Scroll direction.
/// Scroll direction.
open
var
scrollDirection
=
UICollectionViewScrollDirection
.
vertical
open
var
scrollDirection
=
UICollectionViewScrollDirection
.
vertical
...
@@ -129,7 +129,7 @@ open class CollectionViewLayout: UICollectionViewLayout {
...
@@ -129,7 +129,7 @@ open class CollectionViewLayout: UICollectionViewLayout {
return
proposedContentOffset
return
proposedContentOffset
}
}
private
func
prepareLayoutForItems
(
dataSourceItems
:
[
Collection
DataSourceItem
])
{
fileprivate
func
prepareLayoutForItems
(
dataSourceItems
:
[
CollectionView
DataSourceItem
])
{
self
.
dataSourceItems
=
dataSourceItems
self
.
dataSourceItems
=
dataSourceItems
layoutItems
.
removeAll
()
layoutItems
.
removeAll
()
...
...
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