ProMotion-formotion 0.0.9 → 0.1.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.
- data/ProMotion-formotion.gemspec +3 -2
- data/README.md +21 -18
- data/lib/ProMotion/formotion/formotion_screen.rb +73 -55
- data/lib/ProMotion/formotion/version.rb +1 -1
- data/lib/ProMotion-formotion.rb +3 -3
- metadata +22 -6
data/ProMotion-formotion.gemspec
CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.name = "ProMotion-formotion"
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
gem.version = ProMotion::Formotion::VERSION
|
22
|
-
gem.add_runtime_dependency("ProMotion", ">=
|
23
|
-
gem.add_runtime_dependency("formotion", ">= 1.
|
22
|
+
gem.add_runtime_dependency("ProMotion", ">= 1.1.0")
|
23
|
+
gem.add_runtime_dependency("formotion", ">= 1.6.0")
|
24
|
+
gem.add_runtime_dependency("motion-require", ">= 0.0.6")
|
24
25
|
end
|
25
26
|
|
data/README.md
CHANGED
@@ -4,6 +4,9 @@ ProMotion Formotion Screen
|
|
4
4
|
|
5
5
|
Made a gem from the ProMotion formotion example at https://github.com/clearsightstudio/ProMotion#using-your-own-uiviewcontroller
|
6
6
|
|
7
|
+
Now with 100% more motion_require
|
8
|
+
|
9
|
+
|
7
10
|
## Setup
|
8
11
|
|
9
12
|
Add this gem to your project, in Gemfile `gem 'ProMotion-formotion'`,
|
@@ -11,40 +14,40 @@ then `bundle update`
|
|
11
14
|
|
12
15
|
Create a Formotion Screen with:
|
13
16
|
```ruby
|
14
|
-
class
|
15
|
-
|
16
|
-
|
17
|
+
class LoginScreen < PM::FormotionScreen
|
18
|
+
|
19
|
+
title "Login"
|
20
|
+
|
17
21
|
def on_submit(_form)
|
18
|
-
|
19
|
-
if Data.saved?
|
20
|
-
close(saved: true)
|
21
|
-
end
|
22
|
+
|
22
23
|
end
|
23
|
-
|
24
|
-
def
|
24
|
+
|
25
|
+
def table_data
|
25
26
|
{
|
26
27
|
sections: [{
|
27
|
-
title: "
|
28
|
+
title: "Credentials",
|
28
29
|
rows: [{
|
29
|
-
title: "
|
30
|
-
key: :
|
31
|
-
placeholder: "
|
30
|
+
title: "Email",
|
31
|
+
key: :email,
|
32
|
+
placeholder: "example@kohactive.com",
|
32
33
|
type: :string,
|
33
34
|
auto_correction: :no,
|
34
35
|
auto_capitalization: :none
|
35
36
|
},
|
36
37
|
{
|
37
|
-
title: "
|
38
|
-
key: :
|
39
|
-
placeholder: "
|
40
|
-
type: :
|
38
|
+
title: "Password",
|
39
|
+
key: :password,
|
40
|
+
placeholder: "",
|
41
|
+
type: :string,
|
41
42
|
auto_correction: :no,
|
42
43
|
auto_capitalization: :none
|
43
44
|
},
|
44
|
-
]
|
45
|
+
]
|
45
46
|
}]
|
46
47
|
}
|
47
48
|
end
|
48
49
|
|
50
|
+
|
51
|
+
|
49
52
|
end
|
50
53
|
```
|
@@ -1,71 +1,89 @@
|
|
1
1
|
module ProMotion
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
include ::ProMotion::ScreenModule # Not TableScreenModule since we're using Formotion for that
|
2
|
+
if defined?(Formotion) && defined?(Formotion::FormController)
|
3
|
+
class FormotionScreen < Formotion::FormController
|
4
|
+
include ProMotion::ScreenModule
|
6
5
|
|
7
|
-
|
6
|
+
def self.new(args = {})
|
7
|
+
s = self.alloc.initWithStyle(UITableViewStyleGrouped)
|
8
|
+
s.on_create(args) if s.respond_to?(:on_create)
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
if s.respond_to?(:table_data)
|
11
|
+
s.form = s.table_data
|
12
|
+
elsif args[:form]
|
13
|
+
s.form = args[:form]
|
14
|
+
else
|
15
|
+
PM.logger.error "PM::FormotionScreen requires a `table_data` method or form: to be passed into `new`."
|
16
|
+
end
|
17
|
+
|
18
|
+
t = s.title # Formotion kills the title when you request tableView.
|
19
|
+
s.tableView.allowsSelectionDuringEditing = true
|
20
|
+
s.title = t
|
12
21
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@local_form=s.form_data
|
17
|
-
@local_form=::Formotion::Form.new(@local_form) if @local_form.class==Hash
|
18
|
-
if s.respond_to?(:on_submit)
|
19
|
-
@local_form.on_submit do |form|
|
20
|
-
s.on_submit(form.render)
|
22
|
+
s.form.on_submit { |form| s.on_submit(form) if s.respond_to?(:on_submit) }
|
23
|
+
|
24
|
+
s
|
21
25
|
end
|
22
|
-
end
|
23
|
-
s.initWithForm(@local_form)
|
24
|
-
s.update_table_data if s.respond_to?(:update_table_data)
|
25
|
-
s
|
26
|
-
end
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
# emulate the ProMotion table update for formotion
|
28
|
+
def update_table_data
|
29
|
+
self.form = table_data
|
30
|
+
self.form.controller = self
|
31
|
+
self.tableView.reloadData
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
34
|
+
def screen_setup
|
35
|
+
self.title = self.class.send(:get_title)
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
def loadView
|
39
|
+
super
|
40
|
+
self.send(:on_load) if self.respond_to?(:on_load)
|
41
|
+
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
def viewDidLoad
|
44
|
+
super
|
45
|
+
self.view_did_load if self.respond_to?(:view_did_load)
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
def viewWillAppear(animated)
|
49
|
+
super
|
50
|
+
self.view_will_appear(animated) if self.respond_to?("view_will_appear:")
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
def viewDidAppear(animated)
|
54
|
+
super
|
55
|
+
self.view_did_appear(animated) if self.respond_to?("view_did_appear:")
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
def viewWillDisappear(animated)
|
59
|
+
self.view_will_disappear(animated) if self.respond_to?("view_will_disappear:")
|
60
|
+
super
|
61
|
+
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
def viewDidDisappear(animated)
|
64
|
+
if self.respond_to?("view_did_disappear:")
|
65
|
+
self.view_did_disappear(animated)
|
66
|
+
end
|
67
|
+
super
|
68
|
+
end
|
64
69
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
70
|
+
def shouldAutorotateToInterfaceOrientation(orientation)
|
71
|
+
self.should_rotate(orientation)
|
72
|
+
end
|
69
73
|
|
70
|
-
|
74
|
+
def shouldAutorotate
|
75
|
+
self.should_autorotate
|
76
|
+
end
|
77
|
+
|
78
|
+
def willRotateToInterfaceOrientation(orientation, duration:duration)
|
79
|
+
self.will_rotate(orientation, duration)
|
80
|
+
end
|
81
|
+
|
82
|
+
def didRotateFromInterfaceOrientation(orientation)
|
83
|
+
self.on_rotate
|
84
|
+
end
|
85
|
+
end
|
86
|
+
else
|
87
|
+
throw "Unable to find Formotion"
|
88
|
+
end
|
71
89
|
end
|
data/lib/ProMotion-formotion.rb
CHANGED
@@ -2,8 +2,8 @@ unless defined?(Motion::Project::Config)
|
|
2
2
|
raise "This file must be required within a RubyMotion project Rakefile."
|
3
3
|
end
|
4
4
|
|
5
|
+
require "formotion"
|
6
|
+
require "motion-require"
|
5
7
|
require "ProMotion/formotion/version"
|
6
8
|
|
7
|
-
Motion::
|
8
|
-
app.files = Dir.glob(File.join(File.dirname(__FILE__), 'ProMotion/**/*.rb')) | app.files
|
9
|
-
end
|
9
|
+
Motion::Require.all(Dir.glob(File.expand_path('../ProMotion/**/*.rb', __FILE__)))
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ProMotion-formotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ProMotion
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 1.1.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: formotion
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.
|
37
|
+
version: 1.6.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,23 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.
|
45
|
+
version: 1.6.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: motion-require
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.0.6
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.6
|
46
62
|
description: ProMotion-formotion bind ProMotion and formotion together.
|
47
63
|
email:
|
48
64
|
- stephan@rheoli.net
|