This commit is contained in:
Trey t
2022-12-23 09:43:48 -06:00
parent 49e3812659
commit 488832b777
9 changed files with 195 additions and 167 deletions

View File

@@ -25,7 +25,7 @@ struct FeelsApp: App {
} }
UIApplication.shared.applicationIconBadgeNumber = 0 UIApplication.shared.applicationIconBadgeNumber = 0
// PersistenceController.shared.clearDB() // PersistenceController.shared.clearDB()
PersistenceController.shared.populateMemory() // PersistenceController.shared.populateMemory()
} }
var body: some Scene { var body: some Scene {

View File

@@ -23,6 +23,8 @@ class IAPManager: ObservableObject {
@Published private(set) var subscriptions = [Product: (status: [Product.SubscriptionInfo.Status], renewalInfo: RenewalInfo)?]() @Published private(set) var subscriptions = [Product: (status: [Product.SubscriptionInfo.Status], renewalInfo: RenewalInfo)?]()
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date() @AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
@Published private(set) var isLoadingSubscriptions = false
public var sortedSubscriptionKeysByPriceOptions: [Product] { public var sortedSubscriptionKeysByPriceOptions: [Product] {
subscriptions.keys.sorted(by: { subscriptions.keys.sorted(by: {
$0.price < $1.price $0.price < $1.price
@@ -89,7 +91,7 @@ class IAPManager: ObservableObject {
} }
private let iapIdentifiers = Set([ private let iapIdentifiers = Set([
"com.88oakapps.ifeel.IAP.subscriptions.weekly", // "com.88oakapps.ifeel.IAP.subscriptions.weekly",
"com.88oakapps.ifeel.IAP.subscriptions.monthly", "com.88oakapps.ifeel.IAP.subscriptions.monthly",
"com.88oakapps.ifeel.IAP.subscriptions.yearly" "com.88oakapps.ifeel.IAP.subscriptions.yearly"
]) ])
@@ -97,6 +99,8 @@ class IAPManager: ObservableObject {
var expireOnTimer: Timer? var expireOnTimer: Timer?
init() { init() {
isLoadingSubscriptions = true
//Start a transaction listener as close to app launch as possible so you don't miss any transactions. //Start a transaction listener as close to app launch as possible so you don't miss any transactions.
updateListenerTask = listenForTransactions() updateListenerTask = listenForTransactions()
@@ -133,6 +137,9 @@ class IAPManager: ObservableObject {
decideShowIAP() decideShowIAP()
decideShowIAPWarning() decideShowIAPWarning()
DispatchQueue.main.async {
self.isLoadingSubscriptions = false
}
} }
} }

View File

@@ -26,6 +26,7 @@ extension PersistenceController {
} }
func populateMemory() { func populateMemory() {
#if debug
for idx in 1..<255 { for idx in 1..<255 {
let newItem = MoodEntry(context: viewContext) let newItem = MoodEntry(context: viewContext)
newItem.timestamp = Calendar.current.date(byAdding: .day, value: -idx, to: Date()) newItem.timestamp = Calendar.current.date(byAdding: .day, value: -idx, to: Date())
@@ -48,6 +49,7 @@ extension PersistenceController {
let nsError = error as NSError let nsError = error as NSError
fatalError("Unresolved error \(nsError), \(nsError.userInfo)") fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
} }
#endif
} }
func generateObjectNotInArray(forDate date: Date = Date(), withMood mood: Mood = .placeholder) -> MoodEntry { func generateObjectNotInArray(forDate date: Date = Date(), withMood mood: Mood = .placeholder) -> MoodEntry {

View File

@@ -17,6 +17,7 @@ struct IAPWarningView: View {
private let height: Float private let height: Float
private let showManageSubClosure: (() -> Void)? private let showManageSubClosure: (() -> Void)?
@State private var showSettings = false @State private var showSettings = false
public init(height: Float, iapManager: IAPManager, showManageSubClosure: (() -> Void)? = nil, showCountdownTimer: Bool = false) { public init(height: Float, iapManager: IAPManager, showManageSubClosure: (() -> Void)? = nil, showCountdownTimer: Bool = false) {
@@ -27,11 +28,17 @@ struct IAPWarningView: View {
var body: some View { var body: some View {
VStack { VStack {
Text(String(format: String(localized: "iap_warning_view_title"), iapManager.daysLeftBeforeIAP)) if let date = Calendar.current.date(byAdding: .day, value: 30, to: firstLaunchDate) {
Text(String(localized: "iap_warning_view_title"))
.font(.body) .font(.body)
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
.background(theme.currentTheme.secondaryBGColor) .background(theme.currentTheme.secondaryBGColor)
Text(date, style: .relative)
.font(.body)
.bold()
.foregroundColor(textColor)
Button(action: { Button(action: {
showSettings.toggle() showSettings.toggle()
}, label: { }, label: {
@@ -45,7 +52,7 @@ struct IAPWarningView: View {
.frame(height: 50) .frame(height: 50)
.background(RoundedRectangle(cornerRadius: 10).fill(DefaultMoodTint.color(forMood: .great))) .background(RoundedRectangle(cornerRadius: 10).fill(DefaultMoodTint.color(forMood: .great)))
} }
// .frame(height: CGFloat(height)) }
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
.padding() .padding()
.background(theme.currentTheme.secondaryBGColor) .background(theme.currentTheme.secondaryBGColor)

View File

@@ -116,7 +116,6 @@ struct MonthView: View {
} }
} }
.onPreferenceChange(ViewOffsetKey.self) { value in .onPreferenceChange(ViewOffsetKey.self) { value in
print(value)
iAPWarningViewHidden = value < 0 iAPWarningViewHidden = value < 0
} }
} }

View File

@@ -100,6 +100,17 @@ struct PurchaseButtonView: View {
VStack { VStack {
ZStack { ZStack {
theme.currentTheme.secondaryBGColor theme.currentTheme.secondaryBGColor
if iapManager.isLoadingSubscriptions {
VStack(spacing: 20) {
Text(String(localized: "purchase_view_loading"))
.font(.body)
.bold()
.frame(minWidth: 0, maxWidth: .infinity, alignment: .center)
ProgressView()
}
} else {
VStack(spacing: 20) { VStack(spacing: 20) {
Text(String(localized: "purchase_view_title")) Text(String(localized: "purchase_view_title"))
.font(.body) .font(.body)
@@ -156,9 +167,10 @@ struct PurchaseButtonView: View {
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
} }
}
}
.background(.ultraThinMaterial) .background(.ultraThinMaterial)
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
}
.background(.clear) .background(.clear)
} }

View File

@@ -41,9 +41,10 @@ struct SettingsView: View {
subscriptionInfoView subscriptionInfoView
canDelete canDelete
showOnboardingButton showOnboardingButton
specialThanksCell // specialThanksCell
} }
#if DEBUG
Group { Group {
Divider() Divider()
Text("Test builds only") Text("Test builds only")
@@ -62,7 +63,7 @@ struct SettingsView: View {
Divider() Divider()
} }
Spacer() Spacer()
#endif
Text("\(Bundle.main.appName) v \(Bundle.main.versionNumber) (Build \(Bundle.main.buildNumber))") Text("\(Bundle.main.appName) v \(Bundle.main.versionNumber) (Build \(Bundle.main.buildNumber))")
.font(.body) .font(.body)
} }

View File

@@ -81,7 +81,6 @@ struct YearView: View {
.edgesIgnoringSafeArea(.all) .edgesIgnoringSafeArea(.all)
) )
.onPreferenceChange(ViewOffsetKey.self) { value in .onPreferenceChange(ViewOffsetKey.self) { value in
print(value)
iAPWarningViewHidden = value < 0 iAPWarningViewHidden = value < 0
} }
} }

View File

@@ -114,8 +114,9 @@
"purchase_view_current_subscription" = "Current Subscription"; "purchase_view_current_subscription" = "Current Subscription";
"purchase_view_current_subscription_expires_in" = "Trial expires in:"; "purchase_view_current_subscription_expires_in" = "Trial expires in:";
"purchase_view_current_subscription_expired_on" = "Trial expired on:"; "purchase_view_current_subscription_expired_on" = "Trial expired on:";
"purchase_view_loading" = "Loading subscription options";
"iap_warning_view_title" = "In %d day(s) this view will no longer scroll"; "iap_warning_view_title" = "This view will no longer scroll in ";
"iap_warning_view_buy_button" = "Subscribe Now"; "iap_warning_view_buy_button" = "Subscribe Now";
/* not used */ /* not used */
"onboarding_title_title" = "What would you like the reminder to say?"; "onboarding_title_title" = "What would you like the reminder to say?";