ProMotion 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ module ProMotion
2
+ class NavigationController < UINavigationController
3
+
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ module ProMotion
2
+ class TableViewController < UITableViewController
3
+ attr_accessor :screen
4
+
5
+ def viewDidLoad
6
+ super
7
+ self.screen.view_did_load if self.screen && self.screen.respond_to?(:view_did_load)
8
+ end
9
+
10
+ def viewWillAppear(animated)
11
+ super
12
+ self.screen.view_will_appear(animated) if self.screen && self.screen.respond_to?(:view_will_appear)
13
+ end
14
+
15
+ def viewDidAppear(animated)
16
+ super
17
+ self.screen.view_did_appear(animated) if self.screen && self.screen.respond_to?(:view_did_appear)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module ProMotion
2
+ class ViewController < UIViewController
3
+ attr_accessor :screen
4
+
5
+ def viewDidLoad
6
+ super
7
+ self.screen.view_did_load if self.screen && self.screen.respond_to?(:view_did_load)
8
+ end
9
+
10
+ def viewWillAppear(animated)
11
+ super
12
+ self.screen.view_will_appear(animated) if self.screen && self.screen.respond_to?(:view_will_appear)
13
+ end
14
+
15
+ def viewDidAppear(animated)
16
+ super
17
+ self.screen.view_did_appear(animated) if self.screen && self.screen.respond_to?(:view_did_appear)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module ProMotion
2
+ class MeasureHelper
3
+ class << self
4
+ def content_height(view)
5
+ height = 0
6
+ view.subviews.each do |sub_view|
7
+ y = sub_view.frame.origin.y
8
+ h = sub_view.frame.size.height
9
+ if (y + h) > height
10
+ height = y + h
11
+ end
12
+ end
13
+ height
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ module ProMotion
2
+ class TabBar
3
+ class << self
4
+ def tab_bar_item(args = {})
5
+ title = "Untitled"
6
+ title = args[:title] if args[:title]
7
+ args[:tag] ||= 0
8
+
9
+ tb_item = tab_bar_icon(args[:system_icon], args[:tag]) if args[:system_icon]
10
+ tb_item = tab_bar_icon_custom(title, args[:icon], args[:tag]) if args[:icon]
11
+
12
+ if tb_item
13
+ tb_item.badgeValue = args[:badge_number].to_s unless args[:badge_number].nil? || tab[:badge_number] <= 0
14
+
15
+ return tb_item
16
+ end
17
+ nil
18
+ end
19
+
20
+ def tab_bar_icon(icon, tag)
21
+ return UITabBarItem.alloc.initWithTabBarSystemItem(icon, tag: tag)
22
+ end
23
+
24
+ def tab_bar_icon_custom(title, image_name, tag)
25
+ icon_image = UIImage.imageNamed(image_name)
26
+ return UITabBarItem.alloc.initWithTitle(title, image:icon_image, tag:tag)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,56 @@
1
+ module ProMotion::MotionTable
2
+ module SearchableTable
3
+ def makeSearchable(params={})
4
+ $stderr.puts params
5
+
6
+ params[:frame] ||= CGRectMake(0, 0, 320, 44)
7
+ params[:contentController] ||= self
8
+ params[:delegate] ||= self
9
+ params[:searchResultsDataSource] ||= self
10
+ params[:searchResultsDelegate] ||= self
11
+
12
+ searchBar = UISearchBar.alloc.initWithFrame(params[:frame])
13
+ if params[:searchBar] && params[:searchBar][:placeholder]
14
+ searchBar.placeholder = params[:searchBar][:placeholder]
15
+ end
16
+
17
+ @contactsSearchDisplayController = UISearchDisplayController.alloc.initWithSearchBar(searchBar, contentsController: params[:contentController])
18
+ @contactsSearchDisplayController.delegate = params[:delegate]
19
+ @contactsSearchDisplayController.searchResultsDataSource = params[:searchResultsDataSource]
20
+ @contactsSearchDisplayController.searchResultsDelegate = params[:searchResultsDelegate]
21
+
22
+ self.tableView.tableHeaderView = searchBar
23
+ end
24
+
25
+ def searchDisplayController(controller, shouldReloadTableForSearchString:searchString)
26
+ @mt_table_view_groups = []
27
+
28
+ @original_data.each do |section|
29
+ newSection = {}
30
+ newSection[:cells] = []
31
+
32
+ section[:cells].each do |cell|
33
+ if cell[:title].to_s.downcase.strip.include?(searchString.downcase.strip)
34
+ newSection[:cells] << cell
35
+ end
36
+ end
37
+
38
+ if newSection.count > 0
39
+ newSection[:title] = section[:title]
40
+ @mt_table_view_groups << newSection
41
+ end
42
+ end
43
+
44
+ true
45
+ end
46
+
47
+ def searchDisplayControllerWillEndSearch(controller)
48
+ @mt_table_view_groups = @original_data.clone
49
+ @original_data = nil
50
+ end
51
+
52
+ def searchDisplayControllerWillBeginSearch(controller)
53
+ @original_data = @mt_table_view_groups.clone
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,108 @@
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
+ @tableView.reloadData
13
+ end
14
+
15
+ def setTableViewData(data)
16
+ @mt_table_view_groups = data
17
+ end
18
+
19
+ def numberOfSectionsInTableView(tableView)
20
+ return @mt_table_view_groups.length if @mt_table_view_groups
21
+ 0
22
+ end
23
+
24
+ # Number of cells
25
+ def tableView(tableView, numberOfRowsInSection:section)
26
+ return sectionAtIndex(section)[:cells].length
27
+ end
28
+
29
+ def tableView(tableView, titleForHeaderInSection:section)
30
+ return sectionAtIndex(section)[:title]
31
+ end
32
+
33
+ # Set table_data_index if you want the right hand index column (jumplist)
34
+ def sectionIndexTitlesForTableView(tableView)
35
+ self.table_data_index if respond_to? :table_data_index
36
+ end
37
+
38
+ def tableView(tableView, cellForRowAtIndexPath:indexPath)
39
+ dataCell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
40
+ dataCell[:cellStyle] ||= UITableViewCellStyleDefault
41
+
42
+ cellIdentifier = "Cell"
43
+
44
+ tableCell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)
45
+ unless tableCell
46
+ tableCell = UITableViewCell.alloc.initWithStyle(dataCell[:cellStyle], reuseIdentifier:cellIdentifier)
47
+ tableCell.accessoryView = dataCell[:accessoryView] if dataCell[:accessoryView]
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
55
+
56
+ if dataCell[:subtitle]
57
+ tableCell.detailTextLabel.text = dataCell[:subtitle]
58
+ end
59
+ end
60
+
61
+ tableCell.text = dataCell[:title]
62
+ return tableCell
63
+ end
64
+
65
+ def sectionAtIndex(index)
66
+ @mt_table_view_groups.at(index)
67
+ end
68
+
69
+ def cellAtSectionAndIndex(section, index)
70
+ return sectionAtIndex(section)[:cells].at(index)
71
+ end
72
+
73
+ def tableView(tableView, didSelectRowAtIndexPath:indexPath)
74
+ cell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
75
+ tableView.deselectRowAtIndexPath(indexPath, animated: true);
76
+ triggerAction(cell[:action], cell[:arguments]) if cell[:action]
77
+ end
78
+
79
+ def accessoryToggledSwitch(switch)
80
+ tableCell = switch.superview
81
+ indexPath = tableCell.superview.indexPathForCell(tableCell)
82
+
83
+ dataCell = cellAtSectionAndIndex(indexPath.section, indexPath.row)
84
+ dataCell[:arguments] = {} unless dataCell[:arguments]
85
+ dataCell[:arguments][:value] = switch.isOn
86
+
87
+ triggerAction(dataCell[:accessoryAction], dataCell[:arguments]) if dataCell[:accessoryAction]
88
+
89
+ end
90
+
91
+ def triggerAction(action, arguments)
92
+ $stderr.puts "Action: #{action.to_s} and args #{arguments.to_s}"
93
+ if self.respond_to?(action)
94
+ expectedArguments = self.method(action).arity
95
+ if expectedArguments == 0
96
+ self.send(action)
97
+ elsif expectedArguments == 1
98
+ self.send(action, arguments)
99
+ else
100
+ MotionTable::Console.log("MotionTable warning: #{action} expects #{expectedArguments} arguments. Maximum number of required arguments for an action is 1.", withColor: MotionTable::Console::RED_COLOR)
101
+ end
102
+ else
103
+ MotionTable::Console.log(self, actionNotImplemented: action)
104
+ end
105
+ end
106
+
107
+ end
108
+ end
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,13 @@
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,3 +1,3 @@
1
1
  module ProMotion
