element-ios/Riot/Managers/Theme/Themes/DarkTheme.swift

129 lines
5.1 KiB
Swift
Raw Normal View History

/*
Copyright 2018 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import Foundation
import UIKit
2019-01-11 17:29:32 +00:00
/// Color constants for the dark theme
@objcMembers
class DarkTheme: NSObject, Theme {
2020-06-05 07:56:06 +00:00
var identifier: String = "dark"
2020-07-02 17:03:15 +00:00
var backgroundColor: UIColor = UIColor(rgb: 0x15191E)
2020-07-06 13:41:05 +00:00
var baseColor: UIColor = UIColor(rgb: 0x21262C)
2020-07-02 17:03:15 +00:00
var baseIconPrimaryColor: UIColor = UIColor(rgb: 0xEDF3FF)
var baseTextPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
var baseTextSecondaryColor: UIColor = UIColor(rgb: 0xA9B2BC)
2020-07-02 17:03:15 +00:00
var searchBackgroundColor: UIColor = UIColor(rgb: 0x15191E)
var searchPlaceholderColor: UIColor = UIColor(rgb: 0xA9B2BC)
2020-07-06 13:41:05 +00:00
var headerBackgroundColor: UIColor = UIColor(rgb: 0x21262C)
2020-07-02 17:03:15 +00:00
var headerBorderColor: UIColor = UIColor(rgb: 0x15191E)
var headerTextPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
var headerTextSecondaryColor: UIColor = UIColor(rgb: 0xA9B2BC)
2020-07-02 17:03:15 +00:00
var textPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
var textSecondaryColor: UIColor = UIColor(rgb: 0xA9B2BC)
2020-07-10 19:47:50 +00:00
var tintColor: UIColor = UIColor(displayP3Red: 0.05098039216, green: 0.7450980392, blue: 0.5450980392, alpha: 1.0)
var tintBackgroundColor: UIColor = UIColor(rgb: 0x1F6954)
2020-07-02 17:03:15 +00:00
var tabBarUnselectedItemTintColor: UIColor = UIColor(rgb: 0x8E99A4)
var unreadRoomIndentColor: UIColor = UIColor(rgb: 0x2E3648)
2020-07-06 13:41:05 +00:00
var lineBreakColor: UIColor = UIColor(rgb: 0x363D49)
var noticeColor: UIColor = UIColor(rgb: 0xFF4B55)
var noticeSecondaryColor: UIColor = UIColor(rgb: 0x61708B)
2019-02-12 17:54:39 +00:00
var warningColor: UIColor = UIColor(rgb: 0xFF4B55)
var avatarColors: [UIColor] = [
2019-02-12 17:54:39 +00:00
UIColor(rgb: 0x03B381),
UIColor(rgb: 0x368BD6),
UIColor(rgb: 0xAC3BA8)]
var userNameColors: [UIColor] = [
UIColor(rgb: 0x368BD6),
UIColor(rgb: 0xAC3BA8),
UIColor(rgb: 0x03B381),
UIColor(rgb: 0xE64F7A),
UIColor(rgb: 0xFF812D),
UIColor(rgb: 0x2DC2C5),
UIColor(rgb: 0x5C56F5),
UIColor(rgb: 0x74D12C)
]
var statusBarStyle: UIStatusBarStyle = .lightContent
var scrollBarStyle: UIScrollView.IndicatorStyle = .white
var keyboardAppearance: UIKeyboardAppearance = .dark
2020-07-02 17:03:15 +00:00
var placeholderTextColor: UIColor = UIColor(rgb: 0xA1B2D1) // Use secondary text color
var selectedBackgroundColor: UIColor = UIColor(rgb: 0x040506)
var overlayBackgroundColor: UIColor = UIColor(white: 0.7, alpha: 0.5)
var matrixSearchBackgroundImageTintColor: UIColor = UIColor(rgb: 0x7E7E7E)
func applyStyle(onTabBar tabBar: UITabBar) {
2020-07-02 17:03:15 +00:00
tabBar.unselectedItemTintColor = self.tabBarUnselectedItemTintColor
2019-02-27 09:07:51 +00:00
tabBar.tintColor = self.tintColor
2020-07-02 17:03:15 +00:00
tabBar.barTintColor = self.baseColor
2019-02-27 09:07:51 +00:00
tabBar.isTranslucent = false
}
2020-07-02 17:03:15 +00:00
2020-07-07 13:20:50 +00:00
// Note: We are not using UINavigationBarAppearance on iOS 13+ atm because of UINavigationBar directly include UISearchBar on their titleView that cause crop issues with UINavigationController pop.
func applyStyle(onNavigationBar navigationBar: UINavigationBar) {
2020-07-10 12:33:45 +00:00
navigationBar.tintColor = self.tintColor
navigationBar.titleTextAttributes = [
2020-07-02 17:03:15 +00:00
NSAttributedString.Key.foregroundColor: self.textPrimaryColor
]
2019-02-27 09:07:51 +00:00
navigationBar.barTintColor = self.baseColor
2020-07-07 13:20:50 +00:00
navigationBar.shadowImage = UIImage() // Remove bottom shadow
// The navigation bar needs to be opaque so that its background color is the expected one
2019-02-27 09:07:51 +00:00
navigationBar.isTranslucent = false
}
func applyStyle(onSearchBar searchBar: UISearchBar) {
searchBar.searchBarStyle = .default
searchBar.barStyle = .black
searchBar.barTintColor = self.baseColor
searchBar.isTranslucent = false
searchBar.backgroundImage = UIImage() // Remove top and bottom shadow
searchBar.tintColor = self.tintColor
2019-07-25 14:22:17 +00:00
if #available(iOS 13.0, *) {
searchBar.searchTextField.backgroundColor = self.searchBackgroundColor
searchBar.searchTextField.textColor = self.searchPlaceholderColor
} else {
if let searchBarTextField = searchBar.vc_searchTextField {
searchBarTextField.textColor = self.searchPlaceholderColor
}
2019-07-25 14:22:17 +00:00
}
}
func applyStyle(onTextField texField: UITextField) {
texField.textColor = self.textPrimaryColor
texField.tintColor = self.tintColor
}
func applyStyle(onButton button: UIButton) {
// NOTE: Tint color does nothing by default on button type `UIButtonType.custom`
button.tintColor = self.tintColor
2019-09-26 14:32:43 +00:00
button.setTitleColor(self.tintColor, for: .normal)
}
}