Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
01db66a
feat(window): 윈도우를 Movable하게 만듭니다.
chanhihi Aug 17, 2023
0ea8596
feat(contentsView): 오토레이아웃을 설정하여 반응형 디스플레이를 준비합니다.
chanhihi Aug 17, 2023
6f615b9
refactor(webview): 웹뷰 모듈화
chanhihi Aug 18, 2023
0508e03
refactor(webview): 웹뷰 모듈화
chanhihi Aug 18, 2023
3b44fbd
refactor(webview): 웹뷰 모듈화
chanhihi Aug 18, 2023
c1fa4ed
fix(storage): auto cache clean 기능 버그 픽스
chanhihi Aug 18, 2023
4714278
chore: 쓸모없는 기능 잠시 잠금
chanhihi Aug 18, 2023
5876cb9
feat(Button UI): 기존 ContainerView를 Split View로 변경
chanhihi Aug 18, 2023
211a2a8
feat(BoxUI): toolbar를 추가합니다.
chanhihi Aug 18, 2023
fcbb4f6
fix(webview): 복사 붙여넣기 edit menu관련 수정
chanhihi Aug 18, 2023
0519a44
refactor: Resources 위치 변경
chanhihi Aug 20, 2023
58dde9d
chore: xcode.proj
chanhihi Aug 20, 2023
8cf0e3b
feat: split view를 활용해서 button과 contents를 구분합니다.
chanhihi Aug 20, 2023
b04de9e
chore(🚚): 경로를 변경합니다.
chanhihi Aug 20, 2023
68ecc98
refactor(function): button그룹 하단의 function탭의 뷰를 변경하였습니다.
chanhihi Aug 20, 2023
3561a72
refactor: 알아보기쉽게 keydown을 분리하였습니다.
chanhihi Aug 20, 2023
ac3b11d
chore: 쓸모없는 부분을 제거하였습니다.
chanhihi Aug 20, 2023
ec556f1
refactor(webview): 싱글톤 패턴 구조의 WebViewManager로 content hosting view를 관…
chanhihi Aug 20, 2023
b8f6fef
feat(front): ✨ front deploy에 따라서 url을 등록합니다! ✨
chanhihi Aug 20, 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
160 changes: 134 additions & 26 deletions Box42.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions Box42.xcodeproj/xcshareddata/xcschemes/Box42.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DE018BAE2A5099F900FF0AA3"
BuildableName = "Box42.app"
BlueprintName = "Box42"
ReferencedContainer = "container:Box42.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DE018BAE2A5099F900FF0AA3"
BuildableName = "Box42.app"
BlueprintName = "Box42"
ReferencedContainer = "container:Box42.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DE018BAE2A5099F900FF0AA3"
BuildableName = "Box42.app"
BlueprintName = "Box42"
ReferencedContainer = "container:Box42.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
154 changes: 82 additions & 72 deletions Box42/Box/BoxBaseContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,114 +6,124 @@
//

import Cocoa
import SnapKit

