Commit 7dcb66aa authored by Carola Nitz's avatar Carola Nitz

ButtonBarView: add separator underneath categories

parent 6ced633b
......@@ -34,6 +34,7 @@ extension Notification.Name {
public let settingsBackground: UIColor
public let settingsCellBackground: UIColor
public let settingsSeparatorColor: UIColor
public let mediaCategorySeparatorColor: UIColor
public let tabBarColor: UIColor
public let orangeUI: UIColor
......@@ -53,6 +54,7 @@ extension Notification.Name {
settingsBackground: UIColor,
settingsCellBackground: UIColor,
settingsSeparatorColor: UIColor,
mediaCategorySeparatorColor: UIColor,
tabBarColor: UIColor,
orangeUI: UIColor) {
self.isDark = isDark
......@@ -71,6 +73,7 @@ extension Notification.Name {
self.settingsBackground = settingsBackground
self.settingsCellBackground = settingsCellBackground
self.settingsSeparatorColor = settingsSeparatorColor
self.mediaCategorySeparatorColor = mediaCategorySeparatorColor
self.tabBarColor = tabBarColor
self.orangeUI = orangeUI
}
......@@ -149,6 +152,7 @@ let brightPalette = ColorPalette(isDark: false,
settingsBackground: UIColor(0xDCDCDC),
settingsCellBackground: UIColor(0xF9F9F7),
settingsSeparatorColor: UIColor(0xD3D3D3),
mediaCategorySeparatorColor: UIColor(0xECF2F6),
tabBarColor: UIColor(0xFFFFFF),
orangeUI: UIColor(0xFF8800))
......@@ -157,7 +161,7 @@ let darkPalette = ColorPalette(isDark: true,
statusBarStyle: .lightContent,
navigationbarColor: UIColor(0x292B36),
navigationbarTextColor: UIColor(0xD3D3D3),
background: UIColor(0x292B36),
background: UIColor(0x1B1E21),
cellBackgroundA: UIColor(0x292B36),
cellBackgroundB: UIColor(0x000000),
cellDetailTextColor: UIColor(0xD3D3D3),
......@@ -168,5 +172,6 @@ let darkPalette = ColorPalette(isDark: true,
settingsBackground: UIColor(0x292B36),
settingsCellBackground: UIColor(0x3D3F40),
settingsSeparatorColor: UIColor(0xA9A9A9),
mediaCategorySeparatorColor: UIColor(0x25292C),
tabBarColor: UIColor(0x292B36),
orangeUI: UIColor(0xFF8800))
......@@ -15,8 +15,10 @@ import Foundation
open class ButtonBarView: UICollectionView {
open var selectedBar: UIView!
open var separatorView: UIView!
internal var selectedBarHeight: CGFloat = 4
internal let selectedBarHeight: CGFloat = 4
internal let separatorHeight: CGFloat = 0.5
var selectedIndex = 0
......@@ -28,20 +30,32 @@ open class ButtonBarView: UICollectionView {
public override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
setup()
addSubview(selectedBar)
NotificationCenter.default.addObserver(self, selector: #selector(updateTheme), name: .VLCThemeDidChangeNotification, object: nil)
}
func setup() {
backgroundColor = .white
scrollsToTop = false
showsHorizontalScrollIndicator = false
separatorView = UIView(frame: CGRect(x: 0, y: self.frame.size.height - separatorHeight, width: self.frame.size.width, height: separatorHeight))
addSubview(separatorView)
selectedBar = UIView(frame: CGRect(x: 0, y: self.frame.size.height - CGFloat(self.selectedBarHeight), width: 0, height: CGFloat(self.selectedBarHeight)))
addSubview(selectedBar)
updateTheme()
}
@objc func updateTheme() {
backgroundColor = PresentationTheme.current.colors.background
selectedBar.backgroundColor = PresentationTheme.current.colors.orangeUI
separatorView.backgroundColor = PresentationTheme.current.colors.mediaCategorySeparatorColor
}
open func moveTo(index: Int, animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) {
selectedIndex = index
updateSelectedBarPosition(animated, swipeDirection: swipeDirection, pagerScroll: pagerScroll)
updateSubviewPositions(animated, swipeDirection: swipeDirection, pagerScroll: pagerScroll)
}
open func move(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat, pagerScroll: PagerScroll) {
......@@ -82,7 +96,7 @@ open class ButtonBarView: UICollectionView {
setContentOffset(CGPoint(x: targetContentOffset, y: 0), animated: false)
}
open func updateSelectedBarPosition(_ animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) {
open func updateSubviewPositions(_ animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) {
var selectedBarFrame = selectedBar.frame
let selectedCellIndexPath = IndexPath(item: selectedIndex, section: 0)
......@@ -96,10 +110,14 @@ open class ButtonBarView: UICollectionView {
if animated {
UIView.animate(withDuration: 0.3, animations: { [weak self] in
self?.selectedBar.frame = selectedBarFrame
if let strongSelf = self {
strongSelf.selectedBar.frame = selectedBarFrame
strongSelf.separatorView.frame = CGRect(x: 0, y: strongSelf.frame.size.height - strongSelf.separatorHeight, width: strongSelf.frame.size.width, height: strongSelf.separatorHeight)
}
})
} else {
selectedBar.frame = selectedBarFrame
separatorView.frame = CGRect(x: 0, y: frame.size.height - separatorHeight, width: frame.size.width, height: separatorHeight)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment