diff --git a/DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/18-call-quality-rating.swift b/DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/18-call-quality-rating.swift index 5405f4ce8..e2d4965f0 100644 --- a/DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/18-call-quality-rating.swift +++ b/DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/18-call-quality-rating.swift @@ -173,7 +173,7 @@ fileprivate func content() { var body: some View { YourRootView() .modifier(CallModifier(viewModel: viewModel)) - .onCallEnded(additionalPresentationValidator: { $0?.state.createdBy?.id == streamVideo.user.id }) { call, dismiss in + .onCallEnded(presentationValidator: { $0?.state.createdBy?.id == streamVideo.user.id }) { call, dismiss in if let call { DemoFeedbackView(call, dismiss: dismiss) } diff --git a/Sources/StreamVideoSwiftUI/CallView/ViewModifiers/CallEndedViewModifier.swift b/Sources/StreamVideoSwiftUI/CallView/ViewModifiers/CallEndedViewModifier.swift index 916107a53..9137b6388 100644 --- a/Sources/StreamVideoSwiftUI/CallView/ViewModifiers/CallEndedViewModifier.swift +++ b/Sources/StreamVideoSwiftUI/CallView/ViewModifiers/CallEndedViewModifier.swift @@ -30,16 +30,16 @@ private final class CallEndedViewModifierViewModel: ObservableObject { @available(iOS 14.0, *) private struct CallEndedViewModifier: ViewModifier { - private var additionalPresentationValidator: (Call?) -> Bool + private var presentationValidator: (Call?) -> Bool private var subviewProvider: (Call?, @escaping () -> Void) -> Subview @StateObject private var viewModel: CallEndedViewModifierViewModel init( - additionalPresentationValidator: @escaping (Call?) -> Bool, + presentationValidator: @escaping (Call?) -> Bool, @ViewBuilder subviewProvider: @escaping (Call?, @escaping () -> Void) -> Subview ) { - self.additionalPresentationValidator = additionalPresentationValidator + self.presentationValidator = presentationValidator self.subviewProvider = subviewProvider _viewModel = .init(wrappedValue: .init()) } @@ -62,7 +62,7 @@ private struct CallEndedViewModifier: ViewModifier { switch (call, viewModel.lastCall, viewModel.isPresentingSubview) { case (nil, let activeCall, false) where activeCall != nil && viewModel - .maxParticipantsCount > 1 && additionalPresentationValidator(viewModel.lastCall): + .maxParticipantsCount > 1 && presentationValidator(viewModel.lastCall): /// The following presentation criteria are required: /// - The activeCall was ended. /// - Participants, during call's duration, grew to more than one. @@ -105,16 +105,16 @@ private struct CallEndedViewModifier: ViewModifier { @available(iOS, introduced: 13, obsoleted: 14) private struct CallEndedViewModifier_iOS13: ViewModifier { - private var additionalPresentationValidator: (Call?) -> Bool + private var presentationValidator: (Call?) -> Bool private var subviewProvider: (Call?, @escaping () -> Void) -> Subview @BackportStateObject private var viewModel: CallEndedViewModifierViewModel init( - additionalPresentationValidator: @escaping (Call?) -> Bool, + presentationValidator: @escaping (Call?) -> Bool, @ViewBuilder subviewProvider: @escaping (Call?, @escaping () -> Void) -> Subview ) { - self.additionalPresentationValidator = additionalPresentationValidator + self.presentationValidator = presentationValidator self.subviewProvider = subviewProvider _viewModel = .init(wrappedValue: .init()) } @@ -136,7 +136,7 @@ private struct CallEndedViewModifier_iOS13: ViewModifier { switch (call, viewModel.lastCall, viewModel.isPresentingSubview) { case (nil, let activeCall, false) where activeCall != nil && viewModel - .maxParticipantsCount > 1 && additionalPresentationValidator(viewModel.lastCall): + .maxParticipantsCount > 1 && presentationValidator(viewModel.lastCall): /// The following presentation criteria are required: /// - The activeCall was ended. /// - Participants, during call's duration, grew to more than one. @@ -185,26 +185,26 @@ extension View { /// - Participants, during call's duration, grew to more than one. /// /// - Parameters: - /// - additionalPresentationValidator: A closure that can be used to provide additional + /// - presentationValidator: A closure that can be used to provide additional /// validation rules for presentation. The modifier will inject the last available call when calling. /// - content: A viewBuilder that returns the modal's content. The viewModifier /// will provide a dismiss closure that can be called from the content to close the modal. @ViewBuilder public func onCallEnded( - additionalPresentationValidator: @escaping (Call?) -> Bool = { _ in true }, + presentationValidator: @escaping (Call?) -> Bool = { _ in true }, @ViewBuilder _ content: @escaping (Call?, @escaping () -> Void) -> some View ) -> some View { if #available(iOS 14.0, *) { modifier( CallEndedViewModifier( - additionalPresentationValidator: additionalPresentationValidator, + presentationValidator: presentationValidator, subviewProvider: content ) ) } else { modifier( CallEndedViewModifier_iOS13( - additionalPresentationValidator: additionalPresentationValidator, + presentationValidator: presentationValidator, subviewProvider: content ) ) diff --git a/docusaurus/docs/iOS/05-ui-cookbook/18-call-quality-rating.mdx b/docusaurus/docs/iOS/05-ui-cookbook/18-call-quality-rating.mdx index ee2fab5b3..7670722a3 100644 --- a/docusaurus/docs/iOS/05-ui-cookbook/18-call-quality-rating.mdx +++ b/docusaurus/docs/iOS/05-ui-cookbook/18-call-quality-rating.mdx @@ -184,7 +184,7 @@ struct DemoStarRatingView: View { } ``` -With the FeedbackView declared, the next step is to find a way to inject the View in the call's lifecycle in order to be presented to the user at the right time. To simplify this step, the Swift Video SDK provides the `onCallEnded` ViewModifier . The modifier accepts two closures with inputs an optional `Call` object while onlye the second one also receives a dismiss closure. +With the FeedbackView declared, the next step is to find a way to inject the View in the call's lifecycle in order to be presented to the user at the right time. To simplify this step, the Swift Video SDK provides the `onCallEnded` ViewModifier . The modifier accepts two closures with inputs an optional `Call` object while only the second one also receives a dismiss closure. The first closure can be used to provide additional logic when calculating the decision to present or not the modal. The second closure is a `ViewBuilder` that will be called to provide the modal's content. @@ -197,7 +197,7 @@ struct CallContainer: View { var body: some View { YourRootView() .modifier(CallModifier(viewModel: viewModel)) - .onCallEnded(additionalPresentationValidator: { call in call?.state.createdBy?.id == streamVideo.user.id }) { call, dismiss in + .onCallEnded(presentationValidator: { call in call?.state.createdBy?.id == streamVideo.user.id }) { call, dismiss in if let call { DemoFeedbackView(call, dismiss: dismiss) } @@ -209,10 +209,10 @@ struct CallContainer: View { The ViewModifier observes the Call's lifecycle and looks for the following triggering criteria: - Once the active call has ended - If the max number of joined participants, during call's duration, grew to more than one -- It will evaluate the `additionalPresentationValidator` +- It will evaluate the `presentationValidator` Then the modifier will trigger the provided closure and will expect a view that will presented inside the modal. :::note The ViewModifier will provide you with a dismiss closure that you can use in your UI to dismiss the modal. -::: \ No newline at end of file +:::