diff --git a/CodeEdit.xcodeproj/project.pbxproj b/CodeEdit.xcodeproj/project.pbxproj index 8886427008..9827f0aa7d 100644 --- a/CodeEdit.xcodeproj/project.pbxproj +++ b/CodeEdit.xcodeproj/project.pbxproj @@ -10,7 +10,6 @@ 043C321427E31FF6006AE443 /* CodeEditDocumentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043C321327E31FF6006AE443 /* CodeEditDocumentController.swift */; }; 043C321627E3201F006AE443 /* WorkspaceDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043C321527E3201F006AE443 /* WorkspaceDocument.swift */; }; 043C321A27E32295006AE443 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 043C321927E32295006AE443 /* MainMenu.xib */; }; - 04540D5B27DD08C300E91B77 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F2BF0E27DBB28E0024EAB1 /* SettingsView.swift */; }; 04540D5C27DD08C300E91B77 /* GeneralSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F2BF1127DBB3C10024EAB1 /* GeneralSettingsView.swift */; }; 04540D5E27DD08C300E91B77 /* WorkspaceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B658FB3127DA9E0F00EA4DBD /* WorkspaceView.swift */; }; 04660F6427E3ACAF00477777 /* Appearances.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04660F6327E3ACAF00477777 /* Appearances.swift */; }; @@ -36,6 +35,10 @@ 5C403B8F27E20F8000788241 /* WorkspaceClient in Frameworks */ = {isa = PBXBuildFile; productRef = 5C403B8E27E20F8000788241 /* WorkspaceClient */; }; 5CF38A5E27E48E6C0096A0F7 /* CodeFile in Frameworks */ = {isa = PBXBuildFile; productRef = 5CF38A5D27E48E6C0096A0F7 /* CodeFile */; }; 5CFA753B27E896B60002F01B /* GitClient in Frameworks */ = {isa = PBXBuildFile; productRef = 5CFA753A27E896B60002F01B /* GitClient */; }; + 90626FA727EB2FD1008926FE /* Preferences in Frameworks */ = {isa = PBXBuildFile; productRef = 90626FA627EB2FD1008926FE /* Preferences */; }; + 90626FA927EB3017008926FE /* PreferencesIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90626FA827EB3017008926FE /* PreferencesIdentifier.swift */; }; + 90626FAB27EB3254008926FE /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90626FAA27EB3254008926FE /* Theme.swift */; }; + 90626FB027EB3789008926FE /* ThemeSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90626FAF27EB3789008926FE /* ThemeSettingsView.swift */; }; B658FB3427DA9E1000EA4DBD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B658FB3327DA9E1000EA4DBD /* Assets.xcassets */; }; B658FB3727DA9E1000EA4DBD /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B658FB3627DA9E1000EA4DBD /* Preview Assets.xcassets */; }; B65E614627E6765D00255275 /* Introspect in Frameworks */ = {isa = PBXBuildFile; productRef = B65E614527E6765D00255275 /* Introspect */; }; @@ -89,7 +92,6 @@ 0485EB2227E7791400138301 /* QuickOpenPreviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickOpenPreviewView.swift; sourceTree = ""; }; 04ADA0C827E5D29000BF00B2 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = ""; }; 04ADA0CA27E5D41F00BF00B2 /* be */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = be; path = be.lproj/Localizable.strings; sourceTree = ""; }; - 04F2BF0E27DBB28E0024EAB1 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; 04F2BF1127DBB3C10024EAB1 /* GeneralSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneralSettingsView.swift; sourceTree = ""; }; 12F71F7127E833A000095416 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 20F8067027E65A5200EB7827 /* af */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = af; path = af.lproj/Localizable.strings; sourceTree = ""; }; @@ -103,13 +105,16 @@ 289978EC27E4E97E00BB0357 /* FileIconStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileIconStyle.swift; sourceTree = ""; }; 28B0A19727E385C300B73177 /* NavigatorSidebarToolbarTop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigatorSidebarToolbarTop.swift; sourceTree = ""; }; 28FFE1BE27E3A441001939DB /* NavigatorSidebarToolbarBottom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigatorSidebarToolbarBottom.swift; sourceTree = ""; }; - 2B7C962F27EA5D4000DF58C5 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; 2B772A4C27EA6AF800AFCD7E /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = ""; }; + 2B7C962F27EA5D4000DF58C5 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; 34EE19BD27E0469C00F152CE /* BlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurView.swift; sourceTree = ""; }; 5E3C6A3427E72AE000A7CA0D /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; 70F2E28327E848720002BA81 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 7A4D129627E8E7BD00D4AE07 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/Localizable.strings; sourceTree = ""; }; 85D7EE9527E928B900CB9F10 /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = ""; }; + 90626FA827EB3017008926FE /* PreferencesIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesIdentifier.swift; sourceTree = ""; }; + 90626FAA27EB3254008926FE /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = ""; }; + 90626FAF27EB3789008926FE /* ThemeSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeSettingsView.swift; sourceTree = ""; }; B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CodeEdit.app; sourceTree = BUILT_PRODUCTS_DIR; }; B658FB3127DA9E0F00EA4DBD /* WorkspaceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceView.swift; sourceTree = ""; }; B658FB3327DA9E1000EA4DBD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -146,6 +151,7 @@ D7F72DEB27EA3574000C3064 /* Search in Frameworks */, 5CFA753B27E896B60002F01B /* GitClient in Frameworks */, 28CE5EA027E6493D0065D29C /* StatusBar in Frameworks */, + 90626FA727EB2FD1008926FE /* Preferences in Frameworks */, 5CF38A5E27E48E6C0096A0F7 /* CodeFile in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -185,6 +191,8 @@ 04660F6327E3ACAF00477777 /* Appearances.swift */, 04660F6527E3ACEF00477777 /* ReopenBehavior.swift */, 289978EC27E4E97E00BB0357 /* FileIconStyle.swift */, + 90626FA827EB3017008926FE /* PreferencesIdentifier.swift */, + 90626FAA27EB3254008926FE /* Theme.swift */, ); path = Models; sourceTree = ""; @@ -203,8 +211,8 @@ isa = PBXGroup; children = ( 04660F6227E3ACA300477777 /* Models */, - 04F2BF0E27DBB28E0024EAB1 /* SettingsView.swift */, 04F2BF1127DBB3C10024EAB1 /* GeneralSettingsView.swift */, + 90626FAF27EB3789008926FE /* ThemeSettingsView.swift */, ); path = Settings; sourceTree = ""; @@ -373,6 +381,7 @@ 0485EB2427E7B9C800138301 /* Overlays */, 5CFA753A27E896B60002F01B /* GitClient */, D7F72DEA27EA3574000C3064 /* Search */, + 90626FA627EB2FD1008926FE /* Preferences */, ); productName = CodeEdit; productReference = B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */; @@ -460,6 +469,7 @@ mainGroup = B658FB2327DA9E0F00EA4DBD; packageReferences = ( B65E614427E6765D00255275 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */, + 90626FA527EB2FD1008926FE /* XCRemoteSwiftPackageReference "Preferences" */, ); productRefGroup = B658FB2D27DA9E0F00EA4DBD /* Products */; projectDirPath = ""; @@ -547,9 +557,9 @@ 2B7A583527E4BA0100D25D4E /* AppDelegate.swift in Sources */, 2875A46D27E3BE5B007805F8 /* BreadcrumbsView.swift in Sources */, 0485EB1D27E7338100138301 /* QuickOpenItem.swift in Sources */, + 90626FB027EB3789008926FE /* ThemeSettingsView.swift in Sources */, D7012EE827E757850001E1EF /* SidebarSearch.swift in Sources */, D7E201AE27E8B3C000CB86D0 /* String+Ranges.swift in Sources */, - 04540D5B27DD08C300E91B77 /* SettingsView.swift in Sources */, D7E201B027E8C07300CB86D0 /* SearchBar.swift in Sources */, D72E1A8927E44D7C00EB11B9 /* WelcomeWindowView.swift in Sources */, 04540D5C27DD08C300E91B77 /* GeneralSettingsView.swift in Sources */, @@ -562,6 +572,7 @@ D7211D4327E066CE008F2ED7 /* Localized+Ex.swift in Sources */, D7E201B227E8D50000CB86D0 /* SearchModeSelector.swift in Sources */, 287776E927E34BC700D46668 /* TabBar.swift in Sources */, + 90626FAB27EB3254008926FE /* Theme.swift in Sources */, 0485EB1F27E7458B00138301 /* WorkspaceCodeFileView.swift in Sources */, 0485EB1927E70F4900138301 /* QuickOpenView.swift in Sources */, D7E201BD27EA00E200CB86D0 /* SearchResultFileItem.swift in Sources */, @@ -579,6 +590,7 @@ 289978ED27E4E97E00BB0357 /* FileIconStyle.swift in Sources */, 04660F6627E3ACEF00477777 /* ReopenBehavior.swift in Sources */, D72E1A8327E3B0D400EB11B9 /* WelcomeView.swift in Sources */, + 90626FA927EB3017008926FE /* PreferencesIdentifier.swift in Sources */, 043C321627E3201F006AE443 /* WorkspaceDocument.swift in Sources */, 28B0A19827E385C300B73177 /* NavigatorSidebarToolbarTop.swift in Sources */, 28FFE1BF27E3A441001939DB /* NavigatorSidebarToolbarBottom.swift in Sources */, @@ -956,6 +968,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 90626FA527EB2FD1008926FE /* XCRemoteSwiftPackageReference "Preferences" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/sindresorhus/Preferences"; + requirement = { + branch = main; + kind = branch; + }; + }; B65E614427E6765D00255275 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/siteline/SwiftUI-Introspect"; @@ -987,6 +1007,11 @@ isa = XCSwiftPackageProductDependency; productName = GitClient; }; + 90626FA627EB2FD1008926FE /* Preferences */ = { + isa = XCSwiftPackageProductDependency; + package = 90626FA527EB2FD1008926FE /* XCRemoteSwiftPackageReference "Preferences" */; + productName = Preferences; + }; B65E614527E6765D00255275 /* Introspect */ = { isa = XCSwiftPackageProductDependency; package = B65E614427E6765D00255275 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */; diff --git a/CodeEdit.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CodeEdit.xcworkspace/xcshareddata/swiftpm/Package.resolved index 408cdae738..3686a9198d 100644 --- a/CodeEdit.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/CodeEdit.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -3,13 +3,22 @@ "pins": [ { "package": "Highlightr", - "repositoryURL": "https://github.com/raspu/Highlightr.git", + "repositoryURL": "https://github.com/raspu/Highlightr", "state": { "branch": null, "revision": "93199b9e434f04bda956a613af8f571933f9f037", "version": "2.1.2" } }, + { + "package": "Preferences", + "repositoryURL": "https://github.com/sindresorhus/Preferences", + "state": { + "branch": "main", + "revision": "ffeaaad1def45d0625720dc1adae3789cd9c167d", + "version": null + } + }, { "package": "SnapshotTesting", "repositoryURL": "https://github.com/pointfreeco/swift-snapshot-testing.git", diff --git a/CodeEdit/AppDelegate.swift b/CodeEdit/AppDelegate.swift index f68421ace5..454d758d08 100644 --- a/CodeEdit/AppDelegate.swift +++ b/CodeEdit/AppDelegate.swift @@ -6,6 +6,7 @@ // import SwiftUI +import Preferences class CodeEditApplication: NSApplication { let strongDelegate = AppDelegate() @@ -86,27 +87,42 @@ class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject { } // MARK: - Open windows + private lazy var preferencesWindowController = PreferencesWindowController( + panes: [ + Preferences.Pane( + identifier: Preferences.PaneIdentifier.general, + title: "General", + toolbarIcon: NSImage(systemSymbolName: "gearshape", accessibilityDescription: nil)! + ) { + GeneralSettingsView() + }, + Preferences.Pane( + identifier: Preferences.PaneIdentifier.theme, + title: "Theme", + toolbarIcon: NSImage(systemSymbolName: "paintbrush", accessibilityDescription: nil)! + ) { + ThemeSettingsView() + }, + Preferences.Pane( + identifier: Preferences.PaneIdentifier.execution, + title: "Execution", + toolbarIcon: NSImage(systemSymbolName: "arrowtriangle.forward", accessibilityDescription: nil)! + ) { + GeneralSettingsView() + }, + Preferences.Pane( + identifier: Preferences.PaneIdentifier.extension, + title: "Extension", + toolbarIcon: NSImage(systemSymbolName: "shippingbox", accessibilityDescription: nil)! + ) { + GeneralSettingsView() + }, + ] + ) @IBAction func openPreferences(_ sender: Any) { - if let window = NSApp.windows.filter({ window in - return (window.contentView as? NSHostingView) != nil - }).first { - window.makeKeyAndOrderFront(self) - return - } - - let window = NSWindow( - contentRect: NSRect(x: 0, y: 0, width: 500, height: 400), - styleMask: [.titled, .closable], - backing: .buffered, defer: false) - window.center() - window.toolbar = NSToolbar() - window.title = "Settings" - window.toolbarStyle = .unifiedCompact - _ = NSWindowController(window: window) - let contentView = SettingsView() - window.contentView = NSHostingView(rootView: contentView) - window.makeKeyAndOrderFront(sender) + preferencesWindowController.show() + preferencesWindowController.window?.center() } @IBAction func openWelcome(_ sender: Any) { diff --git a/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x-1.png b/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x-1.png new file mode 100644 index 0000000000..4ae190b42e Binary files /dev/null and b/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x-1.png differ diff --git a/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x-2.png b/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x-2.png new file mode 100644 index 0000000000..4ae190b42e Binary files /dev/null and b/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x-2.png differ diff --git a/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x.png b/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x.png new file mode 100644 index 0000000000..4ae190b42e Binary files /dev/null and b/CodeEdit/Assets.xcassets/Agate.imageset/CleanShot 2022-03-23 at 18.58.14@2x.png differ diff --git a/CodeEdit/Assets.xcassets/Agate.imageset/Contents.json b/CodeEdit/Assets.xcassets/Agate.imageset/Contents.json new file mode 100644 index 0000000000..d8daef4ccc --- /dev/null +++ b/CodeEdit/Assets.xcassets/Agate.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "CleanShot 2022-03-23 at 18.58.14@2x-1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.58.14@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.58.14@2x-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x-1.png b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x-1.png new file mode 100644 index 0000000000..c5b787fd1a Binary files /dev/null and b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x-1.png differ diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x-2.png b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x-2.png new file mode 100644 index 0000000000..c5b787fd1a Binary files /dev/null and b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x-2.png differ diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x.png b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x.png new file mode 100644 index 0000000000..c5b787fd1a Binary files /dev/null and b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/CleanShot 2022-03-23 at 18.55.38@2x.png differ diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/Contents.json b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/Contents.json new file mode 100644 index 0000000000..8e6127fda8 --- /dev/null +++ b/CodeEdit/Assets.xcassets/Atelier Savanna Dark.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "CleanShot 2022-03-23 at 18.55.38@2x-1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.55.38@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.55.38@2x-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x-1.png b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x-1.png new file mode 100644 index 0000000000..047fe034cd Binary files /dev/null and b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x-1.png differ diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x-2.png b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x-2.png new file mode 100644 index 0000000000..047fe034cd Binary files /dev/null and b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x-2.png differ diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x.png b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x.png new file mode 100644 index 0000000000..047fe034cd Binary files /dev/null and b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/CleanShot 2022-03-23 at 18.56.54@2x.png differ diff --git a/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/Contents.json b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/Contents.json new file mode 100644 index 0000000000..30acc25968 --- /dev/null +++ b/CodeEdit/Assets.xcassets/Atelier Savanna Light.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "CleanShot 2022-03-23 at 18.56.54@2x-1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.56.54@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.56.54@2x-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x-1.png b/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x-1.png new file mode 100644 index 0000000000..3c8f975f6e Binary files /dev/null and b/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x-1.png differ diff --git a/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x-2.png b/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x-2.png new file mode 100644 index 0000000000..3c8f975f6e Binary files /dev/null and b/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x-2.png differ diff --git a/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x.png b/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x.png new file mode 100644 index 0000000000..3c8f975f6e Binary files /dev/null and b/CodeEdit/Assets.xcassets/Ocean.imageset/CleanShot 2022-03-23 at 18.57.32@2x.png differ diff --git a/CodeEdit/Assets.xcassets/Ocean.imageset/Contents.json b/CodeEdit/Assets.xcassets/Ocean.imageset/Contents.json new file mode 100644 index 0000000000..3aab78fba9 --- /dev/null +++ b/CodeEdit/Assets.xcassets/Ocean.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "CleanShot 2022-03-23 at 18.57.32@2x-1.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.57.32@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "CleanShot 2022-03-23 at 18.57.32@2x-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CodeEdit/Settings/GeneralSettingsView.swift b/CodeEdit/Settings/GeneralSettingsView.swift index dcd89ec5b5..3b8aafaefd 100644 --- a/CodeEdit/Settings/GeneralSettingsView.swift +++ b/CodeEdit/Settings/GeneralSettingsView.swift @@ -32,6 +32,7 @@ struct GeneralSettingsView: View { .onChange(of: appearance) { tag in tag.applyAppearance() } + .fixedSize() Picker("File Icon Style".localized(), selection: $fileIconStyle) { Text("Color".localized()) @@ -39,6 +40,7 @@ struct GeneralSettingsView: View { Text("Monochrome".localized()) .tag(FileIconStyle.monochrome) } + .fixedSize() Picker("Reopen Behavior".localized(), selection: $reopenBehavior) { Text("Welcome Screen".localized()) @@ -49,6 +51,7 @@ struct GeneralSettingsView: View { Text("New Document".localized()) .tag(ReopenBehavior.newDocument) } + .fixedSize() Picker("Editor Theme".localized(), selection: $editorTheme) { Text("Atelier Savanna (Auto)") @@ -57,14 +60,12 @@ struct GeneralSettingsView: View { .tag(CodeFileView.Theme.atelierSavannaDark) Text("Atelier Savanna Light") .tag(CodeFileView.Theme.atelierSavannaLight) - // TODO: Pojoaque does not seem to work (does not change from previous selection) -// Text("Pojoaque") -// .tag(CodeEditor.ThemeName.pojoaque) Text("Agate") .tag(CodeFileView.Theme.agate) Text("Ocean") .tag(CodeFileView.Theme.ocean) } + .fixedSize() Picker("Terminal Shell".localized(), selection: $shellType) { Text("System Default".localized()) @@ -74,7 +75,11 @@ struct GeneralSettingsView: View { Text("Bash") .tag(TerminalShellType.bash) } + .fixedSize() + + Spacer() } + .frame(width: 820, height: 450) .padding() } } diff --git a/CodeEdit/Settings/Models/PreferencesIdentifier.swift b/CodeEdit/Settings/Models/PreferencesIdentifier.swift new file mode 100644 index 0000000000..8e28347fec --- /dev/null +++ b/CodeEdit/Settings/Models/PreferencesIdentifier.swift @@ -0,0 +1,15 @@ +// +// PreferencesIdentifier.swift +// CodeEdit +// +// Created by 朱浩宇 on 2022/3/23. +// + +import Preferences + +extension Preferences.PaneIdentifier { + static let general = Self("general") + static let theme = Self("Theme") + static let execution = Self("execution") + static let `extension` = Self("extension") +} diff --git a/CodeEdit/Settings/Models/Theme.swift b/CodeEdit/Settings/Models/Theme.swift new file mode 100644 index 0000000000..49529ba473 --- /dev/null +++ b/CodeEdit/Settings/Models/Theme.swift @@ -0,0 +1,39 @@ +// +// Theme.swift +// CodeEdit +// +// Created by 朱浩宇 on 2022/3/23. +// + +import SwiftUI +import CodeFile + +/// This is sturct for ThemeSettingsView +struct Themes: Identifiable { + static let all: [Themes] = [ + .init(name: "Atelier Savanna (Auto)", theme: .atelierSavannaAuto, + image: isDarkMode() ? "Atelier Savanna Dark" : "Atelier Savanna Light"), + .init(name: "Atelier Savanna Dark", theme: .atelierSavannaDark, image: "Atelier Savanna Dark"), + .init(name: "Atelier Savanna Light", theme: .atelierSavannaLight, image: "Atelier Savanna Light"), + .init(name: "Agate", theme: .agate, image: "Agate"), + .init(name: "Ocean", theme: .ocean, image: "Ocean") + ] + + let id = UUID() + let name: String + let theme: CodeFileView.Theme + + /// 580 * 310 + let image: Image + + init(name: String, theme: CodeFileView.Theme, image: String) { + self.name = name + self.theme = theme + self.image = Image(image) + } + + /// Tell the appearence + static func isDarkMode() -> Bool { + NSApp.effectiveAppearance.bestMatch(from: [.darkAqua, .aqua]) == .darkAqua + } +} diff --git a/CodeEdit/Settings/SettingsView.swift b/CodeEdit/Settings/SettingsView.swift deleted file mode 100644 index 6549f479a9..0000000000 --- a/CodeEdit/Settings/SettingsView.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// SettingsView.swift -// CodeEdit -// -// Created by Pavel Kasila on 11.03.22. -// - -import SwiftUI - -struct SettingsView: View { - var body: some View { - TabView { - GeneralSettingsView() - .tabItem { - Label("General".localized(), systemImage: "gearshape") - } - } - .padding() - .frame(width: 450, height: 250) - } -} - -struct SettingsView_Previews: PreviewProvider { - static var previews: some View { - SettingsView() - } -} diff --git a/CodeEdit/Settings/ThemeSettingsView.swift b/CodeEdit/Settings/ThemeSettingsView.swift new file mode 100644 index 0000000000..d9ea37ad53 --- /dev/null +++ b/CodeEdit/Settings/ThemeSettingsView.swift @@ -0,0 +1,44 @@ +// +// ThemeSettingsView.swift +// CodeEdit +// +// Created by 朱浩宇 on 2022/3/23. +// + +import SwiftUI + +struct ThemeSettingsView: View { + let gridRule = [GridItem](repeating: GridItem(.flexible(), alignment: .top), count: 5) + + var body: some View { + ScrollView { + LazyVGrid(columns: gridRule) { + ForEach(Themes.all) { themeItem in + VStack { + VStack { + themeItem.image + .resizable() + .frame(width: 116, height: 62) + .scaledToFit() + .border(Color.secondary, width: 1.5) + .cornerRadius(3) + + Text(themeItem.name) + .multilineTextAlignment(.center) + } + .padding() + } + .padding() + } + } + } + .frame(width: 820, height: 450) + .padding() + } +} + +struct ThemeSettingsView_Previews: PreviewProvider { + static var previews: some View { + ThemeSettingsView() + } +}