Skip to content

Commit 64560c8

Browse files
committed
change minimum supported version to iOS 16
1 parent 4937fec commit 64560c8

22 files changed

+123
-243
lines changed

Diff for: HabitRPG/Extensions/NSAttributedString.swift

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ extension NSMutableAttributedString {
3737
}
3838
}
3939

40-
@available(iOS 15, *)
4140
extension AttributedString {
4241
func withHighlightWords(words: String...) -> AttributedString {
4342
var text = self

Diff for: HabitRPG/Repositories/Implementations/InventoryRepository.swift

+11-19
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,12 @@ class InventoryRepository: BaseRepository<InventoryLocalRepository> {
101101
.on(value: { pet in
102102
let alert = HabiticaAlertController()
103103
alert.title = L10n.Inventory.hatched
104-
if #available(iOS 16.0, *) {
105-
let hostingView = UIHostingView(rootView: VStack(spacing: 8) {
106-
StableBackgroundView(content: PetView(pet: pet).padding(.top, 40), animateFlying: true).clipShape(.rect(cornerRadius: 12))
107-
Text("\(pet.text ?? "") Pet").font(.system(size: 16, weight: .medium)).foregroundColor(Color(ThemeService.shared.theme.primaryTextColor))
108-
}.ignoresSafeArea())
109-
hostingView.shouldResizeToFitContent = true
110-
alert.contentView = hostingView
111-
}
104+
let hostingView = UIHostingView(rootView: VStack(spacing: 8) {
105+
StableBackgroundView(content: PetView(pet: pet).padding(.top, 40), animateFlying: true).clipShape(.rect(cornerRadius: 12))
106+
Text("\(pet.text ?? "") Pet").font(.system(size: 16, weight: .medium)).foregroundColor(Color(ThemeService.shared.theme.primaryTextColor))
107+
}.ignoresSafeArea())
108+
hostingView.shouldResizeToFitContent = true
109+
alert.contentView = hostingView
112110
alert.addAction(title: L10n.equip, isMainAction: true) { _ in
113111
self?.equip(type: "pet", key: pet.key ?? "").observeCompleted {}
114112
}
@@ -304,13 +302,11 @@ class InventoryRepository: BaseRepository<InventoryLocalRepository> {
304302
}.on(value: { mountText in
305303
let alert = HabiticaAlertController()
306304
alert.title = L10n.youRaisedPet(pet.text ?? "")
307-
if #available(iOS 16.0, *) {
308-
alert.contentView = UIHostingView(rootView: VStack(spacing: 8) {
309-
StableBackgroundView(content: MountView(mount: pet).padding(.top, 30), animateFlying: false).clipShape(.rect(cornerRadius: 12))
310-
Text("\(mountText ?? "") Mount").font(.system(size: 16, weight: .medium)).foregroundColor(Color(ThemeService.shared.theme.primaryTextColor))
311-
Text("Let's go for a ride!").font(.system(size: 14)).foregroundColor(Color(ThemeService.shared.theme.secondaryTextColor))
312-
})
313-
}
305+
alert.contentView = UIHostingView(rootView: VStack(spacing: 8) {
306+
StableBackgroundView(content: MountView(mount: pet).padding(.top, 30), animateFlying: false).clipShape(.rect(cornerRadius: 12))
307+
Text("\(mountText ?? "") Mount").font(.system(size: 16, weight: .medium)).foregroundColor(Color(ThemeService.shared.theme.primaryTextColor))
308+
Text("Let's go for a ride!").font(.system(size: 14)).foregroundColor(Color(ThemeService.shared.theme.secondaryTextColor))
309+
})
314310
alert.addAction(title: L10n.equip, isMainAction: true) { _ in
315311
self?.equip(type: "mount", key: pet.key ?? "").observeCompleted {}
316312
}
@@ -322,10 +318,6 @@ class InventoryRepository: BaseRepository<InventoryLocalRepository> {
322318
alert.show()
323319
}
324320
}).start()
325-
} else {
326-
if #unavailable(iOS 16.0) {
327-
ToastManager.show(text: response?.message ?? "You fed your pet", color: .green)
328-
}
329321
}
330322
if let userID = self?.currentUserId, let trained = response?.data {
331323
self?.localRepository.updatePetTrained(userID: userID, key: pet.key ?? "", trained: trained, consumedFood: food)

Diff for: HabitRPG/UI/General/FaintViewController.swift

-4
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ struct HabiticaButtonUI<Label: View>: View {
4747
}
4848
var body: some View {
4949
Button(action: onTap, label: {
50-
if #available(iOS 16.0, *) {
5150
label.underline(UIAccessibility.buttonShapesEnabled, color: getForegroundColor())
52-
} else {
53-
label
54-
}
5551
}).buttonStyle { configuration in
5652
configuration.label
5753
.foregroundColor(getForegroundColor())

Diff for: HabitRPG/UI/Inventory/EquipmentDetailViewController.swift

+17-22
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@ class EquipmentDetailViewController: BaseTableViewController, UISearchResultsUpd
3434
navigationItem.backButtonDisplayMode = .minimal
3535
navigationItem.backButtonTitle = nil
3636
navigationItem.title = nil
37-
if #available(iOS 16.0, *) {
38-
self.navigationItem.preferredSearchBarPlacement = .inline
39-
searchController.scopeBarActivation = .automatic
40-
updateSearchSuggestions(withInput: nil)
41-
}
37+
self.navigationItem.preferredSearchBarPlacement = .inline
38+
searchController.scopeBarActivation = .automatic
39+
updateSearchSuggestions(withInput: nil)
4240
searchController.searchBar.showsCancelButton = false
4341
searchController.searchResultsUpdater = self
4442
tableView.keyboardDismissMode = .onDrag
@@ -69,26 +67,23 @@ class EquipmentDetailViewController: BaseTableViewController, UISearchResultsUpd
6967
}
7068

7169
func updateSearchSuggestions(withInput input: String?) {
72-
if #available(iOS 16.0, *) {
73-
let allSuggestions = [
74-
UISearchSuggestionItem(localizedSuggestion: "Spring Gear"),
75-
UISearchSuggestionItem(localizedSuggestion: "Summer Gear"),
76-
UISearchSuggestionItem(localizedSuggestion: "Autumn Gear"),
77-
UISearchSuggestionItem(localizedSuggestion: "Winter Gear"),
78-
UISearchSuggestionItem(localizedSuggestion: "Subscriber Item"),
79-
UISearchSuggestionItem(localizedSuggestion: "Enchanted Armoire")
80-
]
81-
if input?.isEmpty ?? true {
82-
searchController.searchSuggestions = allSuggestions
83-
} else {
84-
searchController.searchSuggestions = allSuggestions.filter({ item in
85-
return item.localizedSuggestion?.lowercased().contains(input?.lowercased() ?? "") != false
86-
})
87-
}
70+
let allSuggestions = [
71+
UISearchSuggestionItem(localizedSuggestion: "Spring Gear"),
72+
UISearchSuggestionItem(localizedSuggestion: "Summer Gear"),
73+
UISearchSuggestionItem(localizedSuggestion: "Autumn Gear"),
74+
UISearchSuggestionItem(localizedSuggestion: "Winter Gear"),
75+
UISearchSuggestionItem(localizedSuggestion: "Subscriber Item"),
76+
UISearchSuggestionItem(localizedSuggestion: "Enchanted Armoire")
77+
]
78+
if input?.isEmpty ?? true {
79+
searchController.searchSuggestions = allSuggestions
80+
} else {
81+
searchController.searchSuggestions = allSuggestions.filter({ item in
82+
return item.localizedSuggestion?.lowercased().contains(input?.lowercased() ?? "") != false
83+
})
8884
}
8985
}
9086

91-
@available(iOS 16.0, *)
9287
func updateSearchResults(for searchController: UISearchController, selecting searchSuggestion: any UISearchSuggestion) {
9388
searchController.searchBar.text = searchSuggestion.localizedSuggestion
9489
}

Diff for: HabitRPG/UI/Inventory/Stable/PetDetailViewController.swift

+8-27
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,14 @@ class PetDetailViewController: StableDetailViewController<PetDetailDataSource> {
5050
guard let pet = stableItem.pet else {
5151
return
5252
}
53-
if #available(iOS 16.0, *) {
54-
let sheet = HostingBottomSheetController(rootView: PetBottomSheetView(pet: pet,
55-
trained: stableItem.trained,
56-
canRaise: stableItem.canRaise,
57-
isCurrentPet: user?.items?.currentPet == stableItem.pet?.key,
58-
onEquip: {[weak self] in
59-
self?.inventoryRepository.equip(type: "pet", key: pet.key ?? "").observeCompleted {}
60-
}))
61-
present(sheet, animated: true)
62-
} else {
63-
let sheet = HostingBottomSheetController(rootView: BottomSheetMenu(Text(stableItem.pet?.text ?? ""), iconName: "stable_Pet-\(stableItem.pet?.key ?? "")", menuItems: {
64-
if stableItem.trained > 0 && stableItem.pet?.type != "special" && stableItem.canRaise {
65-
BottomSheetMenuitem(title: L10n.Stable.feed) {[weak self] in
66-
self?.selectedPet = stableItem.pet
67-
DispatchQueue.main.async {
68-
self?.perform(segue: StoryboardSegue.Main.feedSegue)
69-
}
70-
}
71-
}
72-
if stableItem.trained > 0 {
73-
BottomSheetMenuitem(title: user?.items?.currentPet == stableItem.pet?.key ? L10n.unequip : L10n.equip) {[weak self] in
74-
self?.inventoryRepository.equip(type: "pet", key: stableItem.pet?.key ?? "").observeCompleted {}
75-
}
76-
}
77-
}))
78-
present(sheet, animated: true)
79-
}
53+
let sheet = HostingBottomSheetController(rootView: PetBottomSheetView(pet: pet,
54+
trained: stableItem.trained,
55+
canRaise: stableItem.canRaise,
56+
isCurrentPet: user?.items?.currentPet == stableItem.pet?.key,
57+
onEquip: {[weak self] in
58+
self?.inventoryRepository.equip(type: "pet", key: pet.key ?? "").observeCompleted {}
59+
}))
60+
present(sheet, animated: true)
8061
}
8162

