gallery_motion 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a53f939fc278c8c6964efd8c8b5c67eab4bfdc35
4
+ data.tar.gz: 8478d713ea284bf25d6e24b205d5c7e732a66ecf
5
+ SHA512:
6
+ metadata.gz: f7975e58c367423e95dc94b70bf5e2e2f6cfca4a914289cbe7f4534f7d91bdf6a5f4cb3c7461990de647da6a83c47417f32b45e5a05e1e9d7c371a96165614d7
7
+ data.tar.gz: 936a9c14774d48e2239bd5a1af94e656b6e848f95cc2a8c0b8404ddf38ec21fe642206c7649fc3cdc63fe21f922946ddd5013a80a1fd4caa3e7a6350c6a23485
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # gallery
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'gallery'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install gallery
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ class GalleryViewController < UIViewController
23
+ include ControlGallery
24
+ def viewDidLoad
25
+ @scroll_gallery = UIScrollGallery.alloc.initWithNumImages(images.size,frame: frame_scroll)
26
+ @scroll_gallery.delegate = self
27
+ @scroll_gallery.add_images(images)
28
+ view.addSubview(@scroll_gallery)
29
+
30
+ #This you can edit as you wish
31
+ center = CGPointMake(UIScreen.mainScreen.bounds.size.width / 2, 305)
32
+ frame = [[0, 290], [UIScreen.mainScreen.bounds.size.width, 50]]
33
+ numberOfPages = images.size
34
+
35
+ @page_control = UIPageControlGallery.alloc.initWithCenter(center,frame: frame,numberOfPages: numberOfPages)
36
+ @page_control.addTarget(self, action:'pageTurn:', forControlEvents:UIControlEventValueChanged)
37
+ view.addSubview(@page_control)
38
+ end
39
+
40
+ #this methods are important
41
+ def scroll_gallery
42
+ @scroll_gallery
43
+ end
44
+
45
+ def page_control
46
+ @page_control
47
+ end
48
+
49
+
50
+ # options by users....
51
+ def images
52
+ ['image1.png','image2.png']
53
+ end
54
+
55
+
56
+ def frame_scroll
57
+ [[0,46],[UIScreen.mainScreen.bounds.size.width,380]]
58
+ end
59
+ end
60
+ ```
61
+ ## Contributing
62
+
63
+ 1. Fork it
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
6
+ Motion::Project::App.setup do |app|
7
+ app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
8
+ end
@@ -0,0 +1,4 @@
1
+ class Gallery
2
+
3
+ end
4
+
@@ -0,0 +1,12 @@
1
+ module ControlGallery
2
+ def scrollViewDidScroll(sender)
3
+ pageWidth = scroll_gallery.frame.size.width;
4
+ scroll_gallery.setContentOffset( CGPointMake(scroll_gallery.contentOffset.x, 0) )
5
+ page = ((scroll_gallery.contentOffset.x - pageWidth / 2) /pageWidth) + 1
6
+ page_control.currentPage = page;
7
+ end
8
+
9
+ def pageTurn(pageControl)
10
+ scroll_gallery.setContentOffset( CGPointMake(UIScreen.mainScreen.bounds.size.width * pageControl.currentPage, 0) )
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class UIPageControlGallery < UIPageControl
2
+ def initWithCenter(center,frame: frame,numberOfPages: numberofPages)
3
+ page_control = UIPageControlGallery.alloc.init
4
+ page_control.center = center
5
+ page_control.frame = frame
6
+ page_control.numberOfPages = numberofPages
7
+ page_control.currentPage = 0
8
+ page_control
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ class UIScrollGallery < UIScrollView
2
+ def initWithNumImages(num_images,frame: frame)
3
+ scrollView = UIScrollGallery.alloc.init
4
+ scrollView.frame = frame
5
+ scrollView.pagingEnabled = true;
6
+ scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * num_images, scrollView.frame.size.height);
7
+ scrollView.showsHorizontalScrollIndicator = true
8
+ scrollView.showsVerticalScrollIndicator = false
9
+ scrollView.maximumZoomScale = 1.0
10
+ scrollView.minimumZoomScale = 1.0
11
+ scrollView.clipsToBounds = true
12
+ scrollView.scrollsToTop = false
13
+ scrollView
14
+ end
15
+
16
+ def add_images(images)
17
+ images.each_with_index do |i, x|
18
+ image = UIImageView.alloc.initWithFrame([[UIScreen.mainScreen.bounds.size.width * x, 0], [UIScreen.mainScreen.bounds.size.width, 290]])
19
+ image.image = UIImage.imageNamed(i)
20
+ self.addSubview(image)
21
+ end
22
+ end
23
+
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gallery_motion
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - daniel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: easy implementation for a scrollable gallery in rubymotion
28
+ email:
29
+ - xzdasx@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - lib/gallery_motion.rb
36
+ - lib/project/gallery.rb
37
+ - lib/project/libs/control_gallery.rb
38
+ - lib/project/views/ui_page_control_gallery.rb
39
+ - lib/project/views/ui_scroll_gallery.rb
40
+ homepage: ''
41
+ licenses:
42
+ - ''
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.2.1
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: ''
64
+ test_files: []