Skip to content

Commit

Permalink
Add add new rule button
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Sep 10, 2023
1 parent 5c95cc7 commit c1bf752
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ struct ComplexModificationsEditView: View {

Button(
action: {
errorMessage = settings.replaceComplexModificationsRule(rule!, jsonString)
if errorMessage == nil {
showing = false
if rule!.index < 0 {
errorMessage = settings.pushFrontComplexModificationsRule(jsonString)
if errorMessage == nil {
showing = false
}
} else {
errorMessage = settings.replaceComplexModificationsRule(rule!, jsonString)
if errorMessage == nil {
showing = false
}
}
},
label: {
Expand Down Expand Up @@ -80,7 +87,6 @@ struct ComplexModificationsEditView: View {
}
.padding()
.frame(width: 1000, height: 600)

.onAppear {
description = rule?.description ?? ""

Expand Down
13 changes: 13 additions & 0 deletions src/apps/SettingsWindow/src/View/ComplexModificationsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ struct ComplexModificationsView: View {
AccentColorIconLabel(title: "Add predefined rule", systemImage: "plus.circle.fill")
})

Button(
action: {
var buffer = [Int8](repeating: 0, count: 1024)
libkrbn_core_configuration_get_new_complex_modifications_rule_json_string(
&buffer, buffer.count)

editingRule = LibKrbn.ComplexModificationsRule(-1, "New rule", String(cString: buffer))
showingEditSheet = true
},
label: {
AccentColorIconLabel(title: "Add new rule", systemImage: "pencil.circle.fill")
})

Spacer()

if settings.complexModificationsRules.count > 1 {
Expand Down

0 comments on commit c1bf752

Please sign in to comment.