Created
December 8, 2013 03:14
-
-
Save michelson/7852962 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/cells/museo_table_view_cell.rb | |
class StyledCell < UITableViewCell | |
attr_accessor :image_cell, :title_cell, :subtitle_cell | |
#stylesheet :main_screen | |
def layoutSubviews | |
p title_cell | |
p subtitle_cell | |
#super | |
layout(self.contentView, :cell) do | |
@icon_image_view = subview(UIImageView, :icon, tag: 1) | |
title_view = subview(UILabel, :title, tag: 2, font: UIFont.systemFontOfSize(17)) | |
description_view = subview(UILabel, :description, tag: 3, font: UIFont.systemFontOfSize(12)) | |
logo1_view = subview(UIImageView, :logo1, tag: 4) | |
logo2_view = subview(UIImageView, :logo2, tag: 5) | |
title_view.text = title_cell | |
description_view.text = subtitle_cell | |
profile_thumb | |
end | |
#restyle! | |
end | |
def profile_thumb | |
@icon_image_view.image = UIImage.imageNamed("ui/users.png") | |
Dispatch::Queue.concurrent(priority=:default).async do | |
data = NSData.alloc.initWithContentsOfURL( NSURL.URLWithString(image_cell) ) | |
remote = UIImage.imageWithData(data) | |
Dispatch::Queue.main.async do | |
@icon_image_view.image = remote unless @icon_image_view.nil? | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < ProMotion::TableScreen | |
title "Users" | |
searchable placeholder: "Search Users" | |
refreshable | |
attr_accessor :account | |
tab_bar_item title: "Users", icon: "icons/users.png" | |
def on_appear | |
get_collection unless User.find(external_account_id: account.first.external_id).any? | |
end | |
def get_collection | |
account.first.get_api_users | |
end | |
def loadAndRefresh | |
update_table_data | |
end_refreshing | |
end | |
def users | |
pj = User.find(external_account_id: self.account.first.external_id) | |
usr = pj.collect{|o| | |
{ | |
title_cell: o.name, | |
action: :open_user_profile, | |
arguments: { user_id: o.external_id }, | |
#stylename: :tablecell, | |
image_cell: Utils.gravatar(o.email), | |
subtitle_cell: o.email, | |
cell_class: StyledCell | |
} | |
} | |
@table_data = [{ | |
title: "Users", | |
cells: usr | |
}] | |
end | |
def on_refresh | |
get_collection | |
end | |
def open_user_profile(user) | |
open UserProfileScreen.new(user_id: user[:user_id]) | |
end | |
def table_data | |
users | |
end | |
def open_home | |
open_root_screen WelcomeController.new(nav_bar: true) | |
end | |
def tableView(tableView, heightForRowAtIndexPath:indexPath) | |
80 | |
end | |
def tableView(tableView, didSelectRowAtIndexPath:indexPath) | |
tableView.deselectRowAtIndexPath(indexPath, animated:true) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment