|
|
@@ -7,7 +7,6 @@
|
|
7
|
7
|
//
|
|
8
|
8
|
|
|
9
|
9
|
import Cocoa
|
|
10
|
|
-import UniformTypeIdentifiers
|
|
11
|
10
|
|
|
12
|
11
|
private enum ProfilePagePalette {
|
|
13
|
12
|
static let brandBlue = NSColor(srgbRed: 37 / 255, green: 87 / 255, blue: 167 / 255, alpha: 1)
|
|
|
@@ -18,7 +17,6 @@ private enum ProfilePagePalette {
|
|
18
|
17
|
static let primaryText = NSColor(srgbRed: 45 / 255, green: 45 / 255, blue: 45 / 255, alpha: 1)
|
|
19
|
18
|
static let secondaryText = NSColor(srgbRed: 118 / 255, green: 118 / 255, blue: 118 / 255, alpha: 1)
|
|
20
|
19
|
static let border = NSColor(srgbRed: 212 / 255, green: 210 / 255, blue: 208 / 255, alpha: 1)
|
|
21
|
|
- static let avatarWell = NSColor(srgbRed: 232 / 255, green: 232 / 255, blue: 232 / 255, alpha: 1)
|
|
22
|
20
|
}
|
|
23
|
21
|
|
|
24
|
22
|
final class MyProfilePageView: NSView {
|
|
|
@@ -36,8 +34,6 @@ final class MyProfilePageView: NSView {
|
|
36
|
34
|
private let jobTitleField = NSTextField()
|
|
37
|
35
|
private let addressField = NSTextField()
|
|
38
|
36
|
private let careerField = NSTextField()
|
|
39
|
|
- private let avatarImageView = NSImageView()
|
|
40
|
|
- private let uploadPhotoButton = NSButton(title: "Upload Photo", target: nil, action: nil)
|
|
41
|
37
|
private let saveButton = ProfilePrimaryButton(title: "Save Profile →", target: nil, action: nil)
|
|
42
|
38
|
|
|
43
|
39
|
private let nameEmailRow = NSStackView()
|
|
|
@@ -151,11 +147,8 @@ final class MyProfilePageView: NSView {
|
|
151
|
147
|
|
|
152
|
148
|
formStack.addArrangedSubview(labeledGroup(title: "Address", field: addressField, placeholder: "123 Main St, City, State, ZIP"))
|
|
153
|
149
|
formStack.addArrangedSubview(careerSummaryBlock())
|
|
154
|
|
- formStack.addArrangedSubview(profileImageBlock())
|
|
155
|
150
|
formStack.addArrangedSubview(saveButtonHost())
|
|
156
|
151
|
|
|
157
|
|
- uploadPhotoButton.target = self
|
|
158
|
|
- uploadPhotoButton.action = #selector(didTapUploadPhoto)
|
|
159
|
152
|
saveButton.target = self
|
|
160
|
153
|
saveButton.action = #selector(didTapSave)
|
|
161
|
154
|
}
|
|
|
@@ -354,74 +347,6 @@ final class MyProfilePageView: NSView {
|
|
354
|
347
|
return stack
|
|
355
|
348
|
}
|
|
356
|
349
|
|
|
357
|
|
- private func profileImageBlock() -> NSView {
|
|
358
|
|
- let title = NSTextField(labelWithString: "Profile Image (Optional)")
|
|
359
|
|
- title.font = .systemFont(ofSize: 12, weight: .medium)
|
|
360
|
|
- title.textColor = ProfilePagePalette.secondaryText
|
|
361
|
|
- title.alignment = .left
|
|
362
|
|
- title.translatesAutoresizingMaskIntoConstraints = false
|
|
363
|
|
-
|
|
364
|
|
- let avatarHost = NSView()
|
|
365
|
|
- avatarHost.translatesAutoresizingMaskIntoConstraints = false
|
|
366
|
|
- avatarHost.wantsLayer = true
|
|
367
|
|
- avatarHost.layer?.backgroundColor = ProfilePagePalette.avatarWell.cgColor
|
|
368
|
|
- avatarHost.layer?.cornerRadius = 36
|
|
369
|
|
- avatarHost.layer?.masksToBounds = true
|
|
370
|
|
-
|
|
371
|
|
- avatarImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
372
|
|
- avatarImageView.imageScaling = .scaleProportionallyUpOrDown
|
|
373
|
|
- avatarImageView.symbolConfiguration = NSImage.SymbolConfiguration(pointSize: 36, weight: .light)
|
|
374
|
|
- avatarImageView.image = NSImage(systemSymbolName: "person.crop.circle.fill", accessibilityDescription: nil)
|
|
375
|
|
- avatarImageView.contentTintColor = ProfilePagePalette.secondaryText
|
|
376
|
|
- avatarHost.addSubview(avatarImageView)
|
|
377
|
|
- NSLayoutConstraint.activate([
|
|
378
|
|
- avatarHost.widthAnchor.constraint(equalToConstant: 72),
|
|
379
|
|
- avatarHost.heightAnchor.constraint(equalToConstant: 72),
|
|
380
|
|
- avatarImageView.centerXAnchor.constraint(equalTo: avatarHost.centerXAnchor),
|
|
381
|
|
- avatarImageView.centerYAnchor.constraint(equalTo: avatarHost.centerYAnchor),
|
|
382
|
|
- avatarImageView.widthAnchor.constraint(equalToConstant: 44),
|
|
383
|
|
- avatarImageView.heightAnchor.constraint(equalToConstant: 44)
|
|
384
|
|
- ])
|
|
385
|
|
-
|
|
386
|
|
- uploadPhotoButton.translatesAutoresizingMaskIntoConstraints = false
|
|
387
|
|
- uploadPhotoButton.bezelStyle = .rounded
|
|
388
|
|
- uploadPhotoButton.controlSize = .large
|
|
389
|
|
- uploadPhotoButton.font = .systemFont(ofSize: 13, weight: .medium)
|
|
390
|
|
- if let image = NSImage(systemSymbolName: "arrow.up.circle", accessibilityDescription: nil) {
|
|
391
|
|
- uploadPhotoButton.image = image
|
|
392
|
|
- uploadPhotoButton.imagePosition = .imageLeading
|
|
393
|
|
- uploadPhotoButton.contentTintColor = ProfilePagePalette.brandBlue
|
|
394
|
|
- }
|
|
395
|
|
-
|
|
396
|
|
- let hint = NSTextField(wrappingLabelWithString: "Recommended: Square image, max 2MB")
|
|
397
|
|
- hint.font = .systemFont(ofSize: 11, weight: .regular)
|
|
398
|
|
- hint.textColor = ProfilePagePalette.secondaryText
|
|
399
|
|
- hint.alignment = .left
|
|
400
|
|
- hint.maximumNumberOfLines = 0
|
|
401
|
|
-
|
|
402
|
|
- let rightColumn = NSStackView(views: [uploadPhotoButton, hint])
|
|
403
|
|
- rightColumn.orientation = .vertical
|
|
404
|
|
- rightColumn.alignment = .leading
|
|
405
|
|
- rightColumn.spacing = 6
|
|
406
|
|
- rightColumn.translatesAutoresizingMaskIntoConstraints = false
|
|
407
|
|
-
|
|
408
|
|
- let row = NSStackView(views: [avatarHost, rightColumn])
|
|
409
|
|
- row.orientation = .horizontal
|
|
410
|
|
- row.alignment = .centerY
|
|
411
|
|
- row.spacing = 16
|
|
412
|
|
- row.translatesAutoresizingMaskIntoConstraints = false
|
|
413
|
|
- row.userInterfaceLayoutDirection = .leftToRight
|
|
414
|
|
-
|
|
415
|
|
- let stack = NSStackView(views: [title, row])
|
|
416
|
|
- stack.orientation = .vertical
|
|
417
|
|
- stack.spacing = 12
|
|
418
|
|
- stack.alignment = .width
|
|
419
|
|
- stack.translatesAutoresizingMaskIntoConstraints = false
|
|
420
|
|
- stack.userInterfaceLayoutDirection = .leftToRight
|
|
421
|
|
- row.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
422
|
|
- return stack
|
|
423
|
|
- }
|
|
424
|
|
-
|
|
425
|
350
|
private func saveButtonHost() -> NSView {
|
|
426
|
351
|
saveButton.translatesAutoresizingMaskIntoConstraints = false
|
|
427
|
352
|
let host = NSView()
|
|
|
@@ -438,22 +363,6 @@ final class MyProfilePageView: NSView {
|
|
438
|
363
|
return host
|
|
439
|
364
|
}
|
|
440
|
365
|
|
|
441
|
|
- @objc private func didTapUploadPhoto() {
|
|
442
|
|
- let panel = NSOpenPanel()
|
|
443
|
|
- panel.allowedContentTypes = [UTType.image]
|
|
444
|
|
- panel.allowsMultipleSelection = false
|
|
445
|
|
- panel.canChooseDirectories = false
|
|
446
|
|
- guard let window else { return }
|
|
447
|
|
- panel.beginSheetModal(for: window) { [weak self] response in
|
|
448
|
|
- guard response == .OK, let url = panel.url else { return }
|
|
449
|
|
- if let image = NSImage(contentsOf: url) {
|
|
450
|
|
- self?.avatarImageView.image = image
|
|
451
|
|
- self?.avatarImageView.contentTintColor = nil
|
|
452
|
|
- self?.avatarImageView.imageScaling = .scaleAxesIndependently
|
|
453
|
|
- }
|
|
454
|
|
- }
|
|
455
|
|
- }
|
|
456
|
|
-
|
|
457
|
366
|
@objc private func didTapSave() {
|
|
458
|
367
|
// UI shell only; wire persistence when profiles are stored.
|
|
459
|
368
|
}
|