Skip to content

Instantly share code, notes, and snippets.

@Omnipresent
Last active August 29, 2015 14:01
Show Gist options
  • Save Omnipresent/731a5c47db86849e981d to your computer and use it in GitHub Desktop.
Save Omnipresent/731a5c47db86849e981d to your computer and use it in GitHub Desktop.
class MyController < UIViewController
....
def viewDidLoad
@note_table = rmq(self.view).append(UITableView, :top_stylesheet).get
@note_table_delegate = NoteTableDelegate.new
@note_table.delegate = @note_table_delegate
@note_table.dataSource = @note_table_delegate
@note_table.separatorColor = UIColor.clearColor
end
...
end
class NoteTableDelegate
...
def tableView(table_view, cellForRowAtIndexPath: index_path)
data_row = @data[index_path.row]
if index_path.row == 0
cell1 = table_view.dequeueReusableCellWithIdentifier(FIRST_CELL_ID) || begin
rmq.create(FirstCell, :item_cell, reuse_identifier: FIRST_CELL_ID).get
end
cell1.update(data_row)
cell1
else
cell = table_view.dequeueReusableCellWithIdentifier(NOTE_CELL_ID) || begin
rmq.create(NotesCell, :note_cell, reuse_identifier: NOTE_CELL_ID).get
end
cell.update(data_row)
cell
end
end
....
end
class NotesCell < UITableViewCell
....
def rmq_build
rmq(self.contentView).tap do |q|
@line = q.append(UIView, :line).get
end
end
...
end
class MyStylesheet < ApplicationStyleSheet
def line(st)
st.frame = {l: 0, t: 44, w: 350, h: 2}
st.background_color = "#000000".to_color
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment