Clean
This commit is contained in:
parent
870f4d38d7
commit
66a00d4167
|
@ -77,10 +77,10 @@ final class NewPrivateChatVC : BaseVC, UIPageViewControllerDataSource, UIPageVie
|
|||
pageVCView.set(.width, to: screen.width)
|
||||
let height: CGFloat
|
||||
if #available(iOS 13, *) {
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - TabBar.snHeight
|
||||
} else {
|
||||
let statusBarHeight = UIApplication.shared.statusBarFrame.height
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight - statusBarHeight
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - TabBar.snHeight - statusBarHeight
|
||||
}
|
||||
pageVCView.set(.height, to: height)
|
||||
enterPublicKeyVC.constrainHeight(to: height)
|
||||
|
|
|
@ -39,7 +39,7 @@ final class BlockedModal : Modal {
|
|||
// Unblock button
|
||||
let unblockButton = UIButton()
|
||||
unblockButton.set(.height, to: Values.mediumButtonHeight)
|
||||
unblockButton.layer.cornerRadius = Values.modalButtonCornerRadius
|
||||
unblockButton.layer.cornerRadius = Modal.buttonCornerRadius
|
||||
unblockButton.backgroundColor = Colors.buttonBackground
|
||||
unblockButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
unblockButton.setTitleColor(Colors.text, for: UIControl.State.normal)
|
||||
|
|
|
@ -35,7 +35,7 @@ final class LinkPreviewModal : Modal {
|
|||
// Enable button
|
||||
let enableButton = UIButton()
|
||||
enableButton.set(.height, to: Values.mediumButtonHeight)
|
||||
enableButton.layer.cornerRadius = Values.modalButtonCornerRadius
|
||||
enableButton.layer.cornerRadius = Modal.buttonCornerRadius
|
||||
enableButton.backgroundColor = Colors.buttonBackground
|
||||
enableButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
enableButton.setTitleColor(Colors.text, for: UIControl.State.normal)
|
||||
|
|
|
@ -39,7 +39,7 @@ final class PermissionMissingModal : Modal {
|
|||
// Settings button
|
||||
let settingsButton = UIButton()
|
||||
settingsButton.set(.height, to: Values.mediumButtonHeight)
|
||||
settingsButton.layer.cornerRadius = Values.modalButtonCornerRadius
|
||||
settingsButton.layer.cornerRadius = Modal.buttonCornerRadius
|
||||
settingsButton.backgroundColor = Colors.buttonBackground
|
||||
settingsButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
settingsButton.setTitleColor(Colors.text, for: UIControl.State.normal)
|
||||
|
|
|
@ -37,7 +37,7 @@ final class URLModal : Modal {
|
|||
// Open button
|
||||
let openButton = UIButton()
|
||||
openButton.set(.height, to: Values.mediumButtonHeight)
|
||||
openButton.layer.cornerRadius = Values.modalButtonCornerRadius
|
||||
openButton.layer.cornerRadius = Modal.buttonCornerRadius
|
||||
openButton.backgroundColor = Colors.buttonBackground
|
||||
openButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
openButton.setTitleColor(Colors.text, for: UIControl.State.normal)
|
||||
|
|
|
@ -265,8 +265,8 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
|
|||
pathStatusViewContainer.set(.height, to: pathStatusViewContainerSize)
|
||||
let pathStatusView = PathStatusView()
|
||||
pathStatusView.accessibilityLabel = "Current onion routing path button"
|
||||
pathStatusView.set(.width, to: Values.pathStatusViewSize)
|
||||
pathStatusView.set(.height, to: Values.pathStatusViewSize)
|
||||
pathStatusView.set(.width, to: PathStatusView.size)
|
||||
pathStatusView.set(.height, to: PathStatusView.size)
|
||||
pathStatusViewContainer.addSubview(pathStatusView)
|
||||
pathStatusView.center(.horizontal, in: pathStatusViewContainer)
|
||||
pathStatusView.center(.vertical, in: pathStatusViewContainer)
|
||||
|
|
|
@ -24,6 +24,10 @@ final class FakeChatView : UIView {
|
|||
|
||||
private static let bubbleWidth = CGFloat(224)
|
||||
private static let bubbleCornerRadius = CGFloat(10)
|
||||
private static let startDelay: TimeInterval = 1
|
||||
private static let animationDuration: TimeInterval = 0.4
|
||||
private static let chatDelay: TimeInterval = 1.5
|
||||
private static let popAnimationStartScale: CGFloat = 0.6
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
@ -86,10 +90,10 @@ final class FakeChatView : UIView {
|
|||
}
|
||||
|
||||
private func animate() {
|
||||
let animationDuration = Values.fakeChatAnimationDuration
|
||||
let delayBetweenMessages = Values.fakeChatDelay
|
||||
let animationDuration = FakeChatView.animationDuration
|
||||
let delayBetweenMessages = FakeChatView.chatDelay
|
||||
chatBubbles.forEach { $0.alpha = 0 }
|
||||
Timer.scheduledTimer(withTimeInterval: Values.fakeChatStartDelay, repeats: false) { [weak self] _ in
|
||||
Timer.scheduledTimer(withTimeInterval: FakeChatView.startDelay, repeats: false) { [weak self] _ in
|
||||
self?.showChatBubble(at: 0)
|
||||
Timer.scheduledTimer(withTimeInterval: 1.5 * delayBetweenMessages, repeats: false) { _ in
|
||||
self?.showChatBubble(at: 1)
|
||||
|
@ -120,12 +124,12 @@ final class FakeChatView : UIView {
|
|||
|
||||
private func showChatBubble(at index: Int) {
|
||||
let chatBubble = chatBubbles[index]
|
||||
UIView.animate(withDuration: Values.fakeChatAnimationDuration) {
|
||||
UIView.animate(withDuration: FakeChatView.animationDuration) {
|
||||
chatBubble.alpha = 1
|
||||
}
|
||||
let scale = Values.fakeChatMessagePopAnimationStartScale
|
||||
let scale = FakeChatView.popAnimationStartScale
|
||||
chatBubble.transform = CGAffineTransform(scaleX: scale, y: scale)
|
||||
UIView.animate(withDuration: Values.fakeChatAnimationDuration, delay: 0, usingSpringWithDamping: 0.68, initialSpringVelocity: 4, options: .curveEaseInOut, animations: {
|
||||
UIView.animate(withDuration: FakeChatView.animationDuration, delay: 0, usingSpringWithDamping: 0.68, initialSpringVelocity: 4, options: .curveEaseInOut, animations: {
|
||||
chatBubble.transform = CGAffineTransform(scaleX: 1, y: 1)
|
||||
}, completion: nil)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ final class OptionView : UIView {
|
|||
private let isRecommended: Bool
|
||||
var isSelected = false { didSet { handleIsSelectedChanged() } }
|
||||
|
||||
private static let cornerRadius: CGFloat = 8
|
||||
|
||||
init(title: String, explanation: String, delegate: OptionViewDelegate, isRecommended: Bool = false) {
|
||||
self.title = title
|
||||
self.explanation = explanation
|
||||
|
@ -27,7 +29,7 @@ final class OptionView : UIView {
|
|||
private func setUpViewHierarchy() {
|
||||
backgroundColor = Colors.pnOptionBackground
|
||||
// Round corners
|
||||
layer.cornerRadius = Values.pnOptionCornerRadius
|
||||
layer.cornerRadius = OptionView.cornerRadius
|
||||
// Set up border
|
||||
layer.borderWidth = 1
|
||||
layer.borderColor = Colors.pnOptionBorder.cgColor
|
||||
|
|
|
@ -11,7 +11,7 @@ final class SeedReminderView : UIView {
|
|||
result.progressViewStyle = .bar
|
||||
result.progressTintColor = Colors.accent
|
||||
result.backgroundColor = isLightMode ? UIColor(hex: 0x000000).withAlphaComponent(0.1) : UIColor(hex: 0xFFFFFF).withAlphaComponent(0.1)
|
||||
result.set(.height, to: Values.progressBarThickness)
|
||||
result.set(.height, to: SeedReminderView.progressBarThickness)
|
||||
return result
|
||||
}()
|
||||
|
||||
|
@ -32,6 +32,9 @@ final class SeedReminderView : UIView {
|
|||
return result
|
||||
}()
|
||||
|
||||
// MARK: Settings
|
||||
private static let progressBarThickness: CGFloat = 2
|
||||
|
||||
// MARK: Lifecycle
|
||||
init(hasContinueButton: Bool) {
|
||||
self.hasContinueButton = hasContinueButton
|
||||
|
|
|
@ -78,10 +78,10 @@ final class JoinOpenGroupVC : BaseVC, UIPageViewControllerDataSource, UIPageView
|
|||
pageVCView.set(.width, to: screen.width)
|
||||
let height: CGFloat
|
||||
if #available(iOS 13, *) {
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - TabBar.snHeight
|
||||
} else {
|
||||
let statusBarHeight = UIApplication.shared.statusBarFrame.height
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight - statusBarHeight
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - TabBar.snHeight - statusBarHeight
|
||||
}
|
||||
pageVCView.set(.height, to: height)
|
||||
enterChatURLVC.constrainHeight(to: height)
|
||||
|
|
|
@ -2,6 +2,8 @@ import UIKit
|
|||
|
||||
final class PathStatusView : UIView {
|
||||
|
||||
static let size = CGFloat(8)
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setUpViewHierarchy()
|
||||
|
@ -15,7 +17,7 @@ final class PathStatusView : UIView {
|
|||
}
|
||||
|
||||
private func setUpViewHierarchy() {
|
||||
layer.cornerRadius = Values.pathStatusViewSize / 2
|
||||
layer.cornerRadius = PathStatusView.size / 2
|
||||
layer.masksToBounds = false
|
||||
if OnionRequestAPI.paths.isEmpty {
|
||||
OnionRequestAPI.paths = Storage.shared.getOnionRequestPaths()
|
||||
|
@ -36,7 +38,7 @@ final class PathStatusView : UIView {
|
|||
|
||||
private func setColor(to color: UIColor, isAnimated: Bool) {
|
||||
backgroundColor = color
|
||||
let size = Values.pathStatusViewSize
|
||||
let size = PathStatusView.size
|
||||
let glowConfiguration = UIView.CircularGlowConfiguration(size: size, color: color, isAnimated: isAnimated, radius: isLightMode ? 6 : 8)
|
||||
setCircularGlow(with: glowConfiguration)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,11 @@ final class PathVC : BaseVC {
|
|||
result.addTarget(self, action: #selector(learnMore), for: UIControl.Event.touchUpInside)
|
||||
return result
|
||||
}()
|
||||
|
||||
// MARK: Settings
|
||||
static let dotSize = CGFloat(8)
|
||||
static let expandedDotSize = CGFloat(16)
|
||||
static let rowHeight = isIPhone5OrSmaller ? CGFloat(52) : CGFloat(75)
|
||||
|
||||
// MARK: Lifecycle
|
||||
override func viewDidLoad() {
|
||||
|
@ -131,8 +136,8 @@ final class PathVC : BaseVC {
|
|||
// MARK: General
|
||||
private func getPathRow(title: String, subtitle: String?, location: LineView.Location, dotAnimationStartDelay: Double, dotAnimationRepeatInterval: Double) -> UIStackView {
|
||||
let lineView = LineView(location: location, dotAnimationStartDelay: dotAnimationStartDelay, dotAnimationRepeatInterval: dotAnimationRepeatInterval)
|
||||
lineView.set(.width, to: Values.pathRowExpandedDotSize)
|
||||
lineView.set(.height, to: Values.pathRowHeight)
|
||||
lineView.set(.width, to: PathVC.expandedDotSize)
|
||||
lineView.set(.height, to: PathVC.rowHeight)
|
||||
let titleLabel = UILabel()
|
||||
titleLabel.textColor = Colors.text
|
||||
titleLabel.font = .systemFont(ofSize: Values.mediumFontSize)
|
||||
|
@ -188,10 +193,10 @@ private final class LineView : UIView {
|
|||
|
||||
private lazy var dotView: UIView = {
|
||||
let result = UIView()
|
||||
result.layer.cornerRadius = Values.pathRowDotSize / 2
|
||||
result.layer.cornerRadius = PathVC.dotSize / 2
|
||||
let glowRadius: CGFloat = isLightMode ? 1 : 2
|
||||
let glowColor = isLightMode ? UIColor.black.withAlphaComponent(0.4) : UIColor.black
|
||||
let glowConfiguration = UIView.CircularGlowConfiguration(size: Values.pathRowDotSize, color: glowColor, isAnimated: true, animationDuration: 0.5, radius: glowRadius)
|
||||
let glowConfiguration = UIView.CircularGlowConfiguration(size: PathVC.dotSize, color: glowColor, isAnimated: true, animationDuration: 0.5, radius: glowRadius)
|
||||
result.setCircularGlow(with: glowConfiguration)
|
||||
result.backgroundColor = Colors.accent
|
||||
return result
|
||||
|
@ -215,7 +220,7 @@ private final class LineView : UIView {
|
|||
|
||||
private func setUpViewHierarchy() {
|
||||
let lineView = UIView()
|
||||
lineView.set(.width, to: Values.pathRowLineThickness)
|
||||
lineView.set(.width, to: Values.separatorThickness)
|
||||
lineView.backgroundColor = Colors.text
|
||||
addSubview(lineView)
|
||||
lineView.center(.horizontal, in: self)
|
||||
|
@ -227,7 +232,7 @@ private final class LineView : UIView {
|
|||
case .top, .middle: lineView.pin(.bottom, to: .bottom, of: self)
|
||||
case .bottom: lineView.bottomAnchor.constraint(equalTo: centerYAnchor).isActive = true
|
||||
}
|
||||
let dotSize = Values.pathRowDotSize
|
||||
let dotSize = PathVC.dotSize
|
||||
dotViewWidthConstraint = dotView.set(.width, to: dotSize)
|
||||
dotViewHeightConstraint = dotView.set(.height, to: dotSize)
|
||||
addSubview(dotView)
|
||||
|
@ -254,14 +259,14 @@ private final class LineView : UIView {
|
|||
}
|
||||
|
||||
private func expandDot() {
|
||||
let newSize = Values.pathRowExpandedDotSize
|
||||
let newSize = PathVC.expandedDotSize
|
||||
let newGlowRadius: CGFloat = isLightMode ? 4 : 6
|
||||
let newGlowColor = Colors.accent.withAlphaComponent(0.6)
|
||||
updateDotView(size: newSize, glowRadius: newGlowRadius, glowColor: newGlowColor)
|
||||
}
|
||||
|
||||
private func collapseDot() {
|
||||
let newSize = Values.pathRowDotSize
|
||||
let newSize = PathVC.dotSize
|
||||
let newGlowRadius: CGFloat = isLightMode ? 1 : 2
|
||||
let newGlowColor = isLightMode ? UIColor.black.withAlphaComponent(0.4) : UIColor.black
|
||||
updateDotView(size: newSize, glowRadius: newGlowRadius, glowColor: newGlowColor)
|
||||
|
|
|
@ -23,7 +23,7 @@ final class NukeDataModal : Modal {
|
|||
// Set up nuke data button
|
||||
let nukeDataButton = UIButton()
|
||||
nukeDataButton.set(.height, to: Values.mediumButtonHeight)
|
||||
nukeDataButton.layer.cornerRadius = Values.modalButtonCornerRadius
|
||||
nukeDataButton.layer.cornerRadius = Modal.buttonCornerRadius
|
||||
if isDarkMode {
|
||||
nukeDataButton.backgroundColor = Colors.destructive
|
||||
}
|
||||
|
|
|
@ -68,10 +68,10 @@ final class QRCodeVC : BaseVC, UIPageViewControllerDataSource, UIPageViewControl
|
|||
pageVCView.set(.width, to: screen.width)
|
||||
let height: CGFloat
|
||||
if #available(iOS 13, *) {
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - TabBar.snHeight
|
||||
} else {
|
||||
let statusBarHeight = UIApplication.shared.statusBarFrame.height
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - Values.tabBarHeight - statusBarHeight
|
||||
height = navigationController!.view.bounds.height - navigationBar.height() - TabBar.snHeight - statusBarHeight
|
||||
}
|
||||
pageVCView.set(.height, to: height)
|
||||
viewMyQRCodeVC.constrainHeight(to: height)
|
||||
|
|
|
@ -48,7 +48,7 @@ final class SeedModal : Modal {
|
|||
// Set up copy button
|
||||
let copyButton = UIButton()
|
||||
copyButton.set(.height, to: Values.mediumButtonHeight)
|
||||
copyButton.layer.cornerRadius = Values.modalButtonCornerRadius
|
||||
copyButton.layer.cornerRadius = Modal.buttonCornerRadius
|
||||
copyButton.backgroundColor = Colors.buttonBackground
|
||||
copyButton.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
copyButton.setTitleColor(Colors.text, for: UIControl.State.normal)
|
||||
|
|
|
@ -20,7 +20,7 @@ class Modal : BaseVC {
|
|||
lazy var cancelButton: UIButton = {
|
||||
let result = UIButton()
|
||||
result.set(.height, to: Values.mediumButtonHeight)
|
||||
result.layer.cornerRadius = Values.modalButtonCornerRadius
|
||||
result.layer.cornerRadius = Modal.buttonCornerRadius
|
||||
result.backgroundColor = Colors.buttonBackground
|
||||
result.titleLabel!.font = .systemFont(ofSize: Values.smallFontSize)
|
||||
result.setTitleColor(Colors.text, for: UIControl.State.normal)
|
||||
|
@ -30,6 +30,7 @@ class Modal : BaseVC {
|
|||
|
||||
// MARK: Settings
|
||||
private static let cornerRadius: CGFloat = 10
|
||||
static let buttonCornerRadius = CGFloat(5)
|
||||
|
||||
// MARK: Lifecycle
|
||||
override func viewDidLoad() {
|
||||
|
|
|
@ -12,7 +12,7 @@ public final class TabBar : UIView {
|
|||
result.textColor = Colors.text.withAlphaComponent(Values.mediumOpacity)
|
||||
result.textAlignment = .center
|
||||
result.text = tab.title
|
||||
result.set(.height, to: Values.tabBarHeight - Values.separatorThickness - Values.accentLineThickness)
|
||||
result.set(.height, to: TabBar.snHeight - Values.separatorThickness - Values.accentLineThickness)
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,9 @@ public final class TabBar : UIView {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: Settings
|
||||
public static let snHeight = isIPhone5OrSmaller ? CGFloat(32) : CGFloat(48)
|
||||
|
||||
// MARK: Lifecycle
|
||||
public init(tabs: [Tab]) {
|
||||
self.tabs = tabs
|
||||
|
@ -49,7 +52,7 @@ public final class TabBar : UIView {
|
|||
}
|
||||
|
||||
private func setUpViewHierarchy() {
|
||||
set(.height, to: Values.tabBarHeight)
|
||||
set(.height, to: TabBar.snHeight)
|
||||
tabLabels.forEach { tabLabel in
|
||||
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTabLabelTapped(_:)))
|
||||
tabLabel.addGestureRecognizer(tapGestureRecognizer)
|
||||
|
@ -60,7 +63,7 @@ public final class TabBar : UIView {
|
|||
tabLabelStackView.spacing = Values.mediumSpacing
|
||||
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTabLabelTapped(_:)))
|
||||
tabLabelStackView.addGestureRecognizer(tapGestureRecognizer)
|
||||
tabLabelStackView.set(.height, to: Values.tabBarHeight - Values.separatorThickness - Values.accentLineThickness)
|
||||
tabLabelStackView.set(.height, to: TabBar.snHeight - Values.separatorThickness - Values.accentLineThickness)
|
||||
addSubview(tabLabelStackView)
|
||||
let separator = UIView()
|
||||
separator.backgroundColor = Colors.separator
|
||||
|
|
|
@ -31,18 +31,7 @@ public final class Values : NSObject {
|
|||
|
||||
@objc public static let searchBarHeight = CGFloat(36)
|
||||
|
||||
// TODO ----------------
|
||||
|
||||
@objc public static var separatorThickness: CGFloat { return 1 / UIScreen.main.scale }
|
||||
@objc public static let tabBarHeight = isIPhone5OrSmaller ? CGFloat(32) : CGFloat(48)
|
||||
@objc public static let modalButtonCornerRadius = CGFloat(5)
|
||||
@objc public static let progressBarThickness: CGFloat = 2
|
||||
@objc public static let pnOptionCornerRadius = CGFloat(8)
|
||||
@objc public static let pathStatusViewSize = CGFloat(8)
|
||||
@objc public static var pathRowLineThickness: CGFloat { return 1 / UIScreen.main.scale }
|
||||
@objc public static let pathRowDotSize = CGFloat(8)
|
||||
@objc public static let pathRowExpandedDotSize = CGFloat(16)
|
||||
@objc public static let pathRowHeight = isIPhone5OrSmaller ? CGFloat(52) : CGFloat(75)
|
||||
|
||||
// MARK: - Distances
|
||||
@objc public static let verySmallSpacing = CGFloat(4)
|
||||
|
@ -53,10 +42,4 @@ public final class Values : NSObject {
|
|||
@objc public static let massiveSpacing = CGFloat(64)
|
||||
@objc public static let newConversationButtonBottomOffset = CGFloat(52)
|
||||
@objc public static let onboardingButtonBottomOffset = isIPhone5OrSmaller ? CGFloat(52) : CGFloat(72)
|
||||
|
||||
// MARK: - Animation Values
|
||||
@objc public static let fakeChatStartDelay: TimeInterval = 1
|
||||
@objc public static let fakeChatAnimationDuration: TimeInterval = 0.4
|
||||
@objc public static let fakeChatDelay: TimeInterval = 1.5
|
||||
@objc public static let fakeChatMessagePopAnimationStartScale: CGFloat = 0.6
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue