-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for new application detail screen
- Loading branch information
Showing
25 changed files
with
419 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
source 'https://github.com/CocoaPods/Specs.git' | ||
platform :macos, '10.14' | ||
|
||
# Frameworks | ||
pod 'Family' | ||
|
||
target 'Syncalicious' | ||
target 'Tests' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
PODS: | ||
- Family (0.14.3) | ||
|
||
DEPENDENCIES: | ||
- Family | ||
|
||
SPEC REPOS: | ||
https://github.com/cocoapods/specs.git: | ||
- Family | ||
|
||
SPEC CHECKSUMS: | ||
Family: e895808117f577305a6b5cabd4fc7463ad262e1f | ||
|
||
PODFILE CHECKSUM: 577eb548a5a12c3ca5c8d9a8a4ae97a7f630192b | ||
|
||
COCOAPODS: 1.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
Sources/Features/ApplicationDetail/ApplicationActionsViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Cocoa | ||
|
||
class ApplicationActionsViewController: ViewController { | ||
private var layoutConstraints = [NSLayoutConstraint]() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.subviews.forEach { $0.removeFromSuperview() } | ||
|
||
NSLayoutConstraint.deactivate(layoutConstraints) | ||
layoutConstraints = [] | ||
NSLayoutConstraint.activate(layoutConstraints) | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
Sources/Features/ApplicationDetail/ApplicationContainerViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import Cocoa | ||
import Family | ||
|
||
class ApplicationContainerViewController: FamilyViewController, | ||
SplitViewContainedController, NSCollectionViewDelegate { | ||
weak var listViewController: ApplicationItemViewController? | ||
|
||
lazy var titleLabel = SmallBoldLabel() | ||
lazy var titlebarView = NSView() | ||
|
||
private var layoutConstraints = [NSLayoutConstraint]() | ||
|
||
let applicationInfoViewController: ApplicationInfoViewController | ||
|
||
init(detailViewController: ApplicationInfoViewController) { | ||
self.applicationInfoViewController = detailViewController | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - View lifecycle | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
addChild(applicationInfoViewController, | ||
customInsets: .init(top: 15, left: 15, bottom: 15, right: 15), | ||
height: 120) | ||
addChild(ApplicationActionsViewController(), | ||
customInsets: .init(top: 15, left: 105, bottom: 15, right: 105), | ||
height: 20) | ||
} | ||
|
||
// MARK: - Private methods | ||
|
||
private func render(_ application: Application) { | ||
applicationInfoViewController.render(application) | ||
NSLayoutConstraint.deactivate(layoutConstraints) | ||
layoutConstraints = [] | ||
|
||
titlebarView.subviews.forEach { $0.removeFromSuperview() } | ||
titleLabel.stringValue = application.propertyList.bundleName | ||
titleLabel.alignment = .center | ||
titleLabel.translatesAutoresizingMaskIntoConstraints = false | ||
titlebarView.wantsLayer = true | ||
titlebarView.addSubview(titleLabel) | ||
|
||
let button = NSButton(title: "Apply changes", target: nil, action: nil) | ||
button.translatesAutoresizingMaskIntoConstraints = false | ||
titlebarView.addSubview(button) | ||
|
||
layoutConstraints.append(contentsOf: [ | ||
titleLabel.leadingAnchor.constraint(equalTo: titlebarView.leadingAnchor, constant: 10), | ||
titleLabel.trailingAnchor.constraint(equalTo: titlebarView.trailingAnchor, constant: -10), | ||
titleLabel.centerYAnchor.constraint(equalTo: titlebarView.centerYAnchor), | ||
button.centerYAnchor.constraint(equalTo: titlebarView.centerYAnchor), | ||
button.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor) | ||
]) | ||
|
||
NSLayoutConstraint.activate(layoutConstraints) | ||
} | ||
|
||
// MARK: - NSCollectionViewDelegate | ||
|
||
func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) { | ||
guard let indexPath = indexPaths.first else { return } | ||
guard let listViewController = listViewController else { return } | ||
guard let application = listViewController.model(at: indexPath).data["model"] as? Application else { return } | ||
|
||
render(application) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
Sources/Features/ApplicationDetail/ApplicationInfoViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Cocoa | ||
|
||
class ApplicationInfoViewController: ViewController { | ||
private var layoutConstraints = [NSLayoutConstraint]() | ||
|
||
lazy var stackView = NSStackView() | ||
|
||
func render(_ application: Application) { | ||
view.subviews.forEach { $0.removeFromSuperview() } | ||
stackView.subviews.forEach { $0.removeFromSuperview() } | ||
NSLayoutConstraint.deactivate(layoutConstraints) | ||
layoutConstraints = [] | ||
|
||
let iconView = NSImageView() | ||
let image = NSWorkspace.shared.icon(forFile: application.url.path) | ||
iconView.image = image | ||
|
||
let nameLabel = Label(text: application.propertyList.bundleName) | ||
nameLabel.font = NSFont.boldSystemFont(ofSize: 32) | ||
|
||
let horizontalStackView = NSStackView() | ||
horizontalStackView.orientation = .horizontal | ||
horizontalStackView.addArrangedSubview(iconView) | ||
horizontalStackView.addArrangedSubview(nameLabel) | ||
|
||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
stackView.orientation = .vertical | ||
stackView.alignment = .leading | ||
stackView.distribution = .fillProportionally | ||
stackView.addArrangedSubview(horizontalStackView) | ||
|
||
stackView.addArrangedSubview(createVerticalStackView(with: [ | ||
BoldLabel(text: "Version:"), | ||
Label(text: application.propertyList.versionString), | ||
BoldLabel(text: "Bundle identifier:"), | ||
Label(text: application.propertyList.bundleIdentifier)])) | ||
|
||
stackView.addArrangedSubview(createVerticalStackView(with: [BoldLabel(text: "Location:"), | ||
Label(text: application.url.path)])) | ||
view.addSubview(stackView) | ||
layoutConstraints = [ | ||
stackView.topAnchor.constraint(equalTo: view.topAnchor), | ||
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor), | ||
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor), | ||
stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor) | ||
] | ||
NSLayoutConstraint.activate(layoutConstraints) | ||
} | ||
|
||
func createVerticalStackView(with views: [NSView]) -> NSStackView { | ||
let stackView = NSStackView() | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
stackView.orientation = .horizontal | ||
stackView.alignment = .firstBaseline | ||
stackView.spacing = 5 | ||
views.forEach { stackView.addArrangedSubview($0) } | ||
return stackView | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import Foundation | ||
|
||
struct Application { | ||
let path: URL | ||
struct Application: Hashable { | ||
let url: URL | ||
let propertyList: InfoPropertyList | ||
let preferences: Preferences | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import Foundation | ||
|
||
struct Preferences { | ||
struct Preferences: Hashable { | ||
let path: URL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Cocoa | ||
|
||
protocol SplitViewContainedController { | ||
var titlebarView: NSView { get } | ||
} |
Oops, something went wrong.