Skip to content

Commit

Permalink
Show banner in the Downloads view if FF enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioEstevao committed Nov 15, 2024
1 parent 36c9b4e commit 9ffa791
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 40 deletions.
69 changes: 32 additions & 37 deletions podcasts/DownloadsManageBannerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
22 changes: 19 additions & 3 deletions podcasts/DownloadsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class DownloadsViewController: PCViewController {

title = L10n.downloads

showManageDownloads()

Analytics.track(.downloadsShown)
}

Expand All @@ -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() {
Expand Down

0 comments on commit 9ffa791

Please sign in to comment.