Conversation
| public func rideau<Content: View>( | ||
| configuration: RideauView.Configuration = .init(snapPoints: [.hidden, .fraction(1)]), | ||
| initialSnapPoint: RideauSnapPoint = .fraction(1), | ||
| isPresented: Binding<Bool>, | ||
| onDismiss: (() -> Void)? = nil, | ||
| @ViewBuilder content: () -> Content | ||
| ) -> some View { | ||
| modifier( | ||
| SwiftUIRideauBooleanModifier( | ||
| configuration: configuration, | ||
| initialSnapPoint: initialSnapPoint, | ||
| isPresented: isPresented, | ||
| onDismiss: onDismiss ?? {}, | ||
| body: content() | ||
| ) | ||
| ) | ||
|
|
||
| } | ||
|
|
||
| /** | ||
| Displays a Rideau using the given item as a data source for the Rideau’s content. | ||
| */ | ||
| public func rideau<Item: Identifiable, Content: View>( | ||
| configuration: RideauView.Configuration = .init(snapPoints: [.hidden, .fraction(1)]), | ||
| initialSnapPoint: RideauSnapPoint = .fraction(1), | ||
| item: Binding<Item?>, | ||
| onDismiss: (() -> Void)? = nil, | ||
| @ViewBuilder content: @escaping (Item) -> Content | ||
| ) -> some View { | ||
|
|
||
| modifier( | ||
| SwiftUIRideauItemModifier( | ||
| configuration: configuration, | ||
| initialSnapPoint: initialSnapPoint, | ||
| item: item, | ||
| onDismiss: onDismiss ?? {}, | ||
| body: content | ||
| ) | ||
| ) | ||
| } |
There was a problem hiding this comment.
here is public header
|
|
||
| } | ||
|
|
||
| private struct SwiftUIRideau<Content: View>: UIViewControllerRepresentable { |
There was a problem hiding this comment.
host view to present the view controller that hosts Rideau internally.
|
|
||
| } | ||
|
|
||
| private struct SwiftUIRideauItemModifier<Item: Identifiable, Body: View>: ViewModifier { |
There was a problem hiding this comment.
made a modifier for displaying with item binding
|
|
||
| } | ||
|
|
||
| private struct SwiftUIRideauBooleanModifier<Body: View>: ViewModifier { |
There was a problem hiding this comment.
made a modifier for displaying with boolean binding
Rideau/SwiftUI/Rideau+SwiftUI.swift
Outdated
| configuration: RideauView.Configuration, | ||
| initialSnapPoint: RideauSnapPoint, | ||
| onDidDismiss: @escaping @MainActor () -> Void, | ||
| @ViewBuilder conetnt: () -> Content |
| } | ||
| } | ||
|
|
||
| #if DEBUG |
There was a problem hiding this comment.
FYI in release build, PreviewProviders will not be included
There was a problem hiding this comment.
yeah, I know that. I just added macro for just in case of like adding a dummy struct inside macro.
even though, any types that are defined inside PreviewProvider, will be deleted in production. but not sure.
so still, adding macro makes me relieved.
|
|
||
| // MARK: - Properties | ||
|
|
||
| var onWillDismiss: () -> Void = {} |
There was a problem hiding this comment.
hm, yes, that's called.
but anymore it's not meaningful.
I'll delete it.
| rideauView.containerView.set(bodyView: bodyViewController.view, resizingOption: resizingOption) | ||
| } | ||
|
|
||
| @objc private dynamic func didTapBackdropView(gesture: UITapGestureRecognizer) { |
There was a problem hiding this comment.
Do we need it to by dynamic?
There was a problem hiding this comment.
ah it's kind of classic way to support objc dynamics. in some swift version, swift compiler deleted those symbols in optimization. we could solve that by adding dynamic.
but seems nowadays we don't need to do that anymore.
|
@ntnmrndn |
This PR provides new APIs that display Rideau in SwiftUI world.
those are designed following SwiftUI standard API such sheet modifier.