Skip to content

Instantly share code, notes, and snippets.

@twerth
Last active August 29, 2015 14:17
Show Gist options
  • Save twerth/848c9484ad63781ed60d to your computer and use it in GitHub Desktop.
Save twerth/848c9484ad63781ed60d to your computer and use it in GitHub Desktop.
TOL about new layout method and find_or_append feature for RMQ/RedPotion
class MainScreen < PM::Screen
title "My Screen"
layout MyLayout
stylesheet MainScreenStylesheet
def on_load
stylesheet.layout
set_state user_logged_in: false, first_name: "n/a", last_name: "n/a"
end
def something_happened
set_state user_logged_in: true, first_name: user.firstt_name, last_name: user.last_name
end
end
class MainScreenStylesheet < ApplicationStylesheet
def setup
# Add stylesheet specific setup stuff here.
# Add application specific setup stuff in application_stylesheet.rb
end
def layout
first_label_top = screen.state[:user_logged_in] ? 20 : 60
find_or_append(UILabel, :first_name_label).layout(l: 5, w: 10, t: first_label_top, h: 20)
find_or_append(UILabel, :first_name).layout(l: 5, w: 10, bp: 20, h: 20)
find_or_append(UILabel, :last_name_label).layout(l: 5, w: 10, bp: 40, h: 20)
find_or_append(UILabel, :last_name).layout(l: 5, w: 10, bp: 20, h: 20)
end
def root_view(st)
st.background_color = color.white
end
def first_name_label(st)
end
def first_name(st)
end
def last_name_label(st)
end
def last_name(st)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment