Skip to content

Commit

Permalink
Fix brave/brave-ios#8361: Open Add separator between inactive tabs (b…
Browse files Browse the repository at this point in the history
  • Loading branch information
soner-yuksel authored Nov 21, 2023
1 parent 665bf8e commit 083d1c7
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit 083d1c7

Please sign in to comment.