Skip to content

Commit b4150f8

Browse files
authored
Merge pull request #139 from 42Box/cluster_develop
merge: 3 Week Release
2 parents a085f5e + cd0b8dc commit b4150f8

92 files changed

Lines changed: 3107 additions & 606 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Box42.xcodeproj/project.pbxproj

Lines changed: 146 additions & 6 deletions
Large diffs are not rendered by default.

Box42.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 0 additions & 16 deletions
This file was deleted.
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// BookmarkModel.swift
3+
// Box42
4+
//
5+
// Created by Chan on 2023/09/04.
6+
//
7+
8+
struct URLList: Codable {
9+
let urlList: [URLItem]
10+
}
11+
12+
struct URLItem: Codable {
13+
let name: String
14+
let url: String
15+
}
16+
17+
extension URLItem: Equatable {
18+
static func ==(lhs: URLItem, rhs: URLItem) -> Bool {
19+
return lhs.name == rhs.name && lhs.url == rhs.url
20+
}
21+
}
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
////
2+
//// BookmarkTableView.swift
3+
//// Box42
4+
////
5+
//// Created by Chanhee Kim on 9/4/23.
6+
////
7+
//
8+
//import AppKit
9+
//import SnapKit
10+
//import Combine
11+
//
12+
//class BookmarkTableView: NSTableView {
13+
// var onButtonClicked: ((DraggableButton) -> Void)?
14+
//
15+
// var buttonTitleArray: [String] {
16+
// return BookmarkViewModel.shared.bookMarkList.map { $0.name }
17+
// }
18+
//
19+
// var urlArray: [String] {
20+
// return BookmarkViewModel.shared.bookMarkList.map { $0.url }
21+
// }
22+
//
23+
// var viewModel: BookmarkViewModel? {
24+
// didSet {
25+
// print("ViewModel has been set.")
26+
// setupBindings()
27+
// }
28+
// }
29+
//
30+
// var cancellables: Set<AnyCancellable> = []
31+
//
32+
// private func setupBindings() {
33+
// print("Setting up bindings...") // 디버깅 로그
34+
// viewModel?.$bookMarkList.sink(receiveValue: { [weak self] newScripts in
35+
// print("Received new scripts: \(newScripts)") // 디버깅 로그
36+
// DispatchQueue.main.async {
37+
// self?.reloadData()
38+
// }
39+
// }).store(in: &cancellables)
40+
// }
41+
//
42+
// func setup() {
43+
// self.delegate = self
44+
// self.dataSource = self
45+
// self.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
46+
//
47+
// self.wantsLayer = true
48+
// self.backgroundColor = NSColor(hex: "#E7E7E7")
49+
// self.focusRingType = .none
50+
// self.headerView = nil
51+
// self.autoresizingMask = [.width, .height]
52+
// self.selectionHighlightStyle = .none
53+
// self.intercellSpacing = NSSize(width: 0, height: 0)
54+
// self.setDraggingSourceOperationMask(.move, forLocal: true)
55+
//
56+
// let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("Bookmark"))
57+
// column.title = ""
58+
// // column.width = 100
59+
// column.resizingMask = .autoresizingMask
60+
//
61+
// self.addTableColumn(column)
62+
// }
63+
//}
64+
//
65+
//extension BookmarkTableView: NSTableViewDelegate, NSTableViewDataSource {
66+
//
67+
// func tableView(_ tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation {
68+
// if dropOperation == .above {
69+
// return .move
70+
// } else {
71+
// return []
72+
// }
73+
// }
74+
//
75+
// func tableView(_ aTableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool {
76+
// guard let str = info.draggingPasteboard.string(forType: .string), let from = Int(str) else {
77+
// return false
78+
// }
79+
//
80+
// let to = (from < row) ? row - 1 : row
81+
// let item = BookmarkViewModel.shared.bookMarkList[from]
82+
// BookmarkViewModel.shared.bookMarkList.remove(at: from)
83+
// BookmarkViewModel.shared.bookMarkList.insert(item, at: to)
84+
// self.reloadData()
85+
//
86+
// for (_, subview) in self.subviews.enumerated() {
87+
// guard let cellView = subview as? CustomTableCellView else {
88+
// continue
89+
// }
90+
//
91+
// cellView.button.title = buttonTitleArray[cellView.rowIndex]
92+
// }
93+
//
94+
// return true
95+
// }
96+
//
97+
// func numberOfRows(in tableView: NSTableView) -> Int {
98+
// return BookmarkViewModel.shared.bookMarkList.count
99+
// }
100+
//
101+
// func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
102+
// let cellView = ButtonTableCellView()
103+
// cellView.rowIndex = row
104+
//
105+
// let button = DraggableButton(frame: NSRect(x: 0, y: 0, width: 300, height: 44))
106+
// button.tag = row
107+
// button.bezelStyle = .inline
108+
// button.isBordered = false
109+
// button.title = ""
110+
// button.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
111+
// button.target = self
112+
// button.action = #selector(buttonClicked(_:))
113+
// button.delegate = self
114+
//
115+
// let label = NSTextField(frame: NSRect(x: 26 + 21 + 8, y: 25 / 2, width: button.bounds.width, height: button.bounds.height))
116+
//
117+
// label.stringValue = buttonTitleArray[row]
118+
// label.backgroundColor = .clear
119+
// label.isBordered = false
120+
// label.isEditable = false
121+
//
122+
// let attributes : [NSAttributedString.Key : Any] =
123+
// [
124+
// NSAttributedString.Key.font : NSFont.systemFont(ofSize:18.0, weight: .light),
125+
// NSAttributedString.Key.foregroundColor : NSColor.black,
126+
// ]
127+
// let attributedStringTitle = NSAttributedString(string: label.stringValue , attributes:
128+
// attributes)
129+
// label.attributedStringValue=attributedStringTitle
130+
// button.addSubview(label)
131+
//
132+
//
133+
// // let image = NSImage(named: NSImage.Name("bookmark-default"))
134+
// // image?.size = NSSize(width: 21, height: 21)
135+
// // button.image = image
136+
// // button.imagePosition = .imageLeading
137+
// // button.image?.alignmentRect = NSRect(x: 0, y: 0, width: 21, height: 21)
138+
//
139+
// let imageView = NSImageView(frame: NSRect(x: 26, y: 25 / 2, width: 21, height: 21))
140+
// imageView.image = NSImage(named: NSImage.Name("bookmark-default"))
141+
// imageView.imageScaling = .scaleProportionallyUpOrDown
142+
// imageView.imageAlignment = .alignCenter
143+
// button.addSubview(imageView)
144+
//
145+
//
146+
//
147+
// cellView.addSubview(button)
148+
//
149+
// button.snp.makeConstraints { make in
150+
// make.top.equalToSuperview().offset(2)
151+
// make.leading.equalToSuperview()
152+
// make.trailing.equalToSuperview()
153+
// // make.width.equalTo(268)
154+
// make.width.lessThanOrEqualTo(268)
155+
// make.height.equalTo(44)
156+
// }
157+
//
158+
// tableView.rowHeight = 50
159+
//
160+
// if row == selectedRow {
161+
// button.wantsLayer = true
162+
// button.layer?.cornerRadius = 12
163+
// button.layer?.backgroundColor = NSColor.white.cgColor
164+
// } else {
165+
// button.wantsLayer = true
166+
// button.layer?.cornerRadius = 12
167+
// button.layer?.backgroundColor = NSColor.clear.cgColor
168+
// }
169+
//
170+
// return cellView
171+
// }
172+
//
173+
// func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? {
174+
// let pasteboardItem = NSPasteboardItem()
175+
// pasteboardItem.setString(String(row), forType: .string)
176+
// return pasteboardItem
177+
// }
178+
//
179+
// func sendUpdatedDataToServer() {
180+
// let urlList = zip(buttonTitleArray, urlArray).map { ["name": $0.0, "url": $0.1] }
181+
// let jsonData = try? JSONSerialization.data(withJSONObject: ["urlList": urlList])
182+
//
183+
// var request = URLRequest(url: URL(string:"https://api.42box.kr/user-service/users/me/url-list")!)
184+
// request.httpMethod = "POST"
185+
// request.httpBody = jsonData
186+
//
187+
// URLSession.shared.dataTask(with:request) { (data, response, error) in
188+
// if error != nil{
189+
// print(error!.localizedDescription)
190+
// }
191+
// else{
192+
// print("Data posted successfully")
193+
// }
194+
// }.resume()
195+
// }
196+
//}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//
2+
// BookmarkCreateButton.swift
3+
// Box42
4+
//
5+
// Created by Chanhee Kim on 9/5/23.
6+
//
7+
8+
import AppKit
9+
10+
class BookmarkCreateButton: NSButton {
11+
12+
init() {
13+
super.init(frame: NSRect(x: 0, y: 0, width: 70, height: 40))
14+
15+
self.title = "북마크 추가"
16+
self.isBordered = false
17+
self.wantsLayer = true
18+
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
19+
self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite
20+
21+
let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil)
22+
self.addTrackingArea(trackingArea)
23+
}
24+
25+
required init?(coder: NSCoder) {
26+
fatalError("init(coder:) has not been implemented")
27+
}
28+
29+
override func mouseEntered(with event: NSEvent) {
30+
super.mouseEntered(with: event)
31+
32+
let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
33+
bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite
34+
bgColorAnimation.toValue = WindowButtonUI.color.maximize
35+
bgColorAnimation.duration = WindowButtonUI.animation.duration
36+
37+
let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
38+
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius
39+
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2
40+
cornerAnimation.duration = WindowButtonUI.animation.duration
41+
42+
self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
43+
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")
44+
45+
self.layer?.backgroundColor = WindowButtonUI.color.maximize
46+
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2
47+
}
48+
49+
override func mouseExited(with event: NSEvent) {
50+
super.mouseExited(with: event)
51+
52+
let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
53+
bgColorAnimation.fromValue = WindowButtonUI.color.maximize
54+
bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite
55+
bgColorAnimation.duration = WindowButtonUI.animation.duration
56+
57+
let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
58+
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2
59+
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius
60+
cornerAnimation.duration = WindowButtonUI.animation.duration
61+
62+
self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
63+
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")
64+
65+
self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite
66+
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
67+
}
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//
2+
// BookmarkDeleteButton.swift
3+
// Box42
4+
//
5+
// Created by Chanhee Kim on 9/5/23.
6+
//
7+
8+
import AppKit
9+
10+
class BookmarkDeleteButton: NSButton {
11+
12+
init() {
13+
super.init(frame: NSRect(x: 0, y: 0, width: 53, height: 40))
14+
15+
self.title = "삭제"
16+
self.isBordered = false
17+
self.wantsLayer = true
18+
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
19+
self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite
20+
21+
let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil)
22+
self.addTrackingArea(trackingArea)
23+
}
24+
25+
required init?(coder: NSCoder) {
26+
fatalError("init(coder:) has not been implemented")
27+
}
28+
29+
override func mouseEntered(with event: NSEvent) {
30+
super.mouseEntered(with: event)
31+
32+
let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
33+
bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite
34+
bgColorAnimation.toValue = WindowButtonUI.color.close
35+
bgColorAnimation.duration = WindowButtonUI.animation.duration
36+
37+
let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
38+
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius
39+
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2
40+
cornerAnimation.duration = WindowButtonUI.animation.duration
41+
42+
self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
43+
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")
44+
45+
self.layer?.backgroundColor = WindowButtonUI.color.close
46+
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2
47+
}
48+
49+
override func mouseExited(with event: NSEvent) {
50+
super.mouseExited(with: event)
51+
52+
let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
53+
bgColorAnimation.fromValue = WindowButtonUI.color.close
54+
bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite
55+
bgColorAnimation.duration = WindowButtonUI.animation.duration
56+
57+
let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
58+
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2
59+
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius
60+
cornerAnimation.duration = WindowButtonUI.animation.duration
61+
62+
self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
63+
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")
64+
65+
self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite
66+
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
67+
}
68+
}

0 commit comments

Comments
 (0)