Skip to content

Commit 7b539a4

Browse files
committed
feat: use app list vm as env obj
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent 77a6996 commit 7b539a4

File tree

10 files changed

+52
-38
lines changed

10 files changed

+52
-38
lines changed

TrollFools.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
CC3485162C71B219007E0E28 /* Version.Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Version.Debug.xcconfig; sourceTree = "<group>"; };
7474
CC5E54BB2C4E12F900FDE4A8 /* libxar.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libxar.1.dylib; sourceTree = "<group>"; };
7575
CC5E54BC2C4E12F900FDE4A8 /* install_name_tool */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; path = install_name_tool; sourceTree = "<group>"; };
76+
CC60FBE92CC4E6C400A6D21A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
7677
CC61A87B2C4A677B003BD9A0 /* CydiaSubstrate.framework.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = CydiaSubstrate.framework.zip; sourceTree = "<group>"; };
7778
CCB6A1162C4A540F000D75B0 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
7879
CCB6A1182C4A58C7000D75B0 /* OptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionView.swift; sourceTree = "<group>"; };
@@ -174,6 +175,7 @@
174175
CCF470582C4A4649008D8197 /* TrollFools */ = {
175176
isa = PBXGroup;
176177
children = (
178+
CC60FBE92CC4E6C400A6D21A /* Info.plist */,
177179
CCF5A0A12C4D417F0097D48D /* main.swift */,
178180
CCF470592C4A4649008D8197 /* TrollFoolsApp.swift */,
179181
CCF4706D2C4A4BAB008D8197 /* AppListView.swift */,
@@ -466,13 +468,15 @@
466468
DEVELOPMENT_TEAM = GXZ23M5TP2;
467469
ENABLE_PREVIEWS = NO;
468470
GENERATE_INFOPLIST_FILE = YES;
471+
INFOPLIST_FILE = TrollFools/Info.plist;
469472
INFOPLIST_KEY_CFBundleDisplayName = TrollFools;
470473
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
471474
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
472475
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
473476
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
474477
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
475478
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
479+
INFOPLIST_KEY_UISupportsDocumentBrowser = YES;
476480
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
477481
LD_RUNPATH_SEARCH_PATHS = (
478482
"$(inherited)",
@@ -509,13 +513,15 @@
509513
DEVELOPMENT_TEAM = GXZ23M5TP2;
510514
ENABLE_PREVIEWS = NO;
511515
GENERATE_INFOPLIST_FILE = YES;
516+
INFOPLIST_FILE = TrollFools/Info.plist;
512517
INFOPLIST_KEY_CFBundleDisplayName = TrollFools;
513518
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
514519
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
515520
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
516521
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
517522
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
518523
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
524+
INFOPLIST_KEY_UISupportsDocumentBrowser = YES;
519525
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
520526
LD_RUNPATH_SEARCH_PATHS = (
521527
"$(inherited)",

TrollFools/AppListView.swift

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ final class App: Identifiable, ObservableObject {
6666
}
6767

6868
final class AppListModel: ObservableObject {
69-
static let shared = AppListModel()
7069
static let hasTrollStore: Bool = { LSApplicationProxy(forIdentifier: "com.opa334.TrollStore") != nil }()
7170
private var _allApplications: [App] = []
7271

@@ -87,7 +86,7 @@ final class AppListModel: ObservableObject {
8786
private let applicationChanged = PassthroughSubject<Void, Never>()
8887
private var cancellables = Set<AnyCancellable>()
8988

90-
private init() {
89+
init() {
9190
reload()
9291

9392
filter.$searchKeyword
@@ -234,9 +233,11 @@ final class FilterOptions: ObservableObject {
234233
}
235234

236235
struct AppListCell: View {
237-
@StateObject var app: App
236+
@EnvironmentObject var vm: AppListModel
238237
@EnvironmentObject var filter: FilterOptions
239238

239+
@StateObject var app: App
240+
240241
@available(iOS 15.0, *)
241242
var highlightedName: AttributedString {
242243
let name = app.name
@@ -281,7 +282,7 @@ struct AppListCell: View {
281282
try injector.setDetached(false)
282283
withAnimation {
283284
app.reload()
284-
AppListModel.shared.isRebuildNeeded = true
285+
vm.isRebuildNeeded = true
285286
}
286287
} catch { DDLogError("\(error.localizedDescription)") }
287288
} label: {
@@ -294,7 +295,7 @@ struct AppListCell: View {
294295
try injector.setDetached(true)
295296
withAnimation {
296297
app.reload()
297-
AppListModel.shared.isRebuildNeeded = true
298+
vm.isRebuildNeeded = true
298299
}
299300
} catch { DDLogError("\(error.localizedDescription)") }
300301
} label: {
@@ -399,15 +400,15 @@ struct AppListCell: View {
399400
LSApplicationWorkspace.default().openApplication(withBundleID: app.id)
400401
}
401402

402-
var isFilzaInstalled: Bool { AppListModel.shared.isFilzaInstalled }
403+
var isFilzaInstalled: Bool { vm.isFilzaInstalled }
403404

404405
private func openInFilza() {
405-
AppListModel.shared.openInFilza(app.url)
406+
vm.openInFilza(app.url)
406407
}
407408
}
408409

409410
struct AppListView: View {
410-
@StateObject var vm = AppListModel.shared
411+
@EnvironmentObject var vm: AppListModel
411412

412413
@State var isErrorOccurred: Bool = false
413414
@State var errorMessage: String = ""
@@ -454,10 +455,9 @@ struct AppListView: View {
454455
.font(.footnote)
455456

456457
Button {
457-
guard let url = repoURL else {
458-
return
458+
if let repoURL {
459+
UIApplication.shared.open(repoURL)
459460
}
460-
UIApplication.shared.open(url)
461461
} label: {
462462
Text(NSLocalizedString("Source Code", comment: ""))
463463
.font(.footnote)
@@ -602,6 +602,9 @@ struct AppListView: View {
602602
appList
603603
}
604604
}
605+
.onOpenURL { url in
606+
607+
}
605608
}
606609

607610
private func rebuildIconCache() {

TrollFools/EjectListView.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ struct InjectedPlugIn: Identifiable {
2929
}
3030

3131
struct PlugInCell: View {
32-
let plugIn: InjectedPlugIn
33-
32+
@EnvironmentObject var vm: AppListModel
3433
@EnvironmentObject var filter: FilterOptions
3534

35+
let plugIn: InjectedPlugIn
36+
3637
@available(iOS 15.0, *)
3738
var highlightedName: AttributedString {
3839
let name = plugIn.url.lastPathComponent
@@ -89,10 +90,10 @@ struct PlugInCell: View {
8990
}
9091
}
9192

92-
var isFilzaInstalled: Bool { AppListModel.shared.isFilzaInstalled }
93+
var isFilzaInstalled: Bool { vm.isFilzaInstalled }
9394

9495
private func openInFilza() {
95-
AppListModel.shared.openInFilza(plugIn.url)
96+
vm.openInFilza(plugIn.url)
9697
}
9798
}
9899

TrollFools/Info.plist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDocumentTypes</key>
6+
<array>
7+
<dict>
8+
<key>CFBundleTypeName</key>
9+
<string>Mach-O Binary</string>
10+
<key>LSHandlerRank</key>
11+
<string>Default</string>
12+
<key>LSItemContentTypes</key>
13+
<array>
14+
<string>com.apple.mach-o-binary</string>
15+
</array>
16+
</dict>
17+
</array>
18+
</dict>
19+
</plist>

TrollFools/SuccessView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import SwiftUI
99

1010
struct SuccessView: View {
11-
let title: String
11+
@EnvironmentObject var vm: AppListModel
1212

13-
@StateObject var vm = AppListModel.shared
14-
@StateObject var filter = FilterOptions()
13+
let title: String
1514

1615
var possibleApp: App? {
1716
[
@@ -59,7 +58,6 @@ struct SuccessView: View {
5958
.padding()
6059
.foregroundColor(.primary)
6160
.multilineTextAlignment(.leading)
62-
.environmentObject(filter)
6361
.background(RoundedRectangle(cornerRadius: 12, style: .continuous)
6462
.foregroundColor(Color(.systemBackground))
6563
.shadow(radius: 4))

TrollFools/TrollFoolsApp.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct TrollFoolsApp: SwiftUI.App {
1313
var body: some Scene {
1414
WindowGroup {
1515
AppListView()
16+
.environmentObject(AppListModel())
1617
}
1718
}
1819
}

TrollFools/Version.Debug.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
// Configuration settings file format documentation can be found at:
99
// https://help.apple.com/xcode/#/dev745c5c974
1010

11-
DEBUG_VERSION = 2.6
12-
DEBUG_BUILD_NUMBER = 202408191
11+
DEBUG_VERSION = 2.8
12+
DEBUG_BUILD_NUMBER = 202410201

TrollFools/Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
// Configuration settings file format documentation can be found at:
99
// https://help.apple.com/xcode/#/dev745c5c974
1010

11-
VERSION = 2.7
12-
BUILD_NUMBER = 9
11+
VERSION = 2.8
12+
BUILD_NUMBER = 10

TrollFools/main.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

layout/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: wiki.qaq.trollfools
22
Name: TrollFools
3-
Version: 2.7-9
3+
Version: 2.8-10
44
Section: Applications
55
Depends: firmware (>= 14.0)
66
Architecture: iphoneos-arm

0 commit comments

Comments
 (0)