@@ -71,9 +71,7 @@ public struct AdvancedList<EmptyStateView: View, ErrorStateView: View, LoadingSt
7171 self . loadingStateView = loadingStateView
7272 self . pagination = pagination
7373 }
74- #endif
75-
76- #if targetEnvironment(macCatalyst)
74+ #else
7775 public init ( @ViewBuilder emptyStateView: @escaping ( ) -> EmptyStateView , @ViewBuilder errorStateView: @escaping ( Error ) -> ErrorStateView , @ViewBuilder loadingStateView: @escaping ( ) -> LoadingStateView ) {
7876 self . emptyStateView = emptyStateView
7977 self . errorStateView = errorStateView
@@ -121,24 +119,44 @@ struct AdvancedList_Previews : PreviewProvider {
121119
122120 static var previews : some View {
123121 NavigationView {
124- AdvancedList ( listService: listService, emptyStateView: {
125- Text ( " No data " )
126- } , errorStateView: { error in
127- VStack {
128- Text ( error. localizedDescription)
129- . lineLimit ( nil )
130-
131- Button ( action: {
132- // do something
133- } ) {
134- Text ( " Retry " )
122+ #if targetEnvironment(macCatalyst)
123+ AdvancedList ( emptyStateView: {
124+ Text ( " No data " )
125+ } , errorStateView: { error in
126+ VStack {
127+ Text ( error. localizedDescription)
128+ . lineLimit ( nil )
129+
130+ Button ( action: {
131+ // do something
132+ } ) {
133+ Text ( " Retry " )
134+ }
135135 }
136- }
137- } , loadingStateView: {
138- Text ( " Loading ... " )
139- } , pagination: . noPagination)
140- // TODO: why is this modifier not working on macOS?
141- // .navigationBarTitle(Text("List of Items"))
136+ } , loadingStateView: {
137+ Text ( " Loading ... " )
138+ } )
139+ . environmentObject ( listService)
140+ . environmentObject ( . noPagination)
141+ #else
142+ AdvancedList ( listService: listService, emptyStateView: {
143+ Text ( " No data " )
144+ } , errorStateView: { error in
145+ VStack {
146+ Text ( error. localizedDescription)
147+ . lineLimit ( nil )
148+
149+ Button ( action: {
150+ // do something
151+ } ) {
152+ Text ( " Retry " )
153+ }
154+ }
155+ } , loadingStateView: {
156+ Text ( " Loading ... " )
157+ } , pagination: . noPagination)
158+ // .navigationBarTitle(Text("List of Items"))
159+ #endif
142160 }
143161 }
144162}
0 commit comments