MIMInputToolbar 0.0.1

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: ce71dd2fe6ca0919fe870575434395c7e634505e
4
+ data.tar.gz: 1a861ec6d2edce0f0217c1e7f08652c3c05569e8
5
+ SHA512:
6
+ metadata.gz: a9afaccfbccbad543d4bec19d0bd4e5fdc5f0284304673ece04314d53bc563128704aca5225a57a34df4b65b810bb1886bcee9b65f68f7415f55f72c222dea42
7
+ data.tar.gz: 80db2c94b698cf3c1e4ed8dc83979d0a89c8c7be234955c592f0e5034eb31bbfbffc16e7574fe512a3f4798f83bd55bb0d499ecb94c20b40f8e825942aad518e
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # MIMInputToolbar
2
+
3
+ A very simple gem that provides the one MIMInputToolbar class which you can use as the input accessory view for your UITextFields and UITextViews.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'MIMInputToolbar'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install MIMInputToolbar
18
+
19
+ ## Usage
20
+
21
+ After installing the gem / adding it to your Gemfile, start off by creating an instance of `MIMInputToolbar`.
22
+
23
+ ```ruby
24
+ @field_bar = MIMInputToolbar.new
25
+ ```
26
+
27
+ Give each input the instance through it's input accessor view property.
28
+
29
+ ```ruby
30
+ @text_field_one.inputAccessoryView = @field_bar
31
+ @text_field_two.inputAccessoryView = @field_bar
32
+ @text_field_three.inputAccessoryView = @field_bar
33
+ ```
34
+
35
+ Then finally, give the instance all the fields (in the correct order) that it will be navigating through.
36
+
37
+ ```ruby
38
+ @field_bar.fields = [@text_field_one, @text_field_two, @text_field_three]
39
+ ```
40
+
41
+ This works really well with the [TPKeyboardAvoiding](https://github.com/michaeltyson/TPKeyboardAvoiding).
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ unless defined?(Motion::Project::Config)
4
+ raise "This file must be required within a RubyMotion project Rakefile."
5
+ end
6
+
7
+ lib_dir_path = File.dirname(File.expand_path(__FILE__))
8
+ Motion::Project::App.setup do |app|
9
+ app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
10
+ end
@@ -0,0 +1,42 @@
1
+ class MIMInputToolbar < UIToolbar
2
+ attr_accessor :fields
3
+
4
+ def init
5
+ super
6
+
7
+ self.items = [
8
+ UIBarButtonItem.alloc.initWithTitle('Previous', style: UIBarButtonItemStylePlain, target: self, action: 'previous_field:'),
9
+ UIBarButtonItem.alloc.initWithTitle('Next', style: UIBarButtonItemStylePlain, target: self, action: 'next_field:'),
10
+ UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemFlexibleSpace, target: nil, action: nil),
11
+ UIBarButtonItem.alloc.initWithTitle('Done', style: UIBarButtonItemStyleDone, target: self, action: 'finish_editing:')
12
+ ]
13
+
14
+ self.sizeToFit
15
+
16
+ self
17
+ end
18
+
19
+ def previous_field(sender)
20
+ index = fields.index(selected_field)
21
+ if index >= 1
22
+ fields[index - 1].becomeFirstResponder
23
+ end
24
+ end
25
+
26
+ def next_field(sender)
27
+ index = fields.index(selected_field)
28
+ if index < fields.length - 1
29
+ fields[index + 1].becomeFirstResponder
30
+ end
31
+ end
32
+
33
+ def finish_editing(sender)
34
+ selected_field.resignFirstResponder
35
+ end
36
+
37
+ private
38
+
39
+ def selected_field
40
+ fields.select { |f| f.isFirstResponder }.first
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MIMInputToolbar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jack Dean Watson-Hamblin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-24 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: Simple UIToolbar subclass with next, previous, and done buttons.
28
+ email:
29
+ - info@fluffyjack.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - lib/MIMInputToolbar.rb
36
+ - lib/project/MIMInputToolbar.rb
37
+ homepage: https://github.com/FluffyJack/MIMInputToolbar
38
+ licenses:
39
+ - MIT
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 2.1.11
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: UIToolbar subclass for your input accessory view
61
+ test_files: []