@@ -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- }
0 commit comments