@@ -124,77 +124,74 @@ struct BaseWidget<Content: View>: View {
124124 }
125125
126126 var body : some View {
127- Button { } label: {
128- VStack ( spacing: 0 ) {
129- if isEditing {
130- HStack {
131- HStack ( spacing: 16 ) {
132- Image ( metadata. icon)
133- . resizable ( )
134- . frame ( width: 32 , height: 32 )
127+ VStack ( spacing: 0 ) {
128+ if isEditing {
129+ HStack {
130+ HStack ( spacing: 16 ) {
131+ Image ( metadata. icon)
132+ . resizable ( )
133+ . frame ( width: 32 , height: 32 )
134+
135+ BodyMSBText ( truncate ( metadata. name, 18 ) )
136+ . lineLimit ( 1 )
137+ }
135138
136- BodyMSBText ( truncate ( metadata. name, 18 ) )
137- . lineLimit ( 1 )
138- }
139+ Spacer ( )
139140
140- Spacer ( )
141-
142- // Action buttons when in edit mode
143- if isEditing {
144- HStack ( spacing: 8 ) {
145- // Delete button
146- Button {
147- onDelete ( )
148- } label: {
149- Image ( " trash " )
150- . resizable ( )
151- . foregroundColor ( . textPrimary)
152- . frame ( width: 24 , height: 24 )
153- }
154- . frame ( width: 32 , height: 32 )
155- . contentShape ( Rectangle ( ) )
156- . accessibilityIdentifier ( " \( metadata. name) _WidgetActionDelete " )
157-
158- // Edit button
159- Button {
160- onEdit ( )
161- } label: {
162- Image ( " gear-six " )
163- . resizable ( )
164- . foregroundColor ( . textPrimary)
165- . frame ( width: 24 , height: 24 )
166- }
167- . frame ( width: 32 , height: 32 )
168- . contentShape ( Rectangle ( ) )
169- . accessibilityIdentifier ( " \( metadata. name) _WidgetActionEdit " )
170-
171- Image ( " burger " )
141+ // Action buttons when in edit mode
142+ if isEditing {
143+ HStack ( spacing: 8 ) {
144+ // Delete button
145+ Button {
146+ onDelete ( )
147+ } label: {
148+ Image ( " trash " )
172149 . resizable ( )
173150 . foregroundColor ( . textPrimary)
174151 . frame ( width: 24 , height: 24 )
175- . frame ( width: 32 , height: 32 )
176- . contentShape ( Rectangle ( ) )
177- . overlay {
178- Color . clear
179- . frame ( width: 44 , height: 44 )
180- . contentShape ( Rectangle ( ) )
181- . trackDragHandle ( )
182- }
183- . accessibilityIdentifier ( " \( metadata. name) _WidgetActionReorder " )
184152 }
153+ . frame ( width: 32 , height: 32 )
154+ . contentShape ( Rectangle ( ) )
155+ . accessibilityIdentifier ( " \( metadata. name) _WidgetActionDelete " )
156+
157+ // Edit button
158+ Button {
159+ onEdit ( )
160+ } label: {
161+ Image ( " gear-six " )
162+ . resizable ( )
163+ . foregroundColor ( . textPrimary)
164+ . frame ( width: 24 , height: 24 )
165+ }
166+ . frame ( width: 32 , height: 32 )
167+ . contentShape ( Rectangle ( ) )
168+ . accessibilityIdentifier ( " \( metadata. name) _WidgetActionEdit " )
169+
170+ Image ( " burger " )
171+ . resizable ( )
172+ . foregroundColor ( . textPrimary)
173+ . frame ( width: 24 , height: 24 )
174+ . frame ( width: 32 , height: 32 )
175+ . contentShape ( Rectangle ( ) )
176+ . overlay {
177+ Color . clear
178+ . frame ( width: 44 , height: 44 )
179+ . contentShape ( Rectangle ( ) )
180+ . trackDragHandle ( )
181+ }
182+ . accessibilityIdentifier ( " \( metadata. name) _WidgetActionReorder " )
185183 }
186184 }
187185 }
186+ }
188187
189- // Widget content (only shown when not editing)
190- if !isEditing {
191- content
192- }
188+ // Widget content (only shown when not editing)
189+ if !isEditing {
190+ content
193191 }
194- . contentShape ( Rectangle ( ) )
195192 }
196- . accessibilityIdentifier ( " \( type . rawValue . capitalized ) Widget " )
197- . buttonStyle ( WidgetButtonStyle ( ) )
193+ . contentShape ( Rectangle ( ) )
194+ . accessibilityIdentifierIfPresent ( isEditing ? nil : " \( type . rawValue . capitalized ) Widget " )
198195 . frame ( maxWidth: . infinity)
199196 . padding ( ( hasBackground || isEditing) ? 16 : 0 )
200197 . background ( ( hasBackground || isEditing) ? Color . gray6 : Color . clear)
@@ -229,14 +226,6 @@ struct BaseWidget<Content: View>: View {
229226 }
230227}
231228
232- /// Custom button style for widgets
233- struct WidgetButtonStyle : ButtonStyle {
234- func makeBody( configuration: Configuration ) -> some View {
235- configuration. label
236- . opacity ( configuration. isPressed ? 0.9 : 1.0 )
237- }
238- }
239-
240229// Preview for the BaseWidget
241230#Preview {
242231 VStack {
0 commit comments