-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SwiftUI API #56
base: main
Are you sure you want to change the base?
SwiftUI API #56
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is public header
|
||
} | ||
|
||
private struct SwiftUIRideau<Content: View>: UIViewControllerRepresentable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made a modifier for displaying with item binding
|
||
} | ||
|
||
private struct SwiftUIRideauBooleanModifier<Body: View>: ViewModifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content
} | ||
} | ||
|
||
#if DEBUG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI in release build, PreviewProviders will not be included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need it to by dynamic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.