Skip to content

Commit 1c2924e

Browse files
committed
some refactor
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent 77ec2e3 commit 1c2924e

File tree

17 files changed

+121
-138
lines changed

17 files changed

+121
-138
lines changed

TrollFools.xcodeproj/project.pbxproj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
CC15490C2C4B79D800A4173E /* optool in Resources */ = {isa = PBXBuildFile; fileRef = CC15490B2C4B79D800A4173E /* optool */; };
3636
CC15490E2C4B80AF00A4173E /* EjectListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC15490D2C4B80AF00A4173E /* EjectListView.swift */; };
3737
CC19E4BB2C561D7300E0F1B5 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC19E4BA2C561D7300E0F1B5 /* SettingsView.swift */; };
38-
CC3485172C71B219007E0E28 /* Version.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = CC3485152C71B219007E0E28 /* Version.xcconfig */; };
39-
CC3485182C71B219007E0E28 /* Version.Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */; };
4038
CC5E54BE2C4E12F900FDE4A8 /* install_name_tool in Resources */ = {isa = PBXBuildFile; fileRef = CC5E54BC2C4E12F900FDE4A8 /* install_name_tool */; };
4139
CC5E54BF2C4E131000FDE4A8 /* libxar.1.dylib in Resources */ = {isa = PBXBuildFile; fileRef = CC5E54BB2C4E12F900FDE4A8 /* libxar.1.dylib */; };
4240
CC60FBEC2CC50F5A00A6D21A /* BartyCrouch.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC60FBEB2CC50F5A00A6D21A /* BartyCrouch.swift */; };
@@ -304,7 +302,7 @@
304302
attributes = {
305303
BuildIndependentTargetsInParallel = 1;
306304
LastSwiftUpdateCheck = 1500;
307-
LastUpgradeCheck = 1540;
305+
LastUpgradeCheck = 1620;
308306
TargetAttributes = {
309307
CCF470552C4A4649008D8197 = {
310308
CreatedOnToolsVersion = 15.0.1;
@@ -355,13 +353,11 @@
355353
CC15490C2C4B79D800A4173E /* optool in Resources */,
356354
CCC564EC2C4BE8470097C300 /* libcrypto.3.dylib in Resources */,
357355
CC1548E62C4A974E00A4173E /* libintl.8.dylib in Resources */,
358-
CC3485172C71B219007E0E28 /* Version.xcconfig in Resources */,
359356
CC1548E72C4A974E00A4173E /* libiosexec.1.dylib in Resources */,
360357
CCC564ED2C4BE8470097C300 /* libplist-2.0.3.dylib in Resources */,
361358
CC5E54BF2C4E131000FDE4A8 /* libxar.1.dylib in Resources */,
362359
CC61A87C2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip in Resources */,
363360
CCF4705E2C4A464B008D8197 /* Assets.xcassets in Resources */,
364-
CC3485182C71B219007E0E28 /* Version.Debug.xcconfig in Resources */,
365361
CCF470692C4A4919008D8197 /* Localizable.strings in Resources */,
366362
);
367363
runOnlyForDeploymentPostprocessing = 0;
@@ -660,10 +656,10 @@
660656
};
661657
CC1548FA2C4AADBB00A4173E /* XCRemoteSwiftPackageReference "MachOKit" */ = {
662658
isa = XCRemoteSwiftPackageReference;
663-
repositoryURL = "https://github.com/p-x9/MachOKit.git";
659+
repositoryURL = "https://github.com/Lessica/MachOKit.git";
664660
requirement = {
665-
kind = upToNextMajorVersion;
666-
minimumVersion = 0.19.0;
661+
branch = patch/trollfools;
662+
kind = branch;
667663
};
668664
};
669665
/* End XCRemoteSwiftPackageReference section */

TrollFools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

TrollFools/App.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ final class App: Identifiable, ObservableObject {
2828
lazy var isFromTroll: Bool = isSystem && !isFromApple
2929
lazy var isRemovable: Bool = url.path.contains("/var/containers/Bundle/Application/")
3030

31+
weak var appList: AppListModel?
32+
3133
init(
3234
id: String,
3335
name: String,

TrollFools/AppListCell.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@
88
import SwiftUI
99

1010
struct AppListCell: View {
11-
@EnvironmentObject var vm: AppListModel
12-
@EnvironmentObject var filter: FilterOptions
11+
@EnvironmentObject var appList: AppListModel
1312

1413
@StateObject var app: App
1514

1615
@available(iOS 15.0, *)
1716
var highlightedName: AttributedString {
1817
let name = app.name
1918
var attributedString = AttributedString(name)
20-
if let range = attributedString.range(of: filter.searchKeyword, options: [.caseInsensitive, .diacriticInsensitive]) {
19+
if let range = attributedString.range(of: appList.filter.searchKeyword, options: [.caseInsensitive, .diacriticInsensitive]) {
2120
attributedString[range].foregroundColor = .accentColor
2221
}
2322
return attributedString
@@ -27,7 +26,7 @@ struct AppListCell: View {
2726
var highlightedId: AttributedString {
2827
let id = app.id
2928
var attributedString = AttributedString(id)
30-
if let range = attributedString.range(of: filter.searchKeyword, options: [.caseInsensitive, .diacriticInsensitive]) {
29+
if let range = attributedString.range(of: appList.filter.searchKeyword, options: [.caseInsensitive, .diacriticInsensitive]) {
3130
attributedString[range].foregroundColor = .accentColor
3231
}
3332
return attributedString
@@ -41,13 +40,16 @@ struct AppListCell: View {
4140
Label(NSLocalizedString("Launch", comment: ""), systemImage: "command")
4241
}
4342

44-
if isFilzaInstalled {
45-
Button {
46-
openInFilza()
47-
} label: {
43+
Button {
44+
openInFilza()
45+
} label: {
46+
if isFilzaInstalled {
4847
Label(NSLocalizedString("Show in Filza", comment: ""), systemImage: "scope")
48+
} else {
49+
Label(NSLocalizedString("Filza (URL Scheme) Not Installed", comment: ""), systemImage: "xmark.octagon")
4950
}
5051
}
52+
.disabled(!isFilzaInstalled)
5153

5254
if AppListModel.hasTrollStore && app.isAllowedToAttachOrDetach {
5355
if app.isDetached {
@@ -57,7 +59,7 @@ struct AppListCell: View {
5759
try injector.setDetached(false)
5860
withAnimation {
5961
app.reload()
60-
vm.isRebuildNeeded = true
62+
appList.isRebuildNeeded = true
6163
}
6264
} catch { NSLog("\(error.localizedDescription)") }
6365
} label: {
@@ -70,7 +72,7 @@ struct AppListCell: View {
7072
try injector.setDetached(true)
7173
withAnimation {
7274
app.reload()
73-
vm.isRebuildNeeded = true
75+
appList.isRebuildNeeded = true
7476
}
7577
} catch { NSLog("\(error.localizedDescription)") }
7678
} label: {
@@ -102,7 +104,7 @@ struct AppListCell: View {
102104
// iOS 15
103105
Color.clear
104106
.contextMenu {
105-
if !vm.isSelectorMode {
107+
if !appList.isSelectorMode {
106108
cellContextMenu
107109
}
108110
}
@@ -172,7 +174,7 @@ struct AppListCell: View {
172174
}
173175
}
174176
.contextMenu {
175-
if !vm.isSelectorMode {
177+
if !appList.isSelectorMode {
176178
cellContextMenuWrapper
177179
}
178180
}
@@ -183,9 +185,9 @@ struct AppListCell: View {
183185
LSApplicationWorkspace.default().openApplication(withBundleID: app.id)
184186
}
185187

186-
var isFilzaInstalled: Bool { vm.isFilzaInstalled }
188+
var isFilzaInstalled: Bool { appList.isFilzaInstalled }
187189

188190
private func openInFilza() {
189-
vm.openInFilza(app.url)
191+
appList.openInFilza(app.url)
190192
}
191193
}

TrollFools/AppListModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ final class AppListModel: ObservableObject {
3636
self.selectorURL = selectorURL
3737
reload()
3838

39-
filter.$searchKeyword
40-
.combineLatest(filter.$showPatchedOnly)
39+
$filter
4140
.throttle(for: 0.5, scheduler: DispatchQueue.main, latest: true)
4241
.sink { [weak self] _ in
4342
withAnimation {
@@ -71,6 +70,7 @@ final class AppListModel: ObservableObject {
7170

7271
func reload() {
7372
let allApplications = Self.fetchApplications(&hasTrollRecorder, &unsupportedCount)
73+
allApplications.forEach { $0.appList = self }
7474
self._allApplications = allApplications
7575
if let filzaURL {
7676
self.isFilzaInstalled = UIApplication.shared.canOpenURL(filzaURL)

0 commit comments

Comments
 (0)