mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Fill the QuickTerminalTabBarView with QuickTerminalTabItemView
This commit is contained in:
@ -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()
|
||||
}
|
||||
|
@ -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))
|
||||
)
|
||||
|
Reference in New Issue
Block a user