2018-11-29 13:09:12 +00:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
|
|
|
/// Color constants for the default theme
|
|
|
|
@objcMembers
|
2019-01-18 10:31:29 +00:00
|
|
|
class DefaultTheme: NSObject, Theme {
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-01-18 10:31:29 +00:00
|
|
|
var backgroundColor: UIColor = UIColor(rgb: 0xFFFFFF)
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-02-12 17:54:39 +00:00
|
|
|
var baseColor: UIColor = UIColor(rgb: 0x27303A)
|
2019-01-18 10:31:29 +00:00
|
|
|
var baseTextPrimaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
|
|
|
|
var baseTextSecondaryColor: UIColor = UIColor(rgb: 0xFFFFFF)
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-01-18 10:31:29 +00:00
|
|
|
var searchBackgroundColor: UIColor = UIColor(rgb: 0xFFFFFF)
|
2019-02-12 18:06:22 +00:00
|
|
|
var searchPlaceholderColor: UIColor = UIColor(rgb: 0x61708B)
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-05-20 19:49:27 +00:00
|
|
|
var headerBackgroundColor: UIColor = UIColor(rgb: 0xF3F8FD)
|
2019-02-12 17:54:39 +00:00
|
|
|
var headerBorderColor: UIColor = UIColor(rgb: 0xE9EDF1)
|
|
|
|
var headerTextPrimaryColor: UIColor = UIColor(rgb: 0x61708B)
|
2019-01-18 10:31:29 +00:00
|
|
|
var headerTextSecondaryColor: UIColor = UIColor(rgb: 0xC8C8CD)
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-02-12 17:54:39 +00:00
|
|
|
var textPrimaryColor: UIColor = UIColor(rgb: 0x2E2F32)
|
2019-01-18 10:31:29 +00:00
|
|
|
var textSecondaryColor: UIColor = UIColor(rgb: 0x9E9E9E)
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-02-12 17:54:39 +00:00
|
|
|
var tintColor: UIColor = UIColor(rgb: 0x03B381)
|
2019-05-15 21:35:09 +00:00
|
|
|
var tintBackgroundColor: UIColor = UIColor(rgb: 0xe9fff9)
|
2019-01-18 10:31:29 +00:00
|
|
|
var unreadRoomIndentColor: UIColor = UIColor(rgb: 0x2E3648)
|
2019-02-12 18:06:22 +00:00
|
|
|
var lineBreakColor: UIColor = UIColor(rgb: 0xEEEFEF)
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-02-12 18:06:22 +00:00
|
|
|
var noticeColor: UIColor = UIColor(rgb: 0xFF4B55)
|
|
|
|
var noticeSecondaryColor: UIColor = UIColor(rgb: 0x61708B)
|
2018-11-29 13:09:12 +00:00
|
|
|
|
2019-02-12 17:54:39 +00:00
|
|
|
var warningColor: UIColor = UIColor(rgb: 0xFF4B55)
|
2019-01-18 12:40:09 +00:00
|
|
|
|
2019-01-18 10:31:29 +00:00
|
|
|
var avatarColors: [UIColor] = [
|
2019-02-12 17:54:39 +00:00
|
|
|
UIColor(rgb: 0x03B381),
|
|
|
|
UIColor(rgb: 0x368BD6),
|
|
|
|
UIColor(rgb: 0xAC3BA8)]
|
2019-03-07 16:33:52 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
]
|
2019-01-10 15:35:34 +00:00
|
|
|
|
2019-01-18 10:31:29 +00:00
|
|
|
var statusBarStyle: UIStatusBarStyle = .lightContent
|
2019-02-20 15:45:32 +00:00
|
|
|
var scrollBarStyle: UIScrollView.IndicatorStyle = .default
|
2019-01-18 10:31:29 +00:00
|
|
|
var keyboardAppearance: UIKeyboardAppearance = .light
|
2019-01-10 16:42:43 +00:00
|
|
|
|
2019-01-18 10:31:29 +00:00
|
|
|
var placeholderTextColor: UIColor = UIColor(white: 0.7, alpha: 1.0) // Use default 70% gray color
|
2019-02-27 09:07:51 +00:00
|
|
|
var selectedBackgroundColor: UIColor? // Use the default selection color
|
2019-01-18 10:31:29 +00:00
|
|
|
var overlayBackgroundColor: UIColor = UIColor(white: 0.7, alpha: 0.5)
|
|
|
|
var matrixSearchBackgroundImageTintColor: UIColor = UIColor(rgb: 0xE7E7E7)
|
2019-02-19 08:39:01 +00:00
|
|
|
|
|
|
|
func applyStyle(onTabBar tabBar: UITabBar) {
|
2019-02-27 09:07:51 +00:00
|
|
|
tabBar.tintColor = self.tintColor
|
|
|
|
tabBar.barTintColor = self.headerBackgroundColor
|
|
|
|
tabBar.isTranslucent = false
|
2019-02-19 08:39:01 +00:00
|
|
|
}
|
2019-01-10 16:36:36 +00:00
|
|
|
|
2019-01-10 15:35:34 +00:00
|
|
|
func applyStyle(onNavigationBar navigationBar: UINavigationBar) {
|
2019-02-27 09:07:51 +00:00
|
|
|
navigationBar.tintColor = self.baseTextPrimaryColor
|
2019-01-10 15:35:34 +00:00
|
|
|
navigationBar.titleTextAttributes = [
|
2019-02-20 15:45:32 +00:00
|
|
|
NSAttributedString.Key.foregroundColor: self.baseTextPrimaryColor
|
2019-01-10 15:35:34 +00:00
|
|
|
]
|
2019-02-27 09:07:51 +00:00
|
|
|
navigationBar.barTintColor = self.baseColor
|
2019-01-10 15:35:34 +00:00
|
|
|
|
|
|
|
// 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
|
2019-01-10 15:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func applyStyle(onSearchBar searchBar: UISearchBar) {
|
|
|
|
searchBar.barStyle = .default
|
2020-05-28 16:24:03 +00:00
|
|
|
searchBar.barTintColor = self.baseColor
|
2019-07-25 14:22:17 +00:00
|
|
|
|
2020-05-28 16:24:03 +00:00
|
|
|
if #available(iOS 13.0, *) {
|
|
|
|
searchBar.searchTextField.backgroundColor = self.searchBackgroundColor
|
|
|
|
searchBar.searchTextField.textColor = self.searchPlaceholderColor
|
|
|
|
searchBar.tintColor = self.tintColor
|
|
|
|
} else {
|
|
|
|
searchBar.tintColor = self.searchPlaceholderColor
|
|
|
|
|
|
|
|
if let searchBarTextField = searchBar.vc_searchTextField {
|
|
|
|
searchBarTextField.textColor = searchBar.tintColor
|
|
|
|
}
|
2019-07-25 14:22:17 +00:00
|
|
|
}
|
2019-01-10 15:35:34 +00:00
|
|
|
}
|
2019-01-18 09:40:37 +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)
|
2019-01-18 09:40:37 +00:00
|
|
|
}
|
2018-11-29 13:09:12 +00:00
|
|
|
}
|