From 1bbbed5e407caf2c894ee3de095fe0d953b944e3 Mon Sep 17 00:00:00 2001 From: leits Date: Sun, 13 Aug 2023 23:27:34 +0300 Subject: [PATCH] Show patronate options on General tab --- MeetingBar/Constants.swift | 1 + .../en.lproj/Localizable.strings | 2 +- .../uk.lproj/Localizable.strings | 2 +- MeetingBar/Views/Preferences/GeneralTab.swift | 139 +++++++----------- 4 files changed, 55 insertions(+), 89 deletions(-) diff --git a/MeetingBar/Constants.swift b/MeetingBar/Constants.swift index 5c1ff08d..ce92f493 100644 --- a/MeetingBar/Constants.swift +++ b/MeetingBar/Constants.swift @@ -26,6 +26,7 @@ enum TitleTruncationRules { enum Links { static var patreon = URL(string: "https://www.patreon.com/meetingbar")! + static var buymeacoffee = URL(string: "https://www.buymeacoffee.com/meetingbar")! static var github = URL(string: "https://github.com/leits/MeetingBar")! static var telegram = URL(string: "https://t.me/leits")! static var twitter = URL(string: "https://twitter.com/leits_dev")! diff --git a/MeetingBar/Resources /Localization /en.lproj/Localizable.strings b/MeetingBar/Resources /Localization /en.lproj/Localizable.strings index 354cfa1a..eb7736ce 100644 --- a/MeetingBar/Resources /Localization /en.lproj/Localizable.strings +++ b/MeetingBar/Resources /Localization /en.lproj/Localizable.strings @@ -58,7 +58,7 @@ "preferences_general_patron_six_months" = "6 months – 5.99 USD"; "preferences_general_patron_twelve_months" = "12 months – 11.99 USD"; "preferences_general_patron_description" = "These are one-off purchases, and will not auto-renew."; -"preferences_general_patron_thank_for_purchase" = "Thanks! You have paid to support MeetingBar for %d months. 🎉"; +"preferences_general_patron_thank_for_purchase" = "Thanks! You have supported MeetingBar for %d months 🎉"; "preferences_general_patron_restore_purchases" = "Restore Purchases"; "preferences_general_feedback_title" = "If you have any questions or feedback,\nfeel free to get in contact:"; "preferences_general_feedback_email" = "E-mail"; diff --git a/MeetingBar/Resources /Localization /uk.lproj/Localizable.strings b/MeetingBar/Resources /Localization /uk.lproj/Localizable.strings index 426b9126..1f42919b 100644 --- a/MeetingBar/Resources /Localization /uk.lproj/Localizable.strings +++ b/MeetingBar/Resources /Localization /uk.lproj/Localizable.strings @@ -54,7 +54,7 @@ "preferences_general_patron_six_months" = "6 місяців - 5,99 USD"; "preferences_general_patron_twelve_months" = "12 місяців - 11,99 USD"; "preferences_general_patron_description" = "Це одноразові платежі, які не будуть повторюватись автоматично."; -"preferences_general_patron_thank_for_purchase" = "Дякую! Ви підтримали MeetingBar на %d місяців! 🎉"; +"preferences_general_patron_thank_for_purchase" = "Дякую! Ви підтримали MeetingBar на %d місяців 🎉"; "preferences_general_patron_restore_purchases" = "Відновити платежі"; "preferences_general_feedback_title" = "Якщо у Вас є запитання або ідеї,\nпросто напишіть мені:"; "preferences_general_feedback_email" = "email"; diff --git a/MeetingBar/Views/Preferences/GeneralTab.swift b/MeetingBar/Views/Preferences/GeneralTab.swift index 7c143b5c..363eb25e 100644 --- a/MeetingBar/Views/Preferences/GeneralTab.swift +++ b/MeetingBar/Views/Preferences/GeneralTab.swift @@ -15,7 +15,6 @@ struct GeneralTab: View { var body: some View { VStack(alignment: .leading, spacing: 15) { Section { - Spacer() LaunchAtLoginANDPreferredLanguagePicker() Divider() JoinEventNotificationPicker() @@ -98,107 +97,73 @@ struct ShortcutsModal: View { } struct PatronageAppSection: View { - @State var showingPatronageModal = false @State var showingContactModal = false + @Default(.patronageDuration) var patronageDuration + @Default(.isInstalledFromAppStore) var isInstalledFromAppStore var body: some View { - VStack(alignment: .leading, spacing: 15) { - VStack(alignment: .center) { - Spacer() + VStack(alignment: .center, spacing: 15) { + if isInstalledFromAppStore { HStack { - VStack(alignment: .center) { - Image("appIconForAbout").resizable().frame(width: 120.0, height: 120.0) - Text("MeetingBar").font(.system(size: 20)).bold() - Text(Defaults[.appVersion]).foregroundColor(.gray) - }.lineLimit(1).minimumScaleFactor(0.5).frame(minWidth: 0, maxWidth: .infinity) - VStack { - Spacer() - Text("preferences_general_meeting_bar_description".loco()).multilineTextAlignment(.center) - Spacer() - - HStack { - Spacer() - Button(action: clickPatronage) { - Text("preferences_general_external_patronage".loco()) - }.sheet(isPresented: $showingPatronageModal) { - PatronageModal() - } - Spacer() - Button(action: { Links.github.openInDefaultBrowser() }) { - Text("preferences_general_external_gitHub".loco()) - } - Spacer() - Button(action: { self.showingContactModal.toggle() }) { - Text("preferences_general_external_contact".loco()) - }.sheet(isPresented: $showingContactModal) { - ContactModal() - } - Spacer() - } - Spacer() - }.frame(minWidth: 360, maxWidth: .infinity) + Text("preferences_general_patron_title".loco()).bold() + Spacer() + Text("preferences_general_patron_description".loco()).font(.system(size: 10)) } - Spacer() - } - } - } - - func clickPatronage() { - if Defaults[.isInstalledFromAppStore] { - showingPatronageModal.toggle() - } else { - Links.patreon.openInDefaultBrowser() - } - } -} - -struct PatronageModal: View { - @Environment(\.presentationMode) var presentationMode - - @Default(.patronageDuration) var patronageDuration - - var body: some View { - VStack { - Spacer() - HStack { - VStack(alignment: .leading) { - HStack { - Text("preferences_general_patron_title".loco()).bold() - } - }.frame(width: 120) - Spacer() - VStack(alignment: .leading) { + HStack { Button(action: { purchasePatronage(PatronageProducts.threeMonth) }) { - Text("preferences_general_patron_three_months".loco()).frame(width: 150) + Text("preferences_general_patron_three_months".loco()) } Button(action: { purchasePatronage(PatronageProducts.sixMonth) }) { - Text("preferences_general_patron_six_months".loco()).frame(width: 150) + Text("preferences_general_patron_six_months".loco()) } Button(action: { purchasePatronage(PatronageProducts.twelveMonth) }) { - Text("preferences_general_patron_twelve_months".loco()).frame(width: 150) + Text("preferences_general_patron_twelve_months".loco()) } - Text("preferences_general_patron_description".loco()).font(.system(size: 10)) - }.frame(maxWidth: .infinity) - } - if patronageDuration > 0 { +// Button(action: restorePatronagePurchases) { +// Text("preferences_general_patron_restore_purchases".loco()) +// } + } + if patronageDuration > 0 { + Text("preferences_general_patron_thank_for_purchase".loco(patronageDuration)) + } Divider() - Spacer() - Text("preferences_general_patron_thank_for_purchase".loco(patronageDuration)) } - Spacer() - Divider() + HStack { - Button(action: restorePatronagePurchases) { - Text("preferences_general_patron_restore_purchases".loco()) - } - Spacer() - Button(action: { - self.presentationMode.wrappedValue.dismiss() - }) { - Text("general_close".loco()) - } + VStack(alignment: .center) { + Image("appIconForAbout").resizable().frame(width: 120.0, height: 120.0) + Text("MeetingBar").font(.system(size: 20)).bold() + Text(Defaults[.appVersion]).foregroundColor(.gray) + }.lineLimit(1).minimumScaleFactor(0.5).frame(minWidth: 0, maxWidth: .infinity) + VStack { + Spacer() + Text("preferences_general_meeting_bar_description".loco()).multilineTextAlignment(.center) + Text("") + HStack { + Spacer() + Button(action: { Links.patreon.openInDefaultBrowser() }) { + Text("Patreon") + } + Spacer() + Button(action: { Links.buymeacoffee.openInDefaultBrowser() }) { + Text("Buy Me A Coffee") + } + Spacer() + Button(action: { Links.github.openInDefaultBrowser() }) { + Text("preferences_general_external_gitHub".loco()) + } + Spacer() + Button(action: { self.showingContactModal.toggle() }) { + Text("preferences_general_external_contact".loco()) + }.sheet(isPresented: $showingContactModal) { + ContactModal() + } + Spacer() + } + Spacer() + }.frame(minWidth: 360, maxWidth: .infinity) } - }.padding().frame(width: 400, height: 300) + } } }