Fix Cowabunga Tweaks UI#257
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the “SB Customizer” (SpringBoard Tools) UI/flow under Tweaks, primarily by refactoring the SpringBoard customizer view and wiring it to the shared laramgr so it can trigger actions like respring.
Changes:
- Pass
mgrintoSpringBoardViewfromTweaksView. - Rebuild
SpringBoardViewfrom a custom grid/card UI into aNavigationStack+ListUI with per-option segmented selection and (when applicable) color/blur controls. - Update apply/reset behavior and show an alert with an optional respring action after applying.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lara/views/tweaks/TweaksView.swift |
Routes “SB Customizer” to SpringBoardView(mgr: mgr) so the view can use shared manager actions. |
lara/views/tweaks/sbcustomizer/SpringBoardView.swift |
Refactors the SpringBoard Tools UI and refactors tweak application/overwrite logic into the view. |
Comments suppressed due to low confidence (3)
lara/views/tweaks/sbcustomizer/SpringBoardView.swift:162
load()updatestweakOptions[i].value, but the subsequent conditional checksoption.valuefrom the pre-mutation copy in the loop. This can cause color/blur state not to load when the stored value is "Color". UsetweakOptions[i].value/tweakOptions[i].selectedOptionfor the check (or compute the updated value once and reuse it).
for (i, option) in tweakOptions.enumerated() {
tweakOptions[i].value = getDefaultStr(forKey: option.key)
tweakOptions[i].selectedOption = tweakOptions[i].value
if option.sbType != nil {
if option.value == "Color" {
tweakOptions[i].color = SpringboardColorManager.getColor(forType: option.sbType!)
tweakOptions[i].blur = SpringboardColorManager.getBlur(forType: option.sbType!)
}
lara/views/tweaks/sbcustomizer/SpringBoardView.swift:286
overwriteFilereturnstruefrom inside thefor path in ...loop, so only the first replacement path is processed and thesucceededaggregation is effectively bypassed. Remove the early return and instead iterate all paths, updatingsucceededbased on each overwrite result, and return only after the loop completes.
if replacementPaths[fileIdentifier] != nil {
var succeeded = true
for path in replacementPaths[fileIdentifier]! {
if fileIdentifier == "HomeBar" && value as? Bool == false {
if let url: URL = Bundle.main.url(forResource: "HomeBarAssets", withExtension: "car") {
do {
let replacementCar = try Data(contentsOf: url)
//try MDC.overwriteFile(at: "/System/Library/PrivateFrameworks/" + path, with: replacementCar)
} catch {
print(error.localizedDescription)
succeeded = false
}
} else {
print("Home bar file not found!")
return false
}
} else {
let randomGarbage = Data("###".utf8)
let result = laramgr.shared.lara_overwritefile(target: "/System/Library/PrivateFrameworks/" + path, data: randomGarbage)
if result.ok {
print("i hope it worked")
} else {
print("it didn't")
}
return true
}
lara/views/tweaks/sbcustomizer/SpringBoardView.swift:286
- The overwrite result is not used to determine success: even when
result.okis false, the function still returnstrueand does not setsucceeded = false. Please propagateresult.okintosucceeded(and avoid reporting success on failure).
let result = laramgr.shared.lara_overwritefile(target: "/System/Library/PrivateFrameworks/" + path, data: randomGarbage)
if result.ok {
print("i hope it worked")
} else {
print("it didn't")
}
return true
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if succeeded { | ||
| print("Successfully applied tweak \"" + option.title + "\"") | ||
| } else { | ||
| print("Failed to apply tweak \"" + option.title + "\"!!!") |
Comment on lines
+256
to
293
| if typeOfFile == OverwritingFileTypes.springboard { | ||
| // springboard tweak being applied | ||
| if replacementPaths[fileIdentifier] != nil { | ||
| var succeeded = true | ||
| for path in replacementPaths[fileIdentifier]! { | ||
| if fileIdentifier == "HomeBar" && value as? Bool == false { | ||
| if let url: URL = Bundle.main.url(forResource: "HomeBarAssets", withExtension: "car") { | ||
| do { | ||
| let replacementCar = try Data(contentsOf: url) | ||
| //try MDC.overwriteFile(at: "/System/Library/PrivateFrameworks/" + path, with: replacementCar) | ||
| } catch { | ||
| print(error.localizedDescription) | ||
| succeeded = false | ||
| } | ||
| } else { | ||
| print("Home bar file not found!") | ||
| return false | ||
| } | ||
| HStack { | ||
| Text("Blur: \(Int(option.blur))") | ||
| .frame(width: 125) | ||
| Spacer() | ||
| Slider(value: $option.blur, in: 0...150, step: 1.0) | ||
| .padding(.horizontal) | ||
| } | ||
| } | ||
|
|
||
| // MARK: Disabled Text | ||
| } else if option.selectedOption == "Disabled" { | ||
| Image(systemName: "x.circle") | ||
| .foregroundColor(.red) | ||
| .font(.system(size: 40)) | ||
| } | ||
|
|
||
| Spacer() | ||
|
|
||
| Button(action: { | ||
| // save | ||
| UserDefaults.standard.set(option.selectedOption, forKey: option.key) | ||
| option.value = option.selectedOption | ||
| if option.selectedOption == "Color" || option.selectedOption == "Blur" { | ||
| do { | ||
| try SpringboardColorManager.createColor(forType: option.sbType!, color: CIColor(color: UIColor(option.color)), blur: Int(option.blur), asTemp: false) | ||
| print("Success") | ||
| } catch { | ||
| print(error.localizedDescription) | ||
| } | ||
| } | ||
|
|
||
| // close menu | ||
| if flippedOption!.title == option.title { | ||
| withAnimation(Animation.easeInOut(duration: CardAnimationSpeed)) { | ||
| flippedOption = nil | ||
| option.animate3d.toggle() | ||
| } else { | ||
| let randomGarbage = Data("###".utf8) | ||
|
|
||
| let result = laramgr.shared.lara_overwritefile(target: "/System/Library/PrivateFrameworks/" + path, data: randomGarbage) | ||
|
|
||
| if result.ok { | ||
| print("i hope it worked") | ||
| } else { | ||
| print("it didn't") | ||
| } | ||
|
|
||
| return true | ||
| } | ||
| }) { | ||
| Text("Save") | ||
| } | ||
| //.buttonStyle(TintedButton(color: .blue, fullwidth: true)) | ||
| .padding(25) | ||
| return succeeded | ||
| } | ||
| .background(Color(.secondarySystemBackground)) | ||
| .cornerRadius(10) | ||
| } | ||
|
|
||
| return true | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
Yeah it's not perfect, but at least it's usable now. Kinda needs a rewrite... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the buggy leminware.