Skip to content

Instantly share code, notes, and snippets.

@grimmwerks
Created March 30, 2016 04:27
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/8ec8ec0f7adc5efb582983ab7da87ac5 to your computer and use it in GitHub Desktop.
Save grimmwerks/8ec8ec0f7adc5efb582983ab7da87ac5 to your computer and use it in GitHub Desktop.
Promotion XL Form cell attempt
class StrapCell < PM::XLFormCell
attr_accessor :position, :tension, :name
attr_accessor :strap_name, :strap_position, :strap_tension
include StrapCellStylesheet
def setup(data_cell, screen)
super
draw_cell
# mp self.methods.sort - Object.instance_methods
end
def initWithStyle(style, reuseIdentifier: reuse_identifier)
super.tap do
mp "<---- initWithStyle add " # sends only once upon init, not redraw
draw_cell
end
end
def draw_cell
append!(UIImageView, :strap_image)
@strap_name = append!(UILabel, :strap_name)
@strap_position= append!(UILabel, :strap_position)
@strap_tension = append!(UILabel, :strap_tension)
apply_style :strap_cell
end
def update
super
self.data_cell ||={}
@strap_name.text = value[:strap]
@strap_position.text = "Position: #{value[:position]}"
@strap_tension.text = "Tension: #{value[:tension]}"
# test to see if resetting works
self.apply_style :strap_cell
@strap_name.apply_style(:strap_name)
@strap_position.apply_style(:strap_position)
@strap_tension.apply_style(:strap_tension)
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 StrapCellStylesheet
# 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/strap_cell_stylesheet.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment