tgios 0.0.1 → 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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjFlOTkxYjQ2MGRmMDAwNDE5MTZhYzBhZWI3MzQ5Y2U4NTcwOTcyYQ==
4
+ ODZhNDQ4M2U2YTIwMzViNmRlMTg4N2E0OTcxOTRhYzZlYjAxZDk0Yw==
5
5
  data.tar.gz: !binary |-
6
- NGNkYThiNTU4YWUxMjc2OTQxOTkxYWFkMjFiMWIzYjkyNDQxZThhNQ==
6
+ ZDY1ZWU2MTZkMmVkZGE1M2QxODMwNzhkMjZmNGVkNDQ2YzcyNzJkNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzBkZDQzYzllMjNiNGI1MzNkNTk3ZWM5ZWUyNzU4NDk1YTM4NDFlNWFiNWZh
10
- ZmJhZGI4MGFiZDc1YWExZDcxNmQwNmRhYWQxYjE0ZjJiZjMwNzNkMzBjOGEw
11
- MDU5MzUyZWMyZTQ5MDYxNjIxZmU1ZWIyNjg1Nzc5NmNiMGQyMzQ=
9
+ NTFhNWNhNzcyMjE2MDEyYWMzODA0ZDUyMTM3NWFhOTNkN2UyZTYyZTIzMzUw
10
+ MmE0Yjc5NDYyNjY5ZDIzNDhhNjkwNzQyYTZjOTA4MmE0MDNmMmM1MTVhMGVi
11
+ NjE4NjU1MjkzODRiNDM2MTNkMmEyNGQ4NmQ0MzYwMTRlYTE2YTk=
12
12
  data.tar.gz: !binary |-
13
- NDlkNDkwMGZmY2U5YWNjYmNkNzU1ZDY5ZGJiNjk3MDgxMTQyYWVmYTNlZTEw
14
- OTliODJhMjk5NGYwNjk0YzBjMTMyODdlODZjOGM3MTAxYmU2YjBkNDc1NzNh
15
- MjRjMzJjYTYzOWU3MGY0MzFlNDczNTEzMDljMWY0OGU1NWRlYzI=
13
+ ZTk4NDIyMjUwMmQxNGNkYjdiZWVjODc3MzU2MjYwMTQ3ZmM1ODI1YTBmNTMw
14
+ NjdkMzllNTMwNWYyZjU5Zjc5ZTQxNmVkNzkyZTdhOWViNTY0ZmJiOTNlZTlm
15
+ YjI5NzIyNWU3NWM4ZGY5MGJlNGNiZGYyNjQ5OWM4OWU4MzgwZTY=
@@ -2,8 +2,9 @@ module Tgios
2
2
  module ExtendedUITableView
3
3
  include PlasticCup
4
4
 
5
- def add_full_table_view_to(view)
6
- table = Base.style(UITableView.grouped, :grouped_table)
5
+ def add_full_table_view_to(view, style=:grouped)
6
+ style ||= :plain
7
+ table = UITableView.send(style)
7
8
  Motion::Layout.new do |l|
8
9
  l.view view
9
10
  l.subviews 'table' => table
@@ -1,5 +1,6 @@
1
1
  module Tgios
2
2
  class SearchController < ExtendedUIViewController
3
+ include ExtendedUITableView
3
4
  Events=[:record_selected, :search, :after_layout]
4
5
  attr_accessor :table_list_binding_options, :pop_after_selected, :field_name
5
6
 
@@ -21,17 +22,12 @@ module Tgios
21
22
 
22
23
  def viewDidLoad
23
24
  super
24
- @search_result_table = UITableView.new
25
+ @search_result_table = add_full_table_view_to(self.view, :plain)
25
26
  @search_result_table_binding=UITableViewListBinding.new.bind(@search_result_table, @result, @field_name, @table_list_binding_options)
26
27
  @search_result_table_binding.on(:touch_row) do |record, event|
27
28
  select_record(record)
28
29
  end
29
- Motion::Layout.new do |l|
30
- l.view self.view
31
- l.subviews 'table' => @search_result_table
32
- l.vertical '|[table]|'
33
- l.horizontal '|[table]|'
34
- end
30
+
35
31
  @search_bar=UISearchBar.alloc.init
36
32
  @search_bar.frame=[[0,0],['100',0]]
37
33
  @search_bar.sizeToFit
@@ -1,11 +1,16 @@
1
1
  module Tgios
2
2
  class UITableViewListBinding < BindingBase
3
+ def initialize
4
+ @events={}
5
+ @events[:build_cell]=->(cell_identifier) { build_cell(cell_identifier) }
6
+ @events[:update_cell]=->(record, cell, index_path) { update_cell_text(record, cell, index_path)}
7
+ end
8
+
3
9
  def bind(tableView, list, display_field, options={})
4
10
  @tableView=WeakRef.new(tableView)
5
11
  @tableView.dataSource=self
6
12
  @tableView.delegate=self
7
13
  @display_field=display_field
8
- @events={}
9
14
  @list=WeakRef.new(list)
10
15
  @options=(options || {})
11
16
  return self
@@ -21,18 +26,26 @@ module Tgios
21
26
  @tableView.reloadData()
22
27
  end
23
28
 
29
+ def build_cell(cell_identifier)
30
+ cell=UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: cell_identifier)
31
+ cell.textLabel.adjustsFontSizeToFitWidth = true
32
+ if @options[:lines] && @options[:lines] != 1
33
+ cell.textLabel.numberOfLines = 0
34
+ end
35
+ cell
36
+ end
37
+
38
+ def update_cell_text(record, cell, index_path)
39
+ cell.textLabel.text=record[@display_field]
40
+ cell
41
+ end
42
+
24
43
  def tableView(tableView, cellForRowAtIndexPath: index_path)
25
44
  record = @list[index_path.row]
26
45
  cell_identifier = "CELL_IDENTIFIER"
27
46
  cell=tableView.dequeueReusableCellWithIdentifier(cell_identifier)
28
- if cell.nil?
29
- cell=UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: cell_identifier)
30
- cell.textLabel.adjustsFontSizeToFitWidth = true
31
- if @options[:lines] && @options[:lines] != 1
32
- cell.textLabel.numberOfLines = 0
33
- end
34
- end
35
- cell.textLabel.text=record[@display_field]
47
+ cell = @events[:build_cell].call(cell_identifier) if cell.nil?
48
+ @events[:update_cell].call(record, cell, index_path)
36
49
  cell
37
50
 
38
51
  end
data/lib/tgios/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tgios
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,11 @@
1
+ describe 'Tgios::NSDateHelper' do
2
+ it 'should return NSDate from a normal api time string' do
3
+ date = NSDate.dateWithTimeIntervalSince1970(33)
4
+ date.compare(Tgios::NSDateHelper.to_nsdate('1970-01-01T00:00:33Z')).should == NSOrderedSame
5
+ end
6
+
7
+ it 'should return NSDate from a clear time string' do
8
+ date = NSDate.dateWithTimeIntervalSince1970((((1*365+32)*24+23)*60+55)*60+59)
9
+ date.compare(Tgios::NSDateHelper.to_nsdate('1971-02-02 23:55:59')).should == NSOrderedSame
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tgios
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - April Tsang
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-27 00:00:00.000000000 Z
12
+ date: 2014-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sugarcube
@@ -107,7 +107,7 @@ files:
107
107
  - lib/tgios/ui_text_view_binding.rb
108
108
  - lib/tgios/version.rb
109
109
  - resources/Default-568h@2x.png
110
- - spec/main_spec.rb
110
+ - spec/ns_date_helper_spec.rb
111
111
  - tgios.gemspec
112
112
  homepage: https://github.com/apriltg/tgios
113
113
  licenses:
@@ -134,4 +134,4 @@ signing_key:
134
134
  specification_version: 4
135
135
  summary: A package of ruby-motion libraries written by our team.
136
136
  test_files:
137
- - spec/main_spec.rb
137
+ - spec/ns_date_helper_spec.rb
data/spec/main_spec.rb DELETED
@@ -1,9 +0,0 @@
1
- describe "Application 'tgios'" do
2
- before do
3
- @app = UIApplication.sharedApplication
4
- end
5
-
6
- it "has one window" do
7
- @app.windows.size.should == 1
8
- end
9
- end