motion-form 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62b070da82951513aecbfda093cfbc243beb1768
4
- data.tar.gz: 24a8bea72a87cfdeb04d08d121f0fe63ccb6be1a
3
+ metadata.gz: 0e0b0b39d5e8a5cf433f524a477bf7ca3f04ef31
4
+ data.tar.gz: a689dbf3679b8725d52bc978d9264794c853bf3b
5
5
  SHA512:
6
- metadata.gz: 46285b557f7bbb68a6ded12d7e139ec8d8293330fb68f96614854b7cf073dfd5d83400293d1d8209618925fc070b53cbc8141e007602938be1b60d2cfaa9db89
7
- data.tar.gz: b9d211dd2c64ff3054a7425b521f4a54205431f8983b5a170b4ca723ecdc7505d2bc9a540f28a4dd6dc2b401a054fad9d68551600d79dd6d3cce5aeec039223b
6
+ metadata.gz: 6240ecd1b5189c6623f5e88e20d33e34750a67ff9aa39a1048f4193c875f0719a36aee5ffe57f60de0acff35e051e93c0001d26f40f09634bd6934f06603649c
7
+ data.tar.gz: d979704d5683e4ccba8cf5d326f195e7d967f2ee89dd415264cf140d5d16d762fb2892b00dc20812e2021a25c291dc9bbd4749b4dae2783ae1d4523a2a297f0c
data/lib/motion-form.rb CHANGED
@@ -1,8 +1,5 @@
1
- unless defined?(Motion::Project::Config)
2
- raise "This file must be required within a RubyMotion project Rakefile."
3
- end
1
+ require 'bubble-wrap/core'
2
+ require 'motion-require'
3
+
4
+ Motion::Require.all(Dir.glob(File.expand_path('../project/**/*.rb', __FILE__)))
4
5
 
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
@@ -1,3 +1,5 @@
1
+ motion_require './text_field_cell'
2
+
1
3
  class ButtonCell < TextFieldCell
2
4
  IDENTIFIER = 'ButtonCell'
3
5
 
@@ -1,3 +1,6 @@
1
+ motion_require './base_cell'
2
+ motion_require '../views/icon_view'
3
+
1
4
  class TextFieldCell < BaseCell
2
5
  IDENTIFIER = 'TextFieldCell'
3
6
 
@@ -1,3 +1,5 @@
1
+ motion_require '../views/section_header_view'
2
+
1
3
  module MotionForm
2
4
  class Base < UITableView
3
5
  attr_reader :keyboard_avoiding_delegate
@@ -1,3 +1,6 @@
1
+ motion_require './cells/button_cell'
2
+ motion_require './cells/text_field_cell'
3
+
1
4
  module MotionForm
2
5
  class << self
3
6
  attr_accessor :icon_font
@@ -1,3 +1,6 @@
1
+ motion_require '../cells/button_cell'
2
+ motion_require './text_field_row'
3
+
1
4
  class ButtonRow < TextFieldRow
2
5
  attr_reader :on_tap_callback
3
6
 
@@ -1,3 +1,6 @@
1
+ motion_require './base_row'
2
+ motion_require '../cells/text_field_cell'
3
+
1
4
  class TextFieldRow < BaseRow
2
5
  attr_accessor :value
3
6
 
@@ -1,3 +1,6 @@
1
+ motion_require '../cells/button_cell'
2
+ motion_require '../cells/text_field_cell'
3
+
1
4
  class MotionForm
2
5
  class Section
3
6
  attr_reader :title
@@ -1,3 +1,5 @@
1
+ motion_require './padded_label'
2
+
1
3
  class SectionHeaderView < UIView
2
4
  def initWithFrame(frame)
3
5
  super.tap do |view|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devon Blandin
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: motion-require
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.3
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +66,6 @@ files:
52
66
  - lib/project/cells/text_field_cell.rb
53
67
  - lib/project/controllers/form_controller.rb
54
68
  - lib/project/form/base.rb
55
- - lib/project/keyboard_avoiding_delegate.rb
56
69
  - lib/project/motion-form.rb
57
70
  - lib/project/rows/base_row.rb
58
71
  - lib/project/rows/button_row.rb
