Skip to content

Commit efde1ce

Browse files
committed
Update Tab styles to look more modern
1 parent 7cad406 commit efde1ce

5 files changed

Lines changed: 213 additions & 146 deletions

File tree

Views/Components/ContextualToolbar.swift

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct ContextualToolbar: View {
3636
// MARK: - View Toggle Buttons
3737

3838
private var viewToggleButtons: some View {
39-
HStack(spacing: 0) {
39+
HStack(spacing: 1) {
4040
ViewToggleButton(
4141
icon: "list.bullet",
4242
viewType: .list,
@@ -49,15 +49,15 @@ struct ContextualToolbar: View {
4949
currentViewType: $viewType
5050
)
5151
}
52+
.padding(4)
5253
.background(
53-
RoundedRectangle(cornerRadius: 6)
54-
.fill(Color(NSColor.controlBackgroundColor))
54+
RoundedRectangle(cornerRadius: 8)
55+
.fill(Color(NSColor.controlBackgroundColor).opacity(0.5))
5556
.overlay(
56-
RoundedRectangle(cornerRadius: 6)
57-
.stroke(Color(NSColor.separatorColor), lineWidth: 0.5)
57+
RoundedRectangle(cornerRadius: 8)
58+
.strokeBorder(Color.primary.opacity(0.08), lineWidth: 1)
5859
)
5960
)
60-
.shadow(color: .black.opacity(0.1), radius: 1, x: 0, y: 0.5)
6161
}
6262
}
6363

@@ -67,6 +67,7 @@ private struct ViewToggleButton: View {
6767
let icon: String
6868
let viewType: LibraryViewType
6969
@Binding var currentViewType: LibraryViewType
70+
@State private var isHovered = false
7071

7172
var isSelected: Bool {
7273
currentViewType == viewType
@@ -76,15 +77,29 @@ private struct ViewToggleButton: View {
7677
Button(action: { currentViewType = viewType }) {
7778
Image(systemName: icon)
7879
.font(.system(size: 14, weight: .medium))
79-
.frame(width: 28, height: 24)
80+
.foregroundStyle(
81+
isSelected ? AnyShapeStyle(Color.white) :
82+
isHovered ? AnyShapeStyle(Color.primary) :
83+
AnyShapeStyle(Color.secondary)
84+
)
85+
.frame(width: 32, height: 24)
8086
.background(
81-
RoundedRectangle(cornerRadius: 4)
82-
.fill(isSelected ? Color.accentColor : Color.clear)
87+
RoundedRectangle(cornerRadius: 6)
88+
.fill(
89+
isSelected ? Color.accentColor :
90+
isHovered ? Color.primary.opacity(0.06) :
91+
Color.clear
92+
)
93+
.animation(.easeOut(duration: 0.15), value: isSelected)
94+
.animation(.easeOut(duration: 0.1), value: isHovered)
8395
)
84-
.foregroundColor(isSelected ? .white : .primary)
96+
.contentShape(RoundedRectangle(cornerRadius: 6))
8597
}
86-
.buttonStyle(.borderless)
98+
.buttonStyle(.plain)
8799
.help("\(viewType.displayName)")
100+
.onHover { hovering in
101+
isHovered = hovering
102+
}
88103
}
89104
}
90105

@@ -99,15 +114,3 @@ private struct ViewToggleButton: View {
99114
}
100115
.environmentObject(libraryManager)
101116
}
102-
103-
#Preview {
104-
@State var viewType: LibraryViewType = .list
105-
let libraryManager = LibraryManager()
106-
107-
VStack(spacing: 0) {
108-
ContextualToolbar(selectedTab: .library, viewType: $viewType)
109-
ContextualToolbar(selectedTab: .folders, viewType: $viewType)
110-
ContextualToolbar(selectedTab: .playlists, viewType: $viewType)
111-
}
112-
.environmentObject(libraryManager)
113-
}

Views/Components/TabButton.swift

Lines changed: 0 additions & 36 deletions
This file was deleted.

Views/Components/TitleBarTabs.swift

Lines changed: 0 additions & 70 deletions
This file was deleted.

Views/Main/ContentView.swift

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,78 @@ struct ContentView: View {
9393
}
9494
}
9595

96+
// Modern tab component for titlebar
97+
struct TitleBarTabs: View {
98+
@Binding var selectedTab: MainTab
99+
100+
var body: some View {
101+
HStack(spacing: 1) {
102+
ForEach(MainTab.allCases, id: \.self) { tab in
103+
TitleBarTabButton(
104+
tab: tab,
105+
isSelected: selectedTab == tab,
106+
action: { selectedTab = tab }
107+
)
108+
}
109+
}
110+
.padding(4)
111+
.background(
112+
RoundedRectangle(cornerRadius: 8)
113+
.fill(Color(NSColor.controlBackgroundColor).opacity(0.5))
114+
.overlay(
115+
RoundedRectangle(cornerRadius: 8)
116+
.strokeBorder(Color.primary.opacity(0.08), lineWidth: 1)
117+
)
118+
)
119+
}
120+
}
121+
122+
struct TitleBarTabButton: View {
123+
let tab: MainTab
124+
let isSelected: Bool
125+
let action: () -> Void
126+
@State private var isHovered = false
127+
128+
var body: some View {
129+
Button(action: action) {
130+
HStack(spacing: 5) {
131+
Image(systemName: isSelected ? tab.selectedIcon : tab.icon)
132+
.font(.system(size: 13, weight: .medium))
133+
.foregroundStyle(
134+
isSelected ? AnyShapeStyle(Color.white) :
135+
isHovered ? AnyShapeStyle(Color.primary) :
136+
AnyShapeStyle(Color.secondary)
137+
)
138+
139+
Text(tab.rawValue)
140+
.font(.system(size: 12, weight: .medium))
141+
.foregroundColor(
142+
isSelected ? .white :
143+
isHovered ? .primary :
144+
.secondary
145+
)
146+
}
147+
.frame(width: 90) // Fixed width for all tabs
148+
.padding(.vertical, 5)
149+
.background(
150+
RoundedRectangle(cornerRadius: 6)
151+
.fill(
152+
isSelected ? Color.accentColor :
153+
isHovered ? Color.primary.opacity(0.06) :
154+
Color.clear
155+
)
156+
.animation(.easeOut(duration: 0.15), value: isSelected)
157+
.animation(.easeOut(duration: 0.1), value: isHovered)
158+
)
159+
.contentShape(RoundedRectangle(cornerRadius: 6))
160+
}
161+
.buttonStyle(.plain)
162+
.onHover { hovering in
163+
isHovered = hovering
164+
}
165+
}
166+
}
167+
96168
#Preview {
97169
ContentView()
98170
.environmentObject({

0 commit comments

Comments
 (0)