/Blee/ColorsController.m

https://bitbucket.org/patrickmcconnell/blee · Objective C · 315 lines · 260 code · 31 blank · 24 comment · 1 complexity · ea1f46a3de979feebf8a7c1f2cfc34a6 MD5 · raw file

  1. //
  2. // ColorsController.m
  3. // Blee
  4. //
  5. // Created by Patrick McConnell on 4/6/13.
  6. // Copyright (c) 2013 Patrick McConnell. All rights reserved.
  7. //
  8. #import "ColorsController.h"
  9. #import "Colours.h"
  10. #import "ColorFamily.h"
  11. @implementation ColorsController
  12. - (id)init
  13. {
  14. if (self = [super init]) {
  15. [self loadColorFamilies];
  16. }
  17. return self;
  18. }
  19. /*
  20. - (void)loadColorFamilies
  21. {
  22. NSString *path = [[NSBundle mainBundle] pathForResource:@"ColorFamilies" ofType:@"plist"];
  23. // root object in plist is a array so grab it
  24. NSArray *rootArray = [NSArray arrayWithContentsOfFile:path];
  25. NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:rootArray.count];
  26. for (NSDictionary *d in rootArray) {
  27. [tempArray addObject:[ColorFamily colorFamilyFromDictionary:d]];
  28. }
  29. _colorFamilies = [NSArray arrayWithArray:tempArray];
  30. }
  31. */
  32. - (void)loadColorFamilies
  33. {
  34. _colorFamilies = @[ [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"System Colors",
  35. @"colors" : @[ ColorInfoBlue,
  36. ColorSuccess,
  37. ColorWarning,
  38. ColorDanger ],
  39. @"colorNames" : @[ @"Info Blue",
  40. @"Success",
  41. @"Warning",
  42. @"Danger" ]
  43. }],
  44. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Whites",
  45. @"colors" : @[ColorAntiqueWhite,
  46. ColorOldLace,
  47. ColorIvory,
  48. ColorSeashell,
  49. ColorGhostWhite,
  50. ColorSnow,
  51. ColorLinen ],
  52. @"colorNames" : @[ @"Antique White",
  53. @"Old Lace",
  54. @"Ivory",
  55. @"Seashell",
  56. @"Ghost White",
  57. @"Snow",
  58. @"Linen" ]
  59. }],
  60. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Grays",
  61. @"colors" : @[Color25PercentBlack,
  62. Color50PercentBlack,
  63. Color75PercentBlack,
  64. ColorWarmGray,
  65. ColorCoolGray,
  66. ColorCharcoal ],
  67. @"colorNames" : @[@"25 Percent Black",
  68. @"50 Percent Black",
  69. @"75 Percent Black",
  70. @"Warm Gray",
  71. @"Cool Gray",
  72. @"Charcoal" ]
  73. }],
  74. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Blues",
  75. @"colors" : @[ColorTeal,
  76. ColorSteelBlue,
  77. ColorRobinEgg,
  78. ColorPastelBlue,
  79. ColorTurquoise,
  80. ColorSkyBlue,
  81. ColorIndigo,
  82. ColorDenim,
  83. ColorBlueberry,
  84. ColorCornflower,
  85. ColorBabyBlue,
  86. ColorMidnightBlue,
  87. ColorFadedBlue,
  88. ColorIceberg,
  89. ColorWave ],
  90. @"colorNames" : @[@"Teal",
  91. @"Steel Blue",
  92. @"Robin Egg",
  93. @"Pastel Blue",
  94. @"Turquoise",
  95. @"Sky Blue",
  96. @"Indigo",
  97. @"Denim",
  98. @"Blueberry",
  99. @"Cornflower",
  100. @"Baby Blue",
  101. @"Midnight Blue",
  102. @"Faded Blue",
  103. @"Iceberg",
  104. @"Wave" ]
  105. }],
  106. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Greens",
  107. @"colors" : @[ColorEmerald,
  108. ColorGrass,
  109. ColorPastelGreen,
  110. ColorSeafoam,
  111. ColorPaleGreen,
  112. ColorCactusGreen,
  113. ColorChartreuse,
  114. ColorHollyGreen,
  115. ColorOlive,
  116. ColorOliveDrab,
  117. ColorMoneyGreen,
  118. ColorHoneydew,
  119. ColorLime,
  120. ColorCardTable ],
  121. @"colorNames" : @[@"Emerald",
  122. @"Grass",
  123. @"Pastel Green",
  124. @"Seafoam",
  125. @"Pale Green",
  126. @"Cactus Green",
  127. @"Chartreuse",
  128. @"Holly Green",
  129. @"Olive",
  130. @"Olive Drab",
  131. @"Money Green",
  132. @"Honeydew",
  133. @"Lime",
  134. @"Card Table" ]
  135. }],
  136. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Reds",
  137. @"colors" : @[ColorSalmon,
  138. ColorBrickRed,
  139. ColorEasterPink,
  140. ColorGrapefruit,
  141. ColorPink,
  142. ColorIndianRed,
  143. ColorStrawberry,
  144. ColorCoral,
  145. ColorMaroon,
  146. ColorWatermelon,
  147. ColorTomato,
  148. ColorPinkLipstick,
  149. ColorPaleRose,
  150. ColorCrimson ],
  151. @"colorNames" : @[@"Salmon",
  152. @"BrickRed",
  153. @"EasterPink",
  154. @"Grapefruit",
  155. @"Pink",
  156. @"IndianRed",
  157. @"Strawberry",
  158. @"Coral",
  159. @"Maroon",
  160. @"Watermelon",
  161. @"Tomato",
  162. @"PinkLipstick",
  163. @"PaleRose",
  164. @"Crimson" ]
  165. }],
  166. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Purples",
  167. @"colors" : @[ColorEggplant,
  168. ColorPastelPurple,
  169. ColorPalePurple,
  170. ColorCoolPurple,
  171. ColorViolet,
  172. ColorPlum,
  173. ColorLavender,
  174. ColorRaspberry,
  175. ColorFuschia,
  176. ColorGrape,
  177. ColorPeriwinkle,
  178. ColorOrchid ],
  179. @"colorNames" : @[@"Eggplant",
  180. @"Pastel Purple",
  181. @"PalePurple",
  182. @"CoolPurple",
  183. @"Violet",
  184. @"Plum",
  185. @"Lavender",
  186. @"Raspberry",
  187. @"Fuschia",
  188. @"Grape",
  189. @"Periwinkle",
  190. @"Orchid" ]
  191. }],
  192. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Yellows",
  193. @"colors" : @[ColorGoldenrod,
  194. ColorYellowGreen,
  195. ColorBanana,
  196. ColorMustard,
  197. ColorButtermilk,
  198. ColorGold,
  199. ColorCream,
  200. ColorLightCream,
  201. ColorWheat,
  202. ColorBeige ],
  203. @"colorNames" : @[@"Goldenrod",
  204. @"Yellow Green",
  205. @"Banana",
  206. @"Mustard",
  207. @"Buttermilk",
  208. @"Gold",
  209. @"Cream",
  210. @"LightCream",
  211. @"Wheat",
  212. @"Beige" ]
  213. }],
  214. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Oranges",
  215. @"colors" : @[ColorPeach,
  216. ColorBurntOrange,
  217. ColorPastelOrange,
  218. ColorCantaloupe,
  219. ColorCarrot,
  220. ColorMandarin ],
  221. @"colorNames" : @[@"Peach",
  222. @"Burnt Orange",
  223. @"Pastel Orange",
  224. @"Cantaloupe",
  225. @"Carrot",
  226. @"Mandarin" ]
  227. }],
  228. [ColorFamily colorFamilyFromDictionary: @{ @"name" : @"Browns",
  229. @"colors" : @[ColorChiliPowder,
  230. ColorBurntSienna,
  231. ColorChocolate,
  232. ColorCoffee,
  233. ColorCinnamon,
  234. ColorAlmond,
  235. ColorEggshell,
  236. ColorCoffee,
  237. ColorSand,
  238. ColorMud,
  239. ColorSienna,
  240. ColorDust ],
  241. @"colorNames" : @[@"ChiliPowder",
  242. @"Burnt Sienna",
  243. @"Chocolate",
  244. @"Coffee",
  245. @"Cinnamon",
  246. @"Almond",
  247. @"Eggshell",
  248. @"Coffee",
  249. @"Sand",
  250. @"Mud",
  251. @"Sienna",
  252. @"Dust" ]
  253. }]
  254. ];
  255. }
  256. - (ColorFamily *)colorFamilyAtIndex:(NSInteger)index
  257. {
  258. return [self.colorFamilies objectAtIndex:index];
  259. }
  260. - (NSArray *)colorsForColorFamilyAtIndex:(NSInteger)index
  261. {
  262. return [[self colorFamilyAtIndex:index] colors];
  263. }
  264. - (NSInteger)numberOfColorNamesForColorFamilyAtIndex:(NSInteger)index
  265. {
  266. return [[self colorsForColorFamilyAtIndex:index]count];
  267. }
  268. - (UIColor *)colorForIndexPath:(NSIndexPath *)indexPath
  269. {
  270. return [[self colorFamilyAtIndex:indexPath.section] colors][indexPath.row];
  271. }
  272. - (NSString *)colorNameForIndexPath:(NSIndexPath *)indexPath
  273. {
  274. return [[self colorFamilyAtIndex:indexPath.section] colorNames][indexPath.row];
  275. }
  276. - (NSString *)familyNameForIndex:(NSInteger)index
  277. {
  278. return [[self colorFamilyAtIndex:index] name];
  279. }
  280. @end