Reactions: Customise primary reactions buttons

This commit is contained in:
manuroe 2019-05-15 23:35:09 +02:00
parent 52a480db92
commit 7cd5e79bc6
6 changed files with 84 additions and 4 deletions

View file

@ -71,6 +71,7 @@
325380D7228C2E5800ADDEFA /* ReactionsMenuReactions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 325380D6228C2E5800ADDEFA /* ReactionsMenuReactions.swift */; };
325380DB228C34EF00ADDEFA /* ReactionsMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 325380DA228C34EF00ADDEFA /* ReactionsMenuView.swift */; };
325380DD228C34FC00ADDEFA /* ReactionsMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 325380DC228C34FC00ADDEFA /* ReactionsMenuView.xib */; };
325380DF228C5C2800ADDEFA /* ReactionsMenuButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 325380DE228C5C2800ADDEFA /* ReactionsMenuButton.swift */; };
3275FD8C21A5A2C500B9C13D /* TermsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3275FD8B21A5A2C500B9C13D /* TermsView.swift */; };
3281BCF72201FA4200F4A383 /* UIControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3281BCF62201FA4200F4A383 /* UIControl.swift */; };
3284A35120A07C210044F922 /* postMessageAPI.js in Resources */ = {isa = PBXBuildFile; fileRef = 3284A35020A07C210044F922 /* postMessageAPI.js */; };
@ -574,6 +575,7 @@
325380D6228C2E5800ADDEFA /* ReactionsMenuReactions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionsMenuReactions.swift; sourceTree = "<group>"; };
325380DA228C34EF00ADDEFA /* ReactionsMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionsMenuView.swift; sourceTree = "<group>"; };
325380DC228C34FC00ADDEFA /* ReactionsMenuView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ReactionsMenuView.xib; sourceTree = "<group>"; };
325380DE228C5C2800ADDEFA /* ReactionsMenuButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionsMenuButton.swift; sourceTree = "<group>"; };
3267EFB320E379FD00FF1CAA /* CHANGES.rst */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGES.rst; sourceTree = "<group>"; };
3267EFB420E379FD00FF1CAA /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = Podfile; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
3267EFB520E379FD00FF1CAA /* AUTHORS.rst */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AUTHORS.rst; sourceTree = "<group>"; };
@ -1435,6 +1437,7 @@
325380D6228C2E5800ADDEFA /* ReactionsMenuReactions.swift */,
325380DA228C34EF00ADDEFA /* ReactionsMenuView.swift */,
325380DC228C34FC00ADDEFA /* ReactionsMenuView.xib */,
325380DE228C5C2800ADDEFA /* ReactionsMenuButton.swift */,
);
path = ReactionsMenu;
sourceTree = "<group>";
@ -4026,6 +4029,7 @@
B1B5578620EF564900210D55 /* GroupTableViewCellWithSwitch.m in Sources */,
B1098BE821ECFE52000DDA48 /* Coordinator.swift in Sources */,
B1B557E920EF60F500210D55 /* MessagesSearchResultTextMsgBubbleCell.m in Sources */,
325380DF228C5C2800ADDEFA /* ReactionsMenuButton.swift in Sources */,
324A2050225FC571004FE8B0 /* DeviceVerificationIncomingViewController.swift in Sources */,
B1098C0D21ED07E4000DDA48 /* NavigationRouter.swift in Sources */,
B110872321F098F0003554A5 /* ActivityIndicatorPresenterType.swift in Sources */,

View file

@ -38,6 +38,7 @@ import UIKit
var textSecondaryColor: UIColor { get }
var tintColor: UIColor { get }
var tintBackgroundColor: UIColor { get }
var unreadRoomIndentColor: UIColor { get }

View file

@ -39,6 +39,7 @@ class DarkTheme: NSObject, Theme {
var textSecondaryColor: UIColor = UIColor(rgb: 0xA1B2D1)
var tintColor: UIColor = UIColor(rgb: 0x03B381)
var tintBackgroundColor: UIColor = UIColor(rgb: 0xe9fff9)
var unreadRoomIndentColor: UIColor = UIColor(rgb: 0x2E3648)
var lineBreakColor: UIColor = UIColor(rgb: 0x61708B)

View file

@ -39,6 +39,7 @@ class DefaultTheme: NSObject, Theme {
var textSecondaryColor: UIColor = UIColor(rgb: 0x9E9E9E)
var tintColor: UIColor = UIColor(rgb: 0x03B381)
var tintBackgroundColor: UIColor = UIColor(rgb: 0xe9fff9)
var unreadRoomIndentColor: UIColor = UIColor(rgb: 0x2E3648)
var lineBreakColor: UIColor = UIColor(rgb: 0xEEEFEF)

View file

@ -0,0 +1,73 @@
/*
Copyright 2019 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 UIKit
class ReactionsMenuButton: UIButton {
// MARK: Private
private var theme: Theme!
// MARK: - Setup
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.commonInit()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.commonInit()
}
// MARK: - Life cycle
override func layoutSubviews() {
super.layoutSubviews()
self.layer.cornerRadius = self.frame.size.height / 2
self.layer.borderWidth = self.isSelected ? 1 : 0
}
// MARK: - Private
private func commonInit() {
self.theme = ThemeService.shared().theme
customizeViewRendering()
updateView()
}
func customizeViewRendering() {
self.tintColor = UIColor.clear
// TODO: Color for black theme
self.setTitleColor(self.theme.textPrimaryColor, for: .normal)
self.setTitleColor(self.theme.textPrimaryColor, for: .selected)
self.layer.borderColor = self.theme.tintColor.cgColor
}
func updateView() {
backgroundColor = isSelected ? self.theme.tintBackgroundColor : self.theme.headerBackgroundColor
}
override open var isSelected: Bool {
didSet {
self.updateView()
}
}
}

View file

@ -23,7 +23,7 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="100"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="30O-28-rwy">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="30O-28-rwy" customClass="ReactionsMenuButton" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="104" y="13" width="100" height="38"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -35,7 +35,7 @@
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ebe-PT-0R2">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ebe-PT-0R2" customClass="ReactionsMenuButton" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="104" y="59" width="100" height="38"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -49,7 +49,7 @@
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kao-MQ-QFq">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kao-MQ-QFq" customClass="ReactionsMenuButton" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="210" y="13" width="100" height="38"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
@ -63,7 +63,7 @@
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AgH-2U-HpP">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="AgH-2U-HpP" customClass="ReactionsMenuButton" customModule="Riot" customModuleProvider="target">
<rect key="frame" x="210" y="59" width="100" height="38"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>