From 145d66ff5ce34be00ffb6133b1a28ce8faeb7a91 Mon Sep 17 00:00:00 2001 From: Julien Sagot Date: Thu, 13 Mar 2025 22:38:45 +0100 Subject: [PATCH] Use swift-navigation helpers for presenting alerts and action sheets --- .../UIKit/AlertStateUIKit.swift | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift b/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift index 562893d48c5e..daec59ee70fa 100644 --- a/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift +++ b/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift @@ -28,18 +28,7 @@ public convenience init( store: Store, Action> ) { - let state = store.currentState - self.init( - title: String(state: state.title), - message: state.message.map { String(state: $0) }, - preferredStyle: .alert - ) - for button in state.buttons { - addAction(UIAlertAction(button, action: { _ = $0.map(store.send) })) - } - if state.buttons.isEmpty { - addAction(UIAlertAction(title: "OK", style: .cancel)) - } + self.init(state: store.currentState) { _ = $0.map(store.send) } } /// Creates a `UIAlertController` from a ``Store`` focused on confirmation dialog state. @@ -63,19 +52,7 @@ public convenience init( store: Store, Action> ) { - let state = store.currentState - self.init( - title: String(state: state.title), - message: state.message.map { String(state: $0) }, - preferredStyle: .actionSheet - ) - for button in state.buttons { - addAction(UIAlertAction(button, action: { _ = $0.map(store.send) })) - } - if state.buttons.isEmpty { - addAction(UIAlertAction(title: "OK", style: .cancel)) - } + self.init(state: store.currentState) { _ = $0.map(store.send) } } - } #endif