diff --git a/podcasts/DownloadsManageBannerView.swift b/podcasts/DownloadsManageBannerView.swift index 1c5438728..a2e73cdc2 100644 --- a/podcasts/DownloadsManageBannerView.swift +++ b/podcasts/DownloadsManageBannerView.swift @@ -32,55 +32,50 @@ struct DownloadsManageBannerView: View { @ObservedObject var dataModel: DownloadsManageModel var body: some View { - VStack() { - Spacer() - HStack(alignment: .top) { - Image("cleanup") + HStack(alignment: .top) { + Image("cleanup") + .foregroundColor(theme.primaryText01) + VStack(alignment: .leading, spacing: 8) { + Text(L10n.manageDownloadsTitle) + .font(.system(size: 15, weight: .medium)) .foregroundColor(theme.primaryText01) - VStack(alignment: .leading, spacing: 8) { - Text(L10n.manageDownloadsTitle) - .font(.system(size: 15, weight: .medium)) - .foregroundColor(theme.primaryText01) - Text(L10n.manageDownloadsDetail(dataModel.sizeOccupied)) - .lineLimit(nil) - .fixedSize(horizontal: true, vertical: false) - .multilineTextAlignment(.leading) - .font(.system(size: 14)) - .foregroundColor(theme.secondaryText02) - Button() { + Text(L10n.manageDownloadsDetail(dataModel.sizeOccupied)) + .lineLimit(nil) + .fixedSize(horizontal: true, vertical: false) + .multilineTextAlignment(.leading) + .font(.system(size: 14)) + .foregroundColor(theme.secondaryText02) + Button() { - } label: { - Text(L10n.manageDownloadsAction) - .font(.system(size: 14, weight: .medium)) - .foregroundColor(theme.primaryText02Selected) - } + } label: { + Text(L10n.manageDownloadsAction) + .font(.system(size: 14, weight: .medium)) + .foregroundColor(theme.primaryText02Selected) } - Spacer() } - .padding() - .background(theme.primaryUi01) - .cornerRadius(8) - .overlay( - RoundedRectangle(cornerRadius: 8) - .inset(by: 0.25) - .stroke(theme.secondaryText02, lineWidth: 0.5) - ) - .padding() + Spacer() } - Spacer() + .padding() + .background(theme.primaryUi01) + .cornerRadius(8) + .overlay( + RoundedRectangle(cornerRadius: 8) + .inset(by: 0.25) + .stroke(theme.secondaryText02, lineWidth: 0.5) + ) } } #Preview("Light") { DownloadsManageBannerView(dataModel: .init(initialSize: "100 MB")) - .environmentObject(Theme(previewTheme: .light)) - .padding(16) - .frame(height: 132) + .environmentObject(Theme(previewTheme: .light)) + .padding(16) + .frame(height: 132) } #Preview("Dark") { DownloadsManageBannerView(dataModel: .init(initialSize: "100 MB")) - .environmentObject(Theme(previewTheme: .dark)) - .padding(16) - .frame(height: 132) + .environmentObject(Theme(previewTheme: .dark)) + .padding(16) + .frame(height: 132) } diff --git a/podcasts/DownloadsViewController.swift b/podcasts/DownloadsViewController.swift index c1a48e08b..c91f8400d 100644 --- a/podcasts/DownloadsViewController.swift +++ b/podcasts/DownloadsViewController.swift @@ -113,6 +113,8 @@ class DownloadsViewController: PCViewController { title = L10n.downloads + showManageDownloads() + Analytics.track(.downloadsShown) } @@ -139,13 +141,27 @@ class DownloadsViewController: PCViewController { func showManageDownloads() { guard FeatureFlag.manageDownloadedEpisodes.enabled else { + downloadsTable.tableHeaderView = nil return } - let banner = DownloadsManageBannerView(dataModel: DownloadsManageModel(initialSize: "")).themedUIView - banner.frame.size.height = 116 - downloadsTable.tableHeaderView = banner + + downloadsTable.tableHeaderView = bannerView } + lazy var bannerView: UIView = { + let banner = DownloadsManageBannerView(dataModel: DownloadsManageModel(initialSize: "")).themedUIView + banner.translatesAutoresizingMaskIntoConstraints = false + let wrapperView = UIView(frame: CGRect(x: 116, y: 0, width: 200, height: 132)) + wrapperView.addSubview(banner) + NSLayoutConstraint.activate([ + banner.leadingAnchor.constraint(equalTo: wrapperView.leadingAnchor, constant: 16), + banner.trailingAnchor.constraint(equalTo: wrapperView.trailingAnchor, constant: -16), + banner.topAnchor.constraint(equalTo: wrapperView.topAnchor, constant: 16), + banner.bottomAnchor.constraint(equalTo: wrapperView.bottomAnchor, constant: 0), + ]) + return wrapperView + }() + // MARK: - App Backgrounding override func handleAppWillBecomeActive() {