12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214 |
- // _____ _
- // |_ _| |_ _ _ ___ ___ _ __ __ _
- // | | | ' \| '_/ -_) -_) ' \/ _` |_
- // |_| |_||_|_| \___\___|_|_|_\__,_(_)
- //
- // Threema iOS Client
- // Copyright (c) 2016-2020 Threema GmbH
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU Affero General Public License, version 3,
- // as published by the Free Software Foundation.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU Affero General Public License for more details.
- //
- // You should have received a copy of the GNU Affero General Public License
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
- #import "Colors.h"
- #import "BundleUtil.h"
- #import "UserSettings.h"
- #import "UIImage+ColoredImage.h"
- #import "UITextField+Themed.h"
- #import "ContactNameLabel.h"
- #import "VoIPHelper.h"
- #import "TextStyleUtils.h"
- #import "LicenseStore.h"
- #import "ThreemaFramework/ThreemaFramework-Swift.h"
- #define THREEMA_COLOR_PLACEHOLDER [UIColor lightGrayColor]
- #define THREEMA_COLOR_LIGHT_GREY [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]
- #define THREEMA_COLOR_DARK_GREY [UIColor colorWithRed:0.3 green:0.3 blue:0.3 alpha:1.0]
- #define THREEMA_COLOR_GREEN [UIColor colorWithRed:96.0/255.0 green:194.0/255.0 blue:57.0/255.0 alpha:1.0]
- // MARK: Dark Theme Base
- #define THEME_DARK_BACKGROUND_BASE [UIColor colorWithRed:0.0/255.0 green: 0.0/255.0 blue:0.0/255.0 alpha:1.0]
- #define THEME_DARK_BACKGROUND [UIColor colorWithRed:33.0/255.0 green:33.0/255.0 blue:33.0/255.0 alpha:1.0]
- #define THEME_DARK_BACKGROUND_DARK [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
- #define THEME_DARK_BACKGROUND_CHAT [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
- #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]
- #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]
- #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]
- #define THEME_DARK_BACKGROUND_LIGHT [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
- #define THEME_DARK_BACKGROUND_INVERTED [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
- #define THEME_DARK_SHARE_EXTENSION_SELECTED_BACKGROUND [UIColor colorWithRed:0.82 green:0.82 blue:0.82 alpha:1.0]
- #define THEME_DARK_FONT_NORMAL [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
- #define THEME_DARK_FONT_LIGHT [UIColor colorWithRed:224.0/255.0 green:224.0/255.0 blue:224.0/255.0 alpha:1.0]
- #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]
- #define THEME_DARK_FONT_DARK [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
- #define THEME_DARK_FONT_INVERTED [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
- #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]
- #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]
- #define THEME_DARK_CHATBAR_INPUT [UIColor colorWithRed:33.0/255.0 green:33.0/255.0 blue:33.0/255.0 alpha:1.0]
- #define THEME_DARK_CHATBAR_BACKGROUND [UIColor colorWithRed:22.0/255.0 green:22.0/255.0 blue:22.0/255.0 alpha:1.0]
- #define THEME_DARK_CHATBAR_BORDER [UIColor colorWithRed:66.0/255.0 green:66.0/255.0 blue:66.0/255.0 alpha:1.0]
- #define THEME_DARK_SWITCH_THUMB [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
- #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]
- #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]
- #define THEME_DARK_HAIRLINE [UIColor colorWithRed:55.0/255.0 green:55.0/255.0 blue:55.0/255.0 alpha:1.0]
- #define THEME_DARK_ORANGE [UIColor colorWithRed:246.0/255.0 green:146.0/255.0 blue:30.0/255.0 alpha:1.0]
- #define THEME_DARK_RED [UIColor colorWithRed:235.0/255.0 green:29.0/255.0 blue:36.0/255.0 alpha:1.0]
- #define THEME_DARK_GRAY [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
- #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]
- #define THEME_DARK_MENTION_BACKGROUND [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
- #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]
- #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]
- #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]
- #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]
- #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]
- #define THEME_DARK_MENTION_TEXT_ME THEME_DARK_FONT_INVERTED
- #define THEME_DARK_MENTION_TEXT_OWN_ME THEME_DARK_FONT_INVERTED
- #define THEME_DARK_MENTION_TEXT_OVERVIEW_ME THEME_DARK_FONT_INVERTED
- #define THEME_DARK_BUBBLE_SENT [UIColor colorWithRed:38.0/255.0 green:38.0/255.0 blue:38.0/255.0 alpha:1.0]
- #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]
- #define THEME_DARK_BUBBLE_RECEIVED [UIColor colorWithRed:55.0/255.0 green:55.0/255.0 blue:55.0/255.0 alpha:1.0]
- #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]
- #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]
- #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]
- #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]
- #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]
- #define THEME_DARK_NOTIFICATION_BACKGROUND [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
- #define THEME_DARK_NOTIFICATION_SHADOW [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
- // MARK: Dark Theme
- #define THEME_DARK_MAIN [UIColor colorWithRed:5.0/255.0 green: 166.0/255.0 blue:63.0/255.0 alpha:1.0]
- #define THEME_DARK_FONT_LINK THEME_DARK_MAIN
- #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]
- #define THEME_DARK_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER
- #define THEME_DARK_BUBBLE_CALL_BUTTON THEME_DARK_MAIN
- #define THEME_DARK_BALLOT_HIGHEST_VOTE THEME_DARK_MAIN
- #define THEME_DARK_QUOTE_BAR THEME_DARK_GREEN
- #define THEME_DARK_GREEN THEME_DARK_MAIN
- #define THEME_DARK_VERIFICATION_GREEN THEME_DARK_MAIN
- #define THEME_DARK_WORK_BLUE [UIColor colorWithRed:0.0/255.0 green: 115.0/255.0 blue:196.0/255.0 alpha:1.0]
- #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]
- // MARK: Dark Work Theme
- #define THEME_DARK_WORK_MAIN [UIColor colorWithRed:0.0/255.0 green: 150.0/255.0 blue:255.0/255.0 alpha:1.0]
- #define THEME_DARK_WORK_FONT_LINK THEME_DARK_WORK_MAIN
- #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]
- #define THEME_DARK_WORK_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER
- #define THEME_DARK_WORK_BUBBLE_CALL_BUTTON THEME_DARK_WORK_MAIN
- #define THEME_DARK_WORK_BALLOT_HIGHEST_VOTE THEME_DARK_WORK_MAIN
- #define THEME_DARK_WORK_QUOTE_BAR THEME_DARK_WORK_MAIN
- #define THEME_DARK_WORK_GREEN [UIColor colorWithRed:5.0/255.0 green: 166.0/255.0 blue:63.0/255.0 alpha:1.0]
- #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]
- #define THEME_DARK_WORK_WORK_BLUE THEME_DARK_WORK_MAIN
- #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]
- // MARK: Light Theme Base
- #define THEME_LIGHT_BACKGROUND_BASE [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
- #define THEME_LIGHT_BACKGROUND [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
- #define THEME_LIGHT_BACKGROUND_DARK [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]
- #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]
- #define THEME_LIGHT_BACKGROUND_LIGHT [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
- #define THEME_LIGHT_BACKGROUND_INVERTED [UIColor colorWithRed:158.0/255.0 green:158.0/255.0 blue:158.0/255.0 alpha:1.0]
- #define THEME_LIGHT_BACKGROUND_CHAT [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]
- #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]
- #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]
- #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]
- #define THEME_LIGHT_FONT_NORMAL [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0] // Normal font color
- #define THEME_LIGHT_FONT_LIGHT [UIColor colorWithRed:117.0/255.0 green:117.0/255.0 blue:117.0/255.0 alpha:1.0]
- #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]
- #define THEME_LIGHT_FONT_DARK [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
- #define THEME_LIGHT_FONT_INVERTED [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
- #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]
- #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]
- #define THEME_LIGHT_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER // Placeholder color (Lightgray)
- #define THEME_LIGHT_CHATBAR_INPUT [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
- #define THEME_LIGHT_CHATBAR_BACKGROUND [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]
- #define THEME_LIGHT_CHATBAR_BORDER [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
- #define THEME_LIGHT_SWITCH_THUMB nil
- #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]
- #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]
- #define THEME_LIGHT_HAIRLINE [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
- #define THEME_LIGHT_ORANGE [UIColor colorWithRed:246.0/255.0 green:146.0/255.0 blue:30.0/255.0 alpha:1.0]
- #define THEME_LIGHT_RED [UIColor colorWithRed:235.0/255.0 green:29.0/255.0 blue:36.0/255.0 alpha:1.0]
- #define THEME_LIGHT_GRAY [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
- #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]
- #define THEME_LIGHT_MENTION_BACKGROUND [UIColor colorWithRed:189.0/255.0 green:189.0/255.0 blue:189.0/255.0 alpha:1.0]
- #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]
- #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]
- #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]
- #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]
- #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]
- #define THEME_LIGHT_MENTION_TEXT_ME THEME_LIGHT_FONT_INVERTED
- #define THEME_LIGHT_MENTION_TEXT_OWN_ME THEME_LIGHT_FONT_INVERTED
- #define THEME_LIGHT_MENTION_TEXT_OVERVIEW_ME THEME_LIGHT_FONT_INVERTED
- #define THEME_LIGHT_BUBBLE_RECEIVED [UIColor colorWithRed:232.0/255.0 green:232.0/255.0 blue:232.0/255.0 alpha:1.0]
- #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]
- #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]
- #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]
- #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]
- #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]
- #define THEME_LIGHT_NOTIFICATION_BACKGROUND [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]
- #define THEME_LIGHT_NOTIFICATION_SHADOW [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]
- // MARK: Light Theme
- #define THEME_LIGHT_MAIN [UIColor colorWithRed:5.0/255.0 green: 148.0/255.0 blue:61.0/255.0 alpha:1.0]
- #define THEME_LIGHT_FONT_LINK THEME_LIGHT_MAIN // Link font color
- #define THEME_LIGHT_FONT_LINK_RECEIVED THEME_LIGHT_MAIN
- #define THEME_LIGHT_BUBBLE_SENT [UIColor colorWithRed:220.0/255.0 green:242.0/255.0 blue:211.0/255.0 alpha:1.0]
- #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]
- #define THEME_LIGHT_BUBBLE_CALL_BUTTON THEME_LIGHT_MAIN
- #define THEME_LIGHT_BALLOT_HIGHEST_VOTE THEME_LIGHT_MAIN
- #define THEME_LIGHT_QUOTE_BAR THEME_LIGHT_GREEN
- #define THEME_LIGHT_GREEN THEME_LIGHT_MAIN
- #define THEME_LIGHT_VERIFICATION_GREEN THEME_LIGHT_MAIN
- #define THEME_LIGHT_WORK_BLUE [UIColor colorWithRed:0.0/255.0 green: 115.0/255.0 blue:196.0/255.0 alpha:1.0]
- #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]
- // MARK: Light Work Theme
- #define THEME_LIGHT_WORK_MAIN [UIColor colorWithRed:0.0/255.0 green: 115.0/255.0 blue:196.0/255.0 alpha:1.0]
- #define THEME_LIGHT_WORK_FONT_LINK THEME_LIGHT_WORK_MAIN // Link font color
- #define THEME_LIGHT_WORK_FONT_LINK_RECEIVED THEME_LIGHT_WORK_MAIN
- #define THEME_LIGHT_WORK_FONT_PLACEHOLDER THREEMA_COLOR_PLACEHOLDER // Placeholder color (Lightgray)
- #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]
- #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]
- #define THEME_LIGHT_WORK_BUBBLE_CALL_BUTTON THEME_LIGHT_WORK_MAIN
- #define THEME_LIGHT_WORK_BALLOT_HIGHEST_VOTE THEME_LIGHT_WORK_MAIN
- #define THEME_LIGHT_WORK_QUOTE_BAR THEME_LIGHT_WORK_MAIN
- #define THEME_LIGHT_WORK_GREEN [UIColor colorWithRed:5.0/255.0 green: 153.0/255.0 blue:63.0/255.0 alpha:1.0]
- #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]
- #define THEME_LIGHT_WORK_WORK_BLUE THEME_LIGHT_WORK_MAIN
- #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]
- static UIColor *main;
- static UIColor *backgroundBaseColor;
- static UIColor *background;
- static UIColor *backgroundLight;
- static UIColor *backgroundDark;
- static UIColor *backgroundSelectedDark;
- static UIColor *backgroundInverted;
- static UIColor *backgroundChat;
- static UIColor *chatBackgroundLines;
- static UIColor *chatSystemMessageBackground;
- static UIColor *shareExtensionSelectedBackground;
- static UIColor *fontNormal;
- static UIColor *fontLight;
- static UIColor *fontVeryLight;
- static UIColor *fontDark;
- static UIColor *fontLink;
- static UIColor *fontLinkReceived;
- static UIColor *fontPlaceholder;
- static UIColor *fontInverted;
- static UIColor *fontQuoteId;
- static UIColor *fontQuoteText;
- static UIColor *chatBarInput;
- static UIColor *chatBarBackground;
- static UIColor *chatBarBorder;
- static UIColor *switchThumb;
- static UIColor *bubbleSent;
- static UIColor *bubbleSentSelected;
- static UIColor *bubbleReceived;
- static UIColor *bubbleReceivedSelected;
- static UIColor *bubbleCall;
- static UIColor *bubbleCallButton;
- static UIColor *popupMenuBackground;
- static UIColor *popupMenuHighlight;
- static UIColor *popupMenuSeparator;
- static UIColor *ballotHighestVote;
- static UIColor *ballotRowLight;
- static UIColor *ballotRowDark;
- static UIColor *hairline;
- static UIColor *quoteBar;
- static UIColor *orange;
- static UIColor *red;
- static UIColor *green;
- static UIColor *gray;
- static UIColor *verificationGreen;
- static UIColor *workBlue;
- static UIColor *searchBarStatusBar;
- static UIColor *callStatusBar;
- static UIColor *mentionBackgroundOwnMessageColor;
- static UIColor *mentionBackgroundOverviewColor;
- static UIColor *mentionBackgroundColor;
- static UIColor *mentionBackgroundOwnMessageMeColor;
- static UIColor *mentionBackgroundOverviewMeColor;
- static UIColor *mentionBackgroundMeColor;
- static UIColor *mentionTextOwnMessageMeColor;
- static UIColor *mentionTextOverviewMeColor;
- static UIColor *mentionTextMeColor;
- static UIColor *tagMarkBackground;
- static UIColor *notificationBackground;
- static UIColor *notificationShadow;
- static ColorTheme colorTheme;
- static UITraitCollection *traitCollection;
- @implementation Colors
- + (void)initialize {
- if (@available(iOS 13.0, *)) {
- if ([[UserSettings sharedUserSettings] useSystemTheme] == true) {
- traitCollection = [UITraitCollection currentTraitCollection];
- if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
- [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeDarkWork : ColorThemeDark];
- } else {
- [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeLightWork : ColorThemeLight];
- }
- } else {
- if ([UserSettings sharedUserSettings].darkTheme) {
- [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeDarkWork : ColorThemeDark];
- } else {
- [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeLightWork : ColorThemeLight];
- }
- }
- } else {
- if ([UserSettings sharedUserSettings].darkTheme) {
- [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeDarkWork : ColorThemeDark];
- } else {
- [self setTheme:[LicenseStore requiresLicenseKey] ? ColorThemeLightWork : ColorThemeLight];
- }
- }
- }
- + (BOOL)areCustomized {
- return colorTheme != ColorThemeLight;
- }
- + (void)setTheme:(ColorTheme)newTheme {
- colorTheme = newTheme;
- switch (colorTheme) {
- case ColorThemeDark:
- [self setupDarkTheme];
- [UserSettings sharedUserSettings].darkTheme = YES;
- break;
- case ColorThemeDarkWork:
- [self setupDarkWorkTheme];
- [UserSettings sharedUserSettings].darkTheme = YES;
- break;
- case ColorThemeLight:
- [self setupLightTheme];
- [UserSettings sharedUserSettings].darkTheme = NO;
- break;
- case ColorThemeLightWork:
- [self setupLightWorkTheme];
- [UserSettings sharedUserSettings].darkTheme = NO;
- break;
- case ColorThemeUndefined:
- [self setupLightTheme];
- [UserSettings sharedUserSettings].darkTheme = NO;
- break;
- }
-
- [StyleKit resetThemedCache];
-
- UIWindow *windowAppearance = [UIWindow appearance];
- [self updateWindow:windowAppearance];
-
- UINavigationBar *navigationBarAppearance = [UINavigationBar appearance];
- [self updateNavigationBar:navigationBarAppearance];
-
- UITabBar *tabBarAppearance = [UITabBar appearance];
- [self updateTabBar:tabBarAppearance];
-
- UISwitch *switchAppearance = [UISwitch appearance];
- [self updateSwitch:switchAppearance];
-
- UISearchBar *searchBarAppearance = [UISearchBar appearance];
- [self updateSearchBar:searchBarAppearance];
-
- [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIAlertController class]]] setTintColor:[Colors main]];
- [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIDocumentMenuViewController class]]] setTintColor:[Colors main]];
- [[UIButton appearanceWhenContainedInInstancesOfClasses:@[[UIDocumentMenuViewController class], [UIAlertController class]]] setTintColor:[Colors main]];
- [[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIWindow class], [UIView class]]] setTintColor:[Colors main]];
-
- if(@available(iOS 13, *)) {
- // only use the appearance below iOS 13, in iOS 13 we can set the textColor directly on the searchbar
- } else {
- [[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setDefaultTextAttributes:@{NSForegroundColorAttributeName: fontNormal}];
- }
- }
- + (ColorTheme)getTheme {
- return colorTheme;
- }
- + (void)setupLightTheme {
- main = THEME_LIGHT_MAIN;
-
- backgroundBaseColor = THEME_LIGHT_BACKGROUND_BASE;
-
- background = THEME_LIGHT_BACKGROUND;
- backgroundLight = THEME_LIGHT_BACKGROUND_LIGHT;
- backgroundDark = THEME_LIGHT_BACKGROUND_DARK;
- backgroundSelectedDark = THEME_LIGHT_BACKGROUND_SELECTED_DARK;
- backgroundInverted = THEME_LIGHT_BACKGROUND_INVERTED;
- backgroundChat = THEME_LIGHT_BACKGROUND_CHAT;
- chatBackgroundLines = THEME_LIGHT_CHAT_BACKGROUND_LINES;
- chatSystemMessageBackground = THEME_LIGHT_BACKGROUND_CHAT_SYSTEM_MESSAGE;
- shareExtensionSelectedBackground = THEME_LIGHT_SHARE_EXTENSION_SELECTED_BACKGROUND;
-
- fontNormal = THEME_LIGHT_FONT_NORMAL;
- fontLight = THEME_LIGHT_FONT_LIGHT;
- fontVeryLight = THEME_LIGHT_FONT_VERY_LIGHT;
- fontDark = THEME_LIGHT_FONT_DARK;
- fontLink = THEME_LIGHT_FONT_LINK;
- fontLinkReceived = THEME_LIGHT_FONT_LINK_RECEIVED;
- fontPlaceholder = THEME_LIGHT_FONT_PLACEHOLDER;
- fontInverted = THEME_LIGHT_FONT_INVERTED;
- fontQuoteId = THEME_LIGHT_FONT_QUOTE_ID;
- fontQuoteText = THEME_LIGHT_FONT_QUOTE_TEXT;
-
- chatBarBackground = THEME_LIGHT_CHATBAR_BACKGROUND;
- chatBarInput = THEME_LIGHT_CHATBAR_INPUT;
- chatBarBorder = THEME_LIGHT_CHATBAR_BORDER;
-
- switchThumb = THEME_LIGHT_SWITCH_THUMB;
-
- bubbleSent = THEME_LIGHT_BUBBLE_SENT;
- bubbleSentSelected = THEME_LIGHT_BUBBLE_SENT_SELECTED;
- bubbleReceived = THEME_LIGHT_BUBBLE_RECEIVED;
- bubbleReceivedSelected = THEME_LIGHT_BUBBLE_RECEIVED_SELECTED;
- bubbleCallButton = THEME_LIGHT_BUBBLE_CALL_BUTTON;
-
- popupMenuBackground = THEME_LIGHT_POPUP_MENU_BACKGROUND;
- popupMenuHighlight = THEME_LIGHT_POPUP_MENU_HIGHTLIGHT;
- popupMenuSeparator = THEME_LIGHT_POPUP_MENU_SEPARATOR;
-
- ballotHighestVote = THEME_LIGHT_BALLOT_HIGHEST_VOTE;
- ballotRowLight = THEME_LIGHT_BALLOT_ROW_LIGHT;
- ballotRowDark = THEME_LIGHT_BALLOT_ROW_DARK;
-
- hairline = THEME_LIGHT_HAIRLINE;
- quoteBar = THEME_LIGHT_QUOTE_BAR;
-
- orange = THEME_LIGHT_ORANGE;
- red = THEME_LIGHT_RED;
- green = THEME_LIGHT_GREEN;
- gray = THEME_LIGHT_GRAY;
- verificationGreen = THEME_LIGHT_VERIFICATION_GREEN;
- workBlue = THEME_LIGHT_WORK_BLUE;
-
- searchBarStatusBar = THEME_LIGHT_SEARCH_BAR_STATUS_BAR;
- callStatusBar = THEME_LIGHT_CALL_STATUS_BAR;
-
- mentionBackgroundOwnMessageColor = THEME_LIGHT_MENTION_BACKGROUND_OWN;
- mentionBackgroundColor = THEME_LIGHT_MENTION_BACKGROUND;
- mentionBackgroundOverviewColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW;
- mentionBackgroundOwnMessageMeColor = THEME_LIGHT_MENTION_BACKGROUND_OWN_ME;
- mentionBackgroundMeColor = THEME_LIGHT_MENTION_BACKGROUND_ME;
- mentionBackgroundOverviewMeColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW_ME;
- mentionTextOwnMessageMeColor = THEME_LIGHT_MENTION_TEXT_OWN_ME;
- mentionTextMeColor = THEME_LIGHT_MENTION_TEXT_ME;
- mentionTextOverviewMeColor = THEME_LIGHT_MENTION_TEXT_OVERVIEW_ME;
-
- tagMarkBackground = THEME_LIGHT_TAG_MARK_BACKGROUND;
-
- notificationBackground = THEME_LIGHT_NOTIFICATION_BACKGROUND;
- notificationShadow = THEME_LIGHT_NOTIFICATION_SHADOW;
- }
- + (void)setupLightWorkTheme {
- main = THEME_LIGHT_WORK_MAIN;
-
- backgroundBaseColor = THEME_LIGHT_BACKGROUND_BASE;
-
- background = THEME_LIGHT_BACKGROUND;
- backgroundLight = THEME_LIGHT_BACKGROUND_LIGHT;
- backgroundDark = THEME_LIGHT_BACKGROUND_DARK;
- backgroundSelectedDark = THEME_LIGHT_BACKGROUND_SELECTED_DARK;
- backgroundInverted = THEME_LIGHT_BACKGROUND_INVERTED;
- backgroundChat = THEME_LIGHT_BACKGROUND_CHAT;
- chatBackgroundLines = THEME_LIGHT_CHAT_BACKGROUND_LINES;
- chatSystemMessageBackground = THEME_LIGHT_BACKGROUND_CHAT_SYSTEM_MESSAGE;
- shareExtensionSelectedBackground = THEME_LIGHT_SHARE_EXTENSION_SELECTED_BACKGROUND;
-
- fontNormal = THEME_LIGHT_FONT_NORMAL;
- fontLight = THEME_LIGHT_FONT_LIGHT;
- fontVeryLight = THEME_LIGHT_FONT_VERY_LIGHT;
- fontDark = THEME_LIGHT_FONT_DARK;
- fontLink = THEME_LIGHT_WORK_FONT_LINK;
- fontLinkReceived = THEME_LIGHT_WORK_FONT_LINK_RECEIVED;
- fontPlaceholder = THEME_LIGHT_WORK_FONT_PLACEHOLDER;
- fontInverted = THEME_LIGHT_FONT_INVERTED;
- fontQuoteId = THEME_LIGHT_FONT_QUOTE_ID;
- fontQuoteText = THEME_LIGHT_FONT_QUOTE_TEXT;
-
- chatBarBackground = THEME_LIGHT_CHATBAR_BACKGROUND;
- chatBarInput = THEME_LIGHT_CHATBAR_INPUT;
- chatBarBorder = THEME_LIGHT_CHATBAR_BORDER;
-
- switchThumb = THEME_LIGHT_SWITCH_THUMB;
-
- bubbleSent = THEME_LIGHT_WORK_BUBBLE_SENT;
- bubbleSentSelected = THEME_LIGHT_WORK_BUBBLE_SENT_SELECTED;
- bubbleReceived = THEME_LIGHT_BUBBLE_RECEIVED;
- bubbleReceivedSelected = THEME_LIGHT_BUBBLE_RECEIVED_SELECTED;
- bubbleCallButton = THEME_LIGHT_WORK_BUBBLE_CALL_BUTTON;
-
- popupMenuBackground = THEME_LIGHT_POPUP_MENU_BACKGROUND;
- popupMenuHighlight = THEME_LIGHT_POPUP_MENU_HIGHTLIGHT;
- popupMenuSeparator = THEME_LIGHT_POPUP_MENU_SEPARATOR;
-
- ballotHighestVote = THEME_LIGHT_WORK_BALLOT_HIGHEST_VOTE;
- ballotRowLight = THEME_LIGHT_BALLOT_ROW_LIGHT;
- ballotRowDark = THEME_LIGHT_BALLOT_ROW_DARK;
-
- hairline = THEME_LIGHT_HAIRLINE;
- quoteBar = THEME_LIGHT_WORK_QUOTE_BAR;
-
- orange = THEME_LIGHT_ORANGE;
- red = THEME_LIGHT_RED;
- green = THEME_LIGHT_WORK_GREEN;
- gray = THEME_LIGHT_GRAY;
- verificationGreen = THEME_LIGHT_WORK_VERIFICATION_GREEN;
- workBlue = THEME_LIGHT_WORK_WORK_BLUE;
-
- searchBarStatusBar = THEME_LIGHT_SEARCH_BAR_STATUS_BAR;
- callStatusBar = THEME_LIGHT_WORK_CALL_STATUS_BAR;
-
- mentionBackgroundOwnMessageColor = THEME_LIGHT_MENTION_BACKGROUND_OWN;
- mentionBackgroundColor = THEME_LIGHT_MENTION_BACKGROUND;
- mentionBackgroundOverviewColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW;
- mentionBackgroundOwnMessageMeColor = THEME_LIGHT_MENTION_BACKGROUND_OWN_ME;
- mentionBackgroundMeColor = THEME_LIGHT_MENTION_BACKGROUND_ME;
- mentionBackgroundOverviewMeColor = THEME_LIGHT_MENTION_BACKGROUND_OVERVIEW_ME;
- mentionTextOwnMessageMeColor = THEME_LIGHT_MENTION_TEXT_OWN_ME;
- mentionTextMeColor = THEME_LIGHT_MENTION_TEXT_ME;
- mentionTextOverviewMeColor = THEME_LIGHT_MENTION_TEXT_OVERVIEW_ME;
- tagMarkBackground = THEME_LIGHT_TAG_MARK_BACKGROUND;
-
- notificationBackground = THEME_LIGHT_NOTIFICATION_BACKGROUND;
- notificationShadow = THEME_LIGHT_NOTIFICATION_SHADOW;
- }
- + (void)setupDarkTheme {
- main = THEME_DARK_MAIN;
-
- backgroundBaseColor = THEME_DARK_BACKGROUND_BASE;
-
- background = THEME_DARK_BACKGROUND;
- backgroundLight = THEME_DARK_BACKGROUND_LIGHT;
- backgroundDark = THEME_DARK_BACKGROUND_DARK;
- backgroundSelectedDark = THEME_DARK_BACKGROUND_SELECTED_DARK;
- backgroundInverted = THEME_DARK_BACKGROUND_INVERTED;
- backgroundChat = THEME_DARK_BACKGROUND_CHAT;
- chatBackgroundLines = THEME_DARK_CHAT_BACKGROUND_LINES;
- chatSystemMessageBackground = THEME_DARK_BACKGROUND_CHAT_SYSTEM_MESSAGE;
- shareExtensionSelectedBackground = THEME_DARK_SHARE_EXTENSION_SELECTED_BACKGROUND;
-
- fontNormal = THEME_DARK_FONT_NORMAL;
- fontLight = THEME_DARK_FONT_LIGHT;
- fontVeryLight = THEME_DARK_FONT_VERY_LIGHT;
- fontDark = THEME_DARK_FONT_DARK;
- fontLink = THEME_DARK_FONT_LINK;
- fontLinkReceived = THEME_DARK_FONT_LINK_RECEIVED;
- fontPlaceholder = THEME_DARK_FONT_PLACEHOLDER;
- fontInverted = THEME_DARK_FONT_INVERTED;
- fontQuoteId = THEME_DARK_FONT_QUOTE_ID;
- fontQuoteText = THEME_DARK_FONT_QUOTE_TEXT;
-
- chatBarBackground = THEME_DARK_CHATBAR_BACKGROUND;
- chatBarInput = THEME_DARK_CHATBAR_INPUT;
- chatBarBorder = THEME_DARK_CHATBAR_BORDER;
-
- switchThumb = THEME_DARK_SWITCH_THUMB;
-
- bubbleSent = THEME_DARK_BUBBLE_SENT;
- bubbleSentSelected = THEME_DARK_BUBBLE_SENT_SELECTED;
- bubbleReceived = THEME_DARK_BUBBLE_RECEIVED;
- bubbleReceivedSelected = THEME_DARK_BUBBLE_RECEIVED_SELECTED;
- bubbleCallButton = THEME_DARK_BUBBLE_CALL_BUTTON;
-
- popupMenuBackground = THEME_DARK_POPUP_MENU_BACKGROUND;
- popupMenuHighlight = THEME_DARK_POPUP_MENU_HIGHTLIGHT;
- popupMenuSeparator = THEME_DARK_POPUP_MENU_SEPARATOR;
-
- ballotHighestVote = THEME_DARK_BALLOT_HIGHEST_VOTE;
- ballotRowLight = THEME_DARK_BALLOT_ROW_LIGHT;
- ballotRowDark = THEME_DARK_BALLOT_ROW_DARK;
-
- hairline = THEME_DARK_HAIRLINE;
- quoteBar = THEME_DARK_QUOTE_BAR;
-
- orange = THEME_DARK_ORANGE;
- red = THEME_DARK_RED;
- green = THEME_DARK_GREEN;
- gray = THEME_DARK_GRAY;
- verificationGreen = THEME_DARK_VERIFICATION_GREEN;
- workBlue = THEME_DARK_WORK_BLUE;
-
- searchBarStatusBar = THEME_DARK_SEARCH_BAR_STATUS_BAR;
- callStatusBar = THEME_DARK_CALL_STATUS_BAR;
-
- mentionBackgroundOwnMessageColor = THEME_DARK_MENTION_BACKGROUND_OWN;
- mentionBackgroundColor = THEME_DARK_MENTION_BACKGROUND;
- mentionBackgroundOverviewColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW;
- mentionBackgroundOwnMessageMeColor = THEME_DARK_MENTION_BACKGROUND_OWN_ME;
- mentionBackgroundMeColor = THEME_DARK_MENTION_BACKGROUND_ME;
- mentionBackgroundOverviewMeColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW_ME;
- mentionTextOwnMessageMeColor = THEME_DARK_MENTION_TEXT_OWN_ME;
- mentionTextMeColor = THEME_DARK_MENTION_TEXT_ME;
- mentionTextOverviewMeColor = THEME_DARK_MENTION_TEXT_OVERVIEW_ME;
-
- tagMarkBackground = THEME_DARK_TAG_MARK_BACKGROUND;
-
- notificationBackground = THEME_DARK_NOTIFICATION_BACKGROUND;
- notificationShadow = THEME_DARK_NOTIFICATION_SHADOW;
- }
- + (void)setupDarkWorkTheme {
- main = THEME_DARK_WORK_MAIN;
-
- backgroundBaseColor = THEME_DARK_BACKGROUND_BASE;
-
- background = THEME_DARK_BACKGROUND;
- backgroundLight = THEME_DARK_BACKGROUND_LIGHT;
- backgroundDark = THEME_DARK_BACKGROUND_DARK;
- backgroundSelectedDark = THEME_DARK_BACKGROUND_SELECTED_DARK;
- backgroundInverted = THEME_DARK_BACKGROUND_INVERTED;
- backgroundChat = THEME_DARK_BACKGROUND_CHAT;
- chatBackgroundLines = THEME_DARK_CHAT_BACKGROUND_LINES;
- chatSystemMessageBackground = THEME_DARK_BACKGROUND_CHAT_SYSTEM_MESSAGE;
- shareExtensionSelectedBackground = THEME_DARK_SHARE_EXTENSION_SELECTED_BACKGROUND;
-
- fontNormal = THEME_DARK_FONT_NORMAL;
- fontLight = THEME_DARK_FONT_LIGHT;
- fontVeryLight = THEME_DARK_FONT_VERY_LIGHT;
- fontDark = THEME_DARK_FONT_DARK;
- fontLink = THEME_DARK_WORK_FONT_LINK;
- fontLinkReceived = THEME_DARK_WORK_FONT_LINK_RECEIVED;
- fontPlaceholder = THEME_DARK_WORK_FONT_PLACEHOLDER;
- fontInverted = THEME_DARK_FONT_INVERTED;
- fontQuoteId = THEME_DARK_FONT_QUOTE_ID;
- fontQuoteText = THEME_DARK_FONT_QUOTE_TEXT;
-
- chatBarBackground = THEME_DARK_CHATBAR_BACKGROUND;
- chatBarInput = THEME_DARK_CHATBAR_INPUT;
- chatBarBorder = THEME_DARK_CHATBAR_BORDER;
-
- switchThumb = THEME_DARK_SWITCH_THUMB;
-
- bubbleSent = THEME_DARK_BUBBLE_SENT;
- bubbleSentSelected = THEME_DARK_BUBBLE_SENT_SELECTED;
- bubbleReceived = THEME_DARK_BUBBLE_RECEIVED;
- bubbleReceivedSelected = THEME_DARK_BUBBLE_RECEIVED_SELECTED;
- bubbleCallButton = THEME_DARK_WORK_BUBBLE_CALL_BUTTON;
-
- popupMenuBackground = THEME_DARK_POPUP_MENU_BACKGROUND;
- popupMenuHighlight = THEME_DARK_POPUP_MENU_HIGHTLIGHT;
- popupMenuSeparator = THEME_DARK_POPUP_MENU_SEPARATOR;
-
- ballotHighestVote = THEME_DARK_WORK_BALLOT_HIGHEST_VOTE;
- ballotRowLight = THEME_DARK_BALLOT_ROW_LIGHT;
- ballotRowDark = THEME_DARK_BALLOT_ROW_DARK;
-
- hairline = THEME_DARK_HAIRLINE;
- quoteBar = THEME_DARK_WORK_QUOTE_BAR;
-
- orange = THEME_DARK_ORANGE;
- red = THEME_DARK_RED;
- green = THEME_DARK_WORK_GREEN;
- gray = THEME_DARK_GRAY;
- verificationGreen = THEME_DARK_WORK_VERIFICATION_GREEN;
- workBlue = THEME_DARK_WORK_WORK_BLUE;
-
- searchBarStatusBar = THEME_DARK_SEARCH_BAR_STATUS_BAR;
- callStatusBar = THEME_DARK_WORK_CALL_STATUS_BAR;
-
- mentionBackgroundOwnMessageColor = THEME_DARK_MENTION_BACKGROUND_OWN;
- mentionBackgroundColor = THEME_DARK_MENTION_BACKGROUND;
- mentionBackgroundOverviewColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW;
- mentionBackgroundOwnMessageMeColor = THEME_DARK_MENTION_BACKGROUND_OWN_ME;
- mentionBackgroundMeColor = THEME_DARK_MENTION_BACKGROUND_ME;
- mentionBackgroundOverviewMeColor = THEME_DARK_MENTION_BACKGROUND_OVERVIEW_ME;
- mentionTextOwnMessageMeColor = THEME_DARK_MENTION_TEXT_OWN_ME;
- mentionTextMeColor = THEME_DARK_MENTION_TEXT_ME;
- mentionTextOverviewMeColor = THEME_DARK_MENTION_TEXT_OVERVIEW_ME;
- tagMarkBackground = THEME_DARK_TAG_MARK_BACKGROUND;
-
- notificationBackground = THEME_DARK_NOTIFICATION_BACKGROUND;
- notificationShadow = THEME_DARK_NOTIFICATION_SHADOW;
- }
- + (void)resetToDefault {
- [self setTheme:ColorThemeLight];
- }
- + (void)updateKeyboardAppearanceFor:(id<UITextInputTraits>)textInputTraits {
- if ([textInputTraits respondsToSelector:@selector(setKeyboardAppearance:)]) {
- switch (colorTheme) {
- case ColorThemeDark:
- case ColorThemeDarkWork:
- textInputTraits.keyboardAppearance = UIKeyboardAppearanceDark;
- break;
- case ColorThemeLight:
- case ColorThemeLightWork:
- case ColorThemeUndefined:
- textInputTraits.keyboardAppearance = UIKeyboardAppearanceDefault;
- break;
- }
- }
-
- if ([textInputTraits respondsToSelector:@selector(setTextColor:)]) {
- [textInputTraits performSelector:@selector(setTextColor:) withObject:[Colors fontNormal]];
- }
-
- if ([textInputTraits respondsToSelector:@selector(setTintColor:)]) {
- [textInputTraits performSelector:@selector(setTintColor:) withObject:[Colors main]];
- }
-
- if ([textInputTraits respondsToSelector:@selector(setAttributedPlaceholder:)]) {
- NSAttributedString *placeholder = [textInputTraits performSelector:@selector(attributedPlaceholder)];
- NSMutableAttributedString *mutablePlaceholder = [[NSMutableAttributedString alloc] initWithAttributedString:placeholder];
- [mutablePlaceholder addAttribute:NSForegroundColorAttributeName value:[Colors fontPlaceholder] range:NSMakeRange(0, placeholder.length)];
-
- [textInputTraits performSelector:@selector(setAttributedPlaceholder:) withObject:mutablePlaceholder];
- }
-
- if ([textInputTraits respondsToSelector:@selector(setTintColor:)]) {
- [textInputTraits performSelector:@selector(setTintColor:) withObject:[Colors main]];
- }
-
- if ([textInputTraits isKindOfClass:[UITextField class]]) {
- UITextField *textField = (UITextField *)textInputTraits;
- [textField colorizeClearButton];
- }
- }
- + (void)updateWindow:(UIWindow *)window {
- [window setTintColor:main];
- }
- + (void)updateNavigationBar:(UINavigationBar *)navigationBar {
- switch (colorTheme) {
- case ColorThemeDark:
- case ColorThemeDarkWork:
- [navigationBar setBarStyle:UIBarStyleBlack];
- [navigationBar setTranslucent:YES];
- [navigationBar setTintColor:main];
- [navigationBar setBackgroundColor:nil];
-
- if (@available(iOS 13.0, *)) {
- navigationBar.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
- }
- break;
- case ColorThemeLight:
- case ColorThemeLightWork:
- case ColorThemeUndefined:
- [navigationBar setBarStyle:UIBarStyleDefault];
- [navigationBar setTintColor:main];
- [navigationBar setBackgroundColor:backgroundBaseColor];
-
- if (@available(iOS 13.0, *)) {
- navigationBar.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
- }
- break;
- }
- if ([VoIPHelper shared].isCallActiveInBackground) {
- [navigationBar setBarTintColor:callStatusBar];
- } else {
- [navigationBar setBarTintColor:nil];
- }
-
- if (@available(iOS 13.0, *)) {
- UINavigationBarAppearance *newAppearance = [[UINavigationBarAppearance alloc] init];
- [newAppearance configureWithDefaultBackground];
- if ([VoIPHelper shared].isCallActiveInBackground) {
- newAppearance.backgroundColor = callStatusBar;
- } else {
- newAppearance.backgroundColor = nil;
- }
- navigationBar.standardAppearance = newAppearance;
- navigationBar.scrollEdgeAppearance = newAppearance;
- } else {
- if (@available(iOS 11.0, *)) {
- [navigationBar setTintColor:main];
- [navigationBar setLargeTitleTextAttributes:@{NSForegroundColorAttributeName: fontNormal}];
- }
- }
- }
- + (void)updateTableView:(UITableView *)tableView {
- if (tableView.style == UITableViewStyleGrouped) {
- [tableView setBackgroundColor:[Colors background]];
- } else {
- [tableView setBackgroundColor:[Colors background]];
- }
-
- [tableView setSectionIndexBackgroundColor:[UIColor clearColor]];
- [tableView setSectionIndexColor:[Colors main]];
-
- [tableView setSeparatorColor:[Colors hairline]];
-
- tableView.backgroundView = [[UIView alloc] initWithFrame:tableView.frame];
- tableView.backgroundView.backgroundColor = [Colors backgroundDark];
- }
- + (void)updateTableViewCellBackground:(UITableViewCell *)cell {
- [cell setBackgroundColor:[Colors background]];
-
- cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
- cell.selectedBackgroundView.backgroundColor = [Colors backgroundSelectedDark];
- }
- + (void)updateTableViewCell:(UITableViewCell *)cell {
- [self updateTableViewCellBackground:cell];
-
- UIColor *textColor;
- UIColor *detailTextColor;
-
- if (cell.accessibilityTraits & UIAccessibilityTraitNotEnabled && !cell.isUserInteractionEnabled) {
- textColor = [Colors fontLight];
- detailTextColor = [Colors fontVeryLight];
- } else if (cell.accessibilityTraits & UIAccessibilityTraitButton && cell.accessoryType != UITableViewCellAccessoryDisclosureIndicator && cell.accessoryType != UITableViewCellAccessoryDetailButton && ![cell.accessoryView isKindOfClass:[UISwitch class]]) {
- textColor = [Colors main];
- detailTextColor = [Colors fontLight];
- } else {
- textColor = [Colors fontNormal];
- detailTextColor = [Colors fontLight];
- }
-
- // handle custom table cells
- [self setTextColor:textColor inView:cell.contentView];
-
- if (cell.detailTextLabel) {
- cell.detailTextLabel.textColor = detailTextColor;
- }
-
- [cell setTintColor:[Colors main]];
- }
- + (void)updateTabBar:(UITabBar *)tabBar {
- switch (colorTheme) {
- case ColorThemeDark:
- case ColorThemeDarkWork:
- [tabBar setBarStyle:UIBarStyleBlack];
- [tabBar setTranslucent:YES];
- [tabBar setTintColor:main];
- if (@available(iOS 13.0, *)) {
- tabBar.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
- }
- break;
- case ColorThemeLight:
- case ColorThemeLightWork:
- case ColorThemeUndefined:
- [tabBar setBarStyle:UIBarStyleDefault];
- [tabBar setTintColor:main];
- if (@available(iOS 13.0, *)) {
- tabBar.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
- }
- break;
- }
- }
- + (void)updateSearchBar:(UISearchBar *)searchBar {
- [self updateKeyboardAppearanceFor:searchBar];
-
- switch (colorTheme) {
- case ColorThemeDark:
- case ColorThemeDarkWork:
- searchBar.barStyle = UIBarStyleBlack;
- [searchBar setTranslucent:YES];
- break;
- case ColorThemeLight:
- case ColorThemeLightWork:
- case ColorThemeUndefined:
- searchBar.barStyle = UIBarStyleDefault;
- break;
- }
-
- [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTitleTextAttributes:@{NSForegroundColorAttributeName: main} forState:UIControlStateNormal];
-
- if (@available(iOS 13.0, *)) {
-
- // Since iOS 13 we can set the textColor directly on the searchbar
- searchBar.searchTextField.textColor = fontNormal;
-
- if ([searchBar respondsToSelector:NSSelectorFromString(@"searchTextField")]) {
- id searchTextField = [searchBar valueForKey:@"searchTextField"];
- if ([searchTextField respondsToSelector:NSSelectorFromString(@"backgroundColor")]) {
- [searchTextField setValue:searchBarStatusBar forKey:@"backgroundColor"];
- }
- }
- }
- }
- + (void)updateSwitch:(UISwitch *)switchAppearance {
- [switchAppearance setThumbTintColor:[Colors switchThumb]];
- [switchAppearance setOnTintColor:[Colors main]];
- switch (colorTheme) {
- case ColorThemeDarkWork:
- case ColorThemeDark:
- case ColorThemeLight:
- case ColorThemeLightWork:
- [switchAppearance setOnTintColor:[Colors main]];
- break;
- case ColorThemeUndefined:
- [switchAppearance setOnTintColor:THREEMA_COLOR_GREEN];
- break;
- }
-
- }
- + (void)setTextColor:(UIColor *)color inView:(UIView *)parentView {
- for (UIView *view in parentView.subviews) {
- if ([view isKindOfClass:[ContactNameLabel class]]) {
- continue;
- }
- if ([view isKindOfClass:[UILabel class]]) {
- UILabel *label = (UILabel *)view;
- [label setTextColor:color];
- [label setHighlightedTextColor:color];
- } else if ([view isKindOfClass:[UITextField class]]) {
- UITextField *textField = (UITextField *)view;
- [textField setTextColor:color];
- [textField colorizeClearButton];
-
- if ([textField placeholder] != nil) {
- UIColor *color = [Colors fontPlaceholder];
- textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:[textField placeholder] attributes:@{NSForegroundColorAttributeName: color}];
- }
- } else if ([view isKindOfClass:[UIScrollView class]] || [view isKindOfClass:[UIStackView class]] || [view isKindOfClass:[UIView class]]) {
- [Colors setTextColor:color inView:view];
- }
- }
- }
- + (UIColor *)workBlue {
- return workBlue;
- }
- + (UIColor *)main {
- return main;
- }
- + (UIColor *)background {
- return background;
- }
- + (UIColor *)backgroundBaseColor {
- return backgroundBaseColor;
- }
- + (UIColor *)backgroundLight {
- return backgroundLight;
- }
- + (UIColor *)backgroundDark {
- return backgroundDark;
- }
- + (UIColor *)backgroundSelectedDark {
- return backgroundSelectedDark;
- }
- + (UIColor *)backgroundInverted {
- return backgroundInverted;
- }
- + (UIColor *)backgroundChat {
- return backgroundChat;
- }
- + (UIColor *)chatBackgroundLines {
- return chatBackgroundLines;
- }
- + (UIColor *)chatSystemMessageBackground {
- return chatSystemMessageBackground;
- }
- + (UIColor *)shareExtensionSelectedBackground {
- return shareExtensionSelectedBackground;
- }
- + (UIColor *)fontNormal {
- return fontNormal;
- }
- + (UIColor *)fontLight {
- return fontLight;
- }
- + (UIColor *)fontVeryLight {
- return fontVeryLight;
- }
- + (UIColor *)fontDark {
- return fontDark;
- }
- + (UIColor *)fontLink {
- return fontLink;
- }
- + (UIColor *)fontLinkReceived {
- return fontLinkReceived;
- }
- + (UIColor *)fontPlaceholder {
- return fontPlaceholder;
- }
- + (UIColor *)fontInverted {
- return fontInverted;
- }
- + (UIColor *)fontQuoteId {
- return fontQuoteId;
- }
- + (UIColor *)fontQuoteText {
- return fontQuoteText;
- }
- + (UIColor *)chatBarBackground {
- return chatBarBackground;
- }
- + (UIColor *)chatBarInput {
- return chatBarInput;
- }
- + (UIColor *)chatBarBorder {
- return chatBarBorder;
- }
- + (UIColor *)switchThumb {
- return switchThumb;
- }
- + (UIColor *)bubbleSent {
- return bubbleSent;
- }
- + (UIColor *)bubbleSentSelected {
- return bubbleSentSelected;
- }
- + (UIColor *)bubbleReceived {
- return bubbleReceived;
- }
- + (UIColor *)bubbleReceivedSelected {
- return bubbleReceivedSelected;
- }
- + (UIColor *)bubbleCallButton {
- return bubbleCallButton;
- }
- + (UIColor *)popupMenuBackground {
- return popupMenuBackground;
- }
- + (UIColor *)popupMenuHighlight {
- return popupMenuHighlight;
- }
- + (UIColor *)popupMenuSeparator {
- return popupMenuSeparator;
- }
- + (UIColor *)ballotHighestVote {
- return ballotHighestVote;
- }
- + (UIColor *)ballotRowLight {
- return ballotRowLight;
- }
- + (UIColor *)ballotRowDark {
- return ballotRowDark;
- }
- + (UIColor *)hairline {
- return hairline;
- }
- + (UIColor *)quoteBar {
- return quoteBar;
- }
- + (UIColor *)orange {
- return orange;
- }
- + (UIColor *)red {
- return red;
- }
- + (UIColor *)green {
- return green;
- }
- + (UIColor *)verificationGreen {
- return verificationGreen;
- }
- + (UIColor *)gray {
- return gray;
- }
- + (UIColor *)searchBarStatusBar {
- return searchBarStatusBar;
- }
- + (UIColor *)callStatusBar {
- return callStatusBar;
- }
- + (UIColor *)mentionBackground:(int)messageInfo {
- switch (messageInfo) {
- case TextStyleUtilsMessageInfoReceivedMessage:
- return mentionBackgroundColor;
- case TextStyleUtilsMessageInfoOwnMessage:
- return mentionBackgroundOwnMessageColor;
- case TextStyleUtilsMessageInfoOverview:
- return mentionBackgroundOverviewColor;
-
- default:
- return mentionBackgroundColor;
- }
- }
- + (UIColor *)mentionBackgroundMe:(int)messageInfo {
- switch (messageInfo) {
- case TextStyleUtilsMessageInfoReceivedMessage:
- return mentionBackgroundMeColor;
- case TextStyleUtilsMessageInfoOwnMessage:
- return mentionBackgroundOwnMessageMeColor;
- case TextStyleUtilsMessageInfoOverview:
- return mentionBackgroundOverviewMeColor;
-
- default:
- return mentionBackgroundMeColor;
- }
- }
- + (UIColor *)mentionTextMe:(int)messageInfo {
- switch (messageInfo) {
- case TextStyleUtilsMessageInfoReceivedMessage:
- return mentionTextMeColor;
- case TextStyleUtilsMessageInfoOwnMessage:
- return mentionTextOwnMessageMeColor;
- case TextStyleUtilsMessageInfoOverview:
- return mentionTextOverviewMeColor;
-
- default:
- return mentionTextMeColor;
- }
- }
- + (UIColor *)privacyPolicyLink {
- if ([LicenseStore requiresLicenseKey]) {
- return THEME_DARK_WORK_FONT_LINK;
- } else {
- return THEME_DARK_FONT_LINK;
- }
- }
- + (UIColor *)mainThemeDark {
- if ([LicenseStore requiresLicenseKey]) {
- return THEME_DARK_WORK_MAIN;
- } else {
- return THEME_DARK_MAIN;
- }
- }
- + (UIColor *)backgroundThemeDark {
- return THEME_DARK_BACKGROUND_DARK;
- }
- + (UIColor *)markTag {
- return tagMarkBackground;
- }
- + (UIColor *)white {
- return [UIColor whiteColor];
- }
- + (UIColor *)black {
- return [UIColor blackColor];
- }
- + (UIColor *)darkGrey {
- return THREEMA_COLOR_DARK_GREY;
- }
- + (UIColor *)notificationBackground {
- return notificationBackground;
- }
- + (UIColor *)notificationShadow {
- return notificationShadow;
- }
- @end
|