dynamics 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/base/Rakefile CHANGED
@@ -10,7 +10,7 @@ require 'dynamics'
10
10
  Motion::Project::App.setup do |app|
11
11
  app.name = ''
12
12
  app.delegate_class = ''
13
- app.icons = %w{icon.png}
13
+ app.icons = %w{icon@57.png icon@74.png icon@114.png icon@144.png}
14
14
 
15
15
  Dynamics::setup_framework(app, File.dirname(__FILE__))
16
16
  end
@@ -2,8 +2,10 @@
2
2
  class Application < Dynamics::Application
3
3
 
4
4
  def initialize
5
- #super('Navigation')
6
- #super('Tab Bar')
7
- super('Tab Nav')
5
+ super
6
+
7
+ # self.layout = 'Navigation'
8
+ # self.layout = 'Tab Bar'
9
+ self.layout = 'Tab Nav'
8
10
  end
9
11
  end
@@ -0,0 +1,4 @@
1
+
2
+ class HomeController < Dynamics::Controller
3
+
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ class HomeView < Dynamics::Window
3
+
4
+ end
Binary file
File without changes
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -2,39 +2,57 @@
2
2
  module Dynamics
3
3
 
4
4
  class Application
5
-
5
+ attr_accessor :layout
6
+
6
7
  private
7
-
8
- def initialize(layout)
9
- @layout = layout
10
- end
11
8
 
12
9
  def application(application, didFinishLaunchingWithOptions:launchOptions)
13
- @window = MainView.alloc.initWithFrame(UIScreen.mainScreen.bounds)
10
+ @window = HomeView.alloc.initWithFrame(UIScreen.mainScreen.bounds)
14
11
  @window.makeKeyAndVisible
15
- if @layout == 'Navigation'
12
+ case @layout
13
+ when 'Navigation'
16
14
  # @@Navigation@@
17
15
  # @@End@@
18
- elsif @layout == 'Tab Bar'
16
+ when 'Tab Bar'
19
17
  # @@Tab Bar@@
20
18
  # @@End@@
21
- elsif @layout == 'Tab Nav'
19
+ when 'Tab Nav'
22
20
  # @@Tab Nav@@
23
21
  # @@End@@
24
22
  else
25
- @window.rootViewController = MainController.alloc.initWithNibName(nil, bundle: nil)
23
+ @window.rootViewController = HomeController.alloc.initWithNibName(nil, bundle: nil)
26
24
  end
27
25
  true
28
26
  end
29
27
  end
30
28
 
31
29
  class Controller < UIViewController
32
- attr_accessor :next_controller, :next_view
33
-
34
- def name
35
- self.class.name.underscore.split('_')[0].capitalize
36
- end
30
+ attr_accessor :name, :next_controller, :next_view
37
31
 
32
+ def initWithNibName(name, bundle: bundle)
33
+ super
34
+
35
+ @@index = 0
36
+ @name = self.class.name.underscore.split('_')[0].capitalize
37
+ case App.delegate.layout
38
+ when 'Navigation'
39
+ if @name == 'Home'
40
+ self.navigationItem.title = App.name
41
+ end
42
+ when 'Tab Bar'
43
+ self.tabBarItem = UITabBarItem.alloc.initWithTitle(@name, image: UIImage.imageNamed(@name.downcase + '.png'), tag: @@index)
44
+ when 'Tab Nav'
45
+ if @name == 'Home'
46
+ self.navigationItem.title = App.name
47
+ else
48
+ self.navigationItem.title = @name
49
+ end
50
+ self.tabBarItem = UITabBarItem.alloc.initWithTitle(@name, image: UIImage.imageNamed(@name.downcase + '.png'), tag: @@index)
51
+ end
52
+ @@index += 1
53
+ self
54
+ end
55
+
38
56
  private
39
57
 
40
58
  def loadView
@@ -47,17 +65,24 @@ module Dynamics
47
65
 
48
66
  def viewDidLoad
49
67
  super
50
- if name == 'Main'
51
- self.title = App.name
52
- self.view.backgroundColor = UIColor.whiteColor
68
+
69
+ case App.delegate.layout
70
+ when 'Navigation'
71
+ if !next_controller.nil?
72
+ navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithTitle(next_controller.name, style: UIBarButtonItemStyleBordered, target: self, action: 'nextScreen')
73
+ end
74
+ end
75
+
76
+ case @name
77
+ when 'Home'
78
+ self.view.backgroundColor = UIColor.whiteColor
53
79
  else
54
- self.title = name
55
80
  self.view.backgroundColor = UIColor.grayColor
56
- end
81
+ end
57
82
  end
58
83
 
59
84
  def nextScreen
60
- self.navigationController.pushViewController(@next_controller, animated: true)
85
+ navigationController.pushViewController(@next_controller, animated: true)
61
86
  end
62
87
  end
63
88
 
data/lib/dynamics.rb CHANGED
@@ -41,8 +41,8 @@ module Dynamics
41
41
  controllers_dir = File.join(app_dir, 'controllers')
