Skip to content

Commit

Permalink
Merge pull request #457 from edx/fix-modal-view-for-quality-settings
Browse files Browse the repository at this point in the history
Fix video quality settings in modal representation
  • Loading branch information
rnr authored Jun 13, 2024
2 parents dcb4134 + 3244d1e commit daf4834
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 31 deletions.
77 changes: 49 additions & 28 deletions Core/Core/View/Base/VideoDownloadQualityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -210,3 +217,17 @@ public extension DownloadQuality {
}
}
}

#if DEBUG
struct VideoDownloadQualityView_Previews: PreviewProvider {
static var previews: some View {
VideoDownloadQualityView(
downloadQuality: .auto,
didSelect: nil,
analytics: CoreAnalyticsMock(),
router: BaseRouterMock(),
isModal: true
)
}
}
#endif
3 changes: 2 additions & 1 deletion Course/Course/Presentation/Outline/CourseOutlineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -36,7 +39,8 @@ struct VideoDownloadQualityContainerView: View {
downloadQuality: downloadQuality,
didSelect: didSelect,
analytics: analytics,
router: router
router: router,
isModal: isModal
)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Expand Down

0 comments on commit daf4834

Please sign in to comment.