cha_work 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ class UINavigationController
2
+
3
+ def push(view_controller)
4
+ self.pushViewController(view_controller, animated: true)
5
+ self
6
+ end
7
+
8
+ def pop(to_vc=nil)
9
+ if to_vc == :root
10
+ self.popToRootViewControllerAnimated(true)
11
+ elsif to_vc
12
+ self.popToViewController(to_vc, animated: true)
13
+ else
14
+ self.popViewControllerAnimated(true)
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,151 @@
1
+ module ProMotion
2
+ module ChaTable
3
+ include ProMotion::Styling
4
+ include ProMotion::Table::Refreshable
5
+
6
+ attr_reader :promotion_table_data
7
+
8
+ def table_view
9
+ self.view
10
+ end
11
+
12
+ def table_data
13
+ PM.logger.warn "@data is require" unless @data
14
+ @data || []
15
+ end
16
+
17
+ def screen_setup
18
+ set_up_refreshable
19
+ end
20
+
21
+ def set_up_refreshable
22
+ if self.class.respond_to?(:get_refreshable) && self.class.get_refreshable
23
+ if defined?(UIRefreshControl)
24
+ self.make_refreshable(self.class.get_refreshable_params)
25
+ else
26
+ PM.logger.warn "To use the refresh control on < iOS 6, you need to include the CocoaPod 'CKRefreshControl'."
27
+ end
28
+ end
29
+ end
30
+
31
+ def trigger_action(action, arguments, index_path)
32
+ return PM.logger.info "Action not implemented: #{action.to_s}" unless self.respond_to?(action)
33
+
34
+ case self.method(action).arity
35
+ when 0 then self.send(action) # Just call the method
36
+ when 2 then self.send(action, arguments, index_path) # Send arguments and index path
37
+ else self.send(action, arguments) # Send arguments
38
+ end
39
+ end
40
+
41
+ def update_section(index, bool=false)
42
+ self.view.reloadSections(NSIndexSet.indexSetWithIndex(index), withRowAnimation:bool)
43
+ end
44
+
45
+ ########## Cocoa touch methods #################
46
+ def numberOfSectionsInTableView(table_view)
47
+ if self.respond_to?(:section_count)
48
+ section_count
49
+ else
50
+ 1
51
+ end
52
+ end
53
+
54
+ # Number of cells
55
+ def tableView(table_view, numberOfRowsInSection:section)
56
+ if self.respond_to?(:row_count)
57
+ row_count(section)
58
+ else
59
+ table_data.length
60
+ end
61
+ end
62
+
63
+ def tableView(table_view, cellForRowAtIndexPath:index_path)
64
+ table_view_cell(index_path)
65
+ end
66
+
67
+ def tableView(table_view, willDisplayCell: table_cell, forRowAtIndexPath: index_path)
68
+ # data_cell = self.promotion_table_data.cell(index_path: index_path)
69
+ # set_attributes table_cell, data_cell[:properties] if data_cell[:properties]
70
+ # table_cell.send(:will_display) if table_cell.respond_to?(:will_display)
71
+ # table_cell.send(:restyle!) if table_cell.respond_to?(:restyle!) # Teacup compatibility
72
+ end
73
+
74
+ def tableView(table_view, heightForRowAtIndexPath:index_path)
75
+ cell_height(index_path)
76
+ end
77
+
78
+ def tableView(table_view, didSelectRowAtIndexPath:index_path)
79
+ cell_action(index_path) if self.respond_to?(:cell_action)
80
+ end
81
+
82
+ # Section view methods
83
+ def tableView(table_view, viewForHeaderInSection: index)
84
+ header_view(index) if self.respond_to?(:header_view)
85
+ end
86
+
87
+ def tableView(table_view, heightForHeaderInSection: index)
88
+ if self.respond_to?(:header_height)
89
+ header_height(index)
90
+ else
91
+ 0
92
+ end
93
+ end
94
+
95
+ def update_table_view
96
+ self.view.reloadData
97
+ end
98
+
99
+ protected
100
+
101
+ def map_cell_editing_style(symbol)
102
+ {
103
+ none: UITableViewCellEditingStyleNone,
104
+ delete: UITableViewCellEditingStyleDelete,
105
+ insert: UITableViewCellEditingStyleInsert
106
+ }[symbol] || symbol || UITableViewCellEditingStyleNone
107
+ end
108
+
109
+ def map_row_animation_symbol(symbol)
110
+ symbol ||= UITableViewRowAnimationAutomatic
111
+ {
112
+ fade: UITableViewRowAnimationFade,
113
+ right: UITableViewRowAnimationRight,
114
+ left: UITableViewRowAnimationLeft,
115
+ top: UITableViewRowAnimationTop,
116
+ bottom: UITableViewRowAnimationBottom,
117
+ none: UITableViewRowAnimationNone,
118
+ middle: UITableViewRowAnimationMiddle,
119
+ automatic: UITableViewRowAnimationAutomatic
120
+ }[symbol] || symbol || UITableViewRowAnimationAutomatic
121
+ end
122
+
123
+ module TableClassMethods
124
+ def table_style
125
+ UITableViewStylePlain
126
+ end
127
+
128
+
129
+
130
+ # Refreshable
131
+ def refreshable(params = {})
132
+ @refreshable_params = params
133
+ @refreshable = true
134
+ end
135
+
136
+ def get_refreshable
137
+ @refreshable ||= false
138
+ end
139
+
140
+ def get_refreshable_params
141
+ @refreshable_params ||= nil
142
+ end
143
+
144
+ end
145
+
146
+ def self.included(base)
147
+ base.extend(TableClassMethods)
148
+ end
149
+
150
+ end
151
+ end
@@ -0,0 +1,6 @@
1
+ module ProMotion
2
+ class ChaTableScreen < TableViewController
3
+ include ProMotion::ScreenModule
4
+ include ProMotion::ChaTable
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module ChaWork
2
+ VERSION = "0.1" unless defined?(ChaWork::VERSION)
3
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cha_work
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - smartweb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '10.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '10.0'
27
+ description: Inspired by Sugarcube、BubbleWrap、ProMotion.
28
+ email: sam@chamobile.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/cha_work/basic.rb
34
+ - lib/cha_work/ChaMenu/cha_menu.rb
35
+ - lib/cha_work/chawork.rb
36
+ - lib/cha_work/msg.rb
37
+ - lib/cha_work/persistence.rb
38
+ - lib/cha_work/sugar/fixnum.rb
39
+ - lib/cha_work/sugar/notificationcenter.rb
40
+ - lib/cha_work/sugar/nsdate.rb
41
+ - lib/cha_work/sugar/nsstring.rb
42
+ - lib/cha_work/sugar/symbol.rb
43
+ - lib/cha_work/sugar/time.rb
44
+ - lib/cha_work/sugar/uiactionsheet.rb
45
+ - lib/cha_work/sugar/uibutton.rb
46
+ - lib/cha_work/sugar/uicontrol.rb
47
+ - lib/cha_work/sugar/uiimageview.rb
48
+ - lib/cha_work/sugar/uilabel.rb
49
+ - lib/cha_work/sugar/uitableview.rb
50
+ - lib/cha_work/sugar/uiview.rb
51
+ - lib/cha_work/sugar/uiviewcontroller.rb
52
+ - lib/cha_work/table/table.rb
53
+ - lib/cha_work/table/table_screen.rb
54
+ - lib/cha_work/version.rb
55
+ - lib/cha_work.rb
56
+ - README.md
57
+ homepage: http://github.com/smartweb/ChaWork
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.0.14
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Rubymotion Helper by ChaMobile
81
+ test_files: []