Class: ScreenController
- Inherits:
-
UIViewController
- Object
- UIViewController
- ScreenController
- Defined in:
- app/controllers/screen_controller.rb
Instance Attribute Summary collapse
-
#items_list ⇒ Object
Returns the value of attribute items_list.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #after_hide_table_view ⇒ Object
- #after_show_table_view ⇒ Object
- #cell_was_tapped(index, duplicate_cell_view) ⇒ Object
- #create_reusable_cell(index, reusable_identifier) ⇒ Object
- #hide_reverse_animator_button ⇒ Object
- #perform_reverse_animation(sender) ⇒ Object
- #populate_sample_data ⇒ Object
- #prefersStatusBarHidden ⇒ Object
- #set_up_initial_layout ⇒ Object
- #set_up_reverse_animator_button ⇒ Object
- #set_up_table ⇒ Object
- #show_reverse_animator_button ⇒ Object
- #viewDidLoad ⇒ Object
Instance Attribute Details
#items_list ⇒ Object
Returns the value of attribute items_list.
2 3 4 |
# File 'app/controllers/screen_controller.rb', line 2 def items_list @items_list end |
#table ⇒ Object
Returns the value of attribute table.
2 3 4 |
# File 'app/controllers/screen_controller.rb', line 2 def table @table end |
Instance Method Details
#after_hide_table_view ⇒ Object
67 68 69 70 |
# File 'app/controllers/screen_controller.rb', line 67 def after_hide_table_view final_point = CGPointMake(0,0) @animator.linear_animate(@duplicate_cell_view, to: final_point, duration: 0.3, completion: lambda{|completion| }) end |
#after_show_table_view ⇒ Object
63 64 65 |
# File 'app/controllers/screen_controller.rb', line 63 def after_show_table_view @duplicate_cell_view.removeFromSuperview end |
#cell_was_tapped(index, duplicate_cell_view) ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/controllers/screen_controller.rb', line 41 def cell_was_tapped index, duplicate_cell_view @duplicate_cell_view = duplicate_cell_view @original_view_position = @duplicate_cell_view.frame.origin self.view.addSubview(@duplicate_cell_view) self.view.bringSubviewToFront(@duplicate_cell_view) @table.hide_table_view(0.3) end |
#create_reusable_cell(index, reusable_identifier) ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/controllers/screen_controller.rb', line 49 def create_reusable_cell index, reusable_identifier custom_cell = CustomCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: reusable_identifier) cell_dimensions = CGSizeMake(320, 60) cell_position = CGPointMake(0, 0) custom_cell.set_up_cell(cell_position, cell_dimensions, self.items_list[index]) custom_cell end |
#hide_reverse_animator_button ⇒ Object
76 77 78 |
# File 'app/controllers/screen_controller.rb', line 76 def @button.alpha = 0 end |
#perform_reverse_animation(sender) ⇒ Object
57 58 59 60 61 |
# File 'app/controllers/screen_controller.rb', line 57 def perform_reverse_animation sender @animator.linear_animate(@duplicate_cell_view, to: @original_view_position, duration: 0.3, completion: nil) @table.show_table_view(0.3) end |
#populate_sample_data ⇒ Object
80 81 82 83 84 85 |
# File 'app/controllers/screen_controller.rb', line 80 def populate_sample_data self.items_list = [] 10.times do |n| self.items_list << "http://lorempixel.com/320/60/technics/#{n}" end end |
#prefersStatusBarHidden ⇒ Object
87 88 89 |
# File 'app/controllers/screen_controller.rb', line 87 def prefersStatusBarHidden true end |
#set_up_initial_layout ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/controllers/screen_controller.rb', line 11 def set_up_initial_layout self.view.backgroundColor = UIColor.whiteColor @table = set_up_table @button = self.view.addSubview(@table.view) self.view.addSubview(@button) end |
#set_up_reverse_animator_button ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/screen_controller.rb', line 31 def = UIButton.(UIButtonTypeCustom) .layer.cornerRadius = 10.0 .addTarget(self, action: "perform_reverse_animation:", forControlEvents:UIControlEventTouchDown) .backgroundColor = UIColor.blackColor .setTitle("Reverse Animation", forState:UIControlStateNormal) .frame = CGRectMake(80.0, 440.0, 160.0, 40.0) end |
#set_up_table ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/screen_controller.rb', line 20 def set_up_table table = AnimatedCellTableViewController.new table.height_of_cell = 60 table.number_of_rows = self.items_list.count table.tableView.frame = self.view.bounds table.delegate_controller = self table.tableView.backgroundColor = UIColor.clearColor table.tableView.separatorStyle = UITableViewCellSeparatorStyleNone table end |
#show_reverse_animator_button ⇒ Object
72 73 74 |
# File 'app/controllers/screen_controller.rb', line 72 def @button.alpha = 1 end |
#viewDidLoad ⇒ Object
4 5 6 7 8 9 |
# File 'app/controllers/screen_controller.rb', line 4 def viewDidLoad super populate_sample_data set_up_initial_layout @animator = MotionAnimator.new end |