Skip to content

Commit

Permalink
feat: add context menus
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <[email protected]>
  • Loading branch information
Lessica committed Jul 24, 2024
1 parent e15740a commit d7824bf
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
12 changes: 12 additions & 0 deletions TrollFools.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
<array>
<string>/</string>
</array>
<key>com.apple.springboard.iconState</key>
<true/>
<key>com.apple.springboard.iconState.mutate</key>
<true/>
<key>com.apple.springboard.launchapplications</key>
<true/>
<key>com.apple.springboard.launchapplicationswithoptions</key>
<true/>
<key>com.apple.springboard.opensensitiveurl</key>
<true/>
<key>com.apple.springboard.openurlswhenlocked</key>
<true/>
<key>com.apple.system-task-ports</key>
<true/>
<key>com.apple.system-task-ports.control</key>
Expand Down
42 changes: 42 additions & 0 deletions TrollFools/AppListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ final class AppListModel: ObservableObject {
@Published var hasTrollRecorder: Bool = false
@Published var unsupportedCount: Int = 0

@Published var isFilzaInstalled: Bool = false
private let filzaURL = URL(string: "filza://")

private let applicationChanged = PassthroughSubject<Void, Never>()
private var cancellables = Set<AnyCancellable>()

Expand Down Expand Up @@ -99,6 +102,11 @@ final class AppListModel: ObservableObject {
func reload() {
let allApplications = Self.fetchApplications(&hasTrollRecorder, &unsupportedCount)
self._allApplications = allApplications
if let filzaURL {
self.isFilzaInstalled = UIApplication.shared.canOpenURL(filzaURL)
} else {
self.isFilzaInstalled = false
}
performFilter()
}

Expand Down Expand Up @@ -179,6 +187,14 @@ final class AppListModel: ObservableObject {

return filteredApps
}

func openInFilza(_ url: URL) {
guard let filzaURL else {
return
}
let fileURL = filzaURL.appendingPathComponent(url.path)
UIApplication.shared.open(fileURL)
}
}

final class FilterOptions: ObservableObject {
Expand Down Expand Up @@ -260,6 +276,32 @@ struct AppListCell: View {
.foregroundColor(.secondary)
}
}
.contextMenu {
Button {
launch()
} label: {
Label(NSLocalizedString("Launch", comment: ""), systemImage: "command")
}

if isFilzaInstalled {
Button {
openInFilza()
} label: {
Label(NSLocalizedString("Show in Filza", comment: ""), systemImage: "scope")
}
}
}
}

private func launch() {
LSApplicationWorkspace.default()
.openApplication(withBundleID: app.id)
}

var isFilzaInstalled: Bool { AppListModel.shared.isFilzaInstalled }

private func openInFilza() {
AppListModel.shared.openInFilza(app.url)
}
}

Expand Down
15 changes: 15 additions & 0 deletions TrollFools/EjectListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@ struct PlugInCell: View {
.font(.subheadline)
}
}
.contextMenu {
if isFilzaInstalled {
Button {
openInFilza()
} label: {
Label(NSLocalizedString("Show in Filza", comment: ""), systemImage: "scope")
}
}
}
}

var isFilzaInstalled: Bool { AppListModel.shared.isFilzaInstalled }

private func openInFilza() {
AppListModel.shared.openInFilza(plugIn.url)
}
}

Expand Down
6 changes: 6 additions & 0 deletions TrollFools/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
/* No comment provided by engineer. */
"Injecting" = "Injecting";

/* No comment provided by engineer. */
"Launch" = "Launch";

/* No comment provided by engineer. */
"Lessica, Lakr233, mlgm and other contributors." = "Lessica, Lakr233, mlgm and other contributors.";

Expand Down Expand Up @@ -82,6 +85,9 @@
/* No comment provided by engineer. */
"Search…" = "Search…";

/* No comment provided by engineer. */
"Show in Filza" = "Show in Filza";

/* No comment provided by engineer. */
"Show Patched Only" = "Show Patched Only";

Expand Down
6 changes: 6 additions & 0 deletions TrollFools/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
/* No comment provided by engineer. */
"Injecting" = "注入中";

/* No comment provided by engineer. */
"Launch" = "启动";

/* No comment provided by engineer. */
"Lessica, Lakr233, mlgm and other contributors." = "Lessica, Lakr233, mlgm 及其他贡献者";

Expand Down Expand Up @@ -82,6 +85,9 @@
/* No comment provided by engineer. */
"Search…" = "搜索…";

/* No comment provided by engineer. */
"Show in Filza" = "在 Filza 中显示";

/* No comment provided by engineer. */
"Show Patched Only" = "仅显示已注入的";

Expand Down

0 comments on commit d7824bf

Please sign in to comment.