diff --git a/CodeEdit.xcodeproj/project.pbxproj b/CodeEdit.xcodeproj/project.pbxproj index a39171efc..41407c0ef 100644 --- a/CodeEdit.xcodeproj/project.pbxproj +++ b/CodeEdit.xcodeproj/project.pbxproj @@ -319,6 +319,7 @@ 617DB3DA2C25B07F00B58BFE /* TaskNotificationsDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3D92C25B07F00B58BFE /* TaskNotificationsDetailView.swift */; }; 617DB3DC2C25B14A00B58BFE /* ActivityViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3DB2C25B14A00B58BFE /* ActivityViewer.swift */; }; 617DB3DF2C25E13800B58BFE /* TaskNotificationHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 617DB3DE2C25E13800B58BFE /* TaskNotificationHandlerTests.swift */; }; + 61816B832C81DC2C00C71BF7 /* ThemeSearchField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61816B822C81DC2C00C71BF7 /* ThemeSearchField.swift */; }; 618725A12C29EFCC00987354 /* SchemeDropDownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618725A02C29EFCC00987354 /* SchemeDropDownView.swift */; }; 618725A42C29F00400987354 /* WorkspaceMenuItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618725A32C29F00400987354 /* WorkspaceMenuItemView.swift */; }; 618725A62C29F02500987354 /* DropdownMenuItemStyleModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 618725A52C29F02500987354 /* DropdownMenuItemStyleModifier.swift */; }; @@ -978,6 +979,7 @@ 617DB3D92C25B07F00B58BFE /* TaskNotificationsDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskNotificationsDetailView.swift; sourceTree = ""; }; 617DB3DB2C25B14A00B58BFE /* ActivityViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityViewer.swift; sourceTree = ""; }; 617DB3DE2C25E13800B58BFE /* TaskNotificationHandlerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskNotificationHandlerTests.swift; sourceTree = ""; }; + 61816B822C81DC2C00C71BF7 /* ThemeSearchField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeSearchField.swift; sourceTree = ""; }; 618725A02C29EFCC00987354 /* SchemeDropDownView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchemeDropDownView.swift; sourceTree = ""; }; 618725A32C29F00400987354 /* WorkspaceMenuItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceMenuItemView.swift; sourceTree = ""; }; 618725A52C29F02500987354 /* DropdownMenuItemStyleModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropdownMenuItemStyleModifier.swift; sourceTree = ""; }; @@ -2469,6 +2471,7 @@ children = ( B6F0518D29DA29F900D72287 /* Models */, 58F2EAAF292FB2B0004A9BDE /* ThemeSettingsView.swift */, + 61816B822C81DC2C00C71BF7 /* ThemeSearchField.swift */, B6EA1FF729DB78DB001BF195 /* ThemeSettingThemeRow.swift */, B6EA1FFA29DB78F6001BF195 /* ThemeSettingsThemeDetails.swift */, B6EA1FFC29DB792C001BF195 /* ThemeSettingsColorPreview.swift */, @@ -4252,6 +4255,7 @@ 6C97EBCC2978760400302F95 /* AcknowledgementsWindowController.swift in Sources */, 284DC84F2978B7B400BF2770 /* ContributorsView.swift in Sources */, B62AEDC92A2704F3009A9F52 /* UtilityAreaTabView.swift in Sources */, + 61816B832C81DC2C00C71BF7 /* ThemeSearchField.swift in Sources */, 30B088052C0D53080063A882 /* LanguageServer+DocumentLink.swift in Sources */, 58798250292E78D80085B254 /* CodeFileDocument.swift in Sources */, 5878DAA5291AE76700DD95A3 /* OpenQuicklyView.swift in Sources */, diff --git a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSearchField.swift b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSearchField.swift new file mode 100644 index 000000000..2df783925 --- /dev/null +++ b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSearchField.swift @@ -0,0 +1,58 @@ +// +// ThemeSearchField.swift +// CodeEdit +// +// Created by Tommy Ludwig on 30.08.24. +// + +import SwiftUI + +struct ThemeSearchField: View { + @Binding var themeSearchQuery: String + var body: some View { + VStack { + HStack(alignment: .top) { + Image(systemName: "magnifyingglass") + .padding(.leading, 2) + .padding(.trailing, -7) + + TextField("", text: $themeSearchQuery) + .textFieldStyle(PlainTextFieldStyle()) + .multilineTextAlignment(.leading) + .overlay { + HStack { + Text("Search") + .foregroundStyle(.secondary) + .opacity(themeSearchQuery.isEmpty ? 1 : 0) + .padding(.leading, 6.5) + + Spacer() + } + } + } + .padding(3) + .overlay( + RoundedRectangle(cornerRadius: 5) + .foregroundStyle(.secondary) +// .blendMode(.overlay) + .blendMode(.difference) + .opacity(0.1) + ) + .overlay { + RoundedRectangle(cornerRadius: 5) + .stroke(Color.gray, lineWidth: 1) + .foregroundStyle(.secondary) + .opacity(0.2) + } +// TextField(text: $themeSearchQuery, prompt: Text("Search")) { +// Label("Test", systemImage: "magnifyingglass") +// } +// .textFieldStyle(.roundedBorder) +// .padding() + } + } +} + +#Preview { + ThemeSearchField(themeSearchQuery: .constant("Test")) +} diff --git a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift index 1f4c075e0..c6ccfb0d8 100644 --- a/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift +++ b/CodeEdit/Features/Settings/Pages/ThemeSettings/ThemeSettingsView.swift @@ -22,85 +22,113 @@ struct ThemeSettingsView: View { @State private var filteredThemes: [Theme] = [] var body: some View { - SettingsForm { - Section { - changeThemeOnSystemAppearance - if settings.matchAppearance { - alwaysUseDarkTerminalAppearance - } - useThemeBackground - } - Section { - VStack(spacing: 0) { - HStack { - TextField("Search Themes", text: $themeSearchQuery) - .textFieldStyle(.roundedBorder) + VStack { + Form { + Form { + Section { + HStack { + ThemeSearchField(themeSearchQuery: $themeSearchQuery) + + Button { - Button { - withAnimation { - themeModel.selectedAppearance = themeModel.selectedAppearance == .dark ? .light : .dark + } label: { + Image(systemName: "plus") + } + + Button { + + } label: { + Image(systemName: "ellipsis") } - } label: { -// Image(systemName: "arrow.up.arrow.down") -// .rotationEffect(.degrees(themeModel.selectedAppearance == .dark ? 0 : 180)) -// .animation(.easeInOut, value: themeModel.selectedAppearance) - Image( - systemName: themeModel.selectedAppearance == .dark ? - "moon.circle.fill" : "sun.max.circle" - ).font(.title2) } - .buttonStyle(.icon) } - .padding(10) - .padding(.leading, 10) + } + .formStyle(.columns) - VStack(spacing: 0) { - ForEach(filteredThemes) { theme in - Divider().padding(.horizontal, 10) - ThemeSettingsThemeRow( - theme: $themeModel.themes[themeModel.themes.firstIndex(of: theme)!], - active: themeModel.getThemeActive(theme) - ).id(theme) + if themeSearchQuery.isEmpty { + Section { + changeThemeOnSystemAppearance + if settings.matchAppearance { + alwaysUseDarkTerminalAppearance } + useThemeBackground } } - .padding(-10) - } footer: { - HStack { - Spacer() - Button("Import...") { - themeModel.importTheme() + + Section { + VStack(spacing: 0) { + // HStack { + // TextField("Search Themes", text: $themeSearchQuery) + // .textFieldStyle(.roundedBorder) + // + // Button { + // withAnimation { + // themeModel.selectedAppearance = themeModel.selectedAppearance == .dark ? .light : .dark + // } + // } label: { + //// Image(systemName: "arrow.up.arrow.down") + //// .rotationEffect(.degrees(themeModel.selectedAppearance == .dark ? 0 : 180)) + //// .animation(.easeInOut, value: themeModel.selectedAppearance) + // Image( + // systemName: themeModel.selectedAppearance == .dark ? + // "moon.circle.fill" : "sun.max.circle" + // ).font(.title2) + // } + // .buttonStyle(.icon) + // } + // .padding(10) + // .padding(.leading, 10) + + VStack(spacing: 0) { + ForEach(filteredThemes) { theme in + Divider().padding(.horizontal, 10) + ThemeSettingsThemeRow( + theme: $themeModel.themes[themeModel.themes.firstIndex(of: theme)!], + active: themeModel.getThemeActive(theme) + ).id(theme) + } + } } - } - .padding(.top, 10) - } - } - .sheet(item: $themeModel.detailsTheme) { - themeModel.isAdding = false - } content: { theme in - if let index = themeModel.themes.firstIndex(where: { - $0.fileURL?.absoluteString == theme.fileURL?.absoluteString - }) { - ThemeSettingsThemeDetails(theme: Binding( - get: { themeModel.themes[index] }, - set: { newValue in - themeModel.themes[index] = newValue - themeModel.save(newValue) - if settings.selectedTheme == theme.name { - themeModel.activateTheme(newValue) + .padding(-10) + } footer: { + HStack { + Spacer() + Button("Import...") { + themeModel.importTheme() } } - )) + .padding(.top, 10) + } + .sheet(item: $themeModel.detailsTheme) { + themeModel.isAdding = false + } content: { theme in + if let index = themeModel.themes.firstIndex(where: { + $0.fileURL?.absoluteString == theme.fileURL?.absoluteString + }) { + ThemeSettingsThemeDetails(theme: Binding( + get: { themeModel.themes[index] }, + set: { newValue in + themeModel.themes[index] = newValue + themeModel.save(newValue) + if settings.selectedTheme == theme.name { + themeModel.activateTheme(newValue) + } + } + )) + } + } + .onAppear { + updateFilteredThemes() + } + .onChange(of: themeSearchQuery) { _ in + updateFilteredThemes() + } + .onChange(of: themeModel.selectedAppearance) { _ in + updateFilteredThemes() + } + } - } - .onAppear { - updateFilteredThemes() - } - .onChange(of: themeSearchQuery) { _ in - updateFilteredThemes() - } - .onChange(of: themeModel.selectedAppearance) { _ in - updateFilteredThemes() + .formStyle(.grouped) } }