@@ -1,113 +0,0 @@
1
- class KeyboardAvoidingDelegate
2
- KEYBOARD_ANIMATION_DURATION = 0.3
3
- MINIMUM_SCROLL_FRACTION = 0.2
4
- MAXIMUM_SCROLL_FRACTION = 0.8
5
- PORTRAIT_KEYBOARD_HEIGHT = 216.0
6
- LANDSCAPE_KEYBOARD_HEIGHT = 162.0
7
-
8
- attr_accessor :view, :animated_distance, :active_text_field
9
-
10
- def initialize(view)
11
- self.view = view
12
-
13
- add_tap_recognizer
14
- listen_to_notifications
15
- end
16
-
17
- def listen_to_notifications
18
- observers << notification_center.addObserver(self, selector: 'did_begin_editing:', name: 'FormCellDidBeginEditing', object: nil)
19
- observers << notification_center.addObserver(self, selector: 'did_end_editing:', name: 'FormCellDidEndEditing', object: nil)
20
- end
21
-
22
- def notification_center
23
- NSNotificationCenter.defaultCenter
24
- end
25
-
26
- def did_begin_editing(notification)
27
- textFieldDidBeginEditing(notification.userInfo[:text_field])
28
- end
29
-
30
- def did_end_editing(notification)
31
- textFieldDidEndEditing(notification.userInfo[:text_field])
32
- end
33
-
34
- def observers
35
- @observers ||= []
36
- end
37
-
38
- def remove_all_observers
39
- observers.each do |observer|
40
- notification_center.removeObserver(observer)
41
- end
42
- end
43
-
44
- def dealloc
45
- remove_all_observers
46
- end
47
-
48
- def add_tap_recognizer
49
- view.addGestureRecognizer(tap_recognizer)
50
- end
51
-
52
- def tap_recognizer
53
- UITapGestureRecognizer.alloc.initWithTarget(self, action: 'dismiss_keyboard')
54
- end
55
-
56
- def dismiss_keyboard
57
- active_text_field.resignFirstResponder if active_text_field
58
- end
59
-
60
- def textFieldDidBeginEditing(text_field)
61
- self.active_text_field = text_field
62
-
63
- text_field_rect = view.window.convertRect(text_field.bounds, fromView: text_field)
64
- view_rect = view.window.convertRect(view.bounds, fromView: view)
65
- midline = text_field_rect.origin.y + 0.5 * text_field_rect.size.height
66
- numerator = midline - view_rect.origin.y - MINIMUM_SCROLL_FRACTION * view_rect.size.height
67
- denominator = (MAXIMUM_SCROLL_FRACTION - MINIMUM_SCROLL_FRACTION) * view_rect.size.height
68
- height_fraction = numerator / denominator
69
-
70
- if height_fraction < 0.0
71
- height_fraction = 0.0
72
- elsif height_fraction > 1.0
73
- height_fraction = 1.0
74
- end
75
-
76
- orientation = UIApplication.sharedApplication.statusBarOrientation
77
- if orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown
78
- self.animated_distance = (PORTRAIT_KEYBOARD_HEIGHT * height_fraction).floor
79
- else
80
- self.animated_distance = (LANDSCAPE_KEYBOARD_HEIGHT * height_fraction).floor
81
- end
82
-
83
- view_frame = view.frame
84
- view_frame.origin.y -= animated_distance
85
-
86
- UIView.beginAnimations(nil, context: nil)
87
- UIView.setAnimationBeginsFromCurrentState(true)
88
- UIView.setAnimationDuration(KEYBOARD_ANIMATION_DURATION)
89
-
90
- view.setFrame(view_frame)
91
-
92
- UIView.commitAnimations
93
- end
94
-
95
- def textFieldDidEndEditing(text_field)
96
- view_frame = view.frame
97
- view_frame.origin.y += animated_distance
98
-
99
- UIView.beginAnimations(nil, context: nil)
100
- UIView.setAnimationBeginsFromCurrentState(true)
101
- UIView.setAnimationDuration(KEYBOARD_ANIMATION_DURATION)
102
-
103
- view.setFrame(view_frame)
104
-
105
- UIView.commitAnimations
106
- end
107
-
108
- def textFieldShouldReturn(text_field)
109
- text_field.resignFirstResponder
110
-
111
- true
112
- end
113
- end