@@ -97,72 +97,53 @@ struct BYOKProviderConfigView: View {
9797 // MARK: - UI Components
9898
9999 private var ProviderLabelView : some View {
100- HStack ( spacing: 8 ) {
101- Image ( systemName: " chevron.right " ) . font ( . footnote. bold ( ) )
102- . foregroundColor ( . secondary)
103- . rotationEffect ( . degrees( isExpanded ? 90 : 0 ) )
104- . animation ( . easeInOut( duration: 0.3 ) , value: isExpanded)
105- . buttonStyle ( . borderless)
106- . opacity ( hasApiKey ? 1 : 0 )
107- . allowsHitTesting ( hasApiKey)
108-
109- HStack ( spacing: 8 ) {
110- Text ( provider. title)
111- . foregroundColor (
112- hasApiKey ? . primary : Color (
113- nsColor: colorScheme == . light ? . tertiaryLabelColor : . secondaryLabelColor
114- )
115- )
116- . bold ( ) +
117- Text( hasModels ? " ( \( allModels. filter { $0. isRegistered } . count) of \( allModels. count) Enabled) " : " " )
118- . foregroundColor ( . primary)
119- }
120- . padding ( . vertical, 4 )
121- }
100+ Text ( provider. title)
101+ . foregroundColor (
102+ hasApiKey ? . primary : Color (
103+ nsColor: colorScheme == . light ? . tertiaryLabelColor : . secondaryLabelColor
104+ )
105+ )
106+ . bold ( ) +
107+ Text( hasModels ? " ( \( allModels. filter { $0. isRegistered } . count) of \( allModels. count) Enabled) " : " " )
108+ . foregroundColor ( . primary)
122109 }
123110
124111 private var ProviderHeaderRowView : some View {
125- HStack ( alignment: . center, spacing: 16 ) {
126- ProviderLabelView
127-
128- Spacer ( )
129-
130- if let errorMessage = errorMessage {
131- Badge ( text: " Can't connect. Check your API key or network. " , level: . danger, icon: " xmark.circle.fill " )
132- . help ( " Unable to connect to \( provider. title) . \( errorMessage) Refresh or recheck your key setup. " )
133- }
134-
135- if hasApiKey {
136- if dataManager. isLoadingProvider ( provider) {
137- ProgressView ( ) . controlSize ( . small)
138- } else {
139- ConfiguredProviderActions
112+ DisclosureSettingsRow (
113+ isExpanded: $isExpanded,
114+ isEnabled: hasApiKey,
115+ accessibilityLabel: { expanded in " \( provider. title) \( expanded ? " collapse " : " expand " ) " } ,
116+ onToggle: { wasExpanded, nowExpanded in
117+ if wasExpanded && !nowExpanded && isSearchBarVisible {
118+ searchText = " "
119+ withAnimation ( . easeInOut) { isSearchBarVisible = false }
140120 }
141- } else {
142- UnconfiguredProviderAction
143- }
144- }
145- . padding ( . leading, 20 )
146- . padding ( . trailing, 24 )
147- . padding ( . vertical, 8 )
148- . background ( QuaternarySystemFillColor . opacity ( 0.75 ) )
149- . contentShape ( Rectangle ( ) )
150- . onTapGesture {
151- guard hasApiKey else { return }
152- let wasExpanded = isExpanded
153- withAnimation ( . easeInOut) {
154- isExpanded. toggle ( )
155- }
156- // If we just collapsed, and the search bar was open, reset it.
157- if wasExpanded && !isExpanded && isSearchBarVisible {
158- searchText = " "
159- withAnimation ( . easeInOut) {
160- isSearchBarVisible = false
121+ } ,
122+ title: { ProviderLabelView } ,
123+ actions: {
124+ Group {
125+ if let errorMessage = errorMessage {
126+ Badge (
127+ text: " Can't connect. Check your API key or network. " ,
128+ level: . danger,
129+ icon: " xmark.circle.fill "
130+ )
131+ . help ( " Unable to connect to \( provider. title) . \( errorMessage) Refresh or recheck your key setup. " )
132+ }
133+ if hasApiKey {
134+ if dataManager. isLoadingProvider ( provider) {
135+ ProgressView ( ) . controlSize ( . small)
136+ } else {
137+ ConfiguredProviderActions
138+ }
139+ } else {
140+ UnconfiguredProviderAction
141+ }
161142 }
143+ . padding ( . trailing, 4 )
144+ . frame ( height: 30 )
162145 }
163- }
164- . accessibilityAddTraits ( . isButton)
165- . accessibilityLabel ( " \( provider. title) \( isExpanded ? " collapse " : " expand " ) " )
146+ )
166147 }
167148
168149 @ViewBuilder
0 commit comments