From 5ef90cf38bd76f1b9dabef60763e6ca1c800971c Mon Sep 17 00:00:00 2001 From: Anton Yarmolenko <37253+rnr@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:01:51 +0200 Subject: [PATCH 1/2] chore: added isModal flag --- .../View/Base/VideoDownloadQualityView.swift | 77 ++++++++++++------- .../Outline/CourseOutlineView.swift | 3 +- .../VideoDownloadQualityContainerView.swift | 8 +- 3 files changed, 57 insertions(+), 31 deletions(-) diff --git a/Core/Core/View/Base/VideoDownloadQualityView.swift b/Core/Core/View/Base/VideoDownloadQualityView.swift index 06e3f7c5a..7317499e4 100644 --- a/Core/Core/View/Base/VideoDownloadQualityView.swift +++ b/Core/Core/View/Base/VideoDownloadQualityView.swift @@ -34,13 +34,15 @@ public struct VideoDownloadQualityView: View { private var viewModel: VideoDownloadQualityViewModel private var analytics: CoreAnalytics private var router: BaseRouter + private var isModal: Bool @Environment (\.isHorizontal) private var isHorizontal public init( downloadQuality: DownloadQuality, didSelect: ((DownloadQuality) -> Void)?, analytics: CoreAnalytics, - router: BaseRouter + router: BaseRouter, + isModal: Bool = false ) { self._viewModel = StateObject( wrappedValue: .init( @@ -50,41 +52,46 @@ public struct VideoDownloadQualityView: View { ) self.analytics = analytics self.router = router + self.isModal = isModal } public var body: some View { GeometryReader { proxy in ZStack(alignment: .top) { - VStack { - ThemeAssets.headerBackground.swiftUIImage - .resizable() - .edgesIgnoringSafeArea(.top) + if !isModal { + VStack { + ThemeAssets.headerBackground.swiftUIImage + .resizable() + .edgesIgnoringSafeArea(.top) + } + .frame(maxWidth: .infinity, maxHeight: 200) + .accessibilityIdentifier("auth_bg_image") } - .frame(maxWidth: .infinity, maxHeight: 200) - .accessibilityIdentifier("auth_bg_image") // MARK: - Page name VStack(alignment: .center) { - ZStack { - HStack { - Text(CoreLocalization.Settings.videoDownloadQualityTitle) - .titleSettings(color: Theme.Colors.loginNavigationText) - .accessibilityIdentifier("manage_account_text") + if !isModal { + ZStack { + HStack { + Text(CoreLocalization.Settings.videoDownloadQualityTitle) + .titleSettings(color: Theme.Colors.loginNavigationText) + .accessibilityIdentifier("manage_account_text") + } + VStack { + BackNavigationButton( + color: Theme.Colors.loginNavigationText, + action: { + router.back() + } + ) + .backViewStyle() + .padding(.leading, isHorizontal ? 48 : 0) + .accessibilityIdentifier("back_button") + + }.frame(minWidth: 0, + maxWidth: .infinity, + alignment: .topLeading) } - VStack { - BackNavigationButton( - color: Theme.Colors.loginNavigationText, - action: { - router.back() - } - ) - .backViewStyle() - .padding(.leading, isHorizontal ? 48 : 0) - .accessibilityIdentifier("back_button") - - }.frame(minWidth: 0, - maxWidth: .infinity, - alignment: .topLeading) } // MARK: - Page Body ScrollView { @@ -129,8 +136,8 @@ public struct VideoDownloadQualityView: View { } } } - .navigationBarHidden(true) - .navigationBarBackButtonHidden(true) + .navigationBarHidden(!isModal) + .navigationBarBackButtonHidden(!isModal) .navigationTitle(CoreLocalization.Settings.videoDownloadQualityTitle) .ignoresSafeArea(.all, edges: .horizontal) .background( @@ -210,3 +217,17 @@ public extension DownloadQuality { } } } + +#if DEBUG +struct AddTopic_Previews: PreviewProvider { + static var previews: some View { + VideoDownloadQualityView( + downloadQuality: .auto, + didSelect: nil, + analytics: CoreAnalyticsMock(), + router: BaseRouterMock(), + isModal: true + ) + } +} +#endif diff --git a/Course/Course/Presentation/Outline/CourseOutlineView.swift b/Course/Course/Presentation/Outline/CourseOutlineView.swift index cb7e1bec2..381decc63 100644 --- a/Course/Course/Presentation/Outline/CourseOutlineView.swift +++ b/Course/Course/Presentation/Outline/CourseOutlineView.swift @@ -205,7 +205,8 @@ public struct CourseOutlineView: View { downloadQuality: $0.downloadQuality, didSelect: viewModel.update(downloadQuality:), analytics: viewModel.coreAnalytics, - router: viewModel.router + router: viewModel.router, + isModal: true ) } } diff --git a/Course/Course/Presentation/Subviews/VideoDownloadQualityBarView/VideoDownloadQualityContainerView.swift b/Course/Course/Presentation/Subviews/VideoDownloadQualityBarView/VideoDownloadQualityContainerView.swift index 09fcf8001..79007c35e 100644 --- a/Course/Course/Presentation/Subviews/VideoDownloadQualityBarView/VideoDownloadQualityContainerView.swift +++ b/Course/Course/Presentation/Subviews/VideoDownloadQualityBarView/VideoDownloadQualityContainerView.swift @@ -17,17 +17,20 @@ struct VideoDownloadQualityContainerView: View { private var didSelect: ((DownloadQuality) -> Void)? private let analytics: CoreAnalytics private let router: CourseRouter + private var isModal: Bool init( downloadQuality: DownloadQuality, didSelect: ((DownloadQuality) -> Void)?, analytics: CoreAnalytics, - router: CourseRouter + router: CourseRouter, + isModal: Bool = false ) { self.downloadQuality = downloadQuality self.didSelect = didSelect self.analytics = analytics self.router = router + self.isModal = isModal } var body: some View { @@ -36,7 +39,8 @@ struct VideoDownloadQualityContainerView: View { downloadQuality: downloadQuality, didSelect: didSelect, analytics: analytics, - router: router + router: router, + isModal: isModal ) .navigationBarTitleDisplayMode(.inline) .toolbar { From 3244d1e54e4cb8409dedf5620ffe0b6e7b9ef77f Mon Sep 17 00:00:00 2001 From: Anton Yarmolenko <37253+rnr@users.noreply.github.com> Date: Thu, 13 Jun 2024 08:45:20 +0200 Subject: [PATCH 2/2] chore: fixed wrong name --- Core/Core/View/Base/VideoDownloadQualityView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Core/View/Base/VideoDownloadQualityView.swift b/Core/Core/View/Base/VideoDownloadQualityView.swift index 7317499e4..26cce95c4 100644 --- a/Core/Core/View/Base/VideoDownloadQualityView.swift +++ b/Core/Core/View/Base/VideoDownloadQualityView.swift @@ -219,7 +219,7 @@ public extension DownloadQuality { } #if DEBUG -struct AddTopic_Previews: PreviewProvider { +struct VideoDownloadQualityView_Previews: PreviewProvider { static var previews: some View { VideoDownloadQualityView( downloadQuality: .auto,