Skip to content

Instantly share code, notes, and snippets.

@grimmwerks
Created March 30, 2016 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grimmwerks/3a7348784c36d49aa9229aee497b1be6 to your computer and use it in GitHub Desktop.
Save grimmwerks/3a7348784c36d49aa9229aee497b1be6 to your computer and use it in GitHub Desktop.
class PatientInfoCell < PM::XLFormCell
include PatientInfoCellStylesheet
def on_load
apply_style :patient_info_cell
# Add subviews here, like so:
# append UILabel, :label_style_here
# -or-
# @submit_button = append(UIButton, :submit).get
# -or-
# @submit_button = append! UIButton, :submit
end
def update
super
self.data_cell ||={}
create_cell_items
@patient_name.text = value[:name]
@patient_email.text = "Email: #{value[:email]}"
@patient_username.text = "Username: #{value[:username]}"
@patient_treatment.text = "Treatment Start: #{value[:treatment]}"
apply_cell_styles
end
def create_cell_items
@patient_name ||= append!(UILabel, :patient_name)
@patient_email ||= append!(UILabel, :patient_email)
@patient_username ||= append!(UILabel, :patient_username)
@patient_treatment ||= append!(UILabel, :patient_treatment)
end
def apply_cell_styles
# self.apply_style :patient_info_cell
@patient_name.apply_style(:patient_name)
@patient_email.apply_style(:patient_email)
@patient_username.apply_style(:patient_username)
@patient_treatment.apply_style(:patient_treatment)
end
def on_cell_reused(cell, data)
mp "<---- cell reused"
end
end
# To style this view include its stylesheet at the top of each controller's
# stylesheet that is going to use it:
# class SomeStylesheet < ApplicationStylesheet
# include PatientInfoStylesheet
# Another option is to use your controller's stylesheet to style this view. This
# works well if only one controller uses it. If you do that, delete the
# view's stylesheet with:
# rm app/stylesheets/patient_info_stylesheet.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment