Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Aug 24, 2021
1 parent 803a5f8 commit 6bc0e2a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,22 +265,36 @@ extension BrowserViewController: PlaylistHelperDelegate {
self.openInPlaylistActivityItem = (enabled: true, item: item)
self.addToPlayListActivityItem = nil

PlaylistItem.addItem(item, cachedData: nil) {
PlaylistItem.addItem(item, cachedData: nil) { [weak self] in
guard let self = self else { return }
PlaylistManager.shared.autoDownload(item: item)

self.updatePlaylistURLBar(tab: self.tabManager.selectedTab,
state: .existingItem,
item: item)

completion?(true)
}
}))

alert.addAction(UIAlertAction(title: Strings.CancelString, style: .cancel, handler: { _ in
completion?(false)
}))
self.present(alert, animated: true, completion: nil)

// Sometimes the MENU controller is being displayed and cannot present the alert
// So we need to ask it to present the alert
(presentedViewController ?? self).present(alert, animated: true, completion: nil)
} else {
openInPlaylistActivityItem = (enabled: true, item: item)
addToPlayListActivityItem = nil

PlaylistItem.addItem(item, cachedData: nil) {
PlaylistItem.addItem(item, cachedData: nil) { [weak self] in
guard let self = self else { return }
PlaylistManager.shared.autoDownload(item: item)

self.updatePlaylistURLBar(tab: self.tabManager.selectedTab,
state: .existingItem,
item: item)
completion?(true)
}
}
Expand Down
8 changes: 5 additions & 3 deletions Client/Frontend/Browser/Playlist/Cache/PlaylistManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ class PlaylistManager: NSObject {

do {
let url = try URL(resolvingBookmarkData: cachedData, bookmarkDataIsStale: &isStale)
try FileManager.default.removeItem(at: url)
PlaylistItem.updateCache(pageSrc: item.pageSrc, cachedData: nil)
delegate?.onDownloadStateChanged(id: item.pageSrc, state: .invalid, displayName: nil, error: nil)
if FileManager.default.fileExists(atPath: url.path) {
try FileManager.default.removeItem(atPath: url.path)
PlaylistItem.updateCache(pageSrc: item.pageSrc, cachedData: nil)
delegate?.onDownloadStateChanged(id: item.pageSrc, state: .invalid, displayName: nil, error: nil)
}
return true
} catch {
log.error("An error occured deleting Playlist Cached Item \(item.name): \(error)")
Expand Down
29 changes: 12 additions & 17 deletions Client/Frontend/Browser/Playlist/PlaylistPopoverView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,20 @@ struct PlaylistPopoverView: View {
}) {
if #available(iOS 14.0, *) {
Text(Strings.PlayList.addToPlayListAlertTitle)
.frame(maxWidth: .infinity)
.font(.title3.weight(.medium))
.foregroundColor(Color(UIColor.primaryButtonTint))
.padding()
} else {
Text(Strings.PlayList.addToPlayListAlertTitle)
.frame(maxWidth: .infinity)
.font(.body.weight(.medium))
.foregroundColor(Color(UIColor.primaryButtonTint))
.padding()
}
}
.frame(maxWidth: .infinity)
.background(
Capsule()
.stroke(lineWidth: 1.0)
.foregroundColor(Color(UIColor.secondaryButtonTint))
)
.buttonStyle(BraveOutlineButtonStyle(size: .normal))
.foregroundColor(Color(UIColor.secondaryButtonTint))
}.padding(EdgeInsets(top: 22.0,
leading: 30.0,
bottom: 22.0,
Expand All @@ -93,21 +91,20 @@ struct PlaylistPopoverView: View {
}) {
if #available(iOS 14.0, *) {
Text(Strings.PlayList.playlistPopoverOpenInBravePlaylist)
.frame(maxWidth: .infinity)
.font(.title3.weight(.medium))
.foregroundColor(.white)
.padding()
} else {
Text(Strings.PlayList.playlistPopoverOpenInBravePlaylist)
.frame(maxWidth: .infinity)
.font(.body.weight(.medium))
.foregroundColor(.white)
.padding()
}
}
.frame(maxWidth: .infinity)
.background(
Capsule()
.foregroundColor(Color(UIColor.braveBlurple))
)
.buttonStyle(BraveFilledButtonStyle(size: .small))
.foregroundColor(Color(UIColor.braveBlurple))

Spacer(minLength: 20.0)

Expand All @@ -116,22 +113,20 @@ struct PlaylistPopoverView: View {
}) {
if #available(iOS 14.0, *) {
Text(Strings.PlayList.playlistPopoverRemoveFromBravePlaylist)
.frame(maxWidth: .infinity)
.font(.title3.weight(.medium))
.foregroundColor(Color(UIColor.primaryButtonTint))
.padding()
} else {
Text(Strings.PlayList.playlistPopoverRemoveFromBravePlaylist)
.frame(maxWidth: .infinity)
.font(.body.weight(.medium))
.foregroundColor(Color(UIColor.primaryButtonTint))
.padding()
}
}
.frame(maxWidth: .infinity)
.background(
Capsule()
.stroke(lineWidth: 1.0)
.foregroundColor(Color(UIColor.secondaryButtonTint))
)
.buttonStyle(BraveOutlineButtonStyle(size: .small))
.foregroundColor(Color(UIColor.secondaryButtonTint))
}.padding(EdgeInsets(top: 22.0,
leading: 30.0,
bottom: 22.0,
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Browser/Toolbars/UrlBar/TopToolbarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ class TopToolbarView: UIView, ToolbarProtocol {
private let mainStackView = UIStackView().then {
$0.alignment = .center
$0.spacing = 8
$0.isLayoutMarginsRelativeArrangement = true
$0.layoutMargins = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 10.0)
$0.translatesAutoresizingMaskIntoConstraints = false
}

Expand Down

0 comments on commit 6bc0e2a

Please sign in to comment.