motion-tab 0.0.1 → 0.1.2

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.
@@ -1,34 +1,41 @@
1
1
  module MotionTab
2
- module TabBar
3
- def createTabBarControllerFromData(data)
4
- main_view = MainViewController.alloc.initWithNibName(nil, bundle: nil)
5
- settings_view = SettingsViewController.alloc.initWithNibName(nil, bundle: nil)
6
-
7
- mt_tab_controllers = []
2
+ class TabBar
3
+ class << self
4
+ def createTabBarControllerFromData(data)
5
+ mt_tab_controllers = []
8
6
 
9
- data.each do |tab|
10
- tab[:badgeNumber] = 0 unless tab[:badgeNumber]
11
-
12
- viewController = tab[:viewController].alloc.init
13
- viewController.tabBarItem = tabBarIcon(tab[:systemIcon], tab[:badgeNumber]) if tab[:systemIcon]
14
-
15
- if tab[:navigationController]
16
- controller = UINavigationController.alloc.initWithRootViewController(viewController)
17
- else
18
- controller = viewController
19
- end
7
+ data.each do |tab|
8
+ tab[:badgeNumber] = 0 unless tab[:badgeNumber]
9
+ tab[:tag] = 0 unless tab[:tag]
10
+
11
+ viewController = tab[:viewController].alloc.init
12
+ viewController.tabBarItem = tabBarIcon(tab[:systemIcon], tab[:tag]) if tab[:systemIcon]
13
+ viewController.tabBarItem.badgeValue = tab[:badgeNumber].to_s unless tab[:badgeNumber].nil? || tab[:badgeNumber] <= 0
14
+
15
+ if tab[:navigationController]
16
+ controller = UINavigationController.alloc.initWithRootViewController(viewController)
17
+ else
18
+ controller = viewController
19
+ end
20
20
 
21
- mt_tab_controllers << controller
22
- end
21
+ if tab[:title]
22
+ controller.tabBarItem.title = tab[:title]
23
+ else
24
+ controller.tabBarItem.title = viewController.title
25
+ end
23
26
 
24
- tabBarController = UITabBarController.alloc.init
25
- tabBarController.viewControllers = mt_tab_controllers
27
+ mt_tab_controllers << controller
28
+ end
26
29
 
27
- return tabBarController
28
- end
30
+ tabBarController = UITabBarController.alloc.init
31
+ tabBarController.viewControllers = mt_tab_controllers
29
32
 
30
- def tabBarItem(icon, tag = 0)
31
- return UITabBarItem.alloc.initWithTabBarSystemItem(icon, tag: tag)
33
+ return tabBarController
34
+ end
35
+
36
+ def tabBarIcon(icon, tag = 0)
37
+ return UITabBarItem.alloc.initWithTabBarSystemItem(icon, tag: tag)
38
+ end
32
39
  end
33
40
  end
34
41
  end
@@ -1,3 +1,3 @@
1
1
  module MotionTab
2
- VERSION = "0.0.1" unless defined?(MotionTab::VERSION)
2
+ VERSION = "0.1.2" unless defined?(MotionTab::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-tab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.2
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: 2012-08-23 00:00:00.000000000 Z
12
+ date: 2012-08-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: MotionTab is a RubyMotion gem for making UITabBars easier to implement.
15
15
  email:
@@ -47,8 +47,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  version: '0'
48
48
  requirements: []
49
49
  rubyforge_project:
50
- rubygems_version: 1.8.24
50
+ rubygems_version: 1.8.22
51
51
  signing_key:
52
52
  specification_version: 3
53
53
  summary: ''
54
54
  test_files: []
55
+ has_rdoc: