rm-organizze-form 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 485cf61058bc283c47d9e8adf1d866c06a96b55c
4
+ data.tar.gz: 62b34098b9df5029ceb4b9314201c2fef669a730
5
+ SHA512:
6
+ metadata.gz: 1a05ad4dd9ddacd34ca30033680c57e0397ef295b4e085fc0cb2166a3e5c47d87a4d44e4317e606f5088b59a4f71d3bfab2aa3476b617d0882754b5d7e420fd6
7
+ data.tar.gz: cdb6ff147d4f27f8413c8e1d521f53f8845c44c5bbe62525d05d62fe8e36916c953f017365040001a5d550a89284c52decd6396e7274bd1b3cfa7f1c1a5348d7
@@ -0,0 +1,29 @@
1
+ # organizze-form
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'organizze-form'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install organizze-form
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,62 @@
1
+ # @example Creating a form
2
+ # form = Form.new
3
+ # form.section do |s|
4
+ # s.row do |r|
5
+ # r.type = 'arrow_select'
6
+ # r.label = 'my label'
7
+ # r.key = 'my_field'
8
+ # r.value = 1234
9
+ # end
10
+ # end
11
+ module OrganizzeForm
12
+ class Form
13
+ attr_reader :uuid, :sections
14
+
15
+ def initialize
16
+ @sections = []
17
+ @uuid = NSUUID.alloc.init.UUIDString
18
+ end
19
+
20
+ # Create a section with a block
21
+ #
22
+ # @yield [Section]
23
+ #
24
+ def section(&block)
25
+ _section = Section.new
26
+ @sections << _section
27
+ yield _section
28
+ end
29
+
30
+ # Method to be called in UITableViewDataSource method tableView:cellForRowAtIndexPath:
31
+ #
32
+ # @param tableView [UITableView]
33
+ # @param indexPath [NSIndexPath]
34
+ # @return [UITableViewCell]
35
+ def cellForRowAtIndexPath(tableView, indexPath)
36
+ @tableView ||= WeakRef.new(tableView)
37
+ row = rowFor(indexPath)
38
+ cell_id = "form-cell-#{@uuid}-#{indexPath.section}-#{indexPath.row}".freeze
39
+ (tableView.dequeueReusableCellWithIdentifier(cell_id) || UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: cell_id)).tap do |cell|
40
+ row.setup_cell(cell)
41
+ end
42
+ end
43
+
44
+ # Method to be called in UITableViewDelegate method tableView:didSelectRowAtIndexPath:
45
+ #
46
+ # @param indexPath [NSIndexPath]
47
+ # @return [OrganizzeForm::Row]
48
+ def didSelectRowAtIndexPath(indexPath)
49
+ row = rowFor(indexPath)
50
+ row.row_was_tapped
51
+ row
52
+ end
53
+
54
+ private
55
+
56
+ def rowFor(indexPath)
57
+ section = @sections[indexPath.section]
58
+ row = section.rows[indexPath.row]
59
+ row
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,14 @@
1
+ module OrganizzeForm
2
+ module RowTypes
3
+ class ArrowSelect < Base
4
+ def setup_cell(cell)
5
+ cell.textLabel.text = self.row.label || ''
6
+ # cell.detailTextLabel.text = self.row.value.to_s
7
+ end
8
+
9
+ def row_was_tapped
10
+ Debug.info 'row_was_tapped'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module OrganizzeForm
2
+ module RowTypes
3
+ class Base
4
+ attr_accessor :row
5
+
6
+ def setup_cell(cell)
7
+ # should be implemented in sub-class
8
+ end
9
+
10
+ def row_was_tapped
11
+ # should be implemented in sub-class
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ module OrganizzeForm
2
+ class Row
3
+ attr_accessor :type # row type underscored mapping to a row_type class
4
+ attr_accessor :label # [String] row label
5
+ attr_accessor :key # [String] key that will be on the result hash of form
6
+ attr_accessor :value # [String, Integer] value that will be on the result hash of form
7
+
8
+ def row_type
9
+ @row_type ||= row_type_class.new.tap do |rt|
10
+ rt.row = WeakRef.new(self)
11
+ end
12
+ end
13
+
14
+ def setup_cell(cell)
15
+ row_type.setup_cell(cell)
16
+ end
17
+
18
+ def row_was_tapped
19
+ row_type.row_was_tapped
20
+ end
21
+
22
+ private
23
+
24
+ def row_type_class
25
+ "OrganizzeForm::RowTypes::#{self.type.camelize}".constantize
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ module OrganizzeForm
2
+ class Section
3
+ attr_reader :rows
4
+
5
+ def initialize
6
+ @rows = []
7
+ end
8
+
9
+ def row(&block)
10
+ _row = Row.new
11
+ @rows << _row
12
+ block.call _row
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
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
+ _files = []
10
+ _files << File.join(lib_dir_path, "organizze-form/row-types/base.rb")
11
+ _files += Dir.glob(File.join(lib_dir_path, "organizze-form/**/*.rb"))
12
+ app.files.unshift _files.uniq
13
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rm-organizze-form
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Luis Felipe Colle da Luz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rm-organizze-toolbelt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.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: Simple rubymotion form helper for UITableViews
42
+ email:
43
+ - solanoluz@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - lib/organizze-form/form.rb
50
+ - lib/organizze-form/row-types/arrow_select.rb
51
+ - lib/organizze-form/row-types/base.rb
52
+ - lib/organizze-form/row.rb
53
+ - lib/organizze-form/section.rb
54
+ - lib/rm-organizze-form.rb
55
+ homepage: ''
56
+ licenses:
57
+ - ''
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.4.1
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: This gem helps you to deal with tableView forms way less intrusively than
79
+ formotion.
80
+ test_files: []