@@ -22,6 +22,7 @@ struct ComposeScreen: View {
2222 @State private var defaultFocusRequested = false
2323 @State private var showDraftSheet = false
2424 @State private var showDraftConfirmation = false
25+ @State private var showAccountPicker = false
2526
2627 var body : some View {
2728 VStack (
@@ -262,7 +263,9 @@ struct ComposeScreen: View {
262263
263264 return HStack {
264265 if !accounts. isEmpty {
265- accountPickerMenu ( selected: selected, accounts: accounts) {
266+ Button {
267+ showAccountPicker. toggle ( )
268+ } label: {
266269 HStack ( spacing: 8 ) {
267270 if !selected. isEmpty {
268271 accountAvatarStack ( users: selected)
@@ -279,34 +282,57 @@ struct ComposeScreen: View {
279282 . background ( Color ( . secondarySystemBackground) )
280283 . clipShape ( Capsule ( ) )
281284 }
285+ . buttonStyle ( . plain)
286+ . popover ( isPresented: $showAccountPicker, arrowEdge: . top) {
287+ accountPickerPopover ( selected: selected, accounts: accounts)
288+ }
282289 }
283290 Spacer ( )
284291 }
285292 . padding ( . horizontal)
286293 }
287294
288- private func accountPickerMenu < LabelContent : View > (
295+ private func accountPickerPopover (
289296 selected: [ UiProfile ] ,
290- accounts: [ UiProfile ] ,
291- @ViewBuilder label: ( ) -> LabelContent
297+ accounts: [ UiProfile ]
292298 ) -> some View {
293- Menu {
294- ForEach ( accounts, id: \. accountPickerKey) { user in
295- Toggle (
296- isOn: Binding (
297- get: {
298- selected. containsAccount ( user)
299- } ,
300- set: { _ in
301- presenter. state. selectAccount ( accountKey: user. key)
302- }
299+ ScrollView {
300+ VStack ( alignment: . leading, spacing: 4 ) {
301+ ForEach ( accounts, id: \. accountPickerKey) { user in
302+ accountPickerButton (
303+ user: user,
304+ isSelected: selected. containsAccount ( user)
303305 )
304- ) {
305- accountPickerRow ( user: user)
306306 }
307307 }
308+ . padding ( 8 )
309+ }
310+ . frame ( minWidth: 280 , maxWidth: 340 , maxHeight: 420 )
311+ . presentationDetents ( [ . medium, . large] )
312+ }
313+
314+ private func accountPickerButton(
315+ user: UiProfile ,
316+ isSelected: Bool
317+ ) -> some View {
318+ Button {
319+ presenter. state. selectAccount ( accountKey: user. key)
308320 } label: {
309- label ( )
321+ HStack ( spacing: 10 ) {
322+ Image ( systemName: isSelected ? " checkmark.circle.fill " : " circle " )
323+ . font ( . title3)
324+ . foregroundStyle ( isSelected ? Color . accentColor : Color . secondary)
325+ . frame ( width: 24 )
326+ accountPickerRow ( user: user)
327+ . frame ( maxWidth: . infinity, alignment: . leading)
328+ }
329+ . padding ( . horizontal, 8 )
330+ . padding ( . vertical, 8 )
331+ . background (
332+ isSelected ? Color . accentColor. opacity ( 0.12 ) : Color . clear,
333+ in: RoundedRectangle ( cornerRadius: 8 , style: . continuous)
334+ )
335+ . contentShape ( RoundedRectangle ( cornerRadius: 8 , style: . continuous) )
310336 }
311337 . buttonStyle ( . plain)
312338 }
0 commit comments