motion-imager 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f6d2878f59fe01cecde3fbf9ad89433797a22d6
4
+ data.tar.gz: 4d2ab3633368bebf2ae9412a388fa0b229618bb5
5
+ SHA512:
6
+ metadata.gz: 7e6387e8a8d39a8fa5c2efbed5c03d477ab9d4e3a00ca91fbce00cc54e6bc66ea2d2df7d4432c7ee4847970862497f769edaedf50b470d0bd1ddee1dd3bb623e
7
+ data.tar.gz: 2dbcc3f1d147930cdcef0013f4fb7d60ee3efcf3d26a82d607400fdcba331b2c1ff400143b28a9870671b92765e49955b2f444c89e92815fc67ec98ad344649b
@@ -0,0 +1,122 @@
1
+ # motion-imager
2
+
3
+ motion-imager is a RubyMotion DSL in top of [JTSImageViewController](https://github.com/jaredsinclair/JTSImageViewController) allowing you to easily create a "light-box" type view for users to view an image and interact with it.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'motion-imager'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install motion-imager
18
+
19
+ ## Usage
20
+
21
+ Using a UIImage:
22
+
23
+ ```ruby
24
+ MotionImager.new({
25
+ image: UIImage.imageNamed('something'),
26
+ presenting_from: WeakRef.new(self),
27
+ })
28
+ ```
29
+
30
+ Using a URL:
31
+
32
+ ```ruby
33
+ MotionImager.new({
34
+ # OR an instance of NSURL
35
+ url: 'https://www.google.com/images/srpr/logo11w.png',
36
+ placeholder: 'my_placeholder_image',
37
+ presenting_from: WeakRef.new(self),
38
+ })
39
+
40
+ ```
41
+
42
+ Showing a lightbox with text. This view is only text, no image.
43
+
44
+ ```ruby
45
+ MotionImager.new({
46
+ presenting_from: WeakRef.new(self),
47
+ transition: :original,
48
+ mode: :alt_text,
49
+ text: "This is a cool image",
50
+ })
51
+
52
+ ```
53
+
54
+ Documentation for all available options:
55
+
56
+ ```ruby
57
+ {
58
+ # A local image reference.
59
+ # Can also be a String that will be turned into a UIImage
60
+ # REQUIRED id not specifying `url`
61
+ image: UIImage.imageNamed('something'),
62
+
63
+ # A url can be any displayable image on iOS.
64
+ # Can also be an instance of NSURL
65
+ # REQUIRED if not specifying `image`
66
+ url: 'https://www.google.com/images/srpr/logo11w.png',
67
+
68
+ # Placeholder image that will be displayed during the image download time.
69
+ # Can also be an instance of UIImage
70
+ # OPTIONAL
71
+ placeholder: 'my_placeholder.png',
72
+
73
+ # What view controller to show the lightbox from.
74
+ # REQUIRED. Should almost ALWAYS be `WeakRef.new(self)`
75
+ presenting_from: WeakRef.new(self),
76
+
77
+ # Two image transitions are supported:
78
+ # :original - displays the image zooming from it's original position on the screen
79
+ # :off_screen - slides the image in from off screen.
80
+ # OPTIONAL. Defaults to `:original`
81
+ transition: :original,
82
+
83
+ # Two modes are supported:
84
+ # :image - only dislays the image
85
+ # :alt_text - displays text instead of an image. Requires `text` to be set
86
+ # OPTIONAL. Defaults to `:image`
87
+ mode: :image,
88
+
89
+ # Sets the text for the image when using mode: :alt_text.
90
+ # OPTIONAL
91
+ text: "Some Text",
92
+
93
+ # Sets the animation and style of the background while in lightbox mode
94
+ # Options supported are:
95
+ # none:, scaled:, blurred:, scaled_blurred:
96
+ # OPTIONAL. Defaults to :scaled
97
+ background: :scaled_blurred,
98
+
99
+ # The frame of the originating view on the screen.
100
+ # If set and in :original transition, the full-screen image
101
+ # will zoom from this location on the screen.
102
+ # OPTIONAL
103
+ rect: my_thumbnail.frame,
104
+
105
+ # The the superview of the rect you set above.
106
+ # OPTIONAL
107
+ view: view
108
+ }
109
+ ```
110
+
111
+ ## Roadmap
112
+
113
+ 1. Add convenience constructors like: `MotionImager.url({})`, `MotionImager.image({})`, and `MotionImager.text({})`
114
+ 2. Tests. :)
115
+
116
+ ## Contributing
117
+
118
+ 1. Fork it
119
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
120
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
121
+ 4. Push to the branch (`git push origin my-new-feature`)
122
+ 5. Create new Pull Request
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'motion-cocoapods'
4
+
5
+ unless defined?(Motion::Project::Config)
6
+ raise "This file must be required within a RubyMotion project Rakefile."
7
+ end
8
+
9
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
10
+ Motion::Project::App.setup do |app|
11
+ app.files.unshift(Dir.glob(File.join(lib_dir_path, "motion-imager/**/*.rb")))
12
+
13
+ app.pods do
14
+ pod 'JTSImageViewController', '~> 1.4'
15
+ end
16
+ end
@@ -0,0 +1,63 @@
1
+ class MotionImager
2
+
3
+ def initialize(args={})
4
+ show(args)
5
+ end
6
+
7
+ def show(args={})
8
+ controller(args).showFromViewController(args[:presenting_from],
9
+ transition: transitions[args[:transition]] || JTSImageViewControllerTransition_FromOriginalPosition
10
+ )
11
+ end
12
+
13
+ def controller(args = {})
14
+ JTSImageViewController.alloc.initWithImageInfo(image_info(args),
15
+ mode: modes[args[:mode]] || JTSImageViewControllerMode_Image,
16
+ backgroundStyle: backgrounds[args[:background]] || JTSImageViewControllerBackgroundStyle_Scaled
17
+ )
18
+ end
19
+
20
+ def image_info(args = {})
21
+ JTSImageInfo.new.tap do |i|
22
+ if args[:image]
23
+ args[:image] = UIImage.imageNamed(args[:image]) if args[:image].is_a?(String)
24
+ i.image = args[:image]
25
+ elsif args[:url]
26
+ args[:url] = NSURL.URLWithString(args[:url]) if args[:url].is_a?(String)
27
+ if args[:placeholder]
28
+ args[:placeholder] = UIImage.imageNamed(args[:placeholder]) if args[:placeholder].is_a?(String)
29
+ i.placeholderImage = args[:placeholder]
30
+ end
31
+ i.imageURL = args[:url]
32
+ end
33
+ i.altText = args[:text] if args[:text]
34
+ i.referenceRect = args[:rect] if args[:rect]
35
+ i.referenceView = args[:view] if args[:view]
36
+ end
37
+ end
38
+
39
+ def transitions
40
+ {
41
+ original: JTSImageViewControllerTransition_FromOriginalPosition,
42
+ off_screen: JTSImageViewControllerTransition_FromOffscreen
43
+ }
44
+ end
45
+
46
+ def modes
47
+ {
48
+ image: JTSImageViewControllerMode_Image,
49
+ alt_text: JTSImageViewControllerMode_AltText
50
+ }
51
+ end
52
+
53
+ def backgrounds
54
+ {
55
+ none: JTSImageViewControllerBackgroundOption_None,
56
+ scaled: JTSImageViewControllerBackgroundOption_Scaled,
57
+ blurred: JTSImageViewControllerBackgroundOption_Blurred,
58
+ scaled_blurred: JTSImageViewControllerBackgroundOption_Scaled | JTSImageViewControllerBackgroundOption_Blurred
59
+ }
60
+ end
61
+
62
+ end
63
+
@@ -0,0 +1,3 @@
1
+ module MotionImager
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-imager
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Rickert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: motion-cocoapods
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: 'An interactive iOS image viewer that does it all: double tap to zoom,
42
+ flick to dismiss, et cetera.'
43
+ email:
44
+ - mjar81@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - README.md
50
+ - lib/motion-imager.rb
51
+ - lib/motion-imager/motion-imager.rb
52
+ - lib/motion-imager/version.rb
53
+ homepage: https://github.com/OTGApps/motion-imager
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.0
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: A RubyMotion DSL for JTSImageViewController, a "light box" for iOS. It's
77
+ similar to image viewers you may have seen in apps like Twitter, Tweetbot, and others.
78
+ It presents an image in a full-screen interactive view. Users can pan and zoom,
79
+ and use Tweetbot-style dynamic gestures to dismiss it with a fun flick.
80
+ test_files: []