ProMotion 0.1.0 → 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/Gemfile +0 -1
- data/README.md +20 -2
- data/lib/ProMotion/.DS_Store +0 -0
- data/lib/ProMotion/{ext → _ext}/NavigationController.rb +0 -0
- data/lib/ProMotion/{ext → _ext}/TableViewController.rb +0 -0
- data/lib/ProMotion/{ext → _ext}/ViewController.rb +0 -0
- data/lib/ProMotion/_modules/ScreenElements.rb +31 -0
- data/lib/ProMotion/_modules/ScreenNavigation.rb +92 -0
- data/lib/ProMotion/classes/.DS_Store +0 -0
- data/lib/ProMotion/classes/Screen.rb +6 -128
- data/lib/ProMotion/helpers/ViewHelper.rb +16 -0
- data/lib/ProMotion/helpers/motion-table/{first → 1st}/searchable_table.rb +0 -0
- data/lib/ProMotion/helpers/motion-table/{first → 1st}/sectioned_table.rb +19 -11
- data/lib/ProMotion/helpers/motion-table/{grouped_table.rb → 2nd/grouped_table.rb} +0 -0
- data/lib/ProMotion/helpers/motion-table/{plain_table.rb → 2nd/plain_table.rb} +0 -0
- data/lib/ProMotion/version.rb +1 -1
- metadata +14 -9
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -41,7 +41,7 @@ class HomeScreen < ProMotion::Screen
|
|
41
41
|
# Set up the elements in your view with add_element:
|
42
42
|
@label = add_element UILabel.alloc.initWithFrame(CGRectMake(5, 5, 20, 20)), {
|
43
43
|
text: "This is awesome!",
|
44
|
-
font: UIFont.
|
44
|
+
font: UIFont.systemFontOfSize(18)
|
45
45
|
}
|
46
46
|
end
|
47
47
|
|
@@ -93,6 +93,12 @@ def settings_button_tapped
|
|
93
93
|
end
|
94
94
|
```
|
95
95
|
|
96
|
+
Open a new screen as a modal:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
open_screen SettingsScreen, modal: true
|
100
|
+
```
|
101
|
+
|
96
102
|
You can pass in arguments to other screens if they have accessors:
|
97
103
|
|
98
104
|
```ruby
|
@@ -147,7 +153,19 @@ def on_load
|
|
147
153
|
end
|
148
154
|
```
|
149
155
|
|
150
|
-
The helper add_element takes
|
156
|
+
The helper add_element takes any view object and adds it to the current view. You can also use
|
157
|
+
the helper ProMotion::ViewHelper.set_attributes(view, attributes) to do the same thing without adding
|
158
|
+
it to the current view. Screens include this helper by default.
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
@element = add_element UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20)), {
|
162
|
+
backgroundColor: UIColor.whiteColor
|
163
|
+
}
|
164
|
+
|
165
|
+
@element = set_attributes(UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20)), {
|
166
|
+
backgroundColor: UIColor.whiteColor
|
167
|
+
}
|
168
|
+
```
|
151
169
|
|
152
170
|
You can create sectioned table screens easily. TableScreen, SectionedTableScreen, GroupedTableScreen
|
153
171
|
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ProMotion
|
2
|
+
module ScreenElements
|
3
|
+
include ProMotion::ViewHelper
|
4
|
+
|
5
|
+
def add_element(view, attrs = {})
|
6
|
+
if attrs.length > 0
|
7
|
+
set_attributes(view, attrs)
|
8
|
+
end
|
9
|
+
self.view_controller.view.addSubview(view)
|
10
|
+
view
|
11
|
+
end
|
12
|
+
|
13
|
+
def remove_element(view)
|
14
|
+
view.removeFromSuperview
|
15
|
+
view = nil
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def bounds
|
20
|
+
return self.view_controller.view.bounds
|
21
|
+
end
|
22
|
+
|
23
|
+
def frame
|
24
|
+
return self.view_controller.view.frame
|
25
|
+
end
|
26
|
+
|
27
|
+
def view
|
28
|
+
return self.view_controller.view
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module ProMotion
|
2
|
+
module ScreenNavigation
|
3
|
+
def open_screen(screen, args = {})
|
4
|
+
# Instantiate screen if given a class instead
|
5
|
+
screen = screen.new if screen.respond_to? :new
|
6
|
+
screen.add_nav_bar if args[:nav_bar]
|
7
|
+
screen.parent_screen = self
|
8
|
+
|
9
|
+
screen.main_controller.hidesBottomBarWhenPushed = true if args[:hide_tab_bar]
|
10
|
+
|
11
|
+
if args[:close_all]
|
12
|
+
fresh_start(screen)
|
13
|
+
elsif args[:modal]
|
14
|
+
screen.modal = true
|
15
|
+
self.view_controller.presentModalViewController(screen.main_controller, animated:true)
|
16
|
+
elsif self.navigation_controller
|
17
|
+
screen.navigation_controller = self.navigation_controller
|
18
|
+
push_view_controller screen.view_controller
|
19
|
+
else
|
20
|
+
open_view_controller screen.main_controller
|
21
|
+
end
|
22
|
+
|
23
|
+
screen.send(:on_opened) if screen.respond_to?(:on_opened)
|
24
|
+
end
|
25
|
+
|
26
|
+
def fresh_start(screen)
|
27
|
+
app_delegate.fresh_start(screen)
|
28
|
+
end
|
29
|
+
|
30
|
+
def app_delegate
|
31
|
+
UIApplication.sharedApplication.delegate
|
32
|
+
end
|
33
|
+
|
34
|
+
def close_screen(args = {})
|
35
|
+
# Pop current view, maybe with arguments, if in navigation controller
|
36
|
+
if self.is_modal?
|
37
|
+
self.parent_screen.view_controller.dismissModalViewControllerAnimated(true)
|
38
|
+
elsif self.navigation_controller
|
39
|
+
self.navigation_controller.popViewControllerAnimated(true)
|
40
|
+
else
|
41
|
+
# What do we do now? Nothing to "pop". For now, don't do anything.
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def tab_bar_controller(*screens)
|
46
|
+
tab_bar_controller = UITabBarController.alloc.init
|
47
|
+
|
48
|
+
view_controllers = []
|
49
|
+
screens.each do |s|
|
50
|
+
if s.is_a? Screen
|
51
|
+
s = s.new if s.respond_to? :new
|
52
|
+
view_controllers << s.main_controller
|
53
|
+
else
|
54
|
+
Console.log("Non-Screen passed into tab_bar_controller: #{s.to_s}", withColor: Console::RED_COLOR)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
tab_bar_controller.viewControllers = view_controllers
|
59
|
+
tab_bar_controller
|
60
|
+
end
|
61
|
+
|
62
|
+
def open_tab_bar(*screens)
|
63
|
+
tab_bar = tab_bar_controller(*screens)
|
64
|
+
open_view_controller tab_bar
|
65
|
+
screens.each do |s|
|
66
|
+
s.on_opened if s.respond_to? :on_opened
|
67
|
+
s.parent_screen = self if s.respond_to? "parent_screen="
|
68
|
+
end
|
69
|
+
tab_bar
|
70
|
+
end
|
71
|
+
|
72
|
+
def push_tab_bar(*screens)
|
73
|
+
tab_bar = tab_bar_controller(*screens)
|
74
|
+
push_view_controller tab_bar
|
75
|
+
screens.each do |s|
|
76
|
+
s.on_opened if s.respond_to? :on_opened
|
77
|
+
s.parent_screen = self if s.respond_to? "parent_screen="
|
78
|
+
end
|
79
|
+
tab_bar
|
80
|
+
end
|
81
|
+
|
82
|
+
def open_view_controller(vc)
|
83
|
+
UIApplication.sharedApplication.delegate.load_root_view vc
|
84
|
+
end
|
85
|
+
|
86
|
+
def push_view_controller(vc)
|
87
|
+
# vc.hidesBottomBarWhenPushed = true if args[:hide_tab_bar]
|
88
|
+
Console.log(" You need a nav_bar if you are going to push #{vc.to_s} onto it.", withColor: Console::RED_COLOR) unless self.navigation_controller
|
89
|
+
self.navigation_controller.pushViewController(vc, animated: true)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
Binary file
|
@@ -1,137 +1,10 @@
|
|
1
|
-
module ProMotion
|
2
|
-
module ScreenElements
|
3
|
-
def add_element(view, attrs = {})
|
4
|
-
if attrs.length > 0
|
5
|
-
set_attributes(view, attrs)
|
6
|
-
end
|
7
|
-
self.view_controller.view.addSubview(view)
|
8
|
-
view
|
9
|
-
end
|
10
|
-
|
11
|
-
def remove_element(view)
|
12
|
-
view.removeFromSuperview
|
13
|
-
view = nil
|
14
|
-
nil
|
15
|
-
end
|
16
|
-
|
17
|
-
def bounds
|
18
|
-
return self.view_controller.view.bounds
|
19
|
-
end
|
20
|
-
|
21
|
-
def frame
|
22
|
-
return self.view_controller.view.frame
|
23
|
-
end
|
24
|
-
|
25
|
-
def view
|
26
|
-
return self.view_controller.view
|
27
|
-
end
|
28
|
-
|
29
|
-
def set_attributes(element, args = {})
|
30
|
-
args.each do |k, v|
|
31
|
-
element.send("#{k}=", v) if element.respond_to? "#{k}="
|
32
|
-
end
|
33
|
-
element
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
module ScreenNavigation
|
38
|
-
def open_screen(screen, args = {})
|
39
|
-
# Instantiate screen if given a class instead
|
40
|
-
screen = screen.new if screen.respond_to? :new
|
41
|
-
screen.add_nav_bar if args[:nav_bar]
|
42
|
-
screen.parent_screen = self
|
43
|
-
|
44
|
-
screen.main_controller.hidesBottomBarWhenPushed = true if args[:hide_tab_bar]
|
45
|
-
|
46
|
-
if args[:close_all]
|
47
|
-
fresh_start(screen)
|
48
|
-
elsif self.navigation_controller
|
49
|
-
screen.navigation_controller = self.navigation_controller
|
50
|
-
push_view_controller screen.view_controller
|
51
|
-
else
|
52
|
-
open_view_controller screen.main_controller
|
53
|
-
end
|
54
|
-
|
55
|
-
screen.on_opened if screen.respond_to? :on_opened
|
56
|
-
end
|
57
|
-
|
58
|
-
def fresh_start(screen)
|
59
|
-
app_delegate.fresh_start(screen)
|
60
|
-
end
|
61
|
-
|
62
|
-
def app_delegate
|
63
|
-
UIApplication.sharedApplication.delegate
|
64
|
-
end
|
65
|
-
|
66
|
-
def close_screen(args = {})
|
67
|
-
# Pop current view, maybe with arguments, if in navigation controller
|
68
|
-
if self.navigation_controller
|
69
|
-
self.navigation_controller.popViewControllerAnimated(true)
|
70
|
-
else
|
71
|
-
# What do we do now? Nothing to "pop"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def tab_bar_controller(*screens)
|
76
|
-
tab_bar_controller = UITabBarController.alloc.init
|
77
|
-
|
78
|
-
view_controllers = []
|
79
|
-
screens.each do |s|
|
80
|
-
if s.is_a? Screen
|
81
|
-
s = s.new if s.respond_to? :new
|
82
|
-
view_controllers << s.main_controller
|
83
|
-
else
|
84
|
-
Console.log("Non-Screen passed into tab_bar_controller: #{s.to_s}", withColor: Console::RED_COLOR)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
tab_bar_controller.viewControllers = view_controllers
|
89
|
-
tab_bar_controller
|
90
|
-
end
|
91
|
-
|
92
|
-
def open_tab_bar(*screens)
|
93
|
-
tab_bar = tab_bar_controller(*screens)
|
94
|
-
open_view_controller tab_bar
|
95
|
-
screens.each do |s|
|
96
|
-
s.on_opened if s.respond_to? :on_opened
|
97
|
-
s.parent_screen = self if s.respond_to? "parent_screen="
|
98
|
-
end
|
99
|
-
tab_bar
|
100
|
-
end
|
101
|
-
|
102
|
-
def push_tab_bar(*screens)
|
103
|
-
tab_bar = tab_bar_controller(*screens)
|
104
|
-
push_view_controller tab_bar
|
105
|
-
screens.each do |s|
|
106
|
-
s.on_opened if s.respond_to? :on_opened
|
107
|
-
s.parent_screen = self if s.respond_to? "parent_screen="
|
108
|
-
end
|
109
|
-
tab_bar
|
110
|
-
end
|
111
|
-
|
112
|
-
def open_view_controller(vc)
|
113
|
-
UIApplication.sharedApplication.delegate.load_root_view vc
|
114
|
-
end
|
115
|
-
|
116
|
-
def push_view_controller(vc)
|
117
|
-
# vc.hidesBottomBarWhenPushed = true if args[:hide_tab_bar]
|
118
|
-
Console.log(" You need a nav_bar if you are going to push #{vc.to_s} onto it.", withColor: Console::RED_COLOR) unless self.navigation_controller
|
119
|
-
self.navigation_controller.pushViewController(vc, animated: true)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
1
|
module ProMotion
|
125
2
|
# Instance methods
|
126
3
|
class Screen
|
127
4
|
include ProMotion::ScreenNavigation
|
128
5
|
include ProMotion::ScreenElements
|
129
6
|
|
130
|
-
attr_accessor :view_controller
|
131
|
-
attr_accessor :navigation_controller
|
132
|
-
attr_accessor :parent_screen
|
133
|
-
attr_accessor :first_screen
|
134
|
-
attr_accessor :tab_bar_item
|
7
|
+
attr_accessor :view_controller, :navigation_controller, :parent_screen, :first_screen, :tab_bar_item, :modal
|
135
8
|
|
136
9
|
def initialize(attrs = {})
|
137
10
|
attrs.each do |k, v|
|
@@ -149,6 +22,10 @@ module ProMotion
|
|
149
22
|
self
|
150
23
|
end
|
151
24
|
|
25
|
+
def is_modal?
|
26
|
+
self.modal
|
27
|
+
end
|
28
|
+
|
152
29
|
def load_view_controller
|
153
30
|
self.view_controller ||= ViewController
|
154
31
|
end
|
@@ -200,6 +77,7 @@ module ProMotion
|
|
200
77
|
end
|
201
78
|
|
202
79
|
def view_will_appear(animated)
|
80
|
+
self.will_appear if self.respond_to? :will_appear
|
203
81
|
end
|
204
82
|
|
205
83
|
def view_did_appear(animated)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ProMotion
|
2
|
+
module ViewHelper
|
3
|
+
def set_attributes(element, args = {})
|
4
|
+
args.each do |k, v|
|
5
|
+
element.send("#{k}=", v) if element.respond_to? "#{k}="
|
6
|
+
end
|
7
|
+
element
|
8
|
+
end
|
9
|
+
|
10
|
+
def frame_from_array(array)
|
11
|
+
return CGRectMake(array[0], array[1], array[2], array[3]) if array.length == 4
|
12
|
+
Console.log(" - frame_from_array expects an array with four elements.", withColor: Console::RED_COLOR)
|
13
|
+
CGRectZero
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
@@ -44,18 +44,26 @@ module ProMotion::MotionTable
|
|
44
44
|
tableCell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
|
45
45
|
unless tableCell
|
46
46
|
tableCell = UITableViewCell.alloc.initWithStyle(dataCell[:cellStyle], reuseIdentifier:cellIdentifier)
|
47
|
-
|
48
|
-
|
49
|
-
if dataCell[:accessory] && dataCell[:accessory] == :switch
|
50
|
-
switchView = UISwitch.alloc.initWithFrame(CGRectZero)
|
51
|
-
switchView.addTarget(self, action: "accessoryToggledSwitch:", forControlEvents:UIControlEventValueChanged);
|
52
|
-
switchView.on = true if dataCell[:accessoryDefault]
|
53
|
-
tableCell.accessoryView = switchView
|
54
|
-
end
|
47
|
+
end
|
55
48
|
|
56
|
-
|
57
|
-
|
58
|
-
|
49
|
+
tableCell.accessoryView = dataCell[:accessoryView] if dataCell[:accessoryView]
|
50
|
+
|
51
|
+
if dataCell[:accessory] && dataCell[:accessory] == :switch
|
52
|
+
switchView = UISwitch.alloc.initWithFrame(CGRectZero)
|
53
|
+
switchView.addTarget(self, action: "accessoryToggledSwitch:", forControlEvents:UIControlEventValueChanged);
|
54
|
+
switchView.on = true if dataCell[:accessoryDefault]
|
55
|
+
tableCell.accessoryView = switchView
|
56
|
+
end
|
57
|
+
|
58
|
+
if dataCell[:subtitle]
|
59
|
+
tableCell.detailTextLabel.text = dataCell[:subtitle]
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
if dataCell[:image]
|
64
|
+
tableCell.imageView.layer.masksToBounds = true
|
65
|
+
tableCell.imageView.image = dataCell[:image][:image]
|
66
|
+
tableCell.imageView.layer.cornerRadius = dataCell[:image][:radius] if dataCell[:image][:radius]
|
59
67
|
end
|
60
68
|
|
61
69
|
tableCell.text = dataCell[:title]
|
File without changes
|
File without changes
|
data/lib/ProMotion/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ProMotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: ProMotion is a new way to organize RubyMotion apps.
|
17
17
|
email:
|
@@ -30,22 +30,27 @@ files:
|
|
30
30
|
- app/screens/home_screen.rb
|
31
31
|
- app/screens/test_screen.rb
|
32
32
|
- lib/ProMotion.rb
|
33
|
+
- lib/ProMotion/.DS_Store
|
33
34
|
- lib/ProMotion/AppDelegate.rb
|
34
35
|
- lib/ProMotion/Console.rb
|
35
36
|
- lib/ProMotion/ProMotion.rb
|
37
|
+
- lib/ProMotion/_ext/NavigationController.rb
|
38
|
+
- lib/ProMotion/_ext/TableViewController.rb
|
39
|
+
- lib/ProMotion/_ext/ViewController.rb
|
40
|
+
- lib/ProMotion/_modules/ScreenElements.rb
|
41
|
+
- lib/ProMotion/_modules/ScreenNavigation.rb
|
42
|
+
- lib/ProMotion/classes/.DS_Store
|
36
43
|
- lib/ProMotion/classes/Element.rb
|
37
44
|
- lib/ProMotion/classes/Screen.rb
|
38
45
|
- lib/ProMotion/classes/TableScreen.rb
|
39
|
-
- lib/ProMotion/ext/NavigationController.rb
|
40
|
-
- lib/ProMotion/ext/TableViewController.rb
|
41
|
-
- lib/ProMotion/ext/ViewController.rb
|
42
46
|
- lib/ProMotion/helpers/MeasureHelper.rb
|
43
47
|
- lib/ProMotion/helpers/TabBar.rb
|
48
|
+
- lib/ProMotion/helpers/ViewHelper.rb
|
49
|
+
- lib/ProMotion/helpers/motion-table/1st/searchable_table.rb
|
50
|
+
- lib/ProMotion/helpers/motion-table/1st/sectioned_table.rb
|
51
|
+
- lib/ProMotion/helpers/motion-table/2nd/grouped_table.rb
|
52
|
+
- lib/ProMotion/helpers/motion-table/2nd/plain_table.rb
|
44
53
|
- lib/ProMotion/helpers/motion-table/console.rb
|
45
|
-
- lib/ProMotion/helpers/motion-table/first/searchable_table.rb
|
46
|
-
- lib/ProMotion/helpers/motion-table/first/sectioned_table.rb
|
47
|
-
- lib/ProMotion/helpers/motion-table/grouped_table.rb
|
48
|
-
- lib/ProMotion/helpers/motion-table/plain_table.rb
|
49
54
|
- lib/ProMotion/version.rb
|
50
55
|
homepage: https://github.com/clearsightstudio/ProMotion
|
51
56
|
licenses: []
|