Skip to content

Commit

Permalink
Show patronate options on General tab
Browse files Browse the repository at this point in the history
  • Loading branch information
leits committed Aug 13, 2023
1 parent 83d2010 commit 1bbbed5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 89 deletions.
1 change: 1 addition & 0 deletions MeetingBar/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
139 changes: 52 additions & 87 deletions MeetingBar/Views/Preferences/GeneralTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ struct GeneralTab: View {
var body: some View {
VStack(alignment: .leading, spacing: 15) {
Section {
Spacer()
LaunchAtLoginANDPreferredLanguagePicker()
Divider()
JoinEventNotificationPicker()
Expand Down Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit 1bbbed5

Please sign in to comment.