|
1 | 1 | #if canImport(SwiftUI)
|
2 | 2 |
|
3 |
| - import SwiftUI |
| 3 | +import SwiftUI |
4 | 4 |
|
5 |
| - // NB: Deprecated after 0.10.0: |
| 5 | +// NB: Deprecated after 0.17.0: |
6 | 6 |
|
7 | 7 | @available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
|
8 |
| - extension ActionSheetState { |
9 |
| - @available(*, deprecated, message: "'title' and 'message' should be 'TextState'") |
10 |
| - @_disfavoredOverload |
11 |
| - public init( |
12 |
| - title: LocalizedStringKey, |
13 |
| - message: LocalizedStringKey? = nil, |
14 |
| - buttons: [Button] |
15 |
| - ) { |
16 |
| - self.init( |
17 |
| - title: .init(title), |
18 |
| - message: message.map { .init($0) }, |
19 |
| - buttons: buttons |
20 |
| - ) |
21 |
| - } |
| 8 | +extension IfLetStore { |
| 9 | + @available(*, deprecated, message: "'else' now takes a view builder closure") |
| 10 | + public init<IfContent, ElseContent>( |
| 11 | + _ store: Store<State?, Action>, |
| 12 | + @ViewBuilder then ifContent: @escaping (Store<State, Action>) -> IfContent, |
| 13 | + else elseContent: @escaping @autoclosure () -> ElseContent |
| 14 | + ) where Content == _ConditionalContent<IfContent, ElseContent> { |
| 15 | + self.init(store, then: ifContent, else: elseContent) |
22 | 16 | }
|
| 17 | +} |
| 18 | + |
| 19 | +// NB: Deprecated after 0.10.0: |
23 | 20 |
|
24 | 21 | @available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
|
25 |
| - extension AlertState { |
26 |
| - @available(*, deprecated, message: "'title' and 'message' should be 'TextState'") |
27 |
| - @_disfavoredOverload |
28 |
| - public init( |
29 |
| - title: LocalizedStringKey, |
30 |
| - message: LocalizedStringKey? = nil, |
31 |
| - dismissButton: Button? = nil |
32 |
| - ) { |
33 |
| - self.init( |
34 |
| - title: .init(title), |
35 |
| - message: message.map { .init($0) }, |
36 |
| - dismissButton: dismissButton |
37 |
| - ) |
38 |
| - } |
| 22 | +extension ActionSheetState { |
| 23 | + @available(*, deprecated, message: "'title' and 'message' should be 'TextState'") |
| 24 | + @_disfavoredOverload |
| 25 | + public init( |
| 26 | + title: LocalizedStringKey, |
| 27 | + message: LocalizedStringKey? = nil, |
| 28 | + buttons: [Button] |
| 29 | + ) { |
| 30 | + self.init( |
| 31 | + title: .init(title), |
| 32 | + message: message.map { .init($0) }, |
| 33 | + buttons: buttons |
| 34 | + ) |
| 35 | + } |
| 36 | +} |
39 | 37 |
|
40 |
| - @available(*, deprecated, message: "'title' and 'message' should be 'TextState'") |
41 |
| - @_disfavoredOverload |
42 |
| - public init( |
43 |
| - title: LocalizedStringKey, |
44 |
| - message: LocalizedStringKey? = nil, |
45 |
| - primaryButton: Button, |
46 |
| - secondaryButton: Button |
47 |
| - ) { |
48 |
| - self.init( |
49 |
| - title: .init(title), |
50 |
| - message: message.map { .init($0) }, |
51 |
| - primaryButton: primaryButton, |
52 |
| - secondaryButton: secondaryButton |
53 |
| - ) |
54 |
| - } |
| 38 | + @available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *) |
| 39 | +extension AlertState { |
| 40 | + @available(*, deprecated, message: "'title' and 'message' should be 'TextState'") |
| 41 | + @_disfavoredOverload |
| 42 | + public init( |
| 43 | + title: LocalizedStringKey, |
| 44 | + message: LocalizedStringKey? = nil, |
| 45 | + dismissButton: Button? = nil |
| 46 | + ) { |
| 47 | + self.init( |
| 48 | + title: .init(title), |
| 49 | + message: message.map { .init($0) }, |
| 50 | + dismissButton: dismissButton |
| 51 | + ) |
55 | 52 | }
|
56 | 53 |
|
| 54 | + @available(*, deprecated, message: "'title' and 'message' should be 'TextState'") |
| 55 | + @_disfavoredOverload |
| 56 | + public init( |
| 57 | + title: LocalizedStringKey, |
| 58 | + message: LocalizedStringKey? = nil, |
| 59 | + primaryButton: Button, |
| 60 | + secondaryButton: Button |
| 61 | + ) { |
| 62 | + self.init( |
| 63 | + title: .init(title), |
| 64 | + message: message.map { .init($0) }, |
| 65 | + primaryButton: primaryButton, |
| 66 | + secondaryButton: secondaryButton |
| 67 | + ) |
| 68 | + } |
| 69 | +} |
| 70 | + |
57 | 71 | @available(iOS 13, macOS 10.15, macCatalyst 13, tvOS 13, watchOS 6, *)
|
58 |
| - extension AlertState.Button { |
59 |
| - @available(*, deprecated, message: "'label' should be 'TextState'") |
60 |
| - @_disfavoredOverload |
61 |
| - public static func cancel( |
62 |
| - _ label: LocalizedStringKey, |
63 |
| - send action: Action? = nil |
64 |
| - ) -> Self { |
65 |
| - Self(action: action, type: .cancel(label: .init(label))) |
66 |
| - } |
| 72 | +extension AlertState.Button { |
| 73 | + @available(*, deprecated, message: "'label' should be 'TextState'") |
| 74 | + @_disfavoredOverload |
| 75 | + public static func cancel( |
| 76 | + _ label: LocalizedStringKey, |
| 77 | + send action: Action? = nil |
| 78 | + ) -> Self { |
| 79 | + Self(action: action, type: .cancel(label: .init(label))) |
| 80 | + } |
67 | 81 |
|
68 |
| - @available(*, deprecated, message: "'label' should be 'TextState'") |
69 |
| - @_disfavoredOverload |
70 |
| - public static func `default`( |
71 |
| - _ label: LocalizedStringKey, |
72 |
| - send action: Action? = nil |
73 |
| - ) -> Self { |
74 |
| - Self(action: action, type: .default(label: .init(label))) |
75 |
| - } |
| 82 | + @available(*, deprecated, message: "'label' should be 'TextState'") |
| 83 | + @_disfavoredOverload |
| 84 | + public static func `default`( |
| 85 | + _ label: LocalizedStringKey, |
| 86 | + send action: Action? = nil |
| 87 | + ) -> Self { |
| 88 | + Self(action: action, type: .default(label: .init(label))) |
| 89 | + } |
76 | 90 |
|
77 |
| - @available(*, deprecated, message: "'label' should be 'TextState'") |
78 |
| - @_disfavoredOverload |
79 |
| - public static func destructive( |
80 |
| - _ label: LocalizedStringKey, |
81 |
| - send action: Action? = nil |
82 |
| - ) -> Self { |
83 |
| - Self(action: action, type: .destructive(label: .init(label))) |
84 |
| - } |
| 91 | + @available(*, deprecated, message: "'label' should be 'TextState'") |
| 92 | + @_disfavoredOverload |
| 93 | + public static func destructive( |
| 94 | + _ label: LocalizedStringKey, |
| 95 | + send action: Action? = nil |
| 96 | + ) -> Self { |
| 97 | + Self(action: action, type: .destructive(label: .init(label))) |
85 | 98 | }
|
| 99 | +} |
86 | 100 | #endif
|
87 | 101 |
|
88 | 102 | // NB: Deprecated after 0.9.0:
|
|
0 commit comments