session-ios/Session/Shared/Views/SessionHighlightingBackgroundLabel.swift
Morgan Pretty d8fd3b35b4 Theming tweaks and bug fixes
Made a tweak to prevent some odd looking keyboard transitions when going to conversation settings
Updated the PagedDatabaseObserver to not call 'onChangeUnsorted' on the main thread (now we can generate the changeset on the background thread so there is less main thread work)
Fixed an issue where the most recently received message from the swarm could be removed from the swarm yet the app would still poll for it, resulting in the swarm always returning the oldest possible messages until the user sends a new one-to-one message
Fixed an issue where the initial scroll offset could be incorrect due to certain message types
Fixed an issue where the title view inside a conversation could jump when pushing to the conversation settings screen
Refactored a couple of ObjC functions to Swift as they were crashing (due to memory allocation?) hopefully this will fix it
Tweaked some DispatchQueue priorities to ensure PagedDatabaseObserver loading is prioritised
Updated buttons to use a standard convention for highlighted states
Updated the new conversation button to follow the new highlighted state convention
2022-10-14 17:09:38 +11:00

82 lines
2.3 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import UIKit
import SessionUIKit
import SessionUtilitiesKit
public class SessionHighlightingBackgroundLabel: UIView {
var text: String? {
get { label.text }
set { label.text = newValue }
}
var themeTextColor: ThemeValue? {
get { label.themeTextColor }
set { label.themeTextColor = newValue }
}
// MARK: - Components
private let label: UILabel = {
let result: UILabel = UILabel()
result.translatesAutoresizingMaskIntoConstraints = false
result.font = .boldSystemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary
result.setContentHuggingHigh()
result.setCompressionResistanceHigh()
return result
}()
// MARK: - Initialization
init() {
super.init(frame: .zero)
self.themeBackgroundColor = .solidButton_background
self.layer.cornerRadius = 5
self.setupViewHierarchy()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Layout
private func setupViewHierarchy() {
addSubview(label)
label.pin(to: self, withInset: Values.smallSpacing)
}
// MARK: - Interaction
func setHighlighted(_ highlighted: Bool, animated: Bool) {
self.themeBackgroundColor = (highlighted ?
.highlighted(.solidButton_background) :
.solidButton_background
)
}
func setSelected(_ selected: Bool, animated: Bool) {
// Note: When initially triggering a selection we will be coming from the highlighted
// state but will have already set highlighted to false at this stage, as a result we
// need to swap back into the "highlighted" state so we can properly unhighlight within
// the "deselect" animation
guard !selected else {
self.themeBackgroundColor = .highlighted(.solidButton_background)
return
}
guard animated else {
self.themeBackgroundColor = .solidButton_background
return
}
UIView.animate(withDuration: 0.4) { [weak self] in
self?.themeBackgroundColor = .solidButton_background
}
}
}