Skip to content

Commit

Permalink
Update SettingsMainView layout
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Jan 21, 2025
1 parent 8e12afd commit 5767cf7
Showing 1 changed file with 28 additions and 38 deletions.
66 changes: 28 additions & 38 deletions src/ShowyEdge/swift/Views/Settings/SettingsMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,73 +50,63 @@ struct SettingsMainView: View {

GroupBox(label: Text("Color")) {
VStack(alignment: .leading, spacing: 10.0) {
List($userSettings.customizedLanguageColors) { $languageColor in
VStack(spacing: 4) {
VStack(spacing: 4) {
HStack(spacing: 0) {
ScrollView {
Grid(alignment: .leading) {
ForEach($userSettings.customizedLanguageColors) { $languageColor in
GridRow {
Text(languageColor.inputSourceID)
.truncationMode(.tail)
.lineLimit(1)
.fixedSize(horizontal: false, vertical: true)
.if(languageColor.inputSourceID == workspaceData.currentInputSourceID) {
$0.foregroundColor(.accentColor)
}

Spacer()

Button(
action: {
userSettings.removeCustomizedLanguageColor(
languageColor.inputSourceID
)
},
label: {
Label("Delete", systemImage: "xmark")
})
}

HStack(spacing: 0) {
ColorPicker("color 1", selection: $languageColor.colors.0)
.frame(width: 60)
//.frame(width: 50)
.labelsHidden()

ColorPicker("color 2", selection: $languageColor.colors.1)
.frame(width: 60)
//.frame(width: 50)
.labelsHidden()

ColorPicker("color 3", selection: $languageColor.colors.2)
.frame(width: 60)
//.frame(width: 50)
.labelsHidden()

Spacer()

Button(
role: .destructive,
action: {
userSettings.removeCustomizedLanguageColor(
languageColor.inputSourceID
)
},
label: {
Label("Delete", systemImage: "trash")
.labelStyle(.iconOnly)
.foregroundColor(.red)
}
)
}
.padding(.leading, 20.0)
}
.padding(10)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(
Color(NSColor.selectedControlColor),
lineWidth: languageColor.inputSourceID == workspaceData.currentInputSourceID
? 3 : 0
)
.padding(2)
)

Divider()
}
}
.frame(height: 200)

Button(
action: {
userSettings.appendCustomizedLanguageColor(workspaceData.currentInputSourceID)
},
label: {
Label(
"Add custom color of \(workspaceData.currentInputSourceID)", systemImage: "plus")
"Add \(workspaceData.currentInputSourceID)", systemImage: "plus")
}
).disabled(
userSettings.customizedLanguageColor(inputSourceID: workspaceData.currentInputSourceID)
!= nil
)
}.padding()
}
}.padding()
}
}
}

0 comments on commit 5767cf7

Please sign in to comment.