ProMotion 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -22
- data/.repl_history +0 -0
- data/Gemfile.lock +14 -0
- data/ProMotion.gemspec +4 -3
- data/README.md +252 -25
- data/Rakefile +5 -3
- data/app/app_delegate.rb +2 -2
- data/app/screens/home_screen.rb +14 -3
- data/app/screens/test_screen.rb +19 -3
- data/lib/ProMotion.rb +0 -8
- data/lib/ProMotion/version.rb +1 -1
- metadata +32 -31
- data/.c9revisions/lib/ProMotion.rb.c9save +0 -1
- data/.c9revisions/lib/ProMotion/AppDelegate.rb.c9save +0 -3
- data/.c9revisions/lib/ProMotion/classes/Screen.rb.c9save +0 -2
- data/lib/ProMotion/AppDelegate.rb +0 -60
- data/lib/ProMotion/Console.rb +0 -19
- data/lib/ProMotion/ProMotion.rb +0 -3
- data/lib/ProMotion/_ext/NavigationController.rb +0 -7
- data/lib/ProMotion/_ext/TableViewCell.rb +0 -16
- data/lib/ProMotion/_ext/TableViewController.rb +0 -54
- data/lib/ProMotion/_ext/ViewController.rb +0 -68
- data/lib/ProMotion/_modules/ScreenElements.rb +0 -31
- data/lib/ProMotion/_modules/ScreenNavigation.rb +0 -149
- data/lib/ProMotion/classes/Element.rb +0 -14
- data/lib/ProMotion/classes/Screen.rb +0 -206
- data/lib/ProMotion/classes/TableScreen.rb +0 -52
- data/lib/ProMotion/helpers/MeasureHelper.rb +0 -18
- data/lib/ProMotion/helpers/TabBar.rb +0 -99
- data/lib/ProMotion/helpers/ViewHelper.rb +0 -23
- data/lib/ProMotion/helpers/motion-table/1st/searchable_table.rb +0 -58
- data/lib/ProMotion/helpers/motion-table/1st/sectioned_table.rb +0 -219
- data/lib/ProMotion/helpers/motion-table/2nd/grouped_table.rb +0 -12
- data/lib/ProMotion/helpers/motion-table/2nd/plain_table.rb +0 -13
- data/lib/ProMotion/helpers/motion-table/console.rb +0 -26
- data/lib/ProMotion/helpers/system_helper.rb +0 -29
@@ -1,23 +0,0 @@
|
|
1
|
-
module ProMotion
|
2
|
-
module ViewHelper
|
3
|
-
def set_attributes(element, args = {})
|
4
|
-
args.each do |k, v|
|
5
|
-
if v.is_a? Hash
|
6
|
-
v.each do |k2, v2|
|
7
|
-
sub_element = element.send("#{k}")
|
8
|
-
sub_element.send("#{k2}=", v2) if sub_element.respond_to?("#{k2}=")
|
9
|
-
end
|
10
|
-
else
|
11
|
-
element.send("#{k}=", v) if element.respond_to?("#{k}=")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
element
|
15
|
-
end
|
16
|
-
|
17
|
-
def frame_from_array(array)
|
18
|
-
return CGRectMake(array[0], array[1], array[2], array[3]) if array.length == 4
|
19
|
-
Console.log(" - frame_from_array expects an array with four elements.", withColor: Console::RED_COLOR)
|
20
|
-
CGRectZero
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module ProMotion::MotionTable
|
2
|
-
module SearchableTable
|
3
|
-
def makeSearchable(params={})
|
4
|
-
params[:frame] ||= CGRectMake(0, 0, 320, 44)
|
5
|
-
params[:contentController] ||= self
|
6
|
-
params[:delegate] ||= self
|
7
|
-
params[:searchResultsDataSource] ||= self
|
8
|
-
params[:searchResultsDelegate] ||= self
|
9
|
-
|
10
|
-
searchBar = UISearchBar.alloc.initWithFrame(params[:frame])
|
11
|
-
if params[:searchBar] && params[:searchBar][:placeholder]
|
12
|
-
searchBar.placeholder = params[:searchBar][:placeholder]
|
13
|
-
end
|
14
|
-
|
15
|
-
@contactsSearchDisplayController = UISearchDisplayController.alloc.initWithSearchBar(searchBar, contentsController: params[:contentController])
|
16
|
-
@contactsSearchDisplayController.delegate = params[:delegate]
|
17
|
-
@contactsSearchDisplayController.searchResultsDataSource = params[:searchResultsDataSource]
|
18
|
-
@contactsSearchDisplayController.searchResultsDelegate = params[:searchResultsDelegate]
|
19
|
-
|
20
|
-
self.tableView.tableHeaderView = searchBar
|
21
|
-
end
|
22
|
-
|
23
|
-
def searchDisplayController(controller, shouldReloadTableForSearchString:searchString)
|
24
|
-
@mt_filtered_data = nil
|
25
|
-
@mt_filtered_data = []
|
26
|
-
|
27
|
-
@mt_table_view_groups.each do |section|
|
28
|
-
newSection = {}
|
29
|
-
newSection[:cells] = []
|
30
|
-
|
31
|
-
section[:cells].each do |cell|
|
32
|
-
if cell[:title].to_s.downcase.strip.include?(searchString.downcase.strip)
|
33
|
-
newSection[:cells] << cell
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
if newSection[:cells] && newSection[:cells].length > 0
|
38
|
-
newSection[:title] = section[:title]
|
39
|
-
@mt_filtered_data << newSection
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
true
|
44
|
-
end
|
45
|
-
|
46
|
-
def searchDisplayControllerWillEndSearch(controller)
|
47
|
-
@mt_filtered = false
|
48
|
-
@mt_filtered_data = nil
|
49
|
-
self.tableView.setScrollEnabled true
|
50
|
-
end
|
51
|
-
|
52
|
-
def searchDisplayControllerWillBeginSearch(controller)
|
53
|
-
@mt_filtered = true
|
54
|
-
@mt_filtered_data = []
|
55
|
-
self.tableView.setScrollEnabled false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,219 +0,0 @@
|
|
1
|
-
module ProMotion::MotionTable
|
2
|
-
module SectionedTable
|
3
|
-
# @param [Array] Array of table data
|
4
|
-
# @returns [UITableView] delegated to self
|
5
|
-
def createTableViewFromData(data)
|
6
|
-
setTableViewData data
|
7
|
-
return tableView
|
8
|
-
end
|
9
|
-
|
10
|
-
def updateTableViewData(data)
|
11
|
-
setTableViewData data
|
12
|
-
self.tableView.reloadData
|
13
|
-
end
|
14
|
-
|
15
|
-
def setTableViewData(data)
|
16
|
-
@mt_table_view_groups = data
|
17
|
-
end
|
18
|
-
|
19
|
-
def numberOfSectionsInTableView(tableView)
|
20
|
-
if @mt_filtered
|
21
|
-
return @mt_filtered_data.length if @mt_filtered_data
|
22
|
-
else
|
23
|
-
return @mt_table_view_groups.length if @mt_table_view_groups
|
24
|
-
end
|
25
|
-
0
|
26
|
-
end
|
27
|
-
|
28
|
-
# Number of cells
|
29
|
-
def tableView(tableView, numberOfRowsInSection:section)
|
30
|
-
return sectionAtIndex(section)[:cells].length if sectionAtIndex(section) && sectionAtIndex(section)[:cells]
|
31
|
-
0
|
32
|
-
end
|
33
|
-
|
34
|
-
def tableView(tableView, titleForHeaderInSection:section)
|
35
|
-
return sectionAtIndex(section)[:title] if sectionAtIndex(section) && sectionAtIndex(section)[:title]
|
36
|
-
end
|
37
|
-
|
38
|
-
# Set table_data_index if you want the right hand index column (jumplist)
|
39
|
-
def sectionIndexTitlesForTableView(tableView)
|
40
|
-
if self.respond_to?(:table_data_index)
|
41
|
-
self.table_data_index
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def tableView(tableView, cellForRowAtIndexPath:indexPath)
|
46
|
-
# Aah, magic happens here...
|
47
|
-
|
48
|
-
dataCell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
49
|
-
return UITableViewCell.alloc.init unless dataCell
|
50
|
-
dataCell[:cellStyle] ||= UITableViewCellStyleDefault
|
51
|
-
dataCell[:cellIdentifier] ||= "Cell"
|
52
|
-
cellIdentifier = dataCell[:cellIdentifier]
|
53
|
-
dataCell[:cellClass] ||= PM::TableViewCell
|
54
|
-
|
55
|
-
tableCell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
|
56
|
-
unless tableCell
|
57
|
-
tableCell = dataCell[:cellClass].alloc.initWithStyle(dataCell[:cellStyle], reuseIdentifier:cellIdentifier)
|
58
|
-
|
59
|
-
# Add optimizations here
|
60
|
-
tableCell.layer.masksToBounds = true if dataCell[:masksToBounds]
|
61
|
-
tableCell.backgroundColor = dataCell[:backgroundColor] if dataCell[:backgroundColor]
|
62
|
-
tableCell.selectionStyle = dataCell[:selectionStyle] if dataCell[:selectionStyle]
|
63
|
-
tableCell.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin
|
64
|
-
end
|
65
|
-
|
66
|
-
if dataCell[:cellClassAttributes]
|
67
|
-
set_cell_attributes tableCell, dataCell[:cellClassAttributes]
|
68
|
-
end
|
69
|
-
|
70
|
-
if dataCell[:accessoryView]
|
71
|
-
tableCell.accessoryView = dataCell[:accessoryView]
|
72
|
-
tableCell.accessoryView.autoresizingMask = UIViewAutoresizingFlexibleWidth
|
73
|
-
end
|
74
|
-
|
75
|
-
if dataCell[:accessory] && dataCell[:accessory] == :switch
|
76
|
-
switchView = UISwitch.alloc.initWithFrame(CGRectZero)
|
77
|
-
switchView.addTarget(self, action: "accessoryToggledSwitch:", forControlEvents:UIControlEventValueChanged);
|
78
|
-
switchView.on = true if dataCell[:accessoryDefault]
|
79
|
-
tableCell.accessoryView = switchView
|
80
|
-
end
|
81
|
-
|
82
|
-
if dataCell[:subtitle]
|
83
|
-
tableCell.detailTextLabel.text = dataCell[:subtitle]
|
84
|
-
tableCell.detailTextLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth
|
85
|
-
end
|
86
|
-
|
87
|
-
tableCell.selectionStyle = UITableViewCellSelectionStyleNone if dataCell[:no_select]
|
88
|
-
|
89
|
-
if dataCell[:remoteImage]
|
90
|
-
if tableCell.imageView.respond_to?("setImageWithURL:placeholderImage:")
|
91
|
-
url = dataCell[:remoteImage][:url]
|
92
|
-
url = NSURL.URLWithString(url) unless url.is_a?(NSURL)
|
93
|
-
placeholder = dataCell[:remoteImage][:placeholder]
|
94
|
-
placeholder = UIImage.imageNamed(placeholder) if placeholder.is_a?(String)
|
95
|
-
|
96
|
-
tableCell.image_size = dataCell[:remoteImage][:size] if dataCell[:remoteImage][:size] && tableCell.respond_to?("image_size=")
|
97
|
-
tableCell.imageView.setImageWithURL(url, placeholderImage: placeholder)
|
98
|
-
tableCell.imageView.layer.masksToBounds = true
|
99
|
-
tableCell.imageView.layer.cornerRadius = dataCell[:remoteImage][:radius]
|
100
|
-
else
|
101
|
-
ProMotion::MotionTable::Console.log("ProMotion Warning: to use remoteImage with TableScreen you need to include the CocoaPod 'SDWebImage'.", withColor: MotionTable::Console::RED_COLOR)
|
102
|
-
end
|
103
|
-
elsif dataCell[:image]
|
104
|
-
tableCell.imageView.layer.masksToBounds = true
|
105
|
-
tableCell.imageView.image = dataCell[:image][:image]
|
106
|
-
tableCell.imageView.layer.cornerRadius = dataCell[:image][:radius] if dataCell[:image][:radius]
|
107
|
-
end
|
108
|
-
|
109
|
-
if dataCell[:subViews]
|
110
|
-
tag_number = 0
|
111
|
-
dataCell[:subViews].each do |view|
|
112
|
-
# Remove an existing view at that tag number
|
113
|
-
tag_number += 1
|
114
|
-
existing_view = tableCell.viewWithTag(tag_number)
|
115
|
-
existing_view.removeFromSuperview if existing_view
|
116
|
-
|
117
|
-
# Add the subview if it exists
|
118
|
-
if view
|
119
|
-
view.tag = tag_number
|
120
|
-
tableCell.addSubview view
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
if dataCell[:details]
|
126
|
-
tableCell.addSubview dataCell[:details][:image]
|
127
|
-
end
|
128
|
-
|
129
|
-
if dataCell[:styles] && dataCell[:styles][:textLabel] && dataCell[:styles][:textLabel][:frame]
|
130
|
-
ui_label = false
|
131
|
-
tableCell.contentView.subviews.each do |view|
|
132
|
-
if view.is_a? UILabel
|
133
|
-
ui_label = true
|
134
|
-
view.text = dataCell[:styles][:textLabel][:text]
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
unless ui_label == true
|
139
|
-
label ||= UILabel.alloc.initWithFrame(CGRectZero)
|
140
|
-
set_cell_attributes label, dataCell[:styles][:textLabel]
|
141
|
-
tableCell.contentView.addSubview label
|
142
|
-
end
|
143
|
-
# hackery
|
144
|
-
tableCell.textLabel.textColor = UIColor.clearColor
|
145
|
-
else
|
146
|
-
cell_title = dataCell[:title]
|
147
|
-
cell_title ||= ""
|
148
|
-
tableCell.textLabel.text = cell_title
|
149
|
-
end
|
150
|
-
|
151
|
-
return tableCell
|
152
|
-
end
|
153
|
-
|
154
|
-
def sectionAtIndex(index)
|
155
|
-
if @mt_filtered
|
156
|
-
@mt_filtered_data.at(index)
|
157
|
-
else
|
158
|
-
@mt_table_view_groups.at(index)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def cellAtSectionAndIndex(section, index)
|
163
|
-
return sectionAtIndex(section)[:cells].at(index) if sectionAtIndex(section) && sectionAtIndex(section)[:cells]
|
164
|
-
end
|
165
|
-
|
166
|
-
def tableView(tableView, didSelectRowAtIndexPath:indexPath)
|
167
|
-
cell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
168
|
-
tableView.deselectRowAtIndexPath(indexPath, animated: true);
|
169
|
-
cell[:arguments] ||= {}
|
170
|
-
cell[:arguments][:cell] = cell if cell[:arguments].is_a?(Hash)
|
171
|
-
triggerAction(cell[:action], cell[:arguments]) if cell[:action]
|
172
|
-
end
|
173
|
-
|
174
|
-
def accessoryToggledSwitch(switch)
|
175
|
-
tableCell = switch.superview
|
176
|
-
indexPath = tableCell.superview.indexPathForCell(tableCell)
|
177
|
-
|
178
|
-
dataCell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
|
179
|
-
dataCell[:arguments] = {} unless dataCell[:arguments]
|
180
|
-
dataCell[:arguments][:value] = switch.isOn if dataCell[:arguments].is_a? Hash
|
181
|
-
|
182
|
-
triggerAction(dataCell[:accessoryAction], dataCell[:arguments]) if dataCell[:accessoryAction]
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
def triggerAction(action, arguments)
|
187
|
-
if self.respond_to?(action)
|
188
|
-
expectedArguments = self.method(action).arity
|
189
|
-
if expectedArguments == 0
|
190
|
-
self.send(action)
|
191
|
-
elsif expectedArguments == 1 || expectedArguments == -1
|
192
|
-
self.send(action, arguments)
|
193
|
-
else
|
194
|
-
ProMotion::MotionTable::Console.log("MotionTable warning: #{action} expects #{expectedArguments} arguments. Maximum number of required arguments for an action is 1.", withColor: MotionTable::Console::RED_COLOR)
|
195
|
-
end
|
196
|
-
else
|
197
|
-
ProMotion::MotionTable::Console.log(self, actionNotImplemented: action)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def set_cell_attributes(element, args = {})
|
202
|
-
args.each do |k, v|
|
203
|
-
if v.is_a? Hash
|
204
|
-
v.each do
|
205
|
-
sub_element = element.send("#{k}")
|
206
|
-
set_cell_attributes(sub_element, v)
|
207
|
-
end
|
208
|
-
# v.each do |k2, v2|
|
209
|
-
# sub_element = element.send("#{k}")
|
210
|
-
# sub_element.send("#{k2}=", v2) if sub_element.respond_to?("#{k2}=")
|
211
|
-
# end
|
212
|
-
else
|
213
|
-
element.send("#{k}=", v) if element.respond_to?("#{k}=")
|
214
|
-
end
|
215
|
-
end
|
216
|
-
element
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module ProMotion::MotionTable
|
2
|
-
module GroupedTable
|
3
|
-
include ::ProMotion::MotionTable::SectionedTable
|
4
|
-
|
5
|
-
def tableView
|
6
|
-
@tableView ||= UITableView.alloc.initWithFrame(self.view.frame, style:UITableViewStyleGrouped)
|
7
|
-
@tableView.dataSource = self;
|
8
|
-
@tableView.delegate = self;
|
9
|
-
return @tableView
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module ProMotion::MotionTable
|
2
|
-
module PlainTable
|
3
|
-
include ::ProMotion::MotionTable::SectionedTable
|
4
|
-
include ::ProMotion::MotionTable::SearchableTable
|
5
|
-
|
6
|
-
def tableView
|
7
|
-
@tableView ||= UITableView.alloc.initWithFrame(self.view.frame, style:UITableViewStylePlain)
|
8
|
-
@tableView.dataSource = self;
|
9
|
-
@tableView.delegate = self;
|
10
|
-
return @tableView
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module ProMotion::MotionTable
|
2
|
-
# @author Silas J Matson
|
3
|
-
#
|
4
|
-
# Provides coloring for displaying messages in console when running in the simulator
|
5
|
-
class Console
|
6
|
-
NAME = "MotionTable::Console"
|
7
|
-
DEFAULT_COLOR = [ '', '' ]
|
8
|
-
RED_COLOR = [ "\e[0;31m", "\e[0m" ] # Must be in double quotes
|
9
|
-
GREEN_COLOR = [ "\e[0;32m", "\e[0m" ]
|
10
|
-
PURPLE_COLOR = [ "\e[0;35m", "\e[0m" ]
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def log(obj, actionNotImplemented:action)
|
14
|
-
log " actionNotImplemented -- the action :#{action} is not implemented in #{obj.class.to_s}", withColor: RED_COLOR
|
15
|
-
end
|
16
|
-
|
17
|
-
def log(log, withColor:color)
|
18
|
-
puts color[0] + NAME + log + color[1]
|
19
|
-
end
|
20
|
-
|
21
|
-
def log(log)
|
22
|
-
log(log, withColor: DEFAULT_COLOR)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module ProMotion
|
2
|
-
module SystemHelper
|
3
|
-
module_function
|
4
|
-
|
5
|
-
def ios_version
|
6
|
-
UIDevice.currentDevice.systemVersion
|
7
|
-
end
|
8
|
-
|
9
|
-
def ios_version_is?(version)
|
10
|
-
ios_version == version
|
11
|
-
end
|
12
|
-
|
13
|
-
def ios_version_greater?(version)
|
14
|
-
ios_version > version
|
15
|
-
end
|
16
|
-
|
17
|
-
def ios_version_greater_eq?(version)
|
18
|
-
ios_version >= version
|
19
|
-
end
|
20
|
-
|
21
|
-
def ios_version_less?(version)
|
22
|
-
ios_version < version
|
23
|
-
end
|
24
|
-
|
25
|
-
def ios_version_less_eq?(version)
|
26
|
-
ios_version <= version
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|