WIP
This commit is contained in:
@@ -25,7 +25,7 @@ struct FeelsApp: App {
|
||||
}
|
||||
UIApplication.shared.applicationIconBadgeNumber = 0
|
||||
// PersistenceController.shared.clearDB()
|
||||
PersistenceController.shared.populateMemory()
|
||||
// PersistenceController.shared.populateMemory()
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
|
||||
@@ -23,6 +23,8 @@ class IAPManager: ObservableObject {
|
||||
@Published private(set) var subscriptions = [Product: (status: [Product.SubscriptionInfo.Status], renewalInfo: RenewalInfo)?]()
|
||||
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
|
||||
|
||||
@Published private(set) var isLoadingSubscriptions = false
|
||||
|
||||
public var sortedSubscriptionKeysByPriceOptions: [Product] {
|
||||
subscriptions.keys.sorted(by: {
|
||||
$0.price < $1.price
|
||||
@@ -89,7 +91,7 @@ class IAPManager: ObservableObject {
|
||||
}
|
||||
|
||||
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.yearly"
|
||||
])
|
||||
@@ -97,6 +99,8 @@ class IAPManager: ObservableObject {
|
||||
var expireOnTimer: Timer?
|
||||
|
||||
init() {
|
||||
isLoadingSubscriptions = true
|
||||
|
||||
//Start a transaction listener as close to app launch as possible so you don't miss any transactions.
|
||||
updateListenerTask = listenForTransactions()
|
||||
|
||||
@@ -133,6 +137,9 @@ class IAPManager: ObservableObject {
|
||||
|
||||
decideShowIAP()
|
||||
decideShowIAPWarning()
|
||||
DispatchQueue.main.async {
|
||||
self.isLoadingSubscriptions = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ extension PersistenceController {
|
||||
}
|
||||
|
||||
func populateMemory() {
|
||||
#if debug
|
||||
for idx in 1..<255 {
|
||||
let newItem = MoodEntry(context: viewContext)
|
||||
newItem.timestamp = Calendar.current.date(byAdding: .day, value: -idx, to: Date())
|
||||
@@ -48,6 +49,7 @@ extension PersistenceController {
|
||||
let nsError = error as NSError
|
||||
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
func generateObjectNotInArray(forDate date: Date = Date(), withMood mood: Mood = .placeholder) -> MoodEntry {
|
||||
|
||||
@@ -17,6 +17,7 @@ struct IAPWarningView: View {
|
||||
|
||||
private let height: Float
|
||||
private let showManageSubClosure: (() -> Void)?
|
||||
|
||||
@State private var showSettings = false
|
||||
|
||||
public init(height: Float, iapManager: IAPManager, showManageSubClosure: (() -> Void)? = nil, showCountdownTimer: Bool = false) {
|
||||
@@ -27,11 +28,17 @@ struct IAPWarningView: View {
|
||||
|
||||
var body: some View {
|
||||
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)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.background(theme.currentTheme.secondaryBGColor)
|
||||
|
||||
Text(date, style: .relative)
|
||||
.font(.body)
|
||||
.bold()
|
||||
.foregroundColor(textColor)
|
||||
|
||||
Button(action: {
|
||||
showSettings.toggle()
|
||||
}, label: {
|
||||
@@ -45,7 +52,7 @@ struct IAPWarningView: View {
|
||||
.frame(height: 50)
|
||||
.background(RoundedRectangle(cornerRadius: 10).fill(DefaultMoodTint.color(forMood: .great)))
|
||||
}
|
||||
// .frame(height: CGFloat(height))
|
||||
}
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.padding()
|
||||
.background(theme.currentTheme.secondaryBGColor)
|
||||
|
||||
@@ -116,7 +116,6 @@ struct MonthView: View {
|
||||
}
|
||||
}
|
||||
.onPreferenceChange(ViewOffsetKey.self) { value in
|
||||
print(value)
|
||||
iAPWarningViewHidden = value < 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,17 @@ struct PurchaseButtonView: View {
|
||||
VStack {
|
||||
ZStack {
|
||||
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) {
|
||||
Text(String(localized: "purchase_view_title"))
|
||||
.font(.body)
|
||||
@@ -156,9 +167,10 @@ struct PurchaseButtonView: View {
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
.background(.ultraThinMaterial)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
}
|
||||
.background(.clear)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,10 @@ struct SettingsView: View {
|
||||
subscriptionInfoView
|
||||
canDelete
|
||||
showOnboardingButton
|
||||
specialThanksCell
|
||||
// specialThanksCell
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
Group {
|
||||
Divider()
|
||||
Text("Test builds only")
|
||||
@@ -62,7 +63,7 @@ struct SettingsView: View {
|
||||
Divider()
|
||||
}
|
||||
Spacer()
|
||||
|
||||
#endif
|
||||
Text("\(Bundle.main.appName) v \(Bundle.main.versionNumber) (Build \(Bundle.main.buildNumber))")
|
||||
.font(.body)
|
||||
}
|
||||
|
||||
@@ -81,7 +81,6 @@ struct YearView: View {
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
)
|
||||
.onPreferenceChange(ViewOffsetKey.self) { value in
|
||||
print(value)
|
||||
iAPWarningViewHidden = value < 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,9 @@
|
||||
"purchase_view_current_subscription" = "Current Subscription";
|
||||
"purchase_view_current_subscription_expires_in" = "Trial expires in:";
|
||||
"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";
|
||||
/* not used */
|
||||
"onboarding_title_title" = "What would you like the reminder to say?";
|
||||
|
||||
Reference in New Issue
Block a user