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

View File

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