motion-bureau 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/bureau.gemspec +13 -0
- data/lib/bureau.rb +9 -0
- data/lib/bureau/bureau.rb +183 -0
- data/lib/bureau/bureau_controller.rb +9 -0
- data/motion-bureau-0.0.1.gem +0 -0
- metadata +64 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: c8f0a04f08d9c4d0c1968b34e1c45c0287c9350a
|
|
4
|
+
data.tar.gz: 0e40710b6c0e53784fad2edad0bdb7e0276338b7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 492c804f1a5a3060e72371404abd08799e018613cdbb0d2f532421111dc500ad6e04754f759e01aa3106d54b1b33a1db0a4f0ce3c75197c6112b59df217906b5
|
|
7
|
+
data.tar.gz: 189d1a297bf192ab4ee532ba4f5fdcb6c878783f89960dcd372055d8ee263eaf20d4ab9634fef7c7c5fc0edf3007252bda92387242ae9a3932ca75dce2eadb0d
|
data/.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.DS_Store
|
data/bureau.gemspec
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
Gem::Specification.new do |s|
|
|
3
|
+
s.name = "motion-bureau"
|
|
4
|
+
s.version = "0.0.2"
|
|
5
|
+
s.authors = ["Nick Pachulski"]
|
|
6
|
+
s.email = ["hello@nickpachulski.com"]
|
|
7
|
+
s.homepage = "https://github.com/pachun/bureau"
|
|
8
|
+
s.summary = "A Rubymotion Sidemenu Animator"
|
|
9
|
+
s.description = "A Rubymotion Sidemenu Animator"
|
|
10
|
+
s.add_dependency 'geomotion'
|
|
11
|
+
s.files = `git ls-files`.split($\)
|
|
12
|
+
s.require_paths = ["lib"]
|
|
13
|
+
end
|
data/lib/bureau.rb
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
module Bureau
|
|
2
|
+
class Bureau < UIViewController
|
|
3
|
+
attr_accessor :reuse_id, :bureau_table,
|
|
4
|
+
:bureau_sections, :active_controller, :active_view_origin,
|
|
5
|
+
:drawer_width, :drawer_height, :state, :slide_duration
|
|
6
|
+
|
|
7
|
+
def initialize(bureau_sections, options = {})
|
|
8
|
+
setup_bureau_table
|
|
9
|
+
@state = options[:state] || :closed
|
|
10
|
+
@drawer_width = options[:drawer_width] || 250
|
|
11
|
+
@drawer_height = options[:drawer_height] || 44
|
|
12
|
+
@slide_duration = options[:slide_duration] || 0.3
|
|
13
|
+
@bureau_sections = bureau_sections
|
|
14
|
+
initialize_controllers
|
|
15
|
+
update_active_controller
|
|
16
|
+
init
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def viewDidLoad
|
|
20
|
+
super
|
|
21
|
+
view.backgroundColor = UIColor.whiteColor
|
|
22
|
+
view.addSubview(@bureau_sections_table.tableView)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def toggle
|
|
26
|
+
if @state == :open
|
|
27
|
+
close
|
|
28
|
+
else
|
|
29
|
+
open
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def close
|
|
34
|
+
UIView.animateWithDuration(@slide_duration, delay:0, options:0, animations: lambda do
|
|
35
|
+
@active_controller.view.frame = @active_controller.view.frame.left(@drawer_width)
|
|
36
|
+
end, completion: nil)
|
|
37
|
+
@state = :closed
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def open
|
|
41
|
+
UIView.animateWithDuration(@slide_duration, delay:0, options:0, animations: lambda do
|
|
42
|
+
@active_controller.view.frame = @active_controller.view.frame.right(@drawer_width)
|
|
43
|
+
end, completion: nil)
|
|
44
|
+
@state = :open
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
def setup_bureau_table
|
|
49
|
+
@reuse_id = 'side slider cell'
|
|
50
|
+
@bureau_sections_table = UITableViewController.alloc.initWithStyle(UITableViewStyleGrouped)
|
|
51
|
+
@bureau_sections_table.tableView.delegate = self
|
|
52
|
+
@bureau_sections_table.tableView.dataSource = self
|
|
53
|
+
@bureau_sections_table.tableView.backgroundColor = UIColor.whiteColor
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def update_active_controller
|
|
57
|
+
if @active_controller != open_drawer[:controller]
|
|
58
|
+
remove_active_controller
|
|
59
|
+
@active_controller = open_drawer[:controller]
|
|
60
|
+
add_active_controller
|
|
61
|
+
update_active_view
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def remove_active_controller
|
|
66
|
+
if @active_controller.nil?
|
|
67
|
+
@active_view_origin = (@state == :closed ? CGPoint.make(x:0, y:0) : CGPoint.make(x:@drawer_width, y:0))
|
|
68
|
+
else
|
|
69
|
+
@active_view_origin = @active_controller.view.frame.origin
|
|
70
|
+
@active_controller.view.removeFromSuperview
|
|
71
|
+
@active_controller.removeFromParentViewController
|
|
72
|
+
end
|
|
73
|
+
# puts "active: #{@active_view_controller} @ (#{@active_view_origin.x},#{@active_view_origin.y})"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def add_active_controller
|
|
77
|
+
addChildViewController(@active_controller)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def update_active_view
|
|
81
|
+
view.addSubview(@active_controller.view)
|
|
82
|
+
view_size = @active_controller.view.frame.size
|
|
83
|
+
@active_controller.view.frame = CGRect.make(origin: @active_view_origin, size: view_size)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def initialize_controllers
|
|
87
|
+
rows.each do |row|
|
|
88
|
+
row[:controller] = row[:controller].new if row[:controller].is_a?(Class)
|
|
89
|
+
row[:controller].bureau = self
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def rows
|
|
94
|
+
@bureau_sections.inject([]){ |drawers, section| drawers += section[:drawers] }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def open_drawer
|
|
98
|
+
rows.select{ |row| row[:active] == true }.first
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def update_open_drawer_to(new_drawer)
|
|
102
|
+
open_drawer[:active] = false
|
|
103
|
+
new_drawer[:active] = true
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# table view stuff
|
|
107
|
+
|
|
108
|
+
public
|
|
109
|
+
def numberOfSectionsInTableView(table_view)
|
|
110
|
+
@bureau_sections.count
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def tableView(table_view, numberOfRowsInSection:section)
|
|
114
|
+
@bureau_sections[section].count
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def tableView(table_view, titleForHeaderInSection:section)
|
|
118
|
+
@bureau_sections[section][:title]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# def tableView(table_view, viewForHeaderInSection: section)
|
|
122
|
+
# puts "getting header for section #{section}"
|
|
123
|
+
# header = UIView.alloc.init.tap do |view|
|
|
124
|
+
# view.backgroundColor = :blue.uicolor
|
|
125
|
+
# view.frame = [[0,0], [320,60]]
|
|
126
|
+
# view << UILabel.alloc.init.tap do |label|
|
|
127
|
+
# label.text = @bureau_sections[section][:title]
|
|
128
|
+
# label.frame = [[15,4], [74,17]]
|
|
129
|
+
# end
|
|
130
|
+
# end
|
|
131
|
+
# section(section, header:header)
|
|
132
|
+
# end
|
|
133
|
+
|
|
134
|
+
def tableView(table_view, cellForRowAtIndexPath:index_path)
|
|
135
|
+
cell = recycled_cell
|
|
136
|
+
cell ||= new_cell
|
|
137
|
+
section = index_path.section
|
|
138
|
+
row = index_path.row
|
|
139
|
+
drawer = @bureau_sections[section][:drawers][row]
|
|
140
|
+
cell.textLabel.text = drawer[:title]
|
|
141
|
+
cell.imageView.image = drawer[:icon] if drawer.has_key?(:icon)
|
|
142
|
+
cell.detailTextLabel.text = drawer[:subtitle] if drawer.has_key?(:subtitle)
|
|
143
|
+
cell = section(section, row:row, cell:cell)
|
|
144
|
+
cell
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def tableView(table_view, didSelectRowAtIndexPath:index_path)
|
|
148
|
+
section = index_path.section
|
|
149
|
+
row = index_path.row
|
|
150
|
+
drawer = @bureau_sections[section][:drawers][row]
|
|
151
|
+
|
|
152
|
+
update_open_drawer_to drawer
|
|
153
|
+
update_active_controller
|
|
154
|
+
toggle
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def tableView(table_view, heightForRowAtIndexPath:index_path)
|
|
158
|
+
@drawer_height
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# stubbed for menu customization in a subclass:
|
|
162
|
+
|
|
163
|
+
def section(section, row:row, cell:cell)
|
|
164
|
+
cell
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def section(section, header:header)
|
|
168
|
+
header
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
private
|
|
172
|
+
|
|
173
|
+
def new_cell
|
|
174
|
+
cell = UITableViewCell.alloc.initWithStyle(UITableViewCellStyleSubtitle, reuseIdentifier:@reuse_id)
|
|
175
|
+
cell.selectionStyle = UITableViewCellSelectionStyleNone
|
|
176
|
+
cell
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def recycled_cell
|
|
180
|
+
@bureau_sections_table.tableView.dequeueReusableCellWithIdentifier(@reuse_id)
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: motion-bureau
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nick Pachulski
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: geomotion
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: A Rubymotion Sidemenu Animator
|
|
28
|
+
email:
|
|
29
|
+
- hello@nickpachulski.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- ".DS_Store"
|
|
35
|
+
- ".gitignore"
|
|
36
|
+
- bureau.gemspec
|
|
37
|
+
- lib/bureau.rb
|
|
38
|
+
- lib/bureau/bureau.rb
|
|
39
|
+
- lib/bureau/bureau_controller.rb
|
|
40
|
+
- motion-bureau-0.0.1.gem
|
|
41
|
+
homepage: https://github.com/pachun/bureau
|
|
42
|
+
licenses: []
|
|
43
|
+
metadata: {}
|
|
44
|
+
post_install_message:
|
|
45
|
+
rdoc_options: []
|
|
46
|
+
require_paths:
|
|
47
|
+
- lib
|
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
|
+
requirements:
|
|
55
|
+
- - ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: '0'
|
|
58
|
+
requirements: []
|
|
59
|
+
rubyforge_project:
|
|
60
|
+
rubygems_version: 2.0.3
|
|
61
|
+
signing_key:
|
|
62
|
+
specification_version: 4
|
|
63
|
+
summary: A Rubymotion Sidemenu Animator
|
|
64
|
+
test_files: []
|