class BoxBaseContainerViewController: NSViewController {
var buttonGroup : BoxButtonViewGroup!
var contentGroup : BoxContentsViewGroup!

var splitView: BoxBaseSplitView! = BoxBaseSplitView()
var contentGroup: BoxContentsViewGroup! = BoxContentsViewGroup()
var toolbarGroup: BoxToolbarViewGroup! = BoxToolbarViewGroup()
var functionGroupVC: BoxFunctionViewController! = BoxFunctionViewController()
var buttonGroup: BoxButtonViewGroup!
var leftContainer: MovableContainerView!

override func loadView() {
self.view = NSView() // 뷰 컨트롤러의 뷰 설정
self.view = NSView()
self.view.addSubview(splitView)
splitView.delegate = self

buttonGroup = BoxButtonViewGroupInit()
contentGroup = BoxContentsViewGroup()
panGestureInit()

leftContainerInit()
viewInit()
}

func BoxButtonViewGroupInit() -> BoxButtonViewGroup {
let buttonGroup = BoxButtonViewGroup { sender in
self.clickBtn(sender: sender)
}
view.addSubview(buttonGroup)
return buttonGroup
}

func clickBtn(sender: NSButton) {
guard let clickCount = NSApp.currentEvent?.clickCount else { return }
if sender.title == "Preferences" {
contentGroup.removeAllSubviews()
contentGroup.showPreferences()
return
}
if clickCount == 2 {
WebViewList.shared.list[sender.title]!.reload()
WebViewManager.shared.list[sender.title]!.reload()
print("Dobule Click")
} else if clickCount > 2 {
// let rqURL = URLRequest(url: boxVM.URLdict[sender.title]!)
// WebViewList.shared.list[sender.title]!.load(rqURL)
if let currentURL = WebViewManager.shared.hostingWebView?.url {
NSWorkspace.shared.open(currentURL)
}
print("Triple Click")
} else if clickCount < 2 {
contentGroup.removeAllSubviews()
contentGroup.showWebviews(sender)
}
}

private func leftContainerInit() {
leftContainer = MovableContainerView()
leftContainer.addSubview(buttonGroup)
leftContainer.addSubview(toolbarGroup)
leftContainer.addSubview(functionGroupVC.view)
leftContainerAutolayout()
leftContainer.frame.size.width = BoxSizeManager.shared.windowButtonGroupSize.width
}

private func panGestureInit() {
let panRecognizer = NSPanGestureRecognizer(target: self, action: #selector(handlePanGesture(_:)))
self.view.addGestureRecognizer(panRecognizer) // 뷰 컨트롤러의 뷰에 제스처 추가
private func leftContainerAutolayout() {
toolbarGroup.snp.makeConstraints { make in
make.top.equalTo(leftContainer).offset(Constants.UI.GroupAutolayout)
make.right.equalTo(leftContainer).offset(-Constants.UI.GroupAutolayout)
make.left.equalTo(leftContainer)
}

buttonGroup.snp.makeConstraints { make in
make.top.equalTo(toolbarGroup.snp.bottom).offset(Constants.UI.GroupAutolayout)
make.right.equalTo(leftContainer).offset(-Constants.UI.GroupAutolayout)
make.left.equalTo(leftContainer)
}

functionGroupVC.view.snp.makeConstraints { make in
make.top.equalTo(buttonGroup.snp.bottom).offset(Constants.UI.GroupAutolayout)
make.right.equalTo(leftContainer).offset(-Constants.UI.GroupAutolayout)
make.left.bottom.equalTo(leftContainer)
}
}

func viewInit() {
self.boxViewSizeInit()
self.buttonBoxGroupInit()
self.contentsGroupInit()

// buttonGroup과 contentGroup을 self에 추가합니다.
view.addSubview(buttonGroup)
view.addSubview(contentGroup)

// buttonGroup 오토레이아웃 설정
buttonGroup.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
buttonGroup.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
buttonGroup.topAnchor.constraint(equalTo: self.view.topAnchor),
buttonGroup.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
buttonGroup.widthAnchor.constraint(equalToConstant: BoxSizeManager.shared.buttonGroupSize.width)
])

// contentGroup 오토레이아웃 설정
contentGroup.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
contentGroup.leadingAnchor.constraint(equalTo: buttonGroup.trailingAnchor),
contentGroup.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
contentGroup.topAnchor.constraint(equalTo: self.view.topAnchor),
contentGroup.bottomAnchor.constraint(equalTo: self.view.bottomAnchor)
])
splitView.addArrangedSubview(leftContainer)
splitView.addArrangedSubview(contentGroup)
self.view.addSubview(splitView)

splitView.snp.makeConstraints { make in
make.top.equalTo(self.view).offset(Constants.UI.GroupAutolayout)
make.left.equalTo(self.view).offset(Constants.UI.GroupAutolayout)
make.right.equalTo(self.view).offset(-Constants.UI.GroupAutolayout)
make.bottom.equalTo(self.view).offset(-Constants.UI.GroupAutolayout)
}
}

func boxViewSizeInit() {
self.view.frame.size.width = BoxSizeManager.shared.size.width
self.view.frame.size.height = BoxSizeManager.shared.size.height
}

func contentsGroupInit() {
self.contentGroup.frame.size.width = BoxSizeManager.shared.size.width - BoxSizeManager.shared.buttonGroupSize.width
self.contentGroup.frame.size.height = BoxSizeManager.shared.size.height
}

func buttonBoxGroupInit() {
self.buttonGroup.frame.size.width = BoxSizeManager.shared.buttonGroupSize.width
self.buttonGroup.frame.size.height = BoxSizeManager.shared.buttonGroupSize.height
}
}

extension BoxBaseContainerViewController {
// 추후 논의. 내부 panGesture로 View크기 증감
@objc private func handlePanGesture(_ recognizer: NSPanGestureRecognizer) {
guard let view = recognizer.view else { return }

// 사용자가 드래그한 변화량을 가져옵니다.
let translation = recognizer.translation(in: view)

// 드래그로 인한 크기 변화를 계산합니다.
let newWidth = view.frame.width + translation.x
let newHeight = view.frame.height + translation.y

// 크기를 적용합니다.
view.setFrameSize(NSSize(width: newWidth, height: newHeight))
extension BoxBaseContainerViewController: NSSplitViewDelegate {
func splitView(_ splitView: NSSplitView, constrainMinCoordinate proposedMinimumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {

// 변화량을 리셋합니다.
recognizer.setTranslation(.zero, in: view)

print(newWidth, newHeight)
if dividerIndex == 0 {
return 132
}
return proposedMinimumPosition
}

func splitView(_ splitView: NSSplitView, constrainMaxCoordinate proposedMaximumPosition: CGFloat, ofSubviewAt dividerIndex: Int) -> CGFloat {
if dividerIndex == 0 {
return 200
}
return proposedMaximumPosition
}

func splitView(_ splitView: NSSplitView, resizeSubviewsWithOldSize oldSize: NSSize) {
let dividerThickness = splitView.dividerThickness
let newWidth = splitView.frame.width - dividerThickness

let leftWidth = leftContainer.frame.width
let contentWidth = newWidth - leftWidth

leftContainer.frame = NSRect(x: 0, y: 0, width: leftWidth, height: splitView.bounds.height)
contentGroup.frame = NSRect(x: leftWidth + dividerThickness, y: 0, width: contentWidth, height: splitView.bounds.height)
}
}
Loading