Skip to content

Commit

Permalink
refactor(Architecture🏛): MVC to MVVM in box
Browse files Browse the repository at this point in the history
  • Loading branch information
chanhihi authored Aug 17, 2023
2 parents fb27c4c + 1c1de9c commit eb72032
Show file tree
Hide file tree
Showing 18 changed files with 478 additions and 211 deletions.
99 changes: 97 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,101 @@
### Swift ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.build/

# CocoaPods
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
# Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

### Xcode ###

## Xcode 8 and earlier

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno
**/xcshareddata/WorkspaceSettings.xcsettings

.DS_Store
Box42/.DS_Store
Box42.xcodeproj/xcuserdata/

.prettierrc
.swift-format
43 changes: 34 additions & 9 deletions Box42.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
DE018BF32A509B3300FF0AA3 /* MenubarModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE018BF22A509B3300FF0AA3 /* MenubarModel.swift */; };
DE018BF62A509B3600FF0AA3 /* MenubarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE018BF52A509B3600FF0AA3 /* MenubarView.swift */; };
DE018C032A509B5D00FF0AA3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DE018C022A509B5D00FF0AA3 /* Main.storyboard */; };
DE0A915D2A8E348D00D1D6F1 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = DE0A915C2A8E348D00D1D6F1 /* SnapKit */; };
DE0A91632A8E6A5400D1D6F1 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE0A91622A8E6A5400D1D6F1 /* Constants.swift */; };
DE0A91672A8E6CA700D1D6F1 /* WebViewList.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE0A91662A8E6CA700D1D6F1 /* WebViewList.swift */; };
DE0A916D2A8E7DD700D1D6F1 /* HoverButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE0A916C2A8E7DD700D1D6F1 /* HoverButton.swift */; };
DE0A91702A8E8BDE00D1D6F1 /* GradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE0A916F2A8E8BDE00D1D6F1 /* GradientView.swift */; };
DE1F1A142A8B506600A88DD8 /* importMacOSInfo.sh in Resources */ = {isa = PBXBuildFile; fileRef = DE1F1A112A8B506600A88DD8 /* importMacOSInfo.sh */; };
DE1F1A152A8B506600A88DD8 /* exportMacOSInfo.sh in Resources */ = {isa = PBXBuildFile; fileRef = DE1F1A122A8B506600A88DD8 /* exportMacOSInfo.sh */; };
DE1F1A162A8B506600A88DD8 /* keyMapping.sh in Resources */ = {isa = PBXBuildFile; fileRef = DE1F1A132A8B506600A88DD8 /* keyMapping.sh */; };
Expand Down Expand Up @@ -64,6 +69,10 @@
DE018BF52A509B3600FF0AA3 /* MenubarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenubarView.swift; sourceTree = "<group>"; };
DE018C022A509B5D00FF0AA3 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
DE018C192A509DBA00FF0AA3 /* Box42.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Box42.entitlements; sourceTree = "<group>"; };
DE0A91622A8E6A5400D1D6F1 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
DE0A91662A8E6CA700D1D6F1 /* WebViewList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewList.swift; sourceTree = "<group>"; };
DE0A916C2A8E7DD700D1D6F1 /* HoverButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HoverButton.swift; sourceTree = "<group>"; };
DE0A916F2A8E8BDE00D1D6F1 /* GradientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GradientView.swift; sourceTree = "<group>"; };
DE1F1A112A8B506600A88DD8 /* importMacOSInfo.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = importMacOSInfo.sh; sourceTree = "<group>"; };
DE1F1A122A8B506600A88DD8 /* exportMacOSInfo.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = exportMacOSInfo.sh; sourceTree = "<group>"; };
DE1F1A132A8B506600A88DD8 /* keyMapping.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = keyMapping.sh; sourceTree = "<group>"; };
Expand Down Expand Up @@ -98,7 +107,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D676A64A2A8C5CEA00B5C319 /* SnapKit in Frameworks */,
DE0A915D2A8E348D00D1D6F1 /* SnapKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -125,8 +134,8 @@
DE018BB12A5099F900FF0AA3 /* Box42 */ = {
isa = PBXGroup;
children = (
DE0A916B2A8E7DC700D1D6F1 /* UI */,
DE1F1A202A8B50CA00A88DD8 /* Main */,
DE1F1A182A8B50BB00A88DD8 /* Box */,
DEF749302A85655E00D987C8 /* Extensions */,
DEB862E82A853F6800278FCD /* Window */,
DEB862D22A8511D600278FCD /* Scripts */,
Expand All @@ -135,6 +144,7 @@
DE018C0C2A509BDF00FF0AA3 /* Resources */,
DE018C062A509B9000FF0AA3 /* System */,
DE018C082A509BB500FF0AA3 /* WebView */,
DE1F1A182A8B50BB00A88DD8 /* Box */,
DE018C0E2A509C0C00FF0AA3 /* Menubar */,
);
path = Box42;
Expand All @@ -157,6 +167,7 @@
DE018C0B2A509BC100FF0AA3 /* URL */,
DE018BE92A509B2100FF0AA3 /* WebViewModel.swift */,
DE018BE62A509B1E00FF0AA3 /* WebViewController.swift */,
DE0A91662A8E6CA700D1D6F1 /* WebViewList.swift */,
);
path = WebView;
sourceTree = "<group>";
Expand Down Expand Up @@ -193,6 +204,15 @@
path = Menubar;
sourceTree = "<group>";
};
DE0A916B2A8E7DC700D1D6F1 /* UI */ = {
isa = PBXGroup;
children = (
DE0A916C2A8E7DD700D1D6F1 /* HoverButton.swift */,
DE0A916F2A8E8BDE00D1D6F1 /* GradientView.swift */,
);
path = UI;
sourceTree = "<group>";
};
DE17AF722A834A1600325BF4 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -225,6 +245,7 @@
children = (
DE1F1A282A8B50E200A88DD8 /* BoxSizeManager.swift */,
DE77BA552A82637900713683 /* StateManager.swift */,
DE0A91622A8E6A5400D1D6F1 /* Constants.swift */,
);
path = Shared;
sourceTree = "<group>";
Expand Down Expand Up @@ -298,7 +319,7 @@
);
name = Box42;
packageProductDependencies = (
D676A6492A8C5CEA00B5C319 /* SnapKit */,
DE0A915C2A8E348D00D1D6F1 /* SnapKit */,
);
productName = Box42;
productReference = DE018BAF2A5099F900FF0AA3 /* Box42.app */;
Expand Down Expand Up @@ -328,7 +349,7 @@
);
mainGroup = DE018BA62A5099F900FF0AA3;
packageReferences = (
D676A6482A8C5CEA00B5C319 /* XCRemoteSwiftPackageReference "SnapKit" */,
DE0A915B2A8E348D00D1D6F1 /* XCRemoteSwiftPackageReference "SnapKit" */,
);
productRefGroup = DE018BB02A5099F900FF0AA3 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -376,9 +397,12 @@
DE874F4E2A591DEA00FC3B77 /* Hotkey.swift in Sources */,
DE1F1A252A8B50D500A88DD8 /* BoxViewModel.swift in Sources */,
DE018BB32A5099F900FF0AA3 /* AppDelegate.swift in Sources */,
DE0A91632A8E6A5400D1D6F1 /* Constants.swift in Sources */,
DE018BF32A509B3300FF0AA3 /* MenubarModel.swift in Sources */,
DE7A257A2A6D8CA20043225A /* PreferencesViewController.swift in Sources */,
DE0A916D2A8E7DD700D1D6F1 /* HoverButton.swift in Sources */,
DE1F1A242A8B50D500A88DD8 /* BoxButtonHandler.swift in Sources */,
DE0A91672A8E6CA700D1D6F1 /* WebViewList.swift in Sources */,
DE018BED2A509B2600FF0AA3 /* URLModel.swift in Sources */,
DE1F1A1E2A8B50C500A88DD8 /* BoxButtonViewGroup.swift in Sources */,
DEB862EB2A853F7F00278FCD /* BoxWindowController.swift in Sources */,
Expand All @@ -390,6 +414,7 @@
DE2AD3292A824EEB00002D51 /* Accessibility.swift in Sources */,
DE874F572A591F2500FC3B77 /* Icon.swift in Sources */,
DE1F1A2E2A8BCC9800A88DD8 /* Storage.swift in Sources */,
DE0A91702A8E8BDE00D1D6F1 /* GradientView.swift in Sources */,
DE1F1A312A8BD68F00A88DD8 /* Double.swift in Sources */,
DE018BEA2A509B2100FF0AA3 /* WebViewModel.swift in Sources */,
);
Expand Down Expand Up @@ -449,7 +474,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -504,7 +529,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -577,7 +602,7 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
D676A6482A8C5CEA00B5C319 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
DE0A915B2A8E348D00D1D6F1 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SnapKit/SnapKit.git";
requirement = {
Expand All @@ -588,9 +613,9 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
D676A6492A8C5CEA00B5C319 /* SnapKit */ = {
DE0A915C2A8E348D00D1D6F1 /* SnapKit */ = {
isa = XCSwiftPackageProductDependency;
package = D676A6482A8C5CEA00B5C319 /* XCRemoteSwiftPackageReference "SnapKit" */;
package = DE0A915B2A8E348D00D1D6F1 /* XCRemoteSwiftPackageReference "SnapKit" */;
productName = SnapKit;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
Binary file not shown.
13 changes: 4 additions & 9 deletions Box42/Box/BoxBaseContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class BoxBaseContainerViewController: NSViewController {

func BoxButtonViewGroupInit() -> BoxButtonViewGroup {
let buttonGroup = BoxButtonViewGroup { sender in
// 버튼을 클릭할 때 실행할 코드
self.clickBtn(sender: sender)
}
view.addSubview(buttonGroup)
Expand All @@ -31,9 +30,8 @@ class BoxBaseContainerViewController: NSViewController {
func clickBtn(sender: NSButton) {
guard let clickCount = NSApp.currentEvent?.clickCount else { return }
if sender.title == "Preferences" {
// boxView.contentGroup.subviews.removeAll()
// boxView.contentGroup.addSubview(preferencesVC.view)
// preferencesVC.viewDidAppear()
contentGroup.removeAllSubviews()
contentGroup.showPreferences()
return
}
if clickCount == 2 {
Expand All @@ -44,11 +42,8 @@ class BoxBaseContainerViewController: NSViewController {
// WebViewList.shared.list[sender.title]!.load(rqURL)
print("Triple Click")
} else if clickCount < 2 {
// boxView.contentGroup.subviews.removeAll()
// boxView.contentGroup.addSubview(WebViewList.shared.list[sender.title]!)
WebViewList.shared.list[sender.title]!.configuration.preferences.javaScriptCanOpenWindowsAutomatically = true
WebViewList.shared.list[sender.title]!.configuration.preferences.javaScriptEnabled = true
WebViewList.shared.list[sender.title]?.viewDidMoveToSuperview()
contentGroup.removeAllSubviews()
contentGroup.showWebviews(sender)
}
}

Expand Down
Loading

0 comments on commit eb72032

Please sign in to comment.