From 083d1c7bab80fbfcff1e3c9037942156c4035cc0 Mon Sep 17 00:00:00 2001 From: Soner YUKSEL Date: Tue, 21 Nov 2023 11:35:30 -0500 Subject: [PATCH] Fix brave/brave-ios#8361: Open Add separator between inactive tabs (brave/brave-ios#8442) --- .../Browser/Tabs/TabBar/TabBarCell.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift b/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift index 72b1440c4643..59c46fd26f00 100644 --- a/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift +++ b/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift @@ -30,10 +30,17 @@ class TabBarCell: UICollectionViewCell { $0.layer.shadowOffset = CGSize(width: 0, height: 1) $0.layer.shadowRadius = 2 } + + private let separatorLine = UIView().then { + $0.isHidden = true + } var currentIndex: Int = -1 { didSet { isSelected = currentIndex == tabManager?.currentDisplayedIndex + separatorLine.isHidden = isSelected || + currentIndex == 0 || + currentIndex == (tabManager?.currentDisplayedIndex ?? 0) + 1 } } weak var tab: Tab? @@ -56,7 +63,7 @@ class TabBarCell: UICollectionViewCell { override init(frame: CGRect) { super.init(frame: frame) - [highlightView, closeButton, titleLabel].forEach { contentView.addSubview($0) } + [highlightView, closeButton, titleLabel, separatorLine].forEach { contentView.addSubview($0) } initConstraints() updateFont() @@ -67,6 +74,7 @@ class TabBarCell: UICollectionViewCell { private func updateColors() { let browserColors: any BrowserColors = tabManager?.privateBrowsingManager.browserColors ?? .standard backgroundColor = browserColors.tabBarTabBackground + separatorLine.backgroundColor = browserColors.dividerSubtle highlightView.backgroundColor = isSelected ? browserColors.tabBarTabActiveBackground : .clear highlightView.layer.shadowOpacity = isSelected ? 0.05 : 0.0 highlightView.layer.shadowColor = UIColor.black.cgColor @@ -94,6 +102,12 @@ class TabBarCell: UICollectionViewCell { make.right.equalTo(self).inset(2) make.width.equalTo(30) } + + separatorLine.snp.makeConstraints { make in + make.left.equalToSuperview() + make.width.equalTo(1) + make.top.bottom.equalToSuperview().inset(5) + } } override var isSelected: Bool {