Skip to content

Commit

Permalink
Merge pull request #32 from 42Box/31-feat-import-snapkit
Browse files Browse the repository at this point in the history
feat:SPM으로 SnapKit을 설치했습니다.
  • Loading branch information
DaSol Kim authored Aug 16, 2023
2 parents bef450f + d1ce1c9 commit fb27c4c
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 70 deletions.
29 changes: 28 additions & 1 deletion Box42.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
D676A64A2A8C5CEA00B5C319 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = D676A6492A8C5CEA00B5C319 /* SnapKit */; };
DE018BB32A5099F900FF0AA3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE018BB22A5099F900FF0AA3 /* AppDelegate.swift */; };
DE018BB82A5099F900FF0AA3 /* Box42.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = DE018BB62A5099F900FF0AA3 /* Box42.xcdatamodeld */; };
DE018BDD2A509AEB00FF0AA3 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE018BDC2A509AEB00FF0AA3 /* EventMonitor.swift */; };
Expand Down Expand Up @@ -97,6 +98,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D676A64A2A8C5CEA00B5C319 /* SnapKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -295,6 +297,9 @@
dependencies = (
);
name = Box42;
packageProductDependencies = (
D676A6492A8C5CEA00B5C319 /* SnapKit */,
);
productName = Box42;
productReference = DE018BAF2A5099F900FF0AA3 /* Box42.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -322,6 +327,9 @@
Base,
);
mainGroup = DE018BA62A5099F900FF0AA3;
packageReferences = (
D676A6482A8C5CEA00B5C319 /* XCRemoteSwiftPackageReference "SnapKit" */,
);
productRefGroup = DE018BB02A5099F900FF0AA3 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down Expand Up @@ -568,6 +576,25 @@
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
D676A6482A8C5CEA00B5C319 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SnapKit/SnapKit.git";
requirement = {
kind = exactVersion;
version = 5.6.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
D676A6492A8C5CEA00B5C319 /* SnapKit */ = {
isa = XCSwiftPackageProductDependency;
package = D676A6482A8C5CEA00B5C319 /* XCRemoteSwiftPackageReference "SnapKit" */;
productName = SnapKit;
};
/* End XCSwiftPackageProductDependency section */

/* Begin XCVersionGroup section */
DE018BB62A5099F900FF0AA3 /* Box42.xcdatamodeld */ = {
isa = XCVersionGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "SnapKit",
"repositoryURL": "https://github.com/SnapKit/SnapKit.git",
"state": {
"branch": null,
"revision": "f222cbdf325885926566172f6f5f06af95473158",
"version": "5.6.0"
}
}
]
},
"version": 1
}
Binary file not shown.
53 changes: 39 additions & 14 deletions Box42/Box/BoxButtonViewGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Cocoa
import SnapKit

class BoxButtonViewGroup: NSView {
var boxVM: WebViewModel! = WebViewModel()
Expand Down Expand Up @@ -91,6 +92,31 @@ class BoxButtonViewGroup: NSView {
// ])
//
// lastAddedButton = button
// }
//
// func createHomeButton() {
// let button = NSButton(title: "home", image: NSImage(imageLiteralResourceName: "42box_logo"), target: self, action: #selector(clickBtn(sender:)))
// super.addSubview(button)
//
// button.translatesAutoresizingMaskIntoConstraints = false
// button.isBordered = false
// button.imagePosition = .imageOnly
//
//
//// NSLayoutConstraint.activate([
//// button.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 20),
//// button.topAnchor.constraint(equalTo: self.topAnchor, constant: 0),
//// button.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -20),
////// button.heightAnchor.constraint(equalToConstant: 30)
//// ])
//
// NSLayoutConstraint.activate([
//// button.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 20), // 좌측 간격을 100에서 20으로 변경
//// button.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -20), // 우측 간격을 80에서 20으로 변경
//// button.heightAnchor.constraint(equalToConstant: 30)
// ])
//
// lastAddedButton = nil // home 버튼 이후의 버튼들이 상단에 연결되지 않도록 설정
// }

func createHomeButton() {
Expand All @@ -100,25 +126,24 @@ class BoxButtonViewGroup: NSView {
button.translatesAutoresizingMaskIntoConstraints = false
button.isBordered = false
button.imagePosition = .imageOnly


// NSLayoutConstraint.activate([
// button.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 20),
// button.topAnchor.constraint(equalTo: self.topAnchor, constant: 0),
// button.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -20),
//// button.heightAnchor.constraint(equalToConstant: 30)
// ])

NSLayoutConstraint.activate([
button.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: 20), // 좌측 간격을 100에서 20으로 변경
button.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -20), // 우측 간격을 80에서 20으로 변경
button.heightAnchor.constraint(equalToConstant: 30)
])
button.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(20)
make.trailing.equalToSuperview().offset(-20)
make.height.equalTo(30)

if let lastButton = lastAddedButton {
make.top.equalTo(lastButton.snp.bottom).offset(10)
} else {
make.top.equalToSuperview()
}
}

lastAddedButton = nil // home 버튼 이후의 버튼들이 상단에 연결되지 않도록 설정
lastAddedButton = button
}




// func createQuitButton() {
// let button = NSButton()
Expand Down
4 changes: 2 additions & 2 deletions Box42/Main/BoxViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import Cocoa
import AppKit
import WebKit

class BoxViewController: NSViewController {

class BoxViewController: NSViewController {
var boxView: BoxBaseContainerViewController! = BoxBaseContainerViewController()

let preferencesVC = PreferencesViewController()
Expand All @@ -24,6 +23,7 @@ class BoxViewController: NSViewController {

override func viewDidLoad() {
super.viewDidLoad()

menubarVCDelegate = (NSApplication.shared.delegate as? AppDelegate)?.menubarController
}

Expand Down
2 changes: 0 additions & 2 deletions Box42/Menubar/MenubarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation

import AppKit

class MenubarViewController: NSWorkspace {
Expand All @@ -16,7 +15,6 @@ class MenubarViewController: NSWorkspace {
lazy var eventMonitor: EventMonitor = self.setupEventMonitor()
var boxWindowController: BoxWindowController?


func menubarViewControllerInit() {
self.buttonInit()
}
Expand Down
49 changes: 0 additions & 49 deletions Box42/Resources/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Application-->
Expand Down Expand Up @@ -173,53 +172,5 @@
</objects>
<point key="canvasLocation" x="74" y="-203"/>
</scene>
<!--Box View Controller-->
<scene sceneID="2YF-NG-qgR">
<objects>
<customObject id="xrs-eX-5QB" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
<viewController storyboardIdentifier="Main" id="vnM-6c-Kef" customClass="BoxViewController" customModule="Box42" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" misplaced="YES" verifyAmbiguity="off" id="G4d-7M-cg0">
<rect key="frame" x="0.0" y="0.0" width="900" height="806"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<customView id="ulN-bz-DqK">
<rect key="frame" x="0.0" y="106" width="132" height="700"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="QtO-vD-ZQX">
<rect key="frame" x="12" y="18" width="108" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</box>
</subviews>
<constraints>
<constraint firstAttribute="width" constant="132" id="J1P-Oe-EPc"/>
</constraints>
</customView>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="ru4-50-bBK">
<rect key="frame" x="132" y="0.0" width="768" height="700"/>
<constraints>
<constraint firstAttribute="width" constant="768" id="dJf-8V-0oq"/>
</constraints>
</customView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="ru4-50-bBK" secondAttribute="trailing" id="54D-DP-09D"/>
<constraint firstItem="ulN-bz-DqK" firstAttribute="top" secondItem="G4d-7M-cg0" secondAttribute="top" id="5kR-6R-keB"/>
<constraint firstAttribute="bottom" secondItem="ulN-bz-DqK" secondAttribute="bottom" id="6Os-Kk-Gx4"/>
<constraint firstItem="ulN-bz-DqK" firstAttribute="leading" secondItem="G4d-7M-cg0" secondAttribute="leading" id="8VH-l3-xuI"/>
<constraint firstItem="ru4-50-bBK" firstAttribute="leading" secondItem="ulN-bz-DqK" secondAttribute="trailing" id="CJe-dJ-rLu"/>
<constraint firstItem="ru4-50-bBK" firstAttribute="leading" secondItem="ulN-bz-DqK" secondAttribute="trailing" id="FOT-aI-NWc"/>
<constraint firstAttribute="bottom" secondItem="ru4-50-bBK" secondAttribute="bottom" id="HLm-6B-ijw"/>
<constraint firstItem="ru4-50-bBK" firstAttribute="leading" secondItem="ulN-bz-DqK" secondAttribute="trailing" id="UPx-zD-1UI"/>
<constraint firstItem="ru4-50-bBK" firstAttribute="top" secondItem="G4d-7M-cg0" secondAttribute="top" id="zR2-3O-jUe"/>
</constraints>
</view>
<connections>
<outlet property="boxView" destination="G4d-7M-cg0" id="lRF-TY-gNh"/>
</connections>
</viewController>
</objects>
<point key="canvasLocation" x="74" y="323"/>
</scene>
</scenes>
</document>
2 changes: 1 addition & 1 deletion Box42/System/EventMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class EventMonitor {
private var monitor: Any?
private let mask: NSEvent.EventTypeMask
private let handler: (NSEvent?) -> Void
init(monitor: Any? = nil, mask: NSEvent.EventTypeMask, handler: @escaping (NSEvent?) -> Void) {
self.mask = mask
self.handler = handler
Expand Down
2 changes: 1 addition & 1 deletion Box42/Window/BoxWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import Cocoa

class BoxWindowController: NSWindowController {

override init(window: NSWindow?) {
let contentRect = BoxSizeManager.shared.boxViewSizeNSRect
let styleMask: NSWindow.StyleMask = [.titled, .closable, .resizable, .miniaturizable]
let windowInstance = NSWindow(contentRect: contentRect, styleMask: styleMask, backing: .buffered, defer: false)
windowInstance.title = "Box"
windowInstance.styleMask.insert(.resizable)
windowInstance.backgroundColor = NSColor.red

let boxViewController = BoxViewController(nibName: nil, bundle: nil)
windowInstance.contentViewController = boxViewController
Expand Down

0 comments on commit fb27c4c

Please sign in to comment.