mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
f07313c7ac
Updated to the latest libSession to increase the available size for config message content (size check now happens after compression rather than before) Added some additional logs for config size info Fixed a bug where the database could be accessed before the migrations ran which could result in unexpected behaviours Fixed a bug where you couldn't mark a non one-to-one thread as read/unread Fixed a bug where a database initialization failure wouldn't result in a migration failure (user would be stuck on the splash screen indefinitely) Fixed a bug where if a message was too large for the screen the conversation would open it centered on the screen (now it will be positioned to the top) Started looking at broken unit tests Increased the build number
80 lines
2.4 KiB
Swift
80 lines
2.4 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import UIKit
|
|
import SessionUIKit
|
|
|
|
final class RoundIconButton: UIView {
|
|
private let onTap: () -> ()
|
|
|
|
// MARK: - Settings
|
|
|
|
private static let size: CGFloat = 40
|
|
private static let iconSize: CGFloat = 16
|
|
|
|
// MARK: - Lifecycle
|
|
|
|
init(image: UIImage?, onTap: @escaping () -> ()) {
|
|
self.onTap = onTap
|
|
|
|
super.init(frame: CGRect.zero)
|
|
|
|
setUpViewHierarchy(image: image)
|
|
}
|
|
|
|
override init(frame: CGRect) {
|
|
preconditionFailure("Use init(delegate:) instead.")
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
preconditionFailure("Use init(delegate:) instead.")
|
|
}
|
|
|
|
private func setUpViewHierarchy(image: UIImage?) {
|
|
// Background & blur
|
|
let backgroundView = UIView()
|
|
backgroundView.themeBackgroundColor = .backgroundSecondary
|
|
backgroundView.alpha = Values.lowOpacity
|
|
addSubview(backgroundView)
|
|
backgroundView.pin(to: self)
|
|
|
|
let blurView = UIVisualEffectView()
|
|
addSubview(blurView)
|
|
blurView.pin(to: self)
|
|
|
|
ThemeManager.onThemeChange(observer: blurView) { [weak blurView] theme, _ in
|
|
switch theme.interfaceStyle {
|
|
case .light: blurView?.effect = UIBlurEffect(style: .light)
|
|
default: blurView?.effect = UIBlurEffect(style: .dark)
|
|
}
|
|
}
|
|
|
|
// Size & shape
|
|
set(.width, to: RoundIconButton.size)
|
|
set(.height, to: RoundIconButton.size)
|
|
layer.cornerRadius = (RoundIconButton.size / 2)
|
|
layer.masksToBounds = true
|
|
|
|
// Border
|
|
self.themeBorderColor = .borderSeparator
|
|
layer.borderWidth = Values.separatorThickness
|
|
|
|
// Icon
|
|
let iconImageView = UIImageView(image: image)
|
|
iconImageView.themeTintColor = .textPrimary
|
|
iconImageView.contentMode = .scaleAspectFit
|
|
addSubview(iconImageView)
|
|
iconImageView.center(in: self)
|
|
iconImageView.set(.width, to: RoundIconButton.iconSize)
|
|
iconImageView.set(.height, to: RoundIconButton.iconSize)
|
|
|
|
// Gesture recognizer
|
|
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap))
|
|
addGestureRecognizer(tapGestureRecognizer)
|
|
}
|
|
|
|
// MARK: - Interaction
|
|
|
|
@objc private func handleTap() {
|
|
onTap()
|
|
}
|
|
}
|