Skip to content

Commit

Permalink
Can reset recommended settings notice
Browse files Browse the repository at this point in the history
  • Loading branch information
halo committed Feb 23, 2024
1 parent 04db26a commit 958c56f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
8 changes: 6 additions & 2 deletions LinkLiar/Classes/Config/Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,15 @@ extension Config {

// MARK: General Settings

func dismissRecommendedSettings() -> [String: Any] {
func resetRecommendedSettings() -> [String: Any] {
var dictionary = configDictionary
dictionary.removeValue(forKey: Config.Key.recommendation.rawValue)
return dictionary
}

func dismissRecommendedSettings() -> [String: Any] {
var dictionary = configDictionary
dictionary[Config.Key.recommendation.rawValue] = false

return dictionary
}

Expand Down
10 changes: 10 additions & 0 deletions LinkLiar/Classes/Config/Writer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,19 @@ extension Config {
setFallbackInterfaceAction(.random)
}

denyRerandomization()
removeAllVendors()
}

func resetRecommendedSettings() {
var newDictionary = Config.Builder(state.configDictionary).resetRecommendedSettings()

newDictionary[Config.Key.version.rawValue] = state.version.formatted
if JSONWriter(Paths.configFile).write(newDictionary) {
state.configDictionary = newDictionary
}
}

func dismissRecommendedSettings() {
var newDictionary = Config.Builder(state.configDictionary).dismissRecommendedSettings()

Expand Down
1 change: 1 addition & 0 deletions LinkLiar/Views/Settings/Sections/CommunityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension SettingsView {
VStack(alignment: .center) {
Image(systemName: "bubble.left.and.bubble.right.fill")
.resizable()
.symbolRenderingMode(.hierarchical)
.aspectRatio(contentMode: .fill)
.frame(width: 60, height: 60)
.padding(.bottom, 3)
Expand Down
9 changes: 6 additions & 3 deletions LinkLiar/Views/Settings/Sections/FaqView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension SettingsView {
HStack {
Text("""
You original hardware MAC address will be revealed when you cold boot your computer and Wi-Fi \
is turned on. MAC address modifications do persist when sleeping and waking your computer, however.
is turned on. However, MAC address modifications do persist when sleeping and waking your computer.
""")
Spacer()
}
Expand All @@ -43,15 +43,18 @@ extension SettingsView {
HStack {
Text("""
The MAC address of an interface cannot be modified while connected to a Wi-Fi network. \
That's why LinkLiar will disassociate from any connected network before modifying the MAC address.
That's why LinkLiar will disassociate from any connected network before attempting to modify the MAC address.
""")
Spacer()
}
}).padding(.bottom)

GroupBox("Wi-Fi needs to be on for MAC modification.", content: {
HStack {
Text("When your Wi-Fi (aka Airport) is turned off, you cannot change its MAC address. You might need to turn it on first.")
Text("""
"When your Wi-Fi (aka Airport) is turned off, you cannot change its MAC address. \
You might need to turn it on first.
""")
Spacer()
}
}).padding(.bottom)
Expand Down
33 changes: 33 additions & 0 deletions LinkLiar/Views/Settings/Sections/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,39 @@ extension SettingsView {
}.padding(4)
}

GroupBox {
HStack(alignment: .top) {
let warnOnIdleSettings = Binding<Bool>(
get: { !state.config.general.isDismissingRecommendation },
set: { value, _ in
value ? Config.Writer(state).resetRecommendedSettings() :
Config.Writer(state).dismissRecommendedSettings()
}
)

VStack(alignment: .leading, spacing: 3) {
Text("Warn about no-op configuration")
if warnOnIdleSettings.wrappedValue {
Text("""
If LinkLiar is configured to not do anything, warn about that.
""")
.font(.caption)
.foregroundColor(.secondary)
} else {
Text("""
Don't notify about settings that have no effect.
""")
.font(.caption)
.foregroundColor(.secondary)
}
}
Spacer()
Toggle(isOn: warnOnIdleSettings) {}
.toggleStyle(.switch)
.controlSize(.small)
}.padding(4)
}

}.padding()
}
}
Expand Down
1 change: 1 addition & 0 deletions LinkLiar/Views/Settings/Sections/WelcomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extension SettingsView {
VStack(alignment: .center) {
Image(systemName: "hands.and.sparkles.fill")
.resizable()
.symbolRenderingMode(.hierarchical)
.aspectRatio(contentMode: .fill)
.frame(width: 60, height: 60)
.padding(.bottom, 3)
Expand Down

0 comments on commit 958c56f

Please sign in to comment.