|
|
@@ -7,7 +7,6 @@
|
|
|
//
|
|
|
|
|
|
import Cocoa
|
|
|
-import UniformTypeIdentifiers
|
|
|
|
|
|
private enum ProfilePagePalette {
|
|
|
static let brandBlue = NSColor(srgbRed: 37 / 255, green: 87 / 255, blue: 167 / 255, alpha: 1)
|
|
|
@@ -18,7 +17,6 @@ private enum ProfilePagePalette {
|
|
|
static let primaryText = NSColor(srgbRed: 45 / 255, green: 45 / 255, blue: 45 / 255, alpha: 1)
|
|
|
static let secondaryText = NSColor(srgbRed: 118 / 255, green: 118 / 255, blue: 118 / 255, alpha: 1)
|
|
|
static let border = NSColor(srgbRed: 212 / 255, green: 210 / 255, blue: 208 / 255, alpha: 1)
|
|
|
- static let avatarWell = NSColor(srgbRed: 232 / 255, green: 232 / 255, blue: 232 / 255, alpha: 1)
|
|
|
}
|
|
|
|
|
|
final class MyProfilePageView: NSView {
|
|
|
@@ -36,8 +34,6 @@ final class MyProfilePageView: NSView {
|
|
|
private let jobTitleField = NSTextField()
|
|
|
private let addressField = NSTextField()
|
|
|
private let careerField = NSTextField()
|
|
|
- private let avatarImageView = NSImageView()
|
|
|
- private let uploadPhotoButton = NSButton(title: "Upload Photo", target: nil, action: nil)
|
|
|
private let saveButton = ProfilePrimaryButton(title: "Save Profile →", target: nil, action: nil)
|
|
|
|
|
|
private let nameEmailRow = NSStackView()
|
|
|
@@ -151,11 +147,8 @@ final class MyProfilePageView: NSView {
|
|
|
|
|
|
formStack.addArrangedSubview(labeledGroup(title: "Address", field: addressField, placeholder: "123 Main St, City, State, ZIP"))
|
|
|
formStack.addArrangedSubview(careerSummaryBlock())
|
|
|
- formStack.addArrangedSubview(profileImageBlock())
|
|
|
formStack.addArrangedSubview(saveButtonHost())
|
|
|
|
|
|
- uploadPhotoButton.target = self
|
|
|
- uploadPhotoButton.action = #selector(didTapUploadPhoto)
|
|
|
saveButton.target = self
|
|
|
saveButton.action = #selector(didTapSave)
|
|
|
}
|
|
|
@@ -354,74 +347,6 @@ final class MyProfilePageView: NSView {
|
|
|
return stack
|
|
|
}
|
|
|
|
|
|
- private func profileImageBlock() -> NSView {
|
|
|
- let title = NSTextField(labelWithString: "Profile Image (Optional)")
|
|
|
- title.font = .systemFont(ofSize: 12, weight: .medium)
|
|
|
- title.textColor = ProfilePagePalette.secondaryText
|
|
|
- title.alignment = .left
|
|
|
- title.translatesAutoresizingMaskIntoConstraints = false
|
|
|
-
|
|
|
- let avatarHost = NSView()
|
|
|
- avatarHost.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- avatarHost.wantsLayer = true
|
|
|
- avatarHost.layer?.backgroundColor = ProfilePagePalette.avatarWell.cgColor
|
|
|
- avatarHost.layer?.cornerRadius = 36
|
|
|
- avatarHost.layer?.masksToBounds = true
|
|
|
-
|
|
|
- avatarImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- avatarImageView.imageScaling = .scaleProportionallyUpOrDown
|
|
|
- avatarImageView.symbolConfiguration = NSImage.SymbolConfiguration(pointSize: 36, weight: .light)
|
|
|
- avatarImageView.image = NSImage(systemSymbolName: "person.crop.circle.fill", accessibilityDescription: nil)
|
|
|
- avatarImageView.contentTintColor = ProfilePagePalette.secondaryText
|
|
|
- avatarHost.addSubview(avatarImageView)
|
|
|
- NSLayoutConstraint.activate([
|
|
|
- avatarHost.widthAnchor.constraint(equalToConstant: 72),
|
|
|
- avatarHost.heightAnchor.constraint(equalToConstant: 72),
|
|
|
- avatarImageView.centerXAnchor.constraint(equalTo: avatarHost.centerXAnchor),
|
|
|
- avatarImageView.centerYAnchor.constraint(equalTo: avatarHost.centerYAnchor),
|
|
|
- avatarImageView.widthAnchor.constraint(equalToConstant: 44),
|
|
|
- avatarImageView.heightAnchor.constraint(equalToConstant: 44)
|
|
|
- ])
|
|
|
-
|
|
|
- uploadPhotoButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- uploadPhotoButton.bezelStyle = .rounded
|
|
|
- uploadPhotoButton.controlSize = .large
|
|
|
- uploadPhotoButton.font = .systemFont(ofSize: 13, weight: .medium)
|
|
|
- if let image = NSImage(systemSymbolName: "arrow.up.circle", accessibilityDescription: nil) {
|
|
|
- uploadPhotoButton.image = image
|
|
|
- uploadPhotoButton.imagePosition = .imageLeading
|
|
|
- uploadPhotoButton.contentTintColor = ProfilePagePalette.brandBlue
|
|
|
- }
|
|
|
-
|
|
|
- let hint = NSTextField(wrappingLabelWithString: "Recommended: Square image, max 2MB")
|
|
|
- hint.font = .systemFont(ofSize: 11, weight: .regular)
|
|
|
- hint.textColor = ProfilePagePalette.secondaryText
|
|
|
- hint.alignment = .left
|
|
|
- hint.maximumNumberOfLines = 0
|
|
|
-
|
|
|
- let rightColumn = NSStackView(views: [uploadPhotoButton, hint])
|
|
|
- rightColumn.orientation = .vertical
|
|
|
- rightColumn.alignment = .leading
|
|
|
- rightColumn.spacing = 6
|
|
|
- rightColumn.translatesAutoresizingMaskIntoConstraints = false
|
|
|
-
|
|
|
- let row = NSStackView(views: [avatarHost, rightColumn])
|
|
|
- row.orientation = .horizontal
|
|
|
- row.alignment = .centerY
|
|
|
- row.spacing = 16
|
|
|
- row.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- row.userInterfaceLayoutDirection = .leftToRight
|
|
|
-
|
|
|
- let stack = NSStackView(views: [title, row])
|
|
|
- stack.orientation = .vertical
|
|
|
- stack.spacing = 12
|
|
|
- stack.alignment = .width
|
|
|
- stack.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- stack.userInterfaceLayoutDirection = .leftToRight
|
|
|
- row.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
|
- return stack
|
|
|
- }
|
|
|
-
|
|
|
private func saveButtonHost() -> NSView {
|
|
|
saveButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
let host = NSView()
|
|
|
@@ -438,22 +363,6 @@ final class MyProfilePageView: NSView {
|
|
|
return host
|
|
|
}
|
|
|
|
|
|
- @objc private func didTapUploadPhoto() {
|
|
|
- let panel = NSOpenPanel()
|
|
|
- panel.allowedContentTypes = [UTType.image]
|
|
|
- panel.allowsMultipleSelection = false
|
|
|
- panel.canChooseDirectories = false
|
|
|
- guard let window else { return }
|
|
|
- panel.beginSheetModal(for: window) { [weak self] response in
|
|
|
- guard response == .OK, let url = panel.url else { return }
|
|
|
- if let image = NSImage(contentsOf: url) {
|
|
|
- self?.avatarImageView.image = image
|
|
|
- self?.avatarImageView.contentTintColor = nil
|
|
|
- self?.avatarImageView.imageScaling = .scaleAxesIndependently
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@objc private func didTapSave() {
|
|
|
// UI shell only; wire persistence when profiles are stored.
|
|
|
}
|