Class: ISDBasicColorCollectionViewController
- Inherits:
-
UICollectionViewController
- Object
- UICollectionViewController
- ISDBasicColorCollectionViewController
- Defined in:
- lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb
Constant Summary collapse
- CellIdentifier =
"ColorWell"
Instance Attribute Summary collapse
-
#recent_colors ⇒ Object
readonly
Returns the value of attribute recent_colors.
-
#system_colors ⇒ Object
readonly
Returns the value of attribute system_colors.
-
#web_colors ⇒ Object
readonly
Returns the value of attribute web_colors.
Instance Method Summary collapse
- #collectionView(collectionView, didDeselectItemAtIndexPath: indexPath) ⇒ Object
- #numberOfSectionsInCollectionView(collectionView) ⇒ Object
- #viewDidLoad ⇒ Object
- #viewWillDisappear(animated) ⇒ Object
Instance Attribute Details
#recent_colors ⇒ Object (readonly)
Returns the value of attribute recent_colors.
4 5 6 |
# File 'lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb', line 4 def recent_colors @recent_colors end |
#system_colors ⇒ Object (readonly)
Returns the value of attribute system_colors.
4 5 6 |
# File 'lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb', line 4 def system_colors @system_colors end |
#web_colors ⇒ Object (readonly)
Returns the value of attribute web_colors.
4 5 6 |
# File 'lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb', line 4 def web_colors @web_colors end |
Instance Method Details
#collectionView(collectionView, didDeselectItemAtIndexPath: indexPath) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb', line 41 def collectionView collectionView, numberOfItemsInSection:section case section when 0 self.recent_colors.size when 1 self.system_colors.size when 2 self.web_colors.size end end |
#numberOfSectionsInCollectionView(collectionView) ⇒ Object
37 38 39 |
# File 'lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb', line 37 def numberOfSectionsInCollectionView collectionView 3 end |
#viewDidLoad ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb', line 6 def viewDidLoad super load_recent_colors @system_colors = [:clear, :white, :black, :dark_gray, :light_gray, :gray, :red, :blue, :cyan, :yellow, :magenta, :orange, :purple, :brown ] @web_colors = Symbol.css_colors.dup.sort{|a, b| f = (a.last >> 16) <=> (b.last >> 16) case f when 0 f = (a.last >> 8 & 0xff) <=> (b.last >> 8 & 0xff) case f when 0 (a.last & 0xff) <=> (b.last & 0xff) else f end else f end }.map{|e| e.first} end |
#viewWillDisappear(animated) ⇒ Object
31 32 33 34 35 |
# File 'lib/isd-color-palette/controller/isd_basic_color_collection_view_controller.rb', line 31 def viewWillDisappear animated super record_recent_color save_recent_colors end |