42
42
  Dir.mkdir(controllers_dir)
43
43
 
44
- f = File.new(File.join(controllers_dir, 'main_controller.rb'), 'w+')
45
- f.write(render_code(File.join(base_dir, 'app', 'controllers', 'main_controller.rb')))
44
+ f = File.new(File.join(controllers_dir, 'home_controller.rb'), 'w+')
45
+ f.write(render_code(File.join(base_dir, 'app', 'controllers', 'home_controller.rb')))
46
46
  f.close
47
47
 
48
48
  f = File.new(File.join(controllers_dir, 'sub1_controller.rb'), 'w+')
@@ -58,8 +58,8 @@ module Dynamics
58
58
  views_dir = File.join(app_dir, 'views')
59
59
  Dir.mkdir(views_dir)
60
60
 
61
- f = File.new(File.join(views_dir, 'main_view.rb'), 'w+')
62
- f.write(render_code(File.join(base_dir, 'app', 'views', 'main_view.rb')))
61
+ f = File.new(File.join(views_dir, 'home_view.rb'), 'w+')
62
+ f.write(render_code(File.join(base_dir, 'app', 'views', 'home_view.rb')))
63
63
  f.close
64
64
 
65
65
  f = File.new(File.join(views_dir, 'sub1_view.rb'), 'w+')
@@ -72,9 +72,33 @@ module Dynamics
72
72
 
73
73
  # Resources
74
74
 
75
- f = File.new(File.join(resources_dir, 'icon.png'), 'w+')
76
- f.write(render_code(File.join(base_dir, 'resources', 'icon.png')))
75
+ f = File.new(File.join(resources_dir, 'icon-57.png'), 'w+')
76
+ f.write(render_code(File.join(base_dir, 'resources', 'icon@57.png')))
77
77
  f.close
78
+
79
+ f = File.new(File.join(resources_dir, 'icon-74.png'), 'w+')
80
+ f.write(render_code(File.join(base_dir, 'resources', 'icon@74.png')))
81
+ f.close
82
+
83
+ f = File.new(File.join(resources_dir, 'icon-114.png'), 'w+')
84
+ f.write(render_code(File.join(base_dir, 'resources', 'icon@114.png')))
85
+ f.close
86
+
87
+ f = File.new(File.join(resources_dir, 'icon-144.png'), 'w+')
88
+ f.write(render_code(File.join(base_dir, 'resources', 'icon@144.png')))
89
+ f.close
90
+
91
+ f = File.new(File.join(resources_dir, 'home.png'), 'w+')
92
+ f.write(render_code(File.join(base_dir, 'resources', 'home.png')))
93
+ f.close
94
+
95
+ f = File.new(File.join(resources_dir, 'sub1.png'), 'w+')
96
+ f.write(render_code(File.join(base_dir, 'resources', 'sub1.png')))
97
+ f.close
98
+
99
+ f = File.new(File.join(resources_dir, 'sub2.png'), 'w+')
100
+ f.write(render_code(File.join(base_dir, 'resources', 'sub2.png')))
101
+ f.close
78
102
  end
79
103
  end
80
104
 
@@ -115,8 +139,8 @@ private
115
139
  controllers = []
116
140
  for controller in Dir.glob(File.join(path, 'app', 'controllers', '*.rb'))
117
141
  filename = File.basename(controller)
118
- if filename != 'main_controller.rb'
119
- controllers << {:filename => filename, :class_name => camelize(filename.split('.')[0]), :name => filename.split('_')[0].capitalize}
142
+ if filename != 'home_controller.rb'
143
+ controllers << {:filename => filename, :name => filename.split('_')[0].capitalize}
120
144
  end
121
145
  end
122
146
  controllers
@@ -124,24 +148,18 @@ private
124
148
 
125
149
  def self.navigation_code(path)
126
150
  code = "# @@Navigation@@\n"
127
- code += " main_controller = MainController.alloc.initWithNibName(nil, bundle: nil)\n"
151
+ code += " home_controller = HomeController.alloc.initWithNibName(nil, bundle: nil)\n"
128
152
  controllers = find_controllers(path)
129
- if controllers.size > 0
130
- code += " main_controller.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithTitle('#{controllers.first[:name]}', style: UIBarButtonItemStyleBordered, target:main_controller, action:'nextScreen')\n"
131
- end
132
153
  i = 1
133
- prev_controller = 'main_controller'
154
+ prev_controller = 'home_controller'
134
155
  for controller in controllers
135
- code += " sub#{i}_controller = #{controller[:class_name]}.alloc.initWithNibName(nil, bundle: nil)\n"
156
+ code += " sub#{i}_controller = #{controller[:name]}Controller.alloc.initWithNibName(nil, bundle: nil)\n"
136
157
  code += " sub#{i}_controller.next_view = #{controller[:name]}View.alloc.initWithFrame(UIScreen.mainScreen.bounds)\n"
