Skip to content

Instantly share code, notes, and snippets.

@Flink
Created September 19, 2013 09:08
Show Gist options
  • Save Flink/6620948 to your computer and use it in GitHub Desktop.
Save Flink/6620948 to your computer and use it in GitHub Desktop.
class MovieScreen < PM::Screen
title 'Movie details'
stylesheet :movie_details
attr_accessor :movie
def on_load
self.title = movie.full_title
end
def will_present
layout(view, :main_view) do
subview(scroll, :scroll) do
subview(image_container, :poster)
subview(overview_label, :overview)
subview(movie_staff.view, :staff_list)
end
end
overview_label.sizeToFit
image_container.setImageWithURL(poster_url)
movie_staff.view.frame = [[0, 10 + overview_label.size.height], [view.frame.size.width, view.frame.size.height]]
end
def on_appear
movie_staff.view.frame = [[0, 10 + overview_label.size.height], [view.frame.size.width, movie_staff.view.contentSize.height]]
scroll.contentSize = [scroll.frame.size.width, content_height(scroll)]
end
private
def scroll
@scroll ||= UIScrollView.alloc.initWithFrame(view.bounds)
end
def image_container
@image_container ||= UIImageView.new
end
def overview_label
@overview_label ||= movie.overview.uilabel
end
def movie_staff
@movie_staff ||= MovieStaffScreen.new(movie: movie)
end
def poster_url
"#{ Settings.hostname }#{ movie.poster[:suggested] }".nsurl
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment