motion-assets-library 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/project/assets_library/data_sources/assets_data_source.rb +47 -0
- data/lib/project/assets_library/loader.rb +1 -1
- data/lib/project/assets_library/views/asset_cell.rb +27 -0
- data/lib/project/assets_library/views/assets_collection_view.rb +17 -0
- data/lib/project/assets_library.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6011f54a1d4faf41397d337b39a3f2197609a154
|
4
|
+
data.tar.gz: d3ebbcaf62ef6ffbcffcdf606966814a0dcb101f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 125b585a339e3f0b747661af8ad21259b6759105cc466ffc215a3ed2142d1a46a81689b15e8974df2849cd0e98ebfee0a25f1202d5cc65470bf61b2f83ae402c
|
7
|
+
data.tar.gz: 60d4152b1742b92f95eb1cda0bcacc0a6c718d30f254c807f1820cc72df49d0de7802e3d58e86962c4456fbba9a10cf6b297e3a46e689167a16f582a162a5073
|
data/README.md
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
class Motion
|
2
|
+
class AssetsLibrary
|
3
|
+
class AssetsDataSource
|
4
|
+
attr_accessor :collection_view
|
5
|
+
|
6
|
+
def initialize(collection_view)
|
7
|
+
self.collection_view = collection_view
|
8
|
+
|
9
|
+
register_cells
|
10
|
+
|
11
|
+
asset_loader.load_assets
|
12
|
+
end
|
13
|
+
|
14
|
+
def register_cells
|
15
|
+
collection_view.registerClass(
|
16
|
+
cell_class,
|
17
|
+
forCellWithReuseIdentifier: cell_class::IDENTIFIER)
|
18
|
+
end
|
19
|
+
|
20
|
+
def cell_class
|
21
|
+
AssetsLibrary::AssetCell
|
22
|
+
end
|
23
|
+
|
24
|
+
def collectionView(collection_view, numberOfItemsInSection: section)
|
25
|
+
asset_loader.assets.count
|
26
|
+
end
|
27
|
+
|
28
|
+
def collectionView(collection_view, cellForItemAtIndexPath: index_path)
|
29
|
+
collection_view.dequeueReusableCellWithReuseIdentifier(cell_class::IDENTIFIER, forIndexPath: index_path).tap do |cell|
|
30
|
+
asset = asset_loader.assets[index_path.row]
|
31
|
+
|
32
|
+
cell.reset_with_asset(asset)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def asset_loader
|
37
|
+
@_asset_loader ||= AssetsLibrary::Loader.new.tap do |loader|
|
38
|
+
loader.delegate = WeakRef.new(self)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def did_load_assets(asset)
|
43
|
+
collection_view.reloadData
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Motion
|
2
|
+
class AssetsLibrary
|
3
|
+
class AssetCell < UICollectionViewCell
|
4
|
+
IDENTIFIER = 'AssetCellIdentifier'
|
5
|
+
|
6
|
+
attr_accessor :image_view
|
7
|
+
|
8
|
+
def initWithFrame(frame)
|
9
|
+
super.tap do |cell|
|
10
|
+
cell.add_image_view
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset_with_asset(asset)
|
15
|
+
image_view.image = UIImage.imageWithCGImage(asset.thumbnail)
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def add_image_view
|
21
|
+
self.image_view = UIImageView.alloc.initWithFrame([[0, 0], [105, 105]]).tap do |image_view|
|
22
|
+
contentView.addSubview(image_view)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Motion
|
2
|
+
class AssetsLibrary
|
3
|
+
class AssetsCollectionView < UICollectionView
|
4
|
+
def initWithFrame(frame, collectionViewLayout: layout)
|
5
|
+
super.tap do |collection_view|
|
6
|
+
collection_view.dataSource = _data_source
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def _data_source
|
13
|
+
@_data_source ||= AssetsLibrary::AssetsDataSource.new(WeakRef.new(self))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-assets-library
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devon Blandin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -34,7 +34,10 @@ files:
|
|
34
34
|
- README.md
|
35
35
|
- lib/motion-assets-library.rb
|
36
36
|
- lib/project/assets_library/asset_wrapper.rb
|
37
|
+
- lib/project/assets_library/data_sources/assets_data_source.rb
|
37
38
|
- lib/project/assets_library/loader.rb
|
39
|
+
- lib/project/assets_library/views/asset_cell.rb
|
40
|
+
- lib/project/assets_library/views/assets_collection_view.rb
|
38
41
|
- lib/project/assets_library.rb
|
39
42
|
homepage: https://github.com/dblandin/motion-assets-library
|
40
43
|
licenses:
|