137
158
  code += " #{prev_controller}.next_controller = sub#{i}_controller\n"
138
- if controller != controllers.last
139
- code += " sub#{i}_controller.navigationItem.rightBarButtonItem = UIBarButtonItem.alloc.initWithTitle('#{controllers[i][:name]}', style: UIBarButtonItemStyleBordered, target:sub#{i}_controller, action:'nextScreen')\n"
140
- prev_controller = "sub#{i}_controller"
141
- i += 1
142
- end
159
+ prev_controller = "sub#{i}_controller"
160
+ i += 1
143
161
  end
144
- code += " @window.rootViewController = UINavigationController.alloc.initWithRootViewController(main_controller)\n"
162
+ code += " @window.rootViewController = UINavigationController.alloc.initWithRootViewController(home_controller)\n"
145
163
  code += " # @@End@@"
146
164
  end
147
165
 
@@ -154,15 +172,13 @@ private
154
172
 
155
173
  def self.tab_bar_code(path)
156
174
  code = "# @@Tab Bar@@\n"
157
- controllers_list = 'main_controller'
158
- code += " main_controller = MainController.alloc.initWithNibName(nil, bundle: nil)\n"
159
- code += " main_controller.title = main_controller.name\n"
175
+ controllers_list = 'home_controller'
176
+ code += " home_controller = HomeController.alloc.initWithNibName(nil, bundle: nil)\n"
160
177
  i = 1
161
178
  controllers = find_controllers(path)
162
179
  for controller in controllers
163
180
  controllers_list += ", sub#{i}_controller"
164
- code += " sub#{i}_controller = #{controller[:class_name]}.alloc.initWithNibName(nil, bundle: nil)\n"
165
- code += " sub#{i}_controller.title = sub#{i}_controller.name\n"
181
+ code += " sub#{i}_controller = #{controller[:name]}Controller.alloc.initWithNibName(nil, bundle: nil)\n"
166
182
  i += 1
167
183
  end
168
184
  code += " tab_controller = UITabBarController.alloc.initWithNibName(nil, bundle: nil)\n"
@@ -173,16 +189,14 @@ private
173
189
 
174
190
  def self.tab_nav_code(path)
175
191
  code = "# @@Tab Nav@@\n"
176
- controllers_list = 'main_nav_controller'
177
- code += " main_controller = MainController.alloc.initWithNibName(nil, bundle: nil)\n"
178
- code += " main_controller.title = main_controller.name\n"
179
- code += " main_nav_controller = UINavigationController.alloc.initWithRootViewController(main_controller)\n"
192
+ controllers_list = 'home_nav_controller'
193
+ code += " home_controller = HomeController.alloc.initWithNibName(nil, bundle: nil)\n"
194
+ code += " home_nav_controller = UINavigationController.alloc.initWithRootViewController(home_controller)\n"
180
195
  i = 1
181
196
  controllers = find_controllers(path)
182
197
  for controller in controllers
183
198
  controllers_list += ", sub#{i}_nav_controller"
184
- code += " sub#{i}_controller = #{controller[:class_name]}.alloc.initWithNibName(nil, bundle: nil)\n"
185
- code += " sub#{i}_controller.title = sub#{i}_controller.name\n"
199
+ code += " sub#{i}_controller = #{controller[:name]}Controller.alloc.initWithNibName(nil, bundle: nil)\n"
186
200
  code += " sub#{i}_nav_controller = UINavigationController.alloc.initWithRootViewController(sub#{i}_controller)\n"
187
201
  i += 1
188
202
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamics
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ng Say Joe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-18 00:00:00 Z
18
+ date: 2012-08-19 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: A framework for developing RubyMotion applications quickly.
@@ -30,13 +30,19 @@ files:
30
30
  - lib/dynamics.rb
31
31
  - base/Rakefile
32
32
  - base/app/application.rb
33
- - base/app/controllers/main_controller.rb
33
+ - base/app/controllers/home_controller.rb
34
34
  - base/app/controllers/sub1_controller.rb
35
35
  - base/app/controllers/sub2_controller.rb
36
- - base/app/views/main_view.rb
36
+ - base/app/views/home_view.rb
37
37
  - base/app/views/sub1_view.rb
38
38
  - base/app/views/sub2_view.rb
39
- - base/resources/icon.png
39
+ - base/resources/home.png
40
+ - base/resources/icon@114.png
41
+ - base/resources/icon@144.png
42
+ - base/resources/icon@57.png
43
+ - base/resources/icon@74.png
44
+ - base/resources/sub1.png
45
+ - base/resources/sub2.png
40
46
  - base/templates/dynamics.rb
41
47
  - bin/dynamics
42
48
  homepage: http://www.dynamics.io/
@@ -1,4 +0,0 @@
1
-
2
- class MainController < Dynamics::Controller
3
-
4
- end
@@ -1,4 +0,0 @@
1
-
2
- class MainView < Dynamics::Window
3
-
4
- end