From 9119afbf1da292696e31a82822ba3bdcdf498283 Mon Sep 17 00:00:00 2001 From: Ilias Pavlidakis Date: Fri, 10 May 2024 12:45:29 +0300 Subject: [PATCH] Update docs --- .../18-call-quality-rating.swift | 2 +- .../ViewModifiers/CallEndedViewModifier.swift | 24 +++++++++---------- .../05-ui-cookbook/18-call-quality-rating.mdx | 6 ++--- 3 files changed, 16 insertions(+), 16 deletions(-) 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..b35cb368d 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 @@ -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 +:::