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

merge: 3 Week Release #139

Merged
merged 20 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d483cf3
test: 퀵슬롯 디버깅 메세지
chanhihi Sep 2, 2023
3f83da8
fix: description이 안들어오는 경우를 상정합니다.
chanhihi Sep 2, 2023
8e27b13
refactor: 버튼이 .sh의 전달타입만 sh로 실행합니다.
chanhihi Sep 2, 2023
31fa325
fix:be able to go the new tab in web view and open NSOpenPanel from t…
Sep 2, 2023
7c4b49c
feat: collection view item 설정
chanhihi Sep 2, 2023
73c8804
refactor: script uuid로 구분
chanhihi Sep 2, 2023
affd4f9
feat: quick slot 유저 동기화를 진행합니다.
chanhihi Sep 2, 2023
75f6c64
feat: quick slot 키 단축키를 지정합니다.
chanhihi Sep 2, 2023
9aaca5b
Merge pull request #125 from 42Box/124-quickslot을-개선합니다
chanhihi Sep 2, 2023
bdc630a
refactor: QuickSlot을 개선합니다.
chanhihi Sep 4, 2023
efbfece
fix: configuration을 뺏어가던 webview 하나로 통일
chanhihi Sep 4, 2023
f29a519
refactor: script uuid로 인터페이스를 리팩토링합니다.
chanhihi Sep 4, 2023
7ddd569
Merge pull request #127 from 42Box/126-quick-slot-로직을-개선합니다
chanhihi Sep 4, 2023
371274a
refactor: refactoring the main view.
Sep 4, 2023
cc85bd7
fix: issue xcode issue
Sep 4, 2023
5aea871
Merge pull request #129 from 42Box/128-refactoring-the-main-view
chanhihi Sep 4, 2023
4ca843d
feat: design quickslot and editor view (#132)
Sep 5, 2023
8e05f27
feat: Bookmark table view model view viewmodel (#133)
chanhihi Sep 5, 2023
2bc233d
feat: add pin button and automation setting button. (#135)
Sep 5, 2023
cd0b8dc
feat: add pin button and automation setting button. (#138)
Sep 5, 2023
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
152 changes: 146 additions & 6 deletions Box42.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

Binary file not shown.
21 changes: 21 additions & 0 deletions Box42/Bookmark/Model/BookmarkModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// BookmarkModel.swift
// Box42
//
// Created by Chan on 2023/09/04.
//

struct URLList: Codable {
let urlList: [URLItem]
}

struct URLItem: Codable {
let name: String
let url: String
}

extension URLItem: Equatable {
static func ==(lhs: URLItem, rhs: URLItem) -> Bool {
return lhs.name == rhs.name && lhs.url == rhs.url
}
}
196 changes: 196 additions & 0 deletions Box42/Bookmark/View/BookmarkTableView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
////
//// BookmarkTableView.swift
//// Box42
////
//// Created by Chanhee Kim on 9/4/23.
////
//
//import AppKit
//import SnapKit
//import Combine
//
//class BookmarkTableView: NSTableView {
// var onButtonClicked: ((DraggableButton) -> Void)?
//
// var buttonTitleArray: [String] {
// return BookmarkViewModel.shared.bookMarkList.map { $0.name }
// }
//
// var urlArray: [String] {
// return BookmarkViewModel.shared.bookMarkList.map { $0.url }
// }
//
// var viewModel: BookmarkViewModel? {
// didSet {
// print("ViewModel has been set.")
// setupBindings()
// }
// }
//
// var cancellables: Set<AnyCancellable> = []
//
// private func setupBindings() {
// print("Setting up bindings...") // 디버깅 로그
// viewModel?.$bookMarkList.sink(receiveValue: { [weak self] newScripts in
// print("Received new scripts: \(newScripts)") // 디버깅 로그
// DispatchQueue.main.async {
// self?.reloadData()
// }
// }).store(in: &cancellables)
// }
//
// func setup() {
// self.delegate = self
// self.dataSource = self
// self.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
//
// self.wantsLayer = true
// self.backgroundColor = NSColor(hex: "#E7E7E7")
// self.focusRingType = .none
// self.headerView = nil
// self.autoresizingMask = [.width, .height]
// self.selectionHighlightStyle = .none
// self.intercellSpacing = NSSize(width: 0, height: 0)
// self.setDraggingSourceOperationMask(.move, forLocal: true)
//
// let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("Bookmark"))
// column.title = ""
// // column.width = 100
// column.resizingMask = .autoresizingMask
//
// self.addTableColumn(column)
// }
//}
//
//extension BookmarkTableView: NSTableViewDelegate, NSTableViewDataSource {
//
// func tableView(_ tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation {
// if dropOperation == .above {
// return .move
// } else {
// return []
// }
// }
//
// func tableView(_ aTableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableView.DropOperation) -> Bool {
// guard let str = info.draggingPasteboard.string(forType: .string), let from = Int(str) else {
// return false
// }
//
// let to = (from < row) ? row - 1 : row
// let item = BookmarkViewModel.shared.bookMarkList[from]
// BookmarkViewModel.shared.bookMarkList.remove(at: from)
// BookmarkViewModel.shared.bookMarkList.insert(item, at: to)
// self.reloadData()
//
// for (_, subview) in self.subviews.enumerated() {
// guard let cellView = subview as? CustomTableCellView else {
// continue
// }
//
// cellView.button.title = buttonTitleArray[cellView.rowIndex]
// }
//
// return true
// }
//
// func numberOfRows(in tableView: NSTableView) -> Int {
// return BookmarkViewModel.shared.bookMarkList.count
// }
//
// func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
// let cellView = ButtonTableCellView()
// cellView.rowIndex = row
//
// let button = DraggableButton(frame: NSRect(x: 0, y: 0, width: 300, height: 44))
// button.tag = row
// button.bezelStyle = .inline
// button.isBordered = false
// button.title = ""
// button.registerForDraggedTypes([NSPasteboard.PasteboardType.string])
// button.target = self
// button.action = #selector(buttonClicked(_:))
// button.delegate = self
//
// let label = NSTextField(frame: NSRect(x: 26 + 21 + 8, y: 25 / 2, width: button.bounds.width, height: button.bounds.height))
//
// label.stringValue = buttonTitleArray[row]
// label.backgroundColor = .clear
// label.isBordered = false
// label.isEditable = false
//
// let attributes : [NSAttributedString.Key : Any] =
// [
// NSAttributedString.Key.font : NSFont.systemFont(ofSize:18.0, weight: .light),
// NSAttributedString.Key.foregroundColor : NSColor.black,
// ]
// let attributedStringTitle = NSAttributedString(string: label.stringValue , attributes:
// attributes)
// label.attributedStringValue=attributedStringTitle
// button.addSubview(label)
//
//
// // let image = NSImage(named: NSImage.Name("bookmark-default"))
// // image?.size = NSSize(width: 21, height: 21)
// // button.image = image
// // button.imagePosition = .imageLeading
// // button.image?.alignmentRect = NSRect(x: 0, y: 0, width: 21, height: 21)
//
// let imageView = NSImageView(frame: NSRect(x: 26, y: 25 / 2, width: 21, height: 21))
// imageView.image = NSImage(named: NSImage.Name("bookmark-default"))
// imageView.imageScaling = .scaleProportionallyUpOrDown
// imageView.imageAlignment = .alignCenter
// button.addSubview(imageView)
//
//
//
// cellView.addSubview(button)
//
// button.snp.makeConstraints { make in
// make.top.equalToSuperview().offset(2)
// make.leading.equalToSuperview()
// make.trailing.equalToSuperview()
// // make.width.equalTo(268)
// make.width.lessThanOrEqualTo(268)
// make.height.equalTo(44)
// }
//
// tableView.rowHeight = 50
//
// if row == selectedRow {
// button.wantsLayer = true
// button.layer?.cornerRadius = 12
// button.layer?.backgroundColor = NSColor.white.cgColor
// } else {
// button.wantsLayer = true
// button.layer?.cornerRadius = 12
// button.layer?.backgroundColor = NSColor.clear.cgColor
// }
//
// return cellView
// }
//
// func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? {
// let pasteboardItem = NSPasteboardItem()
// pasteboardItem.setString(String(row), forType: .string)
// return pasteboardItem
// }
//
// func sendUpdatedDataToServer() {
// let urlList = zip(buttonTitleArray, urlArray).map { ["name": $0.0, "url": $0.1] }
// let jsonData = try? JSONSerialization.data(withJSONObject: ["urlList": urlList])
//
// var request = URLRequest(url: URL(string:"https://api.42box.kr/user-service/users/me/url-list")!)
// request.httpMethod = "POST"
// request.httpBody = jsonData
//
// URLSession.shared.dataTask(with:request) { (data, response, error) in
// if error != nil{
// print(error!.localizedDescription)
// }
// else{
// print("Data posted successfully")
// }
// }.resume()
// }
//}
68 changes: 68 additions & 0 deletions Box42/Bookmark/View/Button/BookmarkCreateButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// BookmarkCreateButton.swift
// Box42
//
// Created by Chanhee Kim on 9/5/23.
//

import AppKit

class BookmarkCreateButton: NSButton {

init() {
super.init(frame: NSRect(x: 0, y: 0, width: 70, height: 40))

self.title = "북마크 추가"
self.isBordered = false
self.wantsLayer = true
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite

let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil)
self.addTrackingArea(trackingArea)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func mouseEntered(with event: NSEvent) {
super.mouseEntered(with: event)

let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite
bgColorAnimation.toValue = WindowButtonUI.color.maximize
bgColorAnimation.duration = WindowButtonUI.animation.duration

let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2
cornerAnimation.duration = WindowButtonUI.animation.duration

self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")

self.layer?.backgroundColor = WindowButtonUI.color.maximize
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2
}

override func mouseExited(with event: NSEvent) {
super.mouseExited(with: event)

let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
bgColorAnimation.fromValue = WindowButtonUI.color.maximize
bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite
bgColorAnimation.duration = WindowButtonUI.animation.duration

let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius
cornerAnimation.duration = WindowButtonUI.animation.duration

self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")

self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
}
}
68 changes: 68 additions & 0 deletions Box42/Bookmark/View/Button/BookmarkDeleteButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// BookmarkDeleteButton.swift
// Box42
//
// Created by Chanhee Kim on 9/5/23.
//

import AppKit

class BookmarkDeleteButton: NSButton {

init() {
super.init(frame: NSRect(x: 0, y: 0, width: 53, height: 40))

self.title = "삭제"
self.isBordered = false
self.wantsLayer = true
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite

let trackingArea = NSTrackingArea(rect: self.bounds, options: [.mouseEnteredAndExited, .activeAlways], owner: self, userInfo: nil)
self.addTrackingArea(trackingArea)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func mouseEntered(with event: NSEvent) {
super.mouseEntered(with: event)

let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
bgColorAnimation.fromValue = WindowButtonUI.color.opacityWhite
bgColorAnimation.toValue = WindowButtonUI.color.close
bgColorAnimation.duration = WindowButtonUI.animation.duration

let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius / 2
cornerAnimation.duration = WindowButtonUI.animation.duration

self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")

self.layer?.backgroundColor = WindowButtonUI.color.close
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius / 2
}

override func mouseExited(with event: NSEvent) {
super.mouseExited(with: event)

let bgColorAnimation = CABasicAnimation(keyPath: "backgroundColor")
bgColorAnimation.fromValue = WindowButtonUI.color.close
bgColorAnimation.toValue = WindowButtonUI.color.opacityWhite
bgColorAnimation.duration = WindowButtonUI.animation.duration

let cornerAnimation = CABasicAnimation(keyPath: "cornerRadius")
cornerAnimation.fromValue = WindowButtonUI.size.cornerRadius / 2
cornerAnimation.toValue = WindowButtonUI.size.cornerRadius
cornerAnimation.duration = WindowButtonUI.animation.duration

self.layer?.add(bgColorAnimation, forKey: "backgroundColorAnimation")
self.layer?.add(cornerAnimation, forKey: "cornerRadiusAnimation")

self.layer?.backgroundColor = WindowButtonUI.color.opacityWhite
self.layer?.cornerRadius = WindowButtonUI.size.cornerRadius
}
}
Loading