Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop Downloads storyboard #2556

Merged
merged 7 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 43 additions & 25 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions DuckDuckGo/Bookmarks/View/BookmarkOutlineCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ final class BookmarkOutlineCellView: NSTableCellView {

init(identifier: NSUserInterfaceItemIdentifier) {
super.init(frame: .zero)
self.identifier = identifier

setupUI()
}

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ struct UserText {
static let downloadsOpenWebsiteItem = NSLocalizedString("downloads.open-website.item", value: "Open Originating Website", comment: "Contextual menu item in downloads manager to open the downloaded file originating website")
static let downloadsRemoveFromListItem = NSLocalizedString("downloads.remove-from-list.item", value: "Remove from List", comment: "Contextual menu item in downloads manager to remove the given downloaded from the list of downloaded files")
static let downloadsStopItem = NSLocalizedString("downloads.stop.item", value: "Stop", comment: "Contextual menu item in downloads manager to stop the download")
static let downloadsRestartItem = NSLocalizedString("downloads.restart.item", value: "Stop", comment: "Contextual menu item in downloads manager to restart the download")
static let downloadsRestartItem = restartDownloadToolTip
static let downloadsClearAllItem = NSLocalizedString("downloads.clear-all.item", value: "Clear All", comment: "Contextual menu item in downloads manager to clear all downloaded items from the list")
static let downloadsNoRecentDownload = NSLocalizedString("downloads.no-recent-downloads", value: "No recent downloads", comment: "Label in the downloads manager that shows that there are no recently downloaded items")
static let downloadsOpenDownloadsFolder = NSLocalizedString("downloads.open-downloads-folder", value: "Open Downloads Folder", comment: "Button in the downloads manager that allows the user to open the downloads folder")
Expand Down
77 changes: 77 additions & 0 deletions DuckDuckGo/Common/View/AppKit/PreviewViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//
// PreviewViewController.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import AppKit

@resultBuilder
struct NSViewBuilder {
static func buildBlock(_ component: NSView) -> NSView {
return component
}
}

#if DEBUG
/// Used to preview an NSView using Xcode #Preview macro
/// Usage:
/// ```
/// @available(macOS 14.0, *)
/// #Preview {
/// PreviewViewController(showWindowTitle: false /*hide preview window title*/, adjustWindowFrame: true /*set the window size to the view size*/) {
/// MyNSView()
/// }
/// }
/// ```
@available(macOS 14.0, *)
final class PreviewViewController: NSViewController {
let showWindowTitle: Bool
let adjustWindowFrame: Bool

init(showWindowTitle: Bool = true, adjustWindowFrame: Bool = false, @NSViewBuilder builder: () -> NSView) {
self.showWindowTitle = showWindowTitle
self.adjustWindowFrame = adjustWindowFrame
super.init(nibName: nil, bundle: nil)
self.view = builder()
}

required init?(coder: NSCoder) {
fatalError("\(Self.self): Bad initializer")
}

override func viewDidAppear() {
guard let window = view.window else { return }
if !showWindowTitle {
window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
window.styleMask = []
}
if adjustWindowFrame {
window.setFrame(NSRect(origin: .zero, size: view.bounds.size), display: true)
}
}

}
#else
final class PreviewViewController: NSViewController {
init(showWindowTitle: Bool = true, adjustWindowFrame: Bool = false, @NSViewBuilder builder: () -> NSView) {
fatalError("only for DEBUG")
}
required init?(coder: NSCoder) {
fatalError("only for DEBUG")
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
//

import Foundation
@testable import DuckDuckGo_Privacy_Browser

#if DEBUG
final class DownloadListStoreMock: DownloadListStoring {

var fetchBlock: ((@escaping @MainActor (Result<[DownloadListItem], Error>) -> Void) -> Void)?
func fetch(completionHandler: @escaping @MainActor (Result<[DuckDuckGo_Privacy_Browser.DownloadListItem], any Error>) -> Void) {
func fetch(completionHandler: @escaping @MainActor (Result<[DownloadListItem], any Error>) -> Void) {
fetchBlock?(completionHandler)
}

Expand All @@ -42,3 +42,4 @@ final class DownloadListStoreMock: DownloadListStoring {
}

}
#endif
Loading