8263
private func showHatchingDialog(forStableItem item: PetStableItem) {

Diff for: HabitRPG/UI/Purchases/SubscriptionDetailViewUI.swift

+7-9
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,15 @@ struct SubscriptionDetailViewUI: View {
302302
func cancelSubscription() {
303303
var url: URL?
304304
if plan.paymentMethod == "Apple" || plan.isGifted || plan.dateTerminated != nil {
305-
if #available(iOS 15.0, *) {
306-
if let window = UIApplication.shared.connectedScenes.first as? UIWindowScene {
307-
Task {
308-
do {
309-
try await AppStore.showManageSubscriptions(in: window)
310-
} catch {
311-
312-
}
305+
if let window = UIApplication.shared.connectedScenes.first as? UIWindowScene {
306+
Task {
307+
do {
308+
try await AppStore.showManageSubscriptions(in: window)
309+
} catch {
310+
313311
}
314-
return
315312
}
313+
return
316314
}
317315
url = URL(string: "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions")
318316
} else if plan.paymentMethod == "Google" {

Diff for: HabitRPG/UI/Purchases/SubscriptionOptionViewUI.swift

+5-9
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,12 @@ struct HourglassPromo: View {
3030
}
3131

3232
var body: some View {
33-
if #available(iOS 15.0, *) {
34-
content
35-
.task {
36-
withAnimation(.easeInOut(duration: 2.5).repeatForever(autoreverses: true)) {
37-
animatePromoGradient = true
38-
}
33+
content
34+
.task {
35+
withAnimation(.easeInOut(duration: 2.5).repeatForever(autoreverses: true)) {
36+
animatePromoGradient = true
3937
}
40-
} else {
41-
content
42-
}
38+
}
4339
}
4440
}
4541

Diff for: HabitRPG/UI/Purchases/SubscriptionPage.swift

+13-15
Original file line numberDiff line numberDiff line change
@@ -357,26 +357,24 @@ struct SubscriptionPage: View {
357357
Image(Asset.gemcapRight.name)
358358
}
359359
Text(L10n.resubscribeToPickUp).font(.system(size: 13))
360-
if #available(iOS 15.0, *) {
361-
GeometryReader { reader in
362-
ZStack(alignment: .leading) {
360+
GeometryReader { reader in
361+
ZStack(alignment: .leading) {
362+
Rectangle()
363+
.foregroundColor(.purple100)
364+
.fill()
365+
.cornerRadius(4)
366+
.frame(maxWidth: .infinity)
367+
.frame(height: 8)
363368
Rectangle()
364-
.foregroundColor(.purple100)
369+
.foregroundColor(.green100)
365370
.fill()
366371
.cornerRadius(4)
367-
.frame(maxWidth: .infinity)
368-
.frame(height: 8)
369-
Rectangle()
370-
.foregroundColor(.green100)
371-
.fill()
372-
.cornerRadius(4)
373-
.frame(width: reader.size.width * (CGFloat(viewModel.subscriptionPlan?.gemCapTotal ?? 0) / 50.0), height: 8)
374-
}
372+
.frame(width: reader.size.width * (CGFloat(viewModel.subscriptionPlan?.gemCapTotal ?? 0) / 50.0), height: 8)
375373
}
376-
.frame(height: 8)
377-
.padding(.top, 8)
378-
.padding(.horizontal, 41)
379374
}
375+
.frame(height: 8)
376+
.padding(.top, 8)
377+
.padding(.horizontal, 41)
380378
}
381379
.padding(.bottom, 16)
382380
}

Diff for: HabitRPG/UI/Purchases/SubscriptionViewController.swift

+7-9
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,15 @@ class SubscriptionViewController: BaseTableViewController {
442442
} else {
443443
var url: URL?
444444
if subscriptionPlan.paymentMethod == "Apple" {
445-
if #available(iOS 15.0, *) {
446-
if let window = UIApplication.shared.connectedScenes.first as? UIWindowScene {
447-
Task {
448-
do {
449-
try await AppStore.showManageSubscriptions(in: window)
450-
} catch {
451-
452-
}
445+
if let window = UIApplication.shared.connectedScenes.first as? UIWindowScene {
446+
Task {
447+
do {
448+
try await AppStore.showManageSubscriptions(in: window)
449+
} catch {
450+
453451
}
454-
return
455452
}
453+
return
456454
}
457455
url = URL(string: "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/manageSubscriptions")
458456
} else if subscriptionPlan.paymentMethod == "Google" {

Diff for: HabitRPG/UI/Settings/AccountSettingsViewController.swift

+6-20
Original file line numberDiff line numberDiff line change
@@ -557,17 +557,10 @@ struct ResetAccountView: View {
557557
} else {
558558
Text(L10n.Settings.resetAccountDescription).font(.body).foregroundColor(Color(ThemeService.shared.theme.secondaryTextColor))
559559
}
560-
if #available(iOS 15.0, *) {
561-
TextField(text: $text, prompt: Text(isSocial ? "RESET" : L10n.password)) {
562-
}
563-
.padding(12)
564-
.overlay(RoundedRectangle(cornerRadius: 8).stroke().foregroundColor(Color(ThemeService.shared.theme.tableviewSeparatorColor)))
565-
} else {
566-
TextField(text: $text) {
567-
}
568-
.padding(12)
569-
.overlay(RoundedRectangle(cornerRadius: 8).stroke().foregroundColor(Color(ThemeService.shared.theme.tableviewSeparatorColor)))
560+
TextField(text: $text, prompt: Text(isSocial ? "RESET" : L10n.password)) {
570561
}
562+
.padding(12)
563+
.overlay(RoundedRectangle(cornerRadius: 8).stroke().foregroundColor(Color(ThemeService.shared.theme.tableviewSeparatorColor)))
571564
HabiticaButtonUI(label: Text(L10n.Settings.resetAccount), color: Color(isValidInput() ? ThemeService.shared.theme.errorColor : ThemeService.shared.theme.dimmedColor)) {
572565
onReset(text)
573566
}
@@ -609,17 +602,10 @@ struct DeleteAccountView: View {
609602
} else {
610603
Text(L10n.Settings.deleteAccountDescription).font(.body).foregroundColor(Color(ThemeService.shared.theme.secondaryTextColor))
611604
}
612-
if #available(iOS 15.0, *) {
613-
TextField(text: $text, prompt: Text(isSocial ? "DELETE" : L10n.password)) {
614-
}
615-
.padding(12)
616-
.overlay(RoundedRectangle(cornerRadius: 8).stroke().foregroundColor(Color(ThemeService.shared.theme.tableviewSeparatorColor)))
617-
} else {
618-
TextField(text: $text) {
619-
}
620-
.padding(12)
621-
.overlay(RoundedRectangle(cornerRadius: 8).stroke().foregroundColor(Color(ThemeService.shared.theme.tableviewSeparatorColor)))
605+
TextField(text: $text, prompt: Text(isSocial ? "DELETE" : L10n.password)) {
622606
}
607+
.padding(12)
608+
.overlay(RoundedRectangle(cornerRadius: 8).stroke().foregroundColor(Color(ThemeService.shared.theme.tableviewSeparatorColor)))
623609
HabiticaButtonUI(label: Text(L10n.Settings.deleteAccount), color: Color(isValidInput() ? ThemeService.shared.theme.errorColor : ThemeService.shared.theme.dimmedColor)) {
624610
onDelete(text)
625611
}

0 commit comments

Comments
 (0)