Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #8361: Open Add separator between inactive tabs #8442

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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()

Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down