From 0f2cf4af04a9ac5a2f7c59bb47ab3d404b6bcd65 Mon Sep 17 00:00:00 2001 From: maddiebaka Date: Sat, 20 Jan 2024 23:50:07 -0500 Subject: [PATCH] Refactor and add legal links to payment pages, change contribute view's layout --- Toki Trainer.xcodeproj/project.pbxproj | 8 +- Toki Trainer/Localizable.xcstrings | 63 +++++++++- Toki Trainer/Models/TransactionObserver.swift | 3 +- Toki Trainer/Views/ContributeView.swift | 118 +++++++++++++----- .../Views/WordListViews/DictionaryView.swift | 4 +- .../Views/WordListViews/TranslatorView.swift | 8 +- 6 files changed, 154 insertions(+), 50 deletions(-) diff --git a/Toki Trainer.xcodeproj/project.pbxproj b/Toki Trainer.xcodeproj/project.pbxproj index ecd6f33..ff218b6 100644 --- a/Toki Trainer.xcodeproj/project.pbxproj +++ b/Toki Trainer.xcodeproj/project.pbxproj @@ -497,7 +497,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.3; PRODUCT_BUNDLE_IDENTIFIER = "info.maddie.Toki-Trainer.Toki-Trainer-Widgets"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -524,7 +524,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.3; PRODUCT_BUNDLE_IDENTIFIER = "info.maddie.Toki-Trainer.Toki-Trainer-Widgets"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -678,7 +678,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.3; PRODUCT_BUNDLE_IDENTIFIER = "info.maddie.Toki-Trainer"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -713,7 +713,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.3; PRODUCT_BUNDLE_IDENTIFIER = "info.maddie.Toki-Trainer"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Toki Trainer/Localizable.xcstrings b/Toki Trainer/Localizable.xcstrings index 89a48dd..83237ad 100644 --- a/Toki Trainer/Localizable.xcstrings +++ b/Toki Trainer/Localizable.xcstrings @@ -25,7 +25,14 @@ }, "Contribute" : { - + "localizations" : { + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Contribuer" + } + } + } }, "Correct" : { "localizations" : { @@ -58,10 +65,24 @@ } }, "Donate Monthly" : { - + "localizations" : { + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Faire un don mensuel" + } + } + } }, "Donate Once" : { - + "localizations" : { + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Don unique" + } + } + } }, "Enter Toki Pona Word or Phrase" : { "localizations" : { @@ -124,7 +145,14 @@ } }, "One-Time Donation" : { - + "localizations" : { + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Don unique" + } + } + } }, "Parts of Speech" : { "localizations" : { @@ -155,6 +183,9 @@ } } } + }, + "Privacy Policy" : { + }, "Results" : { "localizations" : { @@ -186,8 +217,21 @@ } } }, - "Thank you for donating!" : { + "Source Code" : { + }, + "Terms of Use" : { + + }, + "Thank you for donating!" : { + "localizations" : { + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Merci pour votre donย !" + } + } + } }, "Words" : { "localizations" : { @@ -200,7 +244,14 @@ } }, "Write Review" : { - + "localizations" : { + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Ecrire une critique" + } + } + } } }, "version" : "1.0" diff --git a/Toki Trainer/Models/TransactionObserver.swift b/Toki Trainer/Models/TransactionObserver.swift index 5693c2d..20f3e1e 100644 --- a/Toki Trainer/Models/TransactionObserver.swift +++ b/Toki Trainer/Models/TransactionObserver.swift @@ -1,5 +1,5 @@ // -// Store.swift +// TransactionObserver.swift // Toki Trainer // // Created by Madeline Pace on 12/18/23. @@ -82,7 +82,6 @@ final class TransactionObserver: ObservableObject { } func processSubscription(_ productID: String) { - // TODO: Write function print("Subscription ID: \(productID)") switch productID { case K.MonthlyTransactions.TierOne: diff --git a/Toki Trainer/Views/ContributeView.swift b/Toki Trainer/Views/ContributeView.swift index 4f1938f..e108794 100644 --- a/Toki Trainer/Views/ContributeView.swift +++ b/Toki Trainer/Views/ContributeView.swift @@ -36,6 +36,7 @@ Please also consider donating financially if you can. ๐Ÿ’• + private var recurringIAPs = ["TierThree"] @EnvironmentObject var transactions: TransactionObserver @@ -49,8 +50,16 @@ Please also consider donating financially if you can. ๐Ÿ’• Text(supportString) .padding(16) Spacer() + +// Link("Source Code", destination: URL(string: "https://git.corrupt.link/maddiefuzz/TokiTrainer")!) +// .padding(12) + +// .padding([.bottom], 12) HStack { ReviewButton() + SourceCodeButton() + } + HStack { SingleDonationButton() RecurringDonationButton() } @@ -82,6 +91,21 @@ struct ThankYouBannerView: View { } } +struct SourceCodeButton: View { + var body: some View { + Link(destination: URL(string: "https://git.corrupt.link/maddiefuzz/TokiTrainer")!) { + VStack { + Image(systemName: "apple.terminal") + .font(.system(size: 24, weight: .regular)) + .padding(2) + Text("Source Code") + } + } + .frame(width: 100) + .padding(8) + } +} + // MARK: ReviewButton struct ReviewButton: View { @Environment(\.requestReview) private var requestReview @@ -98,7 +122,7 @@ struct ReviewButton: View { Text("Write Review") } }) - .frame(width: 80) + .frame(width: 100) .padding(8) } @@ -144,42 +168,51 @@ struct SingleDonationButton: View { Text("Donate Once") } } - .frame(width: 80) + .frame(width: 100) .padding(8) .sheet(item: self.$IAPs) { IAPs in if(productsFetched) { - Text("One-Time Donation") - .font(.largeTitle) - ForEach(IAPs.products) { product in - HStack { - VStack { - Text(product.displayName) - .font(.title) - .frame(maxWidth: .infinity, alignment: .leading) - Text(product.description) - .frame(maxWidth: .infinity, alignment: .leading) - } - .padding(.leading, 12) - Spacer() - Button { - print("Purchase this one: \(product)") - disabledPurchaseButtons = true - Task { - let _ = try? await purchase(product) - disabledPurchaseButtons = false + VStack { + Spacer() + Text("One-Time Donation") + .font(.largeTitle) + Spacer() + ForEach(IAPs.products) { product in + HStack { + VStack { + Text(product.displayName) + .font(.title) + .frame(maxWidth: .infinity, alignment: .leading) + Text(product.description) + .frame(maxWidth: .infinity, alignment: .leading) } - } label: { - Text(product.displayPrice) - .frame(minWidth: 50) - .padding(8) - .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/) + .padding(.leading, 12) + Spacer() + Button { + print("Purchase this one: \(product)") + disabledPurchaseButtons = true + Task { + let _ = try? await purchase(product) + disabledPurchaseButtons = false + } + } label: { + Text(product.displayPrice) + .frame(minWidth: 50) + .padding(8) + .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/) + } + .padding(.trailing, 12) + .buttonStyle(.bordered) + .disabled(disabledPurchaseButtons) } - .padding(.trailing, 12) - .buttonStyle(.bordered) - .disabled(disabledPurchaseButtons) + .padding(12) } - .padding(12) + Spacer() + LegalLinksView() + .padding(16) + .padding([.bottom], 20) } + //.padding([.top], 60) } else { ProgressView() } @@ -244,14 +277,35 @@ struct RecurringDonationButton: View { Text("Donate Monthly") } } - .frame(width: 80) + .frame(width: 100) .padding(8) .sheet(isPresented: $toggleSheet, content: { - SubscriptionStoreView(groupID: self.groupID) + VStack { + SubscriptionStoreView(groupID: self.groupID) +// HStack { +// Link("Terms of Use", destination: URL(string: "https://www.apple.com/legal/internet-services/itunes/dev/stdeula/")!) +// .padding(12) +// Link("Privacy Policy", destination: URL(string: "https://maddie.info/null_privacy_policy")!) +// } + LegalLinksView() + .padding(16) + .padding([.bottom], 20) + } }) } } +struct LegalLinksView: View { + + var body: some View { + HStack { + Link("Terms of Use", destination: URL(string: "https://www.apple.com/legal/internet-services/itunes/dev/stdeula/")!) + .padding(12) + Link("Privacy Policy", destination: URL(string: "https://maddie.info/null_privacy_policy")!) + } + } +} + #Preview { ContributeView().environmentObject(TransactionObserver()) } diff --git a/Toki Trainer/Views/WordListViews/DictionaryView.swift b/Toki Trainer/Views/WordListViews/DictionaryView.swift index 11a777d..1c9ca22 100644 --- a/Toki Trainer/Views/WordListViews/DictionaryView.swift +++ b/Toki Trainer/Views/WordListViews/DictionaryView.swift @@ -52,7 +52,7 @@ struct DictionaryView: View { }) .buttonStyle(.bordered) } - .padding([.top, .leading, .trailing], 8) + .padding([.top, .leading, .trailing], 16) if advancedSearchEnabled == true { VStack { Text("Search for:") @@ -88,7 +88,7 @@ struct DictionaryView: View { .sheet(isPresented: $showGenericLegend, content: { PartsOfSpeechView(selectedPartOfSpeech: nil) }) - .onChange(of: tokiInput) { newValue in + .onChange(of: tokiInput) { filterByInput() //tokiDictViewModel.filterDictionaryEnglishMode(newValue) } diff --git a/Toki Trainer/Views/WordListViews/TranslatorView.swift b/Toki Trainer/Views/WordListViews/TranslatorView.swift index d5369e5..00fde73 100644 --- a/Toki Trainer/Views/WordListViews/TranslatorView.swift +++ b/Toki Trainer/Views/WordListViews/TranslatorView.swift @@ -31,8 +31,8 @@ struct TranslatorView: View { } .buttonStyle(.borderedProminent) } - .padding([.top, .leading, .trailing], 8) - + .padding([.top, .leading, .trailing], 16) + if tokiInput.count == 0 { List(tokiDictViewModel.dictionary, id: \.word) { entry in TokiWordsListEntryView(entry: entry, selectedPartOfSpeech: $selectedPartOfSpeech) @@ -52,8 +52,8 @@ struct TranslatorView: View { .sheet(item: $selectedPartOfSpeech) { selectedPOS in PartsOfSpeechView(selectedPartOfSpeech: selectedPOS) } - .onChange(of: tokiInput) { newValue in - tokiDictViewModel.translatePhrase(newValue) + .onChange(of: tokiInput) { + tokiDictViewModel.translatePhrase(tokiInput) } .onTapGesture { hideKeyboard()