Skip to content

Commit 073b463

Browse files
committed
fix: ios 14
Signed-off-by: Lessica <82flex@gmail.com>
1 parent 516d84b commit 073b463

10 files changed

+128
-60
lines changed

TrollFools/AppListCell.swift

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct AppListCell: View {
1313

1414
@StateObject var app: App
1515

16-
@available(iOS 15.0, *)
16+
@available(iOS 15, *)
1717
var highlightedName: AttributedString {
1818
let name = app.name
1919
var attributedString = AttributedString(name)
@@ -23,7 +23,7 @@ struct AppListCell: View {
2323
return attributedString
2424
}
2525

26-
@available(iOS 15.0, *)
26+
@available(iOS 15, *)
2727
var highlightedId: AttributedString {
2828
let id = app.id
2929
var attributedString = AttributedString(id)
@@ -83,11 +83,11 @@ struct AppListCell: View {
8383

8484
@ViewBuilder
8585
var cellContextMenuWrapper: some View {
86-
if #available(iOS 16.0, *) {
86+
if #available(iOS 16, *) {
8787
// iOS 16
8888
cellContextMenu
8989
} else {
90-
if #available(iOS 15.0, *) { }
90+
if #available(iOS 15, *) { }
9191
else {
9292
// iOS 14
9393
cellContextMenu
@@ -97,8 +97,8 @@ struct AppListCell: View {
9797

9898
@ViewBuilder
9999
var cellBackground: some View {
100-
if #available(iOS 15.0, *) {
101-
if #available(iOS 16.0, *) { }
100+
if #available(iOS 15, *) {
101+
if #available(iOS 16, *) { }
102102
else {
103103
// iOS 15
104104
Color.clear
@@ -114,13 +114,20 @@ struct AppListCell: View {
114114

115115
var body: some View {
116116
HStack(spacing: 12) {
117-
Image(uiImage: app.alternateIcon ?? app.icon ?? UIImage())
118-
.resizable()
119-
.frame(width: 32, height: 32)
117+
if #available(iOS 15, *) {
118+
Image(uiImage: app.alternateIcon ?? app.icon ?? UIImage())
119+
.resizable()
120+
.frame(width: 32, height: 32)
121+
} else {
122+
Image(uiImage: app.alternateIcon ?? app.icon ?? UIImage())
123+
.resizable()
124+
.frame(width: 32, height: 32)
125+
.clipShape(RoundedRectangle(cornerRadius: 8))
126+
}
120127

121128
VStack(alignment: .leading, spacing: 2) {
122129
HStack(spacing: 4) {
123-
if #available(iOS 15.0, *) {
130+
if #available(iOS 15, *) {
124131
Text(highlightedName)
125132
.font(.headline)
126133
.lineLimit(1)
@@ -138,7 +145,7 @@ struct AppListCell: View {
138145
}
139146
}
140147

141-
if #available(iOS 15.0, *) {
148+
if #available(iOS 15, *) {
142149
Text(highlightedId)
143150
.font(.subheadline)
144151
.lineLimit(app.isAdvertisement ? 2 : 1)

TrollFools/AppListView.swift

Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct AppListView: View {
4444
OptionView(app)
4545
}
4646
} label: {
47-
if #available(iOS 16.0, *) {
47+
if #available(iOS 16, *) {
4848
AppListCell(app: app)
4949
} else {
5050
AppListCell(app: app)
@@ -58,7 +58,7 @@ struct AppListView: View {
5858
Button {
5959
UIApplication.shared.open(App.advertisementApp.url)
6060
} label: {
61-
if #available(iOS 16.0, *) {
61+
if #available(iOS 16, *) {
6262
AppListCell(app: App.advertisementApp)
6363
} else {
6464
AppListCell(app: App.advertisementApp)
@@ -82,6 +82,25 @@ struct AppListView: View {
8282
}
8383
}
8484

85+
var appListFooter: some View {
86+
VStack(alignment: .leading, spacing: 20) {
87+
if !appList.filter.showPatchedOnly {
88+
Text(NSLocalizedString("Only removable system applications are eligible and listed.", comment: ""))
89+
.font(.footnote)
90+
}
91+
92+
if !appList.isSelectorMode {
93+
if #available(iOS 16, *) {
94+
appListFooterView
95+
.padding(.top, 8)
96+
} else {
97+
appListFooterView
98+
.padding(.top, 2)
99+
}
100+
}
101+
}
102+
}
103+
85104
var appListView: some View {
86105
List {
87106
if AppListModel.hasTrollStore && appList.isRebuildNeeded {
@@ -103,7 +122,7 @@ struct AppListView: View {
103122
Spacer()
104123

105124
if appList.isRebuilding {
106-
if #available(iOS 16.0, *) {
125+
if #available(iOS 16, *) {
107126
ProgressView()
108127
.progressViewStyle(CircularProgressViewStyle())
109128
.controlSize(.large)
@@ -128,12 +147,24 @@ struct AppListView: View {
128147
Section {
129148
filteredAppList(appList.userApplications)
130149
} header: {
131-
Text(NSLocalizedString("User Applications", comment: ""))
132-
.font(.footnote)
150+
if #available(iOS 15, *) {
151+
Text(NSLocalizedString("User Applications", comment: ""))
152+
.font(.footnote)
153+
} else {
154+
Text(NSLocalizedString("User Applications", comment: ""))
155+
.font(.footnote)
156+
.padding(.horizontal, 16)
157+
}
133158
} footer: {
134159
if !appList.filter.isSearching && !appList.filter.showPatchedOnly && appList.unsupportedCount > 0 {
135-
Text(String(format: NSLocalizedString("And %d more unsupported user applications.", comment: ""), appList.unsupportedCount))
136-
.font(.footnote)
160+
if #available(iOS 15, *) {
161+
Text(String(format: NSLocalizedString("And %d more unsupported user applications.", comment: ""), appList.unsupportedCount))
162+
.font(.footnote)
163+
} else {
164+
Text(String(format: NSLocalizedString("And %d more unsupported user applications.", comment: ""), appList.unsupportedCount))
165+
.font(.footnote)
166+
.padding(.horizontal, 16)
167+
}
137168
}
138169
}
139170

@@ -146,32 +177,34 @@ struct AppListView: View {
146177

147178
filteredAppList(appList.trollApplications)
148179
} header: {
149-
Text(NSLocalizedString("TrollStore Applications", comment: ""))
150-
.font(.footnote)
180+
if #available(iOS 15, *) {
181+
Text(NSLocalizedString("TrollStore Applications", comment: ""))
182+
.font(.footnote)
183+
} else {
184+
Text(NSLocalizedString("TrollStore Applications", comment: ""))
185+
.font(.footnote)
186+
.padding(.horizontal, 16)
187+
}
151188
}
152189

153190
Section {
154191
filteredAppList(appList.appleApplications)
155192
} header: {
156-
Text(NSLocalizedString("Injectable System Applications", comment: ""))
157-
.font(.footnote)
193+
if #available(iOS 15, *) {
194+
Text(NSLocalizedString("Injectable System Applications", comment: ""))
195+
.font(.footnote)
196+
} else {
197+
Text(NSLocalizedString("Injectable System Applications", comment: ""))
198+
.font(.footnote)
199+
.padding(.horizontal, 16)
200+
}
158201
} footer: {
159202
if !appList.filter.isSearching {
160-
VStack(alignment: .leading, spacing: 20) {
161-
if !appList.filter.showPatchedOnly {
162-
Text(NSLocalizedString("Only removable system applications are eligible and listed.", comment: ""))
163-
.font(.footnote)
164-
}
165-
166-
if !appList.isSelectorMode {
167-
if #available(iOS 16.0, *) {
168-
appListFooterView
169-
.padding(.top, 8)
170-
} else {
171-
appListFooterView
172-
.padding(.top, 2)
173-
}
174-
}
203+
if #available(iOS 15, *) {
204+
appListFooter
205+
} else {
206+
appListFooter
207+
.padding(.horizontal, 16)
175208
}
176209
}
177210
}
@@ -200,7 +233,7 @@ struct AppListView: View {
200233
Button {
201234
appList.filter.showPatchedOnly.toggle()
202235
} label: {
203-
if #available(iOS 15.0, *) {
236+
if #available(iOS 15, *) {
204237
Image(systemName: appList.filter.showPatchedOnly
205238
? "line.3.horizontal.decrease.circle.fill"
206239
: "line.3.horizontal.decrease.circle")
@@ -217,7 +250,7 @@ struct AppListView: View {
217250

218251
var body: some View {
219252
NavigationView {
220-
if #available(iOS 15.0, *) {
253+
if #available(iOS 15, *) {
221254
appListView
222255
.refreshable {
223256
withAnimation {

TrollFools/EjectListView.swift

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct EjectListView: View {
3333
}
3434

3535
var deleteAllButton: some View {
36-
if #available(iOS 15.0, *) {
36+
if #available(iOS 15, *) {
3737
Button(role: .destructive) {
3838
deleteAll()
3939
} label: {
@@ -48,11 +48,23 @@ struct EjectListView: View {
4848
}
4949
}
5050

51+
var headerView: some View {
52+
Text(ejectList.filteredPlugIns.isEmpty
53+
? NSLocalizedString("No Injected Plug-Ins", comment: "")
54+
: NSLocalizedString("Injected Plug-Ins", comment: ""))
55+
.font(.footnote)
56+
}
57+
58+
var footerView: some View {
59+
Text(NSLocalizedString("Some plug-ins were not injected by TrollFools, please eject them with caution.", comment: ""))
60+
.font(.footnote)
61+
}
62+
5163
var ejectListView: some View {
5264
List {
5365
Section {
5466
ForEach(ejectList.filteredPlugIns) { plugin in
55-
if #available(iOS 16.0, *) {
67+
if #available(iOS 16, *) {
5668
PlugInCell(plugIn: plugin)
5769
.environmentObject(ejectList)
5870
} else {
@@ -63,10 +75,12 @@ struct EjectListView: View {
6375
}
6476
.onDelete(perform: delete)
6577
} header: {
66-
Text(ejectList.filteredPlugIns.isEmpty
67-
? NSLocalizedString("No Injected Plug-Ins", comment: "")
68-
: NSLocalizedString("Injected Plug-Ins", comment: ""))
69-
.font(.footnote)
78+
if #available(iOS 15, *) {
79+
headerView
80+
} else {
81+
headerView
82+
.padding(.horizontal, 16)
83+
}
7084
}
7185

7286
if !ejectList.filter.isSearching && !ejectList.filteredPlugIns.isEmpty {
@@ -76,8 +90,12 @@ struct EjectListView: View {
7690
.foregroundColor(isDeletingAll ? .secondary : .red)
7791
} footer: {
7892
if ejectList.app.isFromTroll {
79-
Text(NSLocalizedString("Some plug-ins were not injected by TrollFools, please eject them with caution.", comment: ""))
80-
.font(.footnote)
93+
if #available(iOS 15, *) {
94+
footerView
95+
} else {
96+
footerView
97+
.padding(.horizontal, 16)
98+
}
8199
}
82100
}
83101
}
@@ -99,7 +117,7 @@ struct EjectListView: View {
99117
}
100118

101119
var body: some View {
102-
if #available(iOS 15.0, *) {
120+
if #available(iOS 15, *) {
103121
ejectListView
104122
.refreshable {
105123
withAnimation {

TrollFools/InjectView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct InjectView: View {
7272
)
7373
}
7474
} else {
75-
if #available(iOS 16.0, *) {
75+
if #available(iOS 16, *) {
7676
ProgressView()
7777
.progressViewStyle(CircularProgressViewStyle())
7878
.padding(.all, 20)

TrollFools/InjectorV3+Command.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extension InjectorV3 {
3737
// MARK: - cp
3838

3939
fileprivate static let cpBinaryURL: URL = {
40-
if #available(iOS 16.0, *) {
40+
if #available(iOS 16, *) {
4141
Bundle.main.url(forResource: "cp", withExtension: nil)!
4242
} else {
4343
Bundle.main.url(forResource: "cp-15", withExtension: nil)!
@@ -62,7 +62,7 @@ extension InjectorV3 {
6262
// MARK: - ldid
6363

6464
fileprivate static let ldidBinaryURL: URL = {
65-
if #available(iOS 15.0, *) {
65+
if #available(iOS 15, *) {
6666
Bundle.main.url(forResource: "ldid", withExtension: nil)!
6767
} else {
6868
Bundle.main.url(forResource: "ldid-14", withExtension: nil)!
@@ -164,7 +164,7 @@ extension InjectorV3 {
164164
// MARK: - mv
165165

166166
fileprivate static let mvBinaryURL: URL = {
167-
if #available(iOS 16.0, *) {
167+
if #available(iOS 16, *) {
168168
Bundle.main.url(forResource: "mv", withExtension: nil)!
169169
} else {
170170
Bundle.main.url(forResource: "mv-15", withExtension: nil)!

TrollFools/OptionCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct OptionCell: View {
1111
let option: Option
1212

1313
var iconName: String {
14-
if #available(iOS 16.0, *) {
14+
if #available(iOS 16, *) {
1515
option == .attach ? "syringe" : "xmark.bin"
1616
} else {
1717
option == .attach ? "tray.and.arrow.down" : "xmark.bin"

TrollFools/OptionView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct OptionView: View {
8686
isImporterSelected = true
8787
}
8888
.sheet(isPresented: $isSettingsPresented) {
89-
if #available(iOS 16.0, *) {
89+
if #available(iOS 16, *) {
9090
SettingsView(app)
9191
.presentationDetents([.medium, .large])
9292
} else {

TrollFools/PlugInCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct PlugInCell: View {
1919

2020
let plugIn: InjectedPlugIn
2121

22-
@available(iOS 15.0, *)
22+
@available(iOS 15, *)
2323
var highlightedName: AttributedString {
2424
let name = plugIn.url.lastPathComponent
2525
var attributedString = AttributedString(name)
@@ -52,7 +52,7 @@ struct PlugInCell: View {
5252
.foregroundColor(.accentColor)
5353

5454
VStack(alignment: .leading) {
55-
if #available(iOS 15.0, *) {
55+
if #available(iOS 15, *) {
5656
Text(highlightedName)
5757
.font(.headline)
5858
} else {

TrollFools/SettingsView.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ struct SettingsView: View {
3333
Toggle(NSLocalizedString("Prefer Main Executable", comment: ""), isOn: $preferMainExecutable)
3434
Toggle(NSLocalizedString("Use Weak Reference", comment: ""), isOn: $useWeakReference)
3535
} header: {
36-
Text(NSLocalizedString("Injection", comment: ""))
36+
if #available(iOS 15, *) {
37+
Text(NSLocalizedString("Injection", comment: ""))
38+
} else {
39+
Text(NSLocalizedString("Injection", comment: ""))
40+
.padding(.horizontal, 16)
41+
}
3742
} footer: {
38-
Text(NSLocalizedString("If you do not know what these options mean, please do not change them.", comment: ""))
43+
if #available(iOS 15, *) {
44+
Text(NSLocalizedString("If you do not know what these options mean, please do not change them.", comment: ""))
45+
} else {
46+
Text(NSLocalizedString("If you do not know what these options mean, please do not change them.", comment: ""))
47+
.padding(.horizontal, 16)
48+
}
3949
}
4050
}
4151
.navigationTitle(NSLocalizedString("Advanced Settings", comment: ""))

0 commit comments

Comments
 (0)