pm_swipe_cells 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/lib/pm_swipe_cells/pm_table_screen.rb +28 -0
- data/lib/pm_swipe_cells/swipeable_cell.rb +47 -0
- data/lib/pm_swipe_cells.rb +23 -0
- data/pm_swipe_cells-0.0.1.gem +0 -0
- data/pm_swipe_cells.gemspec +14 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aee6464bf2068b46c6ce13f5c7958273cc76cad4
|
4
|
+
data.tar.gz: 3941a0599b9f77c78c6640317eed2dc033d71c69
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88361179a72a5e3122e511f159c540830bdb6dd60126bb039d82a84350f3ee94fc9afb28f5e33d67556f0f80d11c1bb8f7d123991a7b4ce05054e139eb25b346
|
7
|
+
data.tar.gz: a6439286b24ee59a4d300dfe052660ded58a2639eb7f5a818551b522432829c05e7476f59f2031111534c17b134dde6260b458468f5ed8fc2eaf810674b20e88
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ProMotion
|
2
|
+
class TableScreen < TableViewController
|
3
|
+
|
4
|
+
def on_cell_created(cell, data)
|
5
|
+
super
|
6
|
+
cell.setDelegate(self)
|
7
|
+
cell.config(right_cells: data[:properties][:right_cells], left_cells: data[:properties][:left_cells]) if cell.respond_to?(:config)
|
8
|
+
end
|
9
|
+
|
10
|
+
def tableView(tableView, cellForRowAtIndexPath: indexPath)
|
11
|
+
cell = super
|
12
|
+
cell.index_path = indexPath
|
13
|
+
cell
|
14
|
+
end
|
15
|
+
|
16
|
+
def swipeableTableViewCell(cell, didTriggerRightUtilityButtonWithIndex: index)
|
17
|
+
trigger_action(cell.right_cells[index][:action], cell.right_cells[index][:arguments], cell.index_path) if (cell.right_cells and cell.right_cells[index])
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def swipeableTableViewCell(cell, didTriggerLeftUtilityButtonWithIndex: index)
|
22
|
+
trigger_action(cell.left_cells[index][:action], cell.left_cells[index][:arguments], cell.index_path) if (cell.left_cells and cell.left_cells[index])
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class SwipeableCell < SWTableViewCell
|
2
|
+
|
3
|
+
attr_accessor :left_cells, :right_cells, :index_path
|
4
|
+
|
5
|
+
def add_right_cells(cells_to_add = {})
|
6
|
+
right_cells_array = Array.new
|
7
|
+
cells_to_add.each do |opts|
|
8
|
+
right_cells_array.sw_addUtilityButtonWithColor(opts[:color], title: opts[:title].to_s.capitalize)
|
9
|
+
end
|
10
|
+
right_cells_array
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_left_cells(cells_to_add = {})
|
14
|
+
left_cells_array = Array.new
|
15
|
+
cells_to_add.each do |opts|
|
16
|
+
left_cells_array.sw_addUtilityButtonWithColor(opts[:color], title: opts[:title].to_s.capitalize)
|
17
|
+
end
|
18
|
+
left_cells_array
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def config(opts = {})
|
23
|
+
@right_cells = opts[:right_cells] if opts[:right_cells]
|
24
|
+
@left_cells = opts[:left_cells] if opts[:left_cells]
|
25
|
+
if @right_cells
|
26
|
+
self.rightUtilityButtons = add_right_cells(@right_cells)
|
27
|
+
end
|
28
|
+
if @left_cells
|
29
|
+
self.leftUtilityButtons = add_left_cells(@left_cells)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def close
|
34
|
+
self.hideUtilityButtonsAnimated(true)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def show_buttons(side)
|
39
|
+
case side
|
40
|
+
when "right", :right
|
41
|
+
showRightUtilityButtonsAnimated(true)
|
42
|
+
when "left", :left
|
43
|
+
showLeftUtilityButtonsAnimated(true)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'motion-cocoapods'
|
6
|
+
# require ''
|
7
|
+
|
8
|
+
Motion::Project::App.setup do |app|
|
9
|
+
|
10
|
+
# app.name = "pm_swipe_cells"
|
11
|
+
|
12
|
+
app.pods do
|
13
|
+
pod 'SWTableViewCell'
|
14
|
+
end
|
15
|
+
|
16
|
+
# lib_dir_path = File.dirname(File.expand_path(__FILE__))
|
17
|
+
# app.files.unshift(Dir.glob(File.join(lib_dir_path, "timestamps/**/*.rb")))
|
18
|
+
|
19
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'pm_swipe_cells/*.rb')).each do |file|
|
20
|
+
app.files.unshift(file)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.name = "pm_swipe_cells"
|
4
|
+
gem.version = '0.0.2'
|
5
|
+
gem.summary = "Easily add SWTableViewCells to Rubymotion - Promotion projects"
|
6
|
+
gem.description = "It's cool. I'll add more soon."
|
7
|
+
gem.files = `git ls-files`.split("\n")
|
8
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
9
|
+
gem.require_paths = ["lib"]
|
10
|
+
gem.homepage = "https://github.com/Brian-Egan/pm_swipeable_cells"
|
11
|
+
gem.authors = ["Brian Egan"]
|
12
|
+
gem.email = "brianegan@outlook.com"
|
13
|
+
gem.license = "MIT"
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pm_swipe_cells
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Egan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: It's cool. I'll add more soon.
|
14
|
+
email: brianegan@outlook.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/pm_swipe_cells.rb
|
20
|
+
- lib/pm_swipe_cells/pm_table_screen.rb
|
21
|
+
- lib/pm_swipe_cells/swipeable_cell.rb
|
22
|
+
- pm_swipe_cells-0.0.1.gem
|
23
|
+
- pm_swipe_cells.gemspec
|
24
|
+
homepage: https://github.com/Brian-Egan/pm_swipeable_cells
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.4.6
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Easily add SWTableViewCells to Rubymotion - Promotion projects
|
48
|
+
test_files: []
|
49
|
+
has_rdoc:
|