2
- VERSION = "0.0.2" unless defined?(MotionTable::VERSION)
2
+ VERSION = "0.1.0" unless defined?(ProMotion::VERSION)
3
3
  end
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.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,10 +11,9 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-31 00:00:00.000000000 Z
14
+ date: 2012-09-06 00:00:00.000000000 Z
15
15
  dependencies: []
16
- description: ProMotion is a new way to organize RubyMotion apps. Currently a proof
17
- of concept.
16
+ description: ProMotion is a new way to organize RubyMotion apps.
18
17
  email:
19
18
  - jamon@clearsightstudio.com
20
19
  executables: []
@@ -27,9 +26,26 @@ files:
27
26
  - ProMotion.gemspec
28
27
  - README.md
29
28
  - Rakefile
29
+ - app/app_delegate.rb
30
+ - app/screens/home_screen.rb
31
+ - app/screens/test_screen.rb
30
32
  - lib/ProMotion.rb
31
33
  - lib/ProMotion/AppDelegate.rb
32
- - lib/ProMotion/Screen.rb
34
+ - lib/ProMotion/Console.rb
35
+ - lib/ProMotion/ProMotion.rb
36
+ - lib/ProMotion/classes/Element.rb
37
+ - lib/ProMotion/classes/Screen.rb
38
+ - lib/ProMotion/classes/TableScreen.rb
39
+ - lib/ProMotion/ext/NavigationController.rb
40
+ - lib/ProMotion/ext/TableViewController.rb
41
+ - lib/ProMotion/ext/ViewController.rb
42
+ - lib/ProMotion/helpers/MeasureHelper.rb
43
+ - lib/ProMotion/helpers/TabBar.rb
44
+ - 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
33
49
  - lib/ProMotion/version.rb
34
50
  homepage: https://github.com/clearsightstudio/ProMotion
35
51
  licenses: []
@@ -51,10 +67,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
67
  version: '0'
52
68
  requirements: []
53
69
  rubyforge_project:
54
- rubygems_version: 1.8.24
70
+ rubygems_version: 1.8.22
55
71
  signing_key:
56
72
  specification_version: 3
57
73
  summary: ProMotion is a new way to organize RubyMotion apps. Instead of dealing with
58
- UIViewControllers and UIViews, you work with Screens. Screens are a logical way
59
- to think of your app -- similar in some ways to Storyboards.
74
+ UIViewControllers, you work with Screens. Screens are a logical way to think of
75
+ your app -- similar in some ways to Storyboards.
60
76
  test_files: []
77
+ has_rdoc:
@@ -1,11 +0,0 @@
1
- module ProMotion
2
- class Screen
3
- def open_with_nav_bar
4
- # Create UINavigationController, insert view
5
- end
6
-
7
- def open
8
- # Push view onto existing UINavigationController
9
- end
10
- end
11
- end