Fill the QuickTerminalTabBarView with QuickTerminalTabItemView

This commit is contained in:
Soh Satoh
2025-01-25 22:30:31 +09:00
parent f32adf3afa
commit ba919c7f6f
2 changed files with 24 additions and 31 deletions

View File

@ -2,16 +2,15 @@ import SwiftUI
struct QuickTerminalTabBarView: View {
@ObservedObject var tabManager: QuickTerminalTabManager
@GestureState private var isDragging: Bool = false
var body: some View {
HStack(spacing: 0) {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 0) {
ForEach(tabManager.tabs) { tab in
QuickTerminalTabItemView(
tab: tab,
isSelected: tab.isActive,
isSingleTab: tabManager.tabs.count == 1,
onSelect: { tabManager.selectTab(tab) },
onClose: { tabManager.closeTab(tab) }
)
@ -29,13 +28,6 @@ struct QuickTerminalTabBarView: View {
)
}
}
}
.gesture(
DragGesture(minimumDistance: 0)
.updating($isDragging) { _, state, _ in
state = true
}
)
Divider()
@ -43,7 +35,7 @@ struct QuickTerminalTabBarView: View {
.foregroundColor(.gray)
.padding(.horizontal, 8)
.frame(width: 50)
.contentShape(Rectangle()) // Make the entire frame clickable
.contentShape(Rectangle())
.onTapGesture {
tabManager.newTab()
}

View File

@ -3,6 +3,7 @@ import SwiftUI
struct QuickTerminalTabItemView: View {
@ObservedObject var tab: QuickTerminalTab
let isSelected: Bool
let isSingleTab: Bool
let onSelect: () -> Void
let onClose: () -> Void
@ -13,7 +14,7 @@ struct QuickTerminalTabItemView: View {
Text(tab.title)
.lineLimit(1)
.truncationMode(.tail)
.frame(maxWidth: 150)
.frame(minWidth: 0, maxWidth: .infinity)
Button(action: onClose) {
Image(systemName: "xmark")
@ -29,7 +30,7 @@ struct QuickTerminalTabItemView: View {
.background(
RoundedRectangle(cornerRadius: 6)
.fill(
isSelected
isSelected && !isSingleTab
? Color(NSColor.selectedContentBackgroundColor)
: (isHovered ? Color(NSColor.gridColor) : Color.clear))
)