Colors.m 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2016-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. #import "Colors.h"
  21. #import "BundleUtil.h"
  22. #import "UserSettings.h"
  23. #import "UIImage+ColoredImage.h"
  24. #import "UITextField+Themed.h"
  25. #import "ContactNameLabel.h"
  26. #import "VoIPHelper.h"
  27. #import "TextStyleUtils.h"
  28. #import "LicenseStore.h"
  29. #import "ThreemaFramework/ThreemaFramework-Swift.h"
  30. #define THREEMA_COLOR_PLACEHOLDER [UIColor lightGrayColor]
  31. #define THREEMA_COLOR_LIGHT_GREY [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]
  32. #define THREEMA_COLOR_DARK_GREY [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1.0]
  33. #define THREEMA_COLOR_GREEN [UIColor colorWithRed:96.0/255.0 green:194.0/255.0 blue:57.0/255.0 alpha:1.0]
  34. // MARK: Dark Theme Base
  35. #define THEME_DARK_BACKGROUND_BASE [UIColor colorWithRed:0.0/255.0 green: 0.0/255.0 blue:0.0/255.0 alpha:1.0]
  36. #define THEME_DARK_BACKGROUND [UIColor colorWithRed:33.0/255.0 green:33.0/255.0 blue:33.0/255.0 alpha:1.0]
  37. #define THEME_DARK_BACKGROUND_DARK [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
  38. #define THEME_DARK_BACKGROUND_CHAT [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
  39. #define THEME_DARK_CHAT_BACKGROUND_LINES [UIColor colorWithRed:173.0/255.0 green:173.0/255.0 blue:173.0/255.0 alpha:1.0]
  40. #define THEME_DARK_BACKGROUND_CHAT_SYSTEM_MESSAGE [UIColor colorWithRed:97.0/255.0 green:97.0/255.0 blue:97.0/255.0 alpha:1.0]
  41. #define THEME_DARK_BACKGROUND_SELECTED_DARK [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
  42. #define THEME_DARK_BACKGROUND_LIGHT [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
  43. #define THEME_DARK_BACKGROUND_INVERTED [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
  44. #define THEME_DARK_SHARE_EXTENSION_SELECTED_BACKGROUND [UIColor colorWithRed:0.82 green:0.82 blue:0.82 alpha:1.0]
  45. #define THEME_DARK_FONT_NORMAL [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
  46. #define THEME_DARK_FONT_LIGHT [UIColor colorWithRed:224.0/255.0 green:224.0/255.0 blue:224.0/255.0 alpha:1.0]
  47. #define THEME_DARK_FONT_VERY_LIGHT [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  48. #define THEME_DARK_FONT_DARK [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
  49. #define THEME_DARK_FONT_INVERTED [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
  50. #define THEME_DARK_FONT_QUOTE_ID [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
  51. #define THEME_DARK_FONT_QUOTE_TEXT [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  52. #define THEME_DARK_CHATBAR_INPUT [UIColor colorWithRed:33.0/255.0 green:33.0/255.0 blue:33.0/255.0 alpha:1.0]
  53. #define THEME_DARK_CHATBAR_BACKGROUND [UIColor colorWithRed:22.0/255.0 green:22.0/255.0 blue:22.0/255.0 alpha:1.0]
  54. #define THEME_DARK_CHATBAR_BORDER [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
  55. #define THEME_DARK_SWITCH_THUMB [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
  56. #define THEME_DARK_BALLOT_ROW_LIGHT [UIColor colorWithRed:97.0/255.0 green:97.0/255.0 blue:97.0/255.0 alpha:1.0]
  57. #define THEME_DARK_BALLOT_ROW_DARK [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
  58. #define THEME_DARK_HAIRLINE [UIColor colorWithRed:55.0/255.0 green:55.0/255.0 blue:55.0/255.0 alpha:1.0]
  59. #define THEME_DARK_ORANGE [UIColor colorWithRed:246.0/255.0 green:146.0/255.0 blue:30.0/255.0 alpha:1.0]
  60. #define THEME_DARK_RED [UIColor colorWithRed:235.0/255.0 green:29.0/255.0 blue:36.0/255.0 alpha:1.0]
  61. #define THEME_DARK_GRAY [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
  62. #define THEME_DARK_SEARCH_BAR_STATUS_BAR [UIColor colorWithRed:46.0/255.0 green:46.0/255.0 blue:41.0/255.0 alpha:1.0]
  63. #define THEME_DARK_MENTION_BACKGROUND [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
  64. #define THEME_DARK_MENTION_BACKGROUND_OWN [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:1.0]
  65. #define THEME_DARK_MENTION_BACKGROUND_OVERVIEW [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
  66. #define THEME_DARK_MENTION_BACKGROUND_ME [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  67. #define THEME_DARK_MENTION_BACKGROUND_OWN_ME [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  68. #define THEME_DARK_MENTION_BACKGROUND_OVERVIEW_ME [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  69. #define THEME_DARK_MENTION_TEXT_ME THEME_DARK_FONT_INVERTED
  70. #define THEME_DARK_MENTION_TEXT_OWN_ME THEME_DARK_FONT_INVERTED
  71. #define THEME_DARK_MENTION_TEXT_OVERVIEW_ME THEME_DARK_FONT_INVERTED
  72. #define THEME_DARK_BUBBLE_SENT [UIColor colorWithRed:38.0/255.0 green:38.0/255.0 blue:38.0/255.0 alpha:1.0]
  73. #define THEME_DARK_BUBBLE_SENT_SELECTED [UIColor colorWithRed:130.0/255.0 green:130.0/255.0 blue:130.0/255.0 alpha:1.0]
  74. #define THEME_DARK_BUBBLE_RECEIVED [UIColor colorWithRed:55.0/255.0 green:55.0/255.0 blue:55.0/255.0 alpha:1.0]
  75. #define THEME_DARK_BUBBLE_RECEIVED_SELECTED [UIColor colorWithRed:130.0/255.0 green:130.0/255.0 blue:130.0/255.0 alpha:1.0]
  76. #define THEME_DARK_TAG_MARK_BACKGROUND [UIColor colorWithRed:254.0/255.0 green:196.0/255.0 blue:0.0/255.0 alpha:1.0]
  77. #define THEME_DARK_POPUP_MENU_BACKGROUND [UIColor colorWithRed:97.0/255.0 green:97.0/255.0 blue:97.0/255.0 alpha:1.0]
  78. #define THEME_DARK_POPUP_MENU_HIGHTLIGHT [UIColor colorWithRed:130.0/255.0 green:130.0/255.0 blue:130.0/255.0 alpha:1.0]
  79. #define THEME_DARK_POPUP_MENU_SEPARATOR [UIColor colorWithRed:130.0/255.0 green:130.0/255.0 blue:130.0/255.0 alpha:1.0]
  80. #define THEME_DARK_NOTIFICATION_BACKGROUND [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
  81. #define THEME_DARK_NOTIFICATION_SHADOW [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
  82. // MARK: Dark Theme
  83. #define THEME_DARK_MAIN [UIColor colorWithRed:5.0/255.0 green: 166.0/255.0 blue:63.0/255.0 alpha:1.0]
  84. #define THEME_DARK_FONT_LINK THEME_DARK_MAIN
  85. #define THEME_DARK_FONT_LINK_RECEIVED [UIColor colorWithRed:6.0/255.0 green: 204.0/255.0 blue:77.0/255.0 alpha:1.0]
  86. #define THEME_DARK_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER
  87. #define THEME_DARK_BUBBLE_CALL_BUTTON THEME_DARK_MAIN
  88. #define THEME_DARK_BALLOT_HIGHEST_VOTE THEME_DARK_MAIN
  89. #define THEME_DARK_QUOTE_BAR THEME_DARK_GREEN
  90. #define THEME_DARK_GREEN THEME_DARK_MAIN
  91. #define THEME_DARK_VERIFICATION_GREEN THEME_DARK_MAIN
  92. #define THEME_DARK_WORK_BLUE [UIColor colorWithRed:0.0/255.0 green: 115.0/255.0 blue:196.0/255.0 alpha:1.0]
  93. #define THEME_DARK_CALL_STATUS_BAR [UIColor colorWithRed:2.0/255.0 green:52.0/255.0 blue:20.0/255.0 alpha:1.0]
  94. // MARK: Dark Work Theme
  95. #define THEME_DARK_WORK_MAIN [UIColor colorWithRed:0.0/255.0 green: 150.0/255.0 blue:255.0/255.0 alpha:1.0]
  96. #define THEME_DARK_WORK_FONT_LINK THEME_DARK_WORK_MAIN
  97. #define THEME_DARK_WORK_FONT_LINK_RECEIVED [UIColor colorWithRed:20.0/255.0 green: 158.0/255.0 blue:255.0/255.0 alpha:1.0]
  98. #define THEME_DARK_WORK_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER
  99. #define THEME_DARK_WORK_BUBBLE_CALL_BUTTON THEME_DARK_WORK_MAIN
  100. #define THEME_DARK_WORK_BALLOT_HIGHEST_VOTE THEME_DARK_WORK_MAIN
  101. #define THEME_DARK_WORK_QUOTE_BAR THEME_DARK_WORK_MAIN
  102. #define THEME_DARK_WORK_GREEN [UIColor colorWithRed:5.0/255.0 green: 166.0/255.0 blue:63.0/255.0 alpha:1.0]
  103. #define THEME_DARK_WORK_VERIFICATION_GREEN [UIColor colorWithRed:70.0/255.0 green: 168.0/255.0 blue:32.0/255.0 alpha:1.0]
  104. #define THEME_DARK_WORK_WORK_BLUE THEME_DARK_WORK_MAIN
  105. #define THEME_DARK_WORK_CALL_STATUS_BAR [UIColor colorWithRed:0.0/255.0 green:50.0/255.0 blue:7.0/255.0 alpha:1.0]
  106. // MARK: Light Theme Base
  107. #define THEME_LIGHT_BACKGROUND_BASE [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
  108. #define THEME_LIGHT_BACKGROUND [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
  109. #define THEME_LIGHT_BACKGROUND_DARK [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]
  110. #define THEME_LIGHT_BACKGROUND_SELECTED_DARK [UIColor colorWithRed:212.0/255.0 green:212.0/255.0 blue:212.0/255.0 alpha:1.0]
  111. #define THEME_LIGHT_BACKGROUND_LIGHT [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
  112. #define THEME_LIGHT_BACKGROUND_INVERTED [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
  113. #define THEME_LIGHT_BACKGROUND_CHAT [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
  114. #define THEME_LIGHT_CHAT_BACKGROUND_LINES [UIColor colorWithRed:144.0/255.0 green:144.0/255.0 blue:144.0/255.0 alpha:1.0]
  115. #define THEME_LIGHT_BACKGROUND_CHAT_SYSTEM_MESSAGE [UIColor colorWithRed:224.0/255.0 green:224.0/255.0 blue:224.0/255.0 alpha:1.0]
  116. #define THEME_LIGHT_SHARE_EXTENSION_SELECTED_BACKGROUND [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  117. #define THEME_LIGHT_FONT_NORMAL [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0] // Normal font color
  118. #define THEME_LIGHT_FONT_LIGHT [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:1.0]
  119. #define THEME_LIGHT_FONT_VERY_LIGHT [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
  120. #define THEME_LIGHT_FONT_DARK [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
  121. #define THEME_LIGHT_FONT_INVERTED [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
  122. #define THEME_LIGHT_FONT_QUOTE_ID [UIColor colorWithRed:97.0/255.0 green:97.0/255.0 blue:97.0/255.0 alpha:1.0]
  123. #define THEME_LIGHT_FONT_QUOTE_TEXT [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:1.0]
  124. #define THEME_LIGHT_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER // Placeholder color (Lightgray)
  125. #define THEME_LIGHT_CHATBAR_INPUT [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
  126. #define THEME_LIGHT_CHATBAR_BACKGROUND [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]
  127. #define THEME_LIGHT_CHATBAR_BORDER [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  128. #define THEME_LIGHT_SWITCH_THUMB nil
  129. #define THEME_LIGHT_BALLOT_ROW_LIGHT [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]
  130. #define THEME_LIGHT_BALLOT_ROW_DARK [UIColor colorWithRed:224.0/255.0 green:224.0/255.0 blue:224.0/255.0 alpha:1.0]
  131. #define THEME_LIGHT_HAIRLINE [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  132. #define THEME_LIGHT_ORANGE [UIColor colorWithRed:246.0/255.0 green:146.0/255.0 blue:30.0/255.0 alpha:1.0]
  133. #define THEME_LIGHT_RED [UIColor colorWithRed:235.0/255.0 green:29.0/255.0 blue:36.0/255.0 alpha:1.0]
  134. #define THEME_LIGHT_GRAY [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  135. #define THEME_LIGHT_SEARCH_BAR_STATUS_BAR [UIColor colorWithRed:224.0/255.0 green:224.0/255.0 blue:224.0/255.0 alpha:1.0]
  136. #define THEME_LIGHT_MENTION_BACKGROUND [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  137. #define THEME_LIGHT_MENTION_BACKGROUND_OWN [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  138. #define THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  139. #define THEME_LIGHT_MENTION_BACKGROUND_ME [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:1.0]
  140. #define THEME_LIGHT_MENTION_BACKGROUND_OWN_ME [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:1.0]
  141. #define THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW_ME [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:1.0]
  142. #define THEME_LIGHT_MENTION_TEXT_ME THEME_LIGHT_FONT_INVERTED
  143. #define THEME_LIGHT_MENTION_TEXT_OWN_ME THEME_LIGHT_FONT_INVERTED
  144. #define THEME_LIGHT_MENTION_TEXT_OVERVIEW_ME THEME_LIGHT_FONT_INVERTED
  145. #define THEME_LIGHT_BUBBLE_RECEIVED [UIColor colorWithRed:232.0/255.0 green:232.0/255.0 blue:232.0/255.0 alpha:1.0]
  146. #define THEME_LIGHT_BUBBLE_RECEIVED_SELECTED [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
  147. #define THEME_LIGHT_TAG_MARK_BACKGROUND [UIColor colorWithRed:254.0/255.0 green:196.0/255.0 blue:0.0/255.0 alpha:1.0]
  148. #define THEME_LIGHT_POPUP_MENU_BACKGROUND [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.95]
  149. #define THEME_LIGHT_POPUP_MENU_HIGHTLIGHT [UIColor colorWithRed:85.0/255.0 green:85.0/255.0 blue:85.0/255.0 alpha:0.95]
  150. #define THEME_LIGHT_POPUP_MENU_SEPARATOR [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:0.95]
  151. #define THEME_LIGHT_NOTIFICATION_BACKGROUND [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
  152. #define THEME_LIGHT_NOTIFICATION_SHADOW [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
  153. // MARK: Light Theme
  154. #define THEME_LIGHT_MAIN [UIColor colorWithRed:5.0/255.0 green: 148.0/255.0 blue:61.0/255.0 alpha:1.0]
  155. #define THEME_LIGHT_FONT_LINK THEME_LIGHT_MAIN // Link font color
  156. #define THEME_LIGHT_FONT_LINK_RECEIVED THEME_LIGHT_MAIN
  157. #define THEME_LIGHT_BUBBLE_SENT [UIColor colorWithRed:220.0/255.0 green:242.0/255.0 blue:211.0/255.0 alpha:1.0]
  158. #define THEME_LIGHT_BUBBLE_SENT_SELECTED [UIColor colorWithRed:148.0/255.0 green:215.0/255.0 blue:120.0/255.0 alpha:1.0]
  159. #define THEME_LIGHT_BUBBLE_CALL_BUTTON THEME_LIGHT_MAIN
  160. #define THEME_LIGHT_BALLOT_HIGHEST_VOTE THEME_LIGHT_MAIN
  161. #define THEME_LIGHT_QUOTE_BAR THEME_LIGHT_GREEN
  162. #define THEME_LIGHT_GREEN THEME_LIGHT_MAIN
  163. #define THEME_LIGHT_VERIFICATION_GREEN THEME_LIGHT_MAIN
  164. #define THEME_LIGHT_WORK_BLUE [UIColor colorWithRed:0.0/255.0 green: 115.0/255.0 blue:196.0/255.0 alpha:1.0]
  165. #define THEME_LIGHT_CALL_STATUS_BAR [UIColor colorWithRed:196.0/255.0 green:233.0/255.0 blue:181.0/255.0 alpha:1.0]
  166. // MARK: Light Work Theme
  167. #define THEME_LIGHT_WORK_MAIN [UIColor colorWithRed:0.0/255.0 green: 115.0/255.0 blue:196.0/255.0 alpha:1.0]
  168. #define THEME_LIGHT_WORK_FONT_LINK THEME_LIGHT_WORK_MAIN // Link font color
  169. #define THEME_LIGHT_WORK_FONT_LINK_RECEIVED THEME_LIGHT_WORK_MAIN
  170. #define THEME_LIGHT_WORK_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER // Placeholder color (Lightgray)
  171. #define THEME_LIGHT_WORK_BUBBLE_SENT [UIColor colorWithRed:196.0/255.0 green:226.0/255.0 blue:255.0/255.0 alpha:1.0]
  172. #define THEME_LIGHT_WORK_BUBBLE_SENT_SELECTED [UIColor colorWithRed:118.0/255.0 green:187.0/255.0 blue:255.0/255.0 alpha:1.0]
  173. #define THEME_LIGHT_WORK_BUBBLE_CALL_BUTTON THEME_LIGHT_WORK_MAIN
  174. #define THEME_LIGHT_WORK_BALLOT_HIGHEST_VOTE THEME_LIGHT_WORK_MAIN
  175. #define THEME_LIGHT_WORK_QUOTE_BAR THEME_LIGHT_WORK_MAIN
  176. #define THEME_LIGHT_WORK_GREEN [UIColor colorWithRed:5.0/255.0 green: 153.0/255.0 blue:63.0/255.0 alpha:1.0]
  177. #define THEME_LIGHT_WORK_VERIFICATION_GREEN [UIColor colorWithRed:5.0/255.0 green: 153.0/255.0 blue:63.0/255.0 alpha:1.0]
  178. #define THEME_LIGHT_WORK_WORK_BLUE THEME_LIGHT_WORK_MAIN
  179. #define THEME_LIGHT_WORK_CALL_STATUS_BAR [UIColor colorWithRed:157.0/255.0 green:207.0/255.0 blue:255.0/255.0 alpha:1.0]
  180. static UIColor *main;
  181. static UIColor *backgroundBaseColor;
  182. static UIColor *background;
  183. static UIColor *backgroundLight;
  184. static UIColor *backgroundDark;
  185. static UIColor *backgroundSelectedDark;
  186. static UIColor *backgroundInverted;
  187. static UIColor *backgroundChat;
  188. static UIColor *chatBackgroundLines;
  189. static UIColor *chatSystemMessageBackground;
  190. static UIColor *shareExtensionSelectedBackground;
  191. static UIColor *fontNormal;
  192. static UIColor *fontLight;
  193. static UIColor *fontVeryLight;
  194. static UIColor *fontDark;
  195. static UIColor *fontLink;
  196. static UIColor *fontLinkReceived;
  197. static UIColor *fontPlaceholder;
  198. static UIColor *fontInverted;
  199. static UIColor *fontQuoteId;
  200. static UIColor *fontQuoteText;
  201. static UIColor *chatBarInput;
  202. static UIColor *chatBarBackground;
  203. static UIColor *chatBarBorder;
  204. static UIColor *switchThumb;
  205. static UIColor *bubbleSent;
  206. static UIColor *bubbleSentSelected;
  207. static UIColor *bubbleReceived;
  208. static UIColor *bubbleReceivedSelected;
  209. static UIColor *bubbleCall;
  210. static UIColor *bubbleCallButton;
  211. static UIColor *popupMenuBackground;
  212. static UIColor *popupMenuHighlight;
  213. static UIColor *popupMenuSeparator;
  214. static UIColor *ballotHighestVote;
  215. static UIColor *ballotRowLight;
  216. static UIColor *ballotRowDark;
  217. static UIColor *hairline;
  218. static UIColor *quoteBar;
  219. static UIColor *orange;
  220. static UIColor *red;
  221. static UIColor *green;
  222. static UIColor *gray;
  223. static UIColor *verificationGreen;
  224. static UIColor *workBlue;
  225. static UIColor *searchBarStatusBar;
  226. static UIColor *callStatusBar;
  227. static UIColor *mentionBackgroundOwnMessageColor;
  228. static UIColor *mentionBackgroundOverviewColor;
  229. static UIColor *mentionBackgroundColor;
  230. static UIColor *mentionBackgroundOwnMessageMeColor;
  231. static UIColor *mentionBackgroundOverviewMeColor;
  232. static UIColor *mentionBackgroundMeColor;
  233. static UIColor *mentionTextOwnMessageMeColor;
  234. static UIColor *mentionTextOverviewMeColor;
  235. static UIColor *mentionTextMeColor;
  236. static UIColor *tagMarkBackground;
  237. static UIColor *notificationBackground;
  238. static UIColor *notificationShadow;
  239. static ColorTheme colorTheme;
  240. static UITraitCollection *traitCollection;
  241. @implementation Colors
  242. + (void)initialize {
  243. if (@available(iOS 13.0, *)) {
  244. if ([[UserSettings sharedUserSettings] useSystemTheme] == true) {
  245. traitCollection = [UITraitCollection currentTraitCollection];
  246. if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
  247. [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeDarkWork : ColorThemeDark];
  248. } else {
  249. [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeLightWork : ColorThemeLight];
  250. }
  251. } else {
  252. if ([UserSettings sharedUserSettings].darkTheme) {
  253. [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeDarkWork : ColorThemeDark];
  254. } else {
  255. [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeLightWork : ColorThemeLight];
  256. }
  257. }
  258. } else {
  259. if ([UserSettings sharedUserSettings].darkTheme) {
  260. [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeDarkWork : ColorThemeDark];
  261. } else {
  262. [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeLightWork : ColorThemeLight];
  263. }
  264. }
  265. }
  266. + (BOOL)areCustomized {
  267. return colorTheme != ColorThemeLight;
  268. }
  269. + (void)setTheme:(ColorTheme)newTheme {
  270. colorTheme = newTheme;
  271. switch (colorTheme) {
  272. case ColorThemeDark:
  273. [self setupDarkTheme];
  274. [UserSettings sharedUserSettings].darkTheme = YES;
  275. break;
  276. case ColorThemeDarkWork:
  277. [self setupDarkWorkTheme];
  278. [UserSettings sharedUserSettings].darkTheme = YES;
  279. break;
  280. case ColorThemeLight:
  281. [self setupLightTheme];
  282. [UserSettings sharedUserSettings].darkTheme = NO;
  283. break;
  284. case ColorThemeLightWork:
  285. [self setupLightWorkTheme];
  286. [UserSettings sharedUserSettings].darkTheme = NO;
  287. break;
  288. case ColorThemeUndefined:
  289. [self setupLightTheme];
  290. [UserSettings sharedUserSettings].darkTheme = NO;
  291. break;
  292. }
  293. [StyleKit resetThemedCache];
  294. UIWindow *windowAppearance = [UIWindow appearance];
  295. [self updateWindow:windowAppearance];
  296. UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
  297. [self updateNavigationBar:navigationBarAppearance];
  298. UITabBar *tabBarAppearance = [UITabBar appearance];
  299. [self updateTabBar:tabBarAppearance];
  300. UISwitch *switchAppearance = [UISwitch appearance];
  301. [self updateSwitch:switchAppearance];
  302. UISearchBar *searchBarAppearance = [UISearchBar appearance];
  303. [self updateSearchBar:searchBarAppearance];
  304. [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIAlertController class]]] setTintColor:[Colors main]];
  305. [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIDocumentMenuViewController class]]] setTintColor:[Colors main]];
  306. [[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIDocumentMenuViewController class], [UIAlertController class]]] setTintColor:[Colors main]];
  307. [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIWindow class], [UIView class]]] setTintColor:[Colors main]];
  308. if(@available(iOS 13, *)) {
  309. // only use the appearance below iOS 13, in iOS 13 we can set the textColor directly on the searchbar
  310. } else {
  311. [[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setDefaultTextAttributes:@{NSForegroundColorAttributeName: fontNormal}];
  312. }
  313. }
  314. + (ColorTheme)getTheme {
  315. return colorTheme;
  316. }
  317. + (void)setupLightTheme {
  318. main = THEME_LIGHT_MAIN;
  319. backgroundBaseColor = THEME_LIGHT_BACKGROUND_BASE;
  320. background = THEME_LIGHT_BACKGROUND;
  321. backgroundLight = THEME_LIGHT_BACKGROUND_LIGHT;
  322. backgroundDark = THEME_LIGHT_BACKGROUND_DARK;
  323. backgroundSelectedDark = THEME_LIGHT_BACKGROUND_SELECTED_DARK;
  324. backgroundInverted = THEME_LIGHT_BACKGROUND_INVERTED;
  325. backgroundChat = THEME_LIGHT_BACKGROUND_CHAT;
  326. chatBackgroundLines = THEME_LIGHT_CHAT_BACKGROUND_LINES;
  327. chatSystemMessageBackground = THEME_LIGHT_BACKGROUND_CHAT_SYSTEM_MESSAGE;
  328. shareExtensionSelectedBackground = THEME_LIGHT_SHARE_EXTENSION_SELECTED_BACKGROUND;
  329. fontNormal = THEME_LIGHT_FONT_NORMAL;
  330. fontLight = THEME_LIGHT_FONT_LIGHT;
  331. fontVeryLight = THEME_LIGHT_FONT_VERY_LIGHT;
  332. fontDark = THEME_LIGHT_FONT_DARK;
  333. fontLink = THEME_LIGHT_FONT_LINK;
  334. fontLinkReceived = THEME_LIGHT_FONT_LINK_RECEIVED;
  335. fontPlaceholder = THEME_LIGHT_FONT_PLACEHOLDER;
  336. fontInverted = THEME_LIGHT_FONT_INVERTED;
  337. fontQuoteId = THEME_LIGHT_FONT_QUOTE_ID;
  338. fontQuoteText = THEME_LIGHT_FONT_QUOTE_TEXT;
  339. chatBarBackground = THEME_LIGHT_CHATBAR_BACKGROUND;
  340. chatBarInput = THEME_LIGHT_CHATBAR_INPUT;
  341. chatBarBorder = THEME_LIGHT_CHATBAR_BORDER;
  342. switchThumb = THEME_LIGHT_SWITCH_THUMB;
  343. bubbleSent = THEME_LIGHT_BUBBLE_SENT;
  344. bubbleSentSelected = THEME_LIGHT_BUBBLE_SENT_SELECTED;
  345. bubbleReceived = THEME_LIGHT_BUBBLE_RECEIVED;
  346. bubbleReceivedSelected = THEME_LIGHT_BUBBLE_RECEIVED_SELECTED;
  347. bubbleCallButton = THEME_LIGHT_BUBBLE_CALL_BUTTON;
  348. popupMenuBackground = THEME_LIGHT_POPUP_MENU_BACKGROUND;
  349. popupMenuHighlight = THEME_LIGHT_POPUP_MENU_HIGHTLIGHT;
  350. popupMenuSeparator = THEME_LIGHT_POPUP_MENU_SEPARATOR;
  351. ballotHighestVote = THEME_LIGHT_BALLOT_HIGHEST_VOTE;
  352. ballotRowLight = THEME_LIGHT_BALLOT_ROW_LIGHT;
  353. ballotRowDark = THEME_LIGHT_BALLOT_ROW_DARK;
  354. hairline = THEME_LIGHT_HAIRLINE;
  355. quoteBar = THEME_LIGHT_QUOTE_BAR;
  356. orange = THEME_LIGHT_ORANGE;
  357. red = THEME_LIGHT_RED;
  358. green = THEME_LIGHT_GREEN;
  359. gray = THEME_LIGHT_GRAY;
  360. verificationGreen = THEME_LIGHT_VERIFICATION_GREEN;
  361. workBlue = THEME_LIGHT_WORK_BLUE;
  362. searchBarStatusBar = THEME_LIGHT_SEARCH_BAR_STATUS_BAR;
  363. callStatusBar = THEME_LIGHT_CALL_STATUS_BAR;
  364. mentionBackgroundOwnMessageColor = THEME_LIGHT_MENTION_BACKGROUND_OWN;
  365. mentionBackgroundColor = THEME_LIGHT_MENTION_BACKGROUND;
  366. mentionBackgroundOverviewColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW;
  367. mentionBackgroundOwnMessageMeColor = THEME_LIGHT_MENTION_BACKGROUND_OWN_ME;
  368. mentionBackgroundMeColor = THEME_LIGHT_MENTION_BACKGROUND_ME;
  369. mentionBackgroundOverviewMeColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW_ME;
  370. mentionTextOwnMessageMeColor = THEME_LIGHT_MENTION_TEXT_OWN_ME;
  371. mentionTextMeColor = THEME_LIGHT_MENTION_TEXT_ME;
  372. mentionTextOverviewMeColor = THEME_LIGHT_MENTION_TEXT_OVERVIEW_ME;
  373. tagMarkBackground = THEME_LIGHT_TAG_MARK_BACKGROUND;
  374. notificationBackground = THEME_LIGHT_NOTIFICATION_BACKGROUND;
  375. notificationShadow = THEME_LIGHT_NOTIFICATION_SHADOW;
  376. }
  377. + (void)setupLightWorkTheme {
  378. main = THEME_LIGHT_WORK_MAIN;
  379. backgroundBaseColor = THEME_LIGHT_BACKGROUND_BASE;
  380. background = THEME_LIGHT_BACKGROUND;
  381. backgroundLight = THEME_LIGHT_BACKGROUND_LIGHT;
  382. backgroundDark = THEME_LIGHT_BACKGROUND_DARK;
  383. backgroundSelectedDark = THEME_LIGHT_BACKGROUND_SELECTED_DARK;
  384. backgroundInverted = THEME_LIGHT_BACKGROUND_INVERTED;
  385. backgroundChat = THEME_LIGHT_BACKGROUND_CHAT;
  386. chatBackgroundLines = THEME_LIGHT_CHAT_BACKGROUND_LINES;
  387. chatSystemMessageBackground = THEME_LIGHT_BACKGROUND_CHAT_SYSTEM_MESSAGE;
  388. shareExtensionSelectedBackground = THEME_LIGHT_SHARE_EXTENSION_SELECTED_BACKGROUND;
  389. fontNormal = THEME_LIGHT_FONT_NORMAL;
  390. fontLight = THEME_LIGHT_FONT_LIGHT;
  391. fontVeryLight = THEME_LIGHT_FONT_VERY_LIGHT;
  392. fontDark = THEME_LIGHT_FONT_DARK;
  393. fontLink = THEME_LIGHT_WORK_FONT_LINK;
  394. fontLinkReceived = THEME_LIGHT_WORK_FONT_LINK_RECEIVED;
  395. fontPlaceholder = THEME_LIGHT_WORK_FONT_PLACEHOLDER;
  396. fontInverted = THEME_LIGHT_FONT_INVERTED;
  397. fontQuoteId = THEME_LIGHT_FONT_QUOTE_ID;
  398. fontQuoteText = THEME_LIGHT_FONT_QUOTE_TEXT;
  399. chatBarBackground = THEME_LIGHT_CHATBAR_BACKGROUND;
  400. chatBarInput = THEME_LIGHT_CHATBAR_INPUT;
  401. chatBarBorder = THEME_LIGHT_CHATBAR_BORDER;
  402. switchThumb = THEME_LIGHT_SWITCH_THUMB;
  403. bubbleSent = THEME_LIGHT_WORK_BUBBLE_SENT;
  404. bubbleSentSelected = THEME_LIGHT_WORK_BUBBLE_SENT_SELECTED;
  405. bubbleReceived = THEME_LIGHT_BUBBLE_RECEIVED;
  406. bubbleReceivedSelected = THEME_LIGHT_BUBBLE_RECEIVED_SELECTED;
  407. bubbleCallButton = THEME_LIGHT_WORK_BUBBLE_CALL_BUTTON;
  408. popupMenuBackground = THEME_LIGHT_POPUP_MENU_BACKGROUND;
  409. popupMenuHighlight = THEME_LIGHT_POPUP_MENU_HIGHTLIGHT;
  410. popupMenuSeparator = THEME_LIGHT_POPUP_MENU_SEPARATOR;
  411. ballotHighestVote = THEME_LIGHT_WORK_BALLOT_HIGHEST_VOTE;
  412. ballotRowLight = THEME_LIGHT_BALLOT_ROW_LIGHT;
  413. ballotRowDark = THEME_LIGHT_BALLOT_ROW_DARK;
  414. hairline = THEME_LIGHT_HAIRLINE;
  415. quoteBar = THEME_LIGHT_WORK_QUOTE_BAR;
  416. orange = THEME_LIGHT_ORANGE;
  417. red = THEME_LIGHT_RED;
  418. green = THEME_LIGHT_WORK_GREEN;
  419. gray = THEME_LIGHT_GRAY;
  420. verificationGreen = THEME_LIGHT_WORK_VERIFICATION_GREEN;
  421. workBlue = THEME_LIGHT_WORK_WORK_BLUE;
  422. searchBarStatusBar = THEME_LIGHT_SEARCH_BAR_STATUS_BAR;
  423. callStatusBar = THEME_LIGHT_WORK_CALL_STATUS_BAR;
  424. mentionBackgroundOwnMessageColor = THEME_LIGHT_MENTION_BACKGROUND_OWN;
  425. mentionBackgroundColor = THEME_LIGHT_MENTION_BACKGROUND;
  426. mentionBackgroundOverviewColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW;
  427. mentionBackgroundOwnMessageMeColor = THEME_LIGHT_MENTION_BACKGROUND_OWN_ME;
  428. mentionBackgroundMeColor = THEME_LIGHT_MENTION_BACKGROUND_ME;
  429. mentionBackgroundOverviewMeColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW_ME;
  430. mentionTextOwnMessageMeColor = THEME_LIGHT_MENTION_TEXT_OWN_ME;
  431. mentionTextMeColor = THEME_LIGHT_MENTION_TEXT_ME;
  432. mentionTextOverviewMeColor = THEME_LIGHT_MENTION_TEXT_OVERVIEW_ME;
  433. tagMarkBackground = THEME_LIGHT_TAG_MARK_BACKGROUND;
  434. notificationBackground = THEME_LIGHT_NOTIFICATION_BACKGROUND;
  435. notificationShadow = THEME_LIGHT_NOTIFICATION_SHADOW;
  436. }
  437. + (void)setupDarkTheme {
  438. main = THEME_DARK_MAIN;
  439. backgroundBaseColor = THEME_DARK_BACKGROUND_BASE;
  440. background = THEME_DARK_BACKGROUND;
  441. backgroundLight = THEME_DARK_BACKGROUND_LIGHT;
  442. backgroundDark = THEME_DARK_BACKGROUND_DARK;
  443. backgroundSelectedDark = THEME_DARK_BACKGROUND_SELECTED_DARK;
  444. backgroundInverted = THEME_DARK_BACKGROUND_INVERTED;
  445. backgroundChat = THEME_DARK_BACKGROUND_CHAT;
  446. chatBackgroundLines = THEME_DARK_CHAT_BACKGROUND_LINES;
  447. chatSystemMessageBackground = THEME_DARK_BACKGROUND_CHAT_SYSTEM_MESSAGE;
  448. shareExtensionSelectedBackground = THEME_DARK_SHARE_EXTENSION_SELECTED_BACKGROUND;
  449. fontNormal = THEME_DARK_FONT_NORMAL;
  450. fontLight = THEME_DARK_FONT_LIGHT;
  451. fontVeryLight = THEME_DARK_FONT_VERY_LIGHT;
  452. fontDark = THEME_DARK_FONT_DARK;
  453. fontLink = THEME_DARK_FONT_LINK;
  454. fontLinkReceived = THEME_DARK_FONT_LINK_RECEIVED;
  455. fontPlaceholder = THEME_DARK_FONT_PLACEHOLDER;
  456. fontInverted = THEME_DARK_FONT_INVERTED;
  457. fontQuoteId = THEME_DARK_FONT_QUOTE_ID;
  458. fontQuoteText = THEME_DARK_FONT_QUOTE_TEXT;
  459. chatBarBackground = THEME_DARK_CHATBAR_BACKGROUND;
  460. chatBarInput = THEME_DARK_CHATBAR_INPUT;
  461. chatBarBorder = THEME_DARK_CHATBAR_BORDER;
  462. switchThumb = THEME_DARK_SWITCH_THUMB;
  463. bubbleSent = THEME_DARK_BUBBLE_SENT;
  464. bubbleSentSelected = THEME_DARK_BUBBLE_SENT_SELECTED;
  465. bubbleReceived = THEME_DARK_BUBBLE_RECEIVED;
  466. bubbleReceivedSelected = THEME_DARK_BUBBLE_RECEIVED_SELECTED;
  467. bubbleCallButton = THEME_DARK_BUBBLE_CALL_BUTTON;
  468. popupMenuBackground = THEME_DARK_POPUP_MENU_BACKGROUND;
  469. popupMenuHighlight = THEME_DARK_POPUP_MENU_HIGHTLIGHT;
  470. popupMenuSeparator = THEME_DARK_POPUP_MENU_SEPARATOR;
  471. ballotHighestVote = THEME_DARK_BALLOT_HIGHEST_VOTE;
  472. ballotRowLight = THEME_DARK_BALLOT_ROW_LIGHT;
  473. ballotRowDark = THEME_DARK_BALLOT_ROW_DARK;
  474. hairline = THEME_DARK_HAIRLINE;
  475. quoteBar = THEME_DARK_QUOTE_BAR;
  476. orange = THEME_DARK_ORANGE;
  477. red = THEME_DARK_RED;
  478. green = THEME_DARK_GREEN;
  479. gray = THEME_DARK_GRAY;
  480. verificationGreen = THEME_DARK_VERIFICATION_GREEN;
  481. workBlue = THEME_DARK_WORK_BLUE;
  482. searchBarStatusBar = THEME_DARK_SEARCH_BAR_STATUS_BAR;
  483. callStatusBar = THEME_DARK_CALL_STATUS_BAR;
  484. mentionBackgroundOwnMessageColor = THEME_DARK_MENTION_BACKGROUND_OWN;
  485. mentionBackgroundColor = THEME_DARK_MENTION_BACKGROUND;
  486. mentionBackgroundOverviewColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW;
  487. mentionBackgroundOwnMessageMeColor = THEME_DARK_MENTION_BACKGROUND_OWN_ME;
  488. mentionBackgroundMeColor = THEME_DARK_MENTION_BACKGROUND_ME;
  489. mentionBackgroundOverviewMeColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW_ME;
  490. mentionTextOwnMessageMeColor = THEME_DARK_MENTION_TEXT_OWN_ME;
  491. mentionTextMeColor = THEME_DARK_MENTION_TEXT_ME;
  492. mentionTextOverviewMeColor = THEME_DARK_MENTION_TEXT_OVERVIEW_ME;
  493. tagMarkBackground = THEME_DARK_TAG_MARK_BACKGROUND;
  494. notificationBackground = THEME_DARK_NOTIFICATION_BACKGROUND;
  495. notificationShadow = THEME_DARK_NOTIFICATION_SHADOW;
  496. }
  497. + (void)setupDarkWorkTheme {
  498. main = THEME_DARK_WORK_MAIN;
  499. backgroundBaseColor = THEME_DARK_BACKGROUND_BASE;
  500. background = THEME_DARK_BACKGROUND;
  501. backgroundLight = THEME_DARK_BACKGROUND_LIGHT;
  502. backgroundDark = THEME_DARK_BACKGROUND_DARK;
  503. backgroundSelectedDark = THEME_DARK_BACKGROUND_SELECTED_DARK;
  504. backgroundInverted = THEME_DARK_BACKGROUND_INVERTED;
  505. backgroundChat = THEME_DARK_BACKGROUND_CHAT;
  506. chatBackgroundLines = THEME_DARK_CHAT_BACKGROUND_LINES;
  507. chatSystemMessageBackground = THEME_DARK_BACKGROUND_CHAT_SYSTEM_MESSAGE;
  508. shareExtensionSelectedBackground = THEME_DARK_SHARE_EXTENSION_SELECTED_BACKGROUND;
  509. fontNormal = THEME_DARK_FONT_NORMAL;
  510. fontLight = THEME_DARK_FONT_LIGHT;
  511. fontVeryLight = THEME_DARK_FONT_VERY_LIGHT;
  512. fontDark = THEME_DARK_FONT_DARK;
  513. fontLink = THEME_DARK_WORK_FONT_LINK;
  514. fontLinkReceived = THEME_DARK_WORK_FONT_LINK_RECEIVED;
  515. fontPlaceholder = THEME_DARK_WORK_FONT_PLACEHOLDER;
  516. fontInverted = THEME_DARK_FONT_INVERTED;
  517. fontQuoteId = THEME_DARK_FONT_QUOTE_ID;
  518. fontQuoteText = THEME_DARK_FONT_QUOTE_TEXT;
  519. chatBarBackground = THEME_DARK_CHATBAR_BACKGROUND;
  520. chatBarInput = THEME_DARK_CHATBAR_INPUT;
  521. chatBarBorder = THEME_DARK_CHATBAR_BORDER;
  522. switchThumb = THEME_DARK_SWITCH_THUMB;
  523. bubbleSent = THEME_DARK_BUBBLE_SENT;
  524. bubbleSentSelected = THEME_DARK_BUBBLE_SENT_SELECTED;
  525. bubbleReceived = THEME_DARK_BUBBLE_RECEIVED;
  526. bubbleReceivedSelected = THEME_DARK_BUBBLE_RECEIVED_SELECTED;
  527. bubbleCallButton = THEME_DARK_WORK_BUBBLE_CALL_BUTTON;
  528. popupMenuBackground = THEME_DARK_POPUP_MENU_BACKGROUND;
  529. popupMenuHighlight = THEME_DARK_POPUP_MENU_HIGHTLIGHT;
  530. popupMenuSeparator = THEME_DARK_POPUP_MENU_SEPARATOR;
  531. ballotHighestVote = THEME_DARK_WORK_BALLOT_HIGHEST_VOTE;
  532. ballotRowLight = THEME_DARK_BALLOT_ROW_LIGHT;
  533. ballotRowDark = THEME_DARK_BALLOT_ROW_DARK;
  534. hairline = THEME_DARK_HAIRLINE;
  535. quoteBar = THEME_DARK_WORK_QUOTE_BAR;
  536. orange = THEME_DARK_ORANGE;
  537. red = THEME_DARK_RED;
  538. green = THEME_DARK_WORK_GREEN;
  539. gray = THEME_DARK_GRAY;
  540. verificationGreen = THEME_DARK_WORK_VERIFICATION_GREEN;
  541. workBlue = THEME_DARK_WORK_WORK_BLUE;
  542. searchBarStatusBar = THEME_DARK_SEARCH_BAR_STATUS_BAR;
  543. callStatusBar = THEME_DARK_WORK_CALL_STATUS_BAR;
  544. mentionBackgroundOwnMessageColor = THEME_DARK_MENTION_BACKGROUND_OWN;
  545. mentionBackgroundColor = THEME_DARK_MENTION_BACKGROUND;
  546. mentionBackgroundOverviewColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW;
  547. mentionBackgroundOwnMessageMeColor = THEME_DARK_MENTION_BACKGROUND_OWN_ME;
  548. mentionBackgroundMeColor = THEME_DARK_MENTION_BACKGROUND_ME;
  549. mentionBackgroundOverviewMeColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW_ME;
  550. mentionTextOwnMessageMeColor = THEME_DARK_MENTION_TEXT_OWN_ME;
  551. mentionTextMeColor = THEME_DARK_MENTION_TEXT_ME;
  552. mentionTextOverviewMeColor = THEME_DARK_MENTION_TEXT_OVERVIEW_ME;
  553. tagMarkBackground = THEME_DARK_TAG_MARK_BACKGROUND;
  554. notificationBackground = THEME_DARK_NOTIFICATION_BACKGROUND;
  555. notificationShadow = THEME_DARK_NOTIFICATION_SHADOW;
  556. }
  557. + (void)resetToDefault {
  558. [self setTheme:ColorThemeLight];
  559. }
  560. + (void)updateKeyboardAppearanceFor:(id<UITextInputTraits>)textInputTraits {
  561. if ([textInputTraits respondsToSelector:@selector(setKeyboardAppearance:)]) {
  562. switch (colorTheme) {
  563. case ColorThemeDark:
  564. case ColorThemeDarkWork:
  565. textInputTraits.keyboardAppearance = UIKeyboardAppearanceDark;
  566. break;
  567. case ColorThemeLight:
  568. case ColorThemeLightWork:
  569. case ColorThemeUndefined:
  570. textInputTraits.keyboardAppearance = UIKeyboardAppearanceDefault;
  571. break;
  572. }
  573. }
  574. if ([textInputTraits respondsToSelector:@selector(setTextColor:)]) {
  575. [textInputTraits performSelector:@selector(setTextColor:) withObject:[Colors fontNormal]];
  576. }
  577. if ([textInputTraits respondsToSelector:@selector(setTintColor:)]) {
  578. [textInputTraits performSelector:@selector(setTintColor:) withObject:[Colors main]];
  579. }
  580. if ([textInputTraits respondsToSelector:@selector(setAttributedPlaceholder:)]) {
  581. NSAttributedString *placeholder = [textInputTraits performSelector:@selector(attributedPlaceholder)];
  582. NSMutableAttributedString *mutablePlaceholder = [[NSMutableAttributedString alloc] initWithAttributedString:placeholder];
  583. [mutablePlaceholder addAttribute:NSForegroundColorAttributeName value:[Colors fontPlaceholder] range:NSMakeRange(0, placeholder.length)];
  584. [textInputTraits performSelector:@selector(setAttributedPlaceholder:) withObject:mutablePlaceholder];
  585. }
  586. if ([textInputTraits respondsToSelector:@selector(setTintColor:)]) {
  587. [textInputTraits performSelector:@selector(setTintColor:) withObject:[Colors main]];
  588. }
  589. if ([textInputTraits isKindOfClass:[UITextField class]]) {
  590. UITextField *textField = (UITextField *)textInputTraits;
  591. [textField colorizeClearButton];
  592. }
  593. }
  594. + (void)updateWindow:(UIWindow *)window {
  595. [window setTintColor:main];
  596. }
  597. + (void)updateNavigationBar:(UINavigationBar *)navigationBar {
  598. switch (colorTheme) {
  599. case ColorThemeDark:
  600. case ColorThemeDarkWork:
  601. [navigationBar setBarStyle:UIBarStyleBlack];
  602. [navigationBar setTranslucent:YES];
  603. [navigationBar setTintColor:main];
  604. [navigationBar setBackgroundColor:nil];
  605. if (@available(iOS 13.0, *)) {
  606. navigationBar.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
  607. }
  608. break;
  609. case ColorThemeLight:
  610. case ColorThemeLightWork:
  611. case ColorThemeUndefined:
  612. [navigationBar setBarStyle:UIBarStyleDefault];
  613. [navigationBar setTintColor:main];
  614. [navigationBar setBackgroundColor:backgroundBaseColor];
  615. if (@available(iOS 13.0, *)) {
  616. navigationBar.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
  617. }
  618. break;
  619. }
  620. if ([VoIPHelper shared].isCallActiveInBackground) {
  621. [navigationBar setBarTintColor:callStatusBar];
  622. } else {
  623. [navigationBar setBarTintColor:nil];
  624. }
  625. if (@available(iOS 13.0, *)) {
  626. UINavigationBarAppearance *newAppearance = [[UINavigationBarAppearance alloc] init];
  627. [newAppearance configureWithDefaultBackground];
  628. if ([VoIPHelper shared].isCallActiveInBackground) {
  629. newAppearance.backgroundColor = callStatusBar;
  630. } else {
  631. newAppearance.backgroundColor = nil;
  632. }
  633. navigationBar.standardAppearance = newAppearance;
  634. navigationBar.scrollEdgeAppearance = newAppearance;
  635. } else {
  636. if (@available(iOS 11.0, *)) {
  637. [navigationBar setTintColor:main];
  638. [navigationBar setLargeTitleTextAttributes:@{NSForegroundColorAttributeName: fontNormal}];
  639. }
  640. }
  641. }
  642. + (void)updateTableView:(UITableView *)tableView {
  643. if (tableView.style == UITableViewStyleGrouped) {
  644. [tableView setBackgroundColor:[Colors background]];
  645. } else {
  646. [tableView setBackgroundColor:[Colors background]];
  647. }
  648. [tableView setSectionIndexBackgroundColor:[UIColor clearColor]];
  649. [tableView setSectionIndexColor:[Colors main]];
  650. [tableView setSeparatorColor:[Colors hairline]];
  651. tableView.backgroundView = [[UIView alloc] initWithFrame:tableView.frame];
  652. tableView.backgroundView.backgroundColor = [Colors backgroundDark];
  653. }
  654. + (void)updateTableViewCellBackground:(UITableViewCell *)cell {
  655. [cell setBackgroundColor:[Colors background]];
  656. cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
  657. cell.selectedBackgroundView.backgroundColor = [Colors backgroundSelectedDark];
  658. }
  659. + (void)updateTableViewCell:(UITableViewCell *)cell {
  660. [self updateTableViewCellBackground:cell];
  661. UIColor *textColor;
  662. UIColor *detailTextColor;
  663. if (cell.accessibilityTraits & UIAccessibilityTraitNotEnabled && !cell.isUserInteractionEnabled) {
  664. textColor = [Colors fontLight];
  665. detailTextColor = [Colors fontVeryLight];
  666. } else if (cell.accessibilityTraits & UIAccessibilityTraitButton && cell.accessoryType != UITableViewCellAccessoryDisclosureIndicator && cell.accessoryType != UITableViewCellAccessoryDetailButton && ![cell.accessoryView isKindOfClass:[UISwitch class]]) {
  667. textColor = [Colors main];
  668. detailTextColor = [Colors fontLight];
  669. } else {
  670. textColor = [Colors fontNormal];
  671. detailTextColor = [Colors fontLight];
  672. }
  673. // handle custom table cells
  674. [self setTextColor:textColor inView:cell.contentView];
  675. if (cell.detailTextLabel) {
  676. cell.detailTextLabel.textColor = detailTextColor;
  677. }
  678. [cell setTintColor:[Colors main]];
  679. }
  680. + (void)updateTabBar:(UITabBar *)tabBar {
  681. switch (colorTheme) {
  682. case ColorThemeDark:
  683. case ColorThemeDarkWork:
  684. [tabBar setBarStyle:UIBarStyleBlack];
  685. [tabBar setTranslucent:YES];
  686. [tabBar setTintColor:main];
  687. if (@available(iOS 13.0, *)) {
  688. tabBar.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
  689. }
  690. break;
  691. case ColorThemeLight:
  692. case ColorThemeLightWork:
  693. case ColorThemeUndefined:
  694. [tabBar setBarStyle:UIBarStyleDefault];
  695. [tabBar setTintColor:main];
  696. if (@available(iOS 13.0, *)) {
  697. tabBar.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
  698. }
  699. break;
  700. }
  701. }
  702. + (void)updateSearchBar:(UISearchBar *)searchBar {
  703. [self updateKeyboardAppearanceFor:searchBar];
  704. switch (colorTheme) {
  705. case ColorThemeDark:
  706. case ColorThemeDarkWork:
  707. searchBar.barStyle = UIBarStyleBlack;
  708. [searchBar setTranslucent:YES];
  709. break;
  710. case ColorThemeLight:
  711. case ColorThemeLightWork:
  712. case ColorThemeUndefined:
  713. searchBar.barStyle = UIBarStyleDefault;
  714. break;
  715. }
  716. [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTitleTextAttributes:@{NSForegroundColorAttributeName: main} forState:UIControlStateNormal];
  717. if (@available(iOS 13.0, *)) {
  718. // Since iOS 13 we can set the textColor directly on the searchbar
  719. searchBar.searchTextField.textColor = fontNormal;
  720. if ([searchBar respondsToSelector:NSSelectorFromString(@"searchTextField")]) {
  721. id searchTextField = [searchBar valueForKey:@"searchTextField"];
  722. if ([searchTextField respondsToSelector:NSSelectorFromString(@"backgroundColor")]) {
  723. [searchTextField setValue:searchBarStatusBar forKey:@"backgroundColor"];
  724. }
  725. }
  726. }
  727. }
  728. + (void)updateSwitch:(UISwitch *)switchAppearance {
  729. [switchAppearance setThumbTintColor:[Colors switchThumb]];
  730. [switchAppearance setOnTintColor:[Colors main]];
  731. switch (colorTheme) {
  732. case ColorThemeDarkWork:
  733. case ColorThemeDark:
  734. case ColorThemeLight:
  735. case ColorThemeLightWork:
  736. [switchAppearance setOnTintColor:[Colors main]];
  737. break;
  738. case ColorThemeUndefined:
  739. [switchAppearance setOnTintColor:THREEMA_COLOR_GREEN];
  740. break;
  741. }
  742. }
  743. + (void)setTextColor:(UIColor *)color inView:(UIView *)parentView {
  744. for (UIView *view in parentView.subviews) {
  745. if ([view isKindOfClass:[ContactNameLabel class]]) {
  746. continue;
  747. }
  748. if ([view isKindOfClass:[UILabel class]]) {
  749. UILabel *label = (UILabel *)view;
  750. [label setTextColor:color];
  751. [label setHighlightedTextColor:color];
  752. } else if ([view isKindOfClass:[UITextField class]]) {
  753. UITextField *textField = (UITextField *)view;
  754. [textField setTextColor:color];
  755. [textField colorizeClearButton];
  756. if ([textField placeholder] != nil) {
  757. UIColor *color = [Colors fontPlaceholder];
  758. textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:[textField placeholder] attributes:@{NSForegroundColorAttributeName: color}];
  759. }
  760. } else if ([view isKindOfClass:[UIScrollView class]] || [view isKindOfClass:[UIStackView class]] || [view isKindOfClass:[UIView class]]) {
  761. [Colors setTextColor:color inView:view];
  762. }
  763. }
  764. }
  765. + (UIColor *)workBlue {
  766. return workBlue;
  767. }
  768. + (UIColor *)main {
  769. return main;
  770. }
  771. + (UIColor *)background {
  772. return background;
  773. }
  774. + (UIColor *)backgroundBaseColor {
  775. return backgroundBaseColor;
  776. }
  777. + (UIColor *)backgroundLight {
  778. return backgroundLight;
  779. }
  780. + (UIColor *)backgroundDark {
  781. return backgroundDark;
  782. }
  783. + (UIColor *)backgroundSelectedDark {
  784. return backgroundSelectedDark;
  785. }
  786. + (UIColor *)backgroundInverted {
  787. return backgroundInverted;
  788. }
  789. + (UIColor *)backgroundChat {
  790. return backgroundChat;
  791. }
  792. + (UIColor *)chatBackgroundLines {
  793. return chatBackgroundLines;
  794. }
  795. + (UIColor *)chatSystemMessageBackground {
  796. return chatSystemMessageBackground;
  797. }
  798. + (UIColor *)shareExtensionSelectedBackground {
  799. return shareExtensionSelectedBackground;
  800. }
  801. + (UIColor *)fontNormal {
  802. return fontNormal;
  803. }
  804. + (UIColor *)fontLight {
  805. return fontLight;
  806. }
  807. + (UIColor *)fontVeryLight {
  808. return fontVeryLight;
  809. }
  810. + (UIColor *)fontDark {
  811. return fontDark;
  812. }
  813. + (UIColor *)fontLink {
  814. return fontLink;
  815. }
  816. + (UIColor *)fontLinkReceived {
  817. return fontLinkReceived;
  818. }
  819. + (UIColor *)fontPlaceholder {
  820. return fontPlaceholder;
  821. }
  822. + (UIColor *)fontInverted {
  823. return fontInverted;
  824. }
  825. + (UIColor *)fontQuoteId {
  826. return fontQuoteId;
  827. }
  828. + (UIColor *)fontQuoteText {
  829. return fontQuoteText;
  830. }
  831. + (UIColor *)chatBarBackground {
  832. return chatBarBackground;
  833. }
  834. + (UIColor *)chatBarInput {
  835. return chatBarInput;
  836. }
  837. + (UIColor *)chatBarBorder {
  838. return chatBarBorder;
  839. }
  840. + (UIColor *)switchThumb {
  841. return switchThumb;
  842. }
  843. + (UIColor *)bubbleSent {
  844. return bubbleSent;
  845. }
  846. + (UIColor *)bubbleSentSelected {
  847. return bubbleSentSelected;
  848. }
  849. + (UIColor *)bubbleReceived {
  850. return bubbleReceived;
  851. }
  852. + (UIColor *)bubbleReceivedSelected {
  853. return bubbleReceivedSelected;
  854. }
  855. + (UIColor *)bubbleCallButton {
  856. return bubbleCallButton;
  857. }
  858. + (UIColor *)popupMenuBackground {
  859. return popupMenuBackground;
  860. }
  861. + (UIColor *)popupMenuHighlight {
  862. return popupMenuHighlight;
  863. }
  864. + (UIColor *)popupMenuSeparator {
  865. return popupMenuSeparator;
  866. }
  867. + (UIColor *)ballotHighestVote {
  868. return ballotHighestVote;
  869. }
  870. + (UIColor *)ballotRowLight {
  871. return ballotRowLight;
  872. }
  873. + (UIColor *)ballotRowDark {
  874. return ballotRowDark;
  875. }
  876. + (UIColor *)hairline {
  877. return hairline;
  878. }
  879. + (UIColor *)quoteBar {
  880. return quoteBar;
  881. }
  882. + (UIColor *)orange {
  883. return orange;
  884. }
  885. + (UIColor *)red {
  886. return red;
  887. }
  888. + (UIColor *)green {
  889. return green;
  890. }
  891. + (UIColor *)verificationGreen {
  892. return verificationGreen;
  893. }
  894. + (UIColor *)gray {
  895. return gray;
  896. }
  897. + (UIColor *)searchBarStatusBar {
  898. return searchBarStatusBar;
  899. }
  900. + (UIColor *)callStatusBar {
  901. return callStatusBar;
  902. }
  903. + (UIColor *)mentionBackground:(int)messageInfo {
  904. switch (messageInfo) {
  905. case TextStyleUtilsMessageInfoReceivedMessage:
  906. return mentionBackgroundColor;
  907. case TextStyleUtilsMessageInfoOwnMessage:
  908. return mentionBackgroundOwnMessageColor;
  909. case TextStyleUtilsMessageInfoOverview:
  910. return mentionBackgroundOverviewColor;
  911. default:
  912. return mentionBackgroundColor;
  913. }
  914. }
  915. + (UIColor *)mentionBackgroundMe:(int)messageInfo {
  916. switch (messageInfo) {
  917. case TextStyleUtilsMessageInfoReceivedMessage:
  918. return mentionBackgroundMeColor;
  919. case TextStyleUtilsMessageInfoOwnMessage:
  920. return mentionBackgroundOwnMessageMeColor;
  921. case TextStyleUtilsMessageInfoOverview:
  922. return mentionBackgroundOverviewMeColor;
  923. default:
  924. return mentionBackgroundMeColor;
  925. }
  926. }
  927. + (UIColor *)mentionTextMe:(int)messageInfo {
  928. switch (messageInfo) {
  929. case TextStyleUtilsMessageInfoReceivedMessage:
  930. return mentionTextMeColor;
  931. case TextStyleUtilsMessageInfoOwnMessage:
  932. return mentionTextOwnMessageMeColor;
  933. case TextStyleUtilsMessageInfoOverview:
  934. return mentionTextOverviewMeColor;
  935. default:
  936. return mentionTextMeColor;
  937. }
  938. }
  939. + (UIColor *)privacyPolicyLink {
  940. if ([LicenseStore requiresLicenseKey]) {
  941. return THEME_DARK_WORK_FONT_LINK;
  942. } else {
  943. return THEME_DARK_FONT_LINK;
  944. }
  945. }
  946. + (UIColor *)mainThemeDark {
  947. if ([LicenseStore requiresLicenseKey]) {
  948. return THEME_DARK_WORK_MAIN;
  949. } else {
  950. return THEME_DARK_MAIN;
  951. }
  952. }
  953. + (UIColor *)backgroundThemeDark {
  954. return THEME_DARK_BACKGROUND_DARK;
  955. }
  956. + (UIColor *)markTag {
  957. return tagMarkBackground;
  958. }
  959. + (UIColor *)white {
  960. return [UIColor whiteColor];
  961. }
  962. + (UIColor *)black {
  963. return [UIColor blackColor];
  964. }
  965. + (UIColor *)darkGrey {
  966. return THREEMA_COLOR_DARK_GREY;
  967. }
  968. + (UIColor *)notificationBackground {
  969. return notificationBackground;
  970. }
  971. + (UIColor *)notificationShadow {
  972. return notificationShadow;
  973. }
  974. @end