WIP
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -88,10 +90,10 @@ extension PersistenceController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func longestStreak() -> [MoodEntry] {
|
func longestStreak() -> [MoodEntry] {
|
||||||
// let predicate = NSPredicate(format: "forDate == %@", date as NSDate)
|
// let predicate = NSPredicate(format: "forDate == %@", date as NSDate)
|
||||||
|
|
||||||
let fetchRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
|
let fetchRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
|
||||||
// fetchRequest.predicate = predicate
|
// fetchRequest.predicate = predicate
|
||||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "forDate", ascending: true)]
|
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "forDate", ascending: true)]
|
||||||
let data = try! viewContext.fetch(fetchRequest)
|
let data = try! viewContext.fetch(fetchRequest)
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -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,25 +28,31 @@ 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) {
|
||||||
.font(.body)
|
Text(String(localized: "iap_warning_view_title"))
|
||||||
.frame(minWidth: 0, maxWidth: .infinity)
|
.font(.body)
|
||||||
.background(theme.currentTheme.secondaryBGColor)
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
.background(theme.currentTheme.secondaryBGColor)
|
||||||
Button(action: {
|
|
||||||
showSettings.toggle()
|
Text(date, style: .relative)
|
||||||
}, label: {
|
.font(.body)
|
||||||
Text(String(localized: "iap_warning_view_buy_button"))
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.bold()
|
.bold()
|
||||||
.frame(maxWidth: .infinity)
|
.foregroundColor(textColor)
|
||||||
.contentShape(Rectangle())
|
|
||||||
})
|
Button(action: {
|
||||||
.frame(maxWidth: .infinity)
|
showSettings.toggle()
|
||||||
.frame(height: 50)
|
}, label: {
|
||||||
.background(RoundedRectangle(cornerRadius: 10).fill(DefaultMoodTint.color(forMood: .great)))
|
Text(String(localized: "iap_warning_view_buy_button"))
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.bold()
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
})
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.frame(height: 50)
|
||||||
|
.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)
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,65 +100,77 @@ struct PurchaseButtonView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
ZStack {
|
ZStack {
|
||||||
theme.currentTheme.secondaryBGColor
|
theme.currentTheme.secondaryBGColor
|
||||||
VStack(spacing: 20) {
|
|
||||||
Text(String(localized: "purchase_view_title"))
|
|
||||||
.font(.body)
|
|
||||||
.bold()
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
|
||||||
|
|
||||||
if showCountdownTimer {
|
|
||||||
if let date = Calendar.current.date(byAdding: .day, value: 30, to: firstLaunchDate) {
|
|
||||||
HStack {
|
|
||||||
if iapManager.daysLeftBeforeIAP > 0 {
|
|
||||||
Text(String(localized: "purchase_view_current_subscription_expires_in"))
|
|
||||||
.font(.body)
|
|
||||||
.bold()
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
|
|
||||||
Text(date, style: .relative)
|
|
||||||
.font(.body)
|
|
||||||
.bold()
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
} else {
|
|
||||||
Text(String(localized: "purchase_view_current_subscription_expired_on"))
|
|
||||||
.font(.body)
|
|
||||||
.bold()
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
|
|
||||||
Text(date, style: .date)
|
|
||||||
.font(.body)
|
|
||||||
.bold()
|
|
||||||
.foregroundColor(textColor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HStack {
|
|
||||||
ForEach(iapManager.sortedSubscriptionKeysByPriceOptions) { product in
|
|
||||||
Button(action: {
|
|
||||||
purchase(product: product)
|
|
||||||
}, label: {
|
|
||||||
Text("\(product.displayPrice)\n\(product.displayName)")
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.bold()
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.contentShape(Rectangle())
|
|
||||||
})
|
|
||||||
.padding()
|
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.background(RoundedRectangle(cornerRadius: 10).fill(iapManager.colorForIAPButton(iapIdentifier: product.id)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.padding([.leading, .trailing])
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity)
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
.bold()
|
||||||
|
.foregroundColor(textColor)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||||
|
|
||||||
|
if showCountdownTimer {
|
||||||
|
if let date = Calendar.current.date(byAdding: .day, value: 30, to: firstLaunchDate) {
|
||||||
|
HStack {
|
||||||
|
if iapManager.daysLeftBeforeIAP > 0 {
|
||||||
|
Text(String(localized: "purchase_view_current_subscription_expires_in"))
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.foregroundColor(textColor)
|
||||||
|
|
||||||
|
Text(date, style: .relative)
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.foregroundColor(textColor)
|
||||||
|
} else {
|
||||||
|
Text(String(localized: "purchase_view_current_subscription_expired_on"))
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.foregroundColor(textColor)
|
||||||
|
|
||||||
|
Text(date, style: .date)
|
||||||
|
.font(.body)
|
||||||
|
.bold()
|
||||||
|
.foregroundColor(textColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HStack {
|
||||||
|
ForEach(iapManager.sortedSubscriptionKeysByPriceOptions) { product in
|
||||||
|
Button(action: {
|
||||||
|
purchase(product: product)
|
||||||
|
}, label: {
|
||||||
|
Text("\(product.displayPrice)\n\(product.displayName)")
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.bold()
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.contentShape(Rectangle())
|
||||||
|
})
|
||||||
|
.padding()
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.background(RoundedRectangle(cornerRadius: 10).fill(iapManager.colorForIAPButton(iapIdentifier: product.id)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding([.leading, .trailing])
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.background(.ultraThinMaterial)
|
|
||||||
.frame(minWidth: 0, maxWidth: .infinity)
|
|
||||||
}
|
}
|
||||||
|
.background(.ultraThinMaterial)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
.background(.clear)
|
.background(.clear)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ struct SettingsView: View {
|
|||||||
@State private var importContent = ""
|
@State private var importContent = ""
|
||||||
|
|
||||||
@State private var showOnboarding = false
|
@State private var showOnboarding = false
|
||||||
|
|
||||||
@State private var showSpecialThanks = false
|
@State private var showSpecialThanks = false
|
||||||
@State private var showWhyBGMode = false
|
@State private var showWhyBGMode = false
|
||||||
@ObservedObject var syncMonitor = SyncMonitor.shared
|
@ObservedObject var syncMonitor = SyncMonitor.shared
|
||||||
@@ -29,7 +29,7 @@ struct SettingsView: View {
|
|||||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
||||||
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
|
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
VStack {
|
VStack {
|
||||||
@@ -37,24 +37,25 @@ struct SettingsView: View {
|
|||||||
closeButtonView
|
closeButtonView
|
||||||
.padding()
|
.padding()
|
||||||
|
|
||||||
// cloudKitEnable
|
// cloudKitEnable
|
||||||
subscriptionInfoView
|
subscriptionInfoView
|
||||||
canDelete
|
canDelete
|
||||||
showOnboardingButton
|
showOnboardingButton
|
||||||
specialThanksCell
|
// specialThanksCell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
Group {
|
Group {
|
||||||
Divider()
|
Divider()
|
||||||
Text("Test builds only")
|
Text("Test builds only")
|
||||||
addTestDataCell
|
addTestDataCell
|
||||||
clearDB
|
clearDB
|
||||||
// randomIcons
|
// randomIcons
|
||||||
|
|
||||||
if useCloudKit {
|
if useCloudKit {
|
||||||
cloudKitStatus
|
cloudKitStatus
|
||||||
}
|
}
|
||||||
// fixWeekday
|
// fixWeekday
|
||||||
exportData
|
exportData
|
||||||
importData
|
importData
|
||||||
editFirstLaunchDatePast
|
editFirstLaunchDatePast
|
||||||
@@ -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)
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
let localTime = dateFormatter.date(from: columns[3])!
|
let localTime = dateFormatter.date(from: columns[3])!
|
||||||
moodEntry.weekDay = Int16(Calendar.current.component(.weekday, from: localTime))
|
moodEntry.weekDay = Int16(Calendar.current.component(.weekday, from: localTime))
|
||||||
// let _ = print("import info: ", columns[3], dateFormatter.date(from: columns[3]), localTime, Int16(Calendar.current.component(.weekday, from: localTime)))
|
// let _ = print("import info: ", columns[3], dateFormatter.date(from: columns[3]), localTime, Int16(Calendar.current.component(.weekday, from: localTime)))
|
||||||
try! PersistenceController.shared.viewContext.save()
|
try! PersistenceController.shared.viewContext.save()
|
||||||
}
|
}
|
||||||
PersistenceController.shared.saveAndRunDataListerners()
|
PersistenceController.shared.saveAndRunDataListerners()
|
||||||
@@ -184,7 +185,7 @@ struct SettingsView: View {
|
|||||||
Text(String(localized: "settings_view_special_thanks_to_title"))
|
Text(String(localized: "settings_view_special_thanks_to_title"))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
|
|
||||||
if showSpecialThanks {
|
if showSpecialThanks {
|
||||||
Divider()
|
Divider()
|
||||||
@@ -213,7 +214,7 @@ struct SettingsView: View {
|
|||||||
Text("Add test data")
|
Text("Add test data")
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
@@ -263,7 +264,7 @@ struct SettingsView: View {
|
|||||||
Text("Clear DB")
|
Text("Clear DB")
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
@@ -278,7 +279,7 @@ struct SettingsView: View {
|
|||||||
Text("Fix Weekday")
|
Text("Fix Weekday")
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
@@ -296,7 +297,7 @@ struct SettingsView: View {
|
|||||||
Text(String(localized: "settings_view_why_bg_mode_title"))
|
Text(String(localized: "settings_view_why_bg_mode_title"))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
if showWhyBGMode {
|
if showWhyBGMode {
|
||||||
Text(String(localized: "settings_view_why_bg_mode_body"))
|
Text(String(localized: "settings_view_why_bg_mode_body"))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
@@ -318,7 +319,7 @@ struct SettingsView: View {
|
|||||||
Text(String(localized: "settings_view_show_onboarding"))
|
Text(String(localized: "settings_view_show_onboarding"))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
@@ -332,10 +333,10 @@ struct SettingsView: View {
|
|||||||
Text(String(localized: "settings_use_cloudkit_title"))
|
Text(String(localized: "settings_use_cloudkit_title"))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.onChange(of: useCloudKit) { newValue in
|
.onChange(of: useCloudKit) { newValue in
|
||||||
EventLogger.log(event: "toggle_use_cloudkit", withData: ["value": newValue])
|
EventLogger.log(event: "toggle_use_cloudkit", withData: ["value": newValue])
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
Text(String(localized: "settings_use_cloudkit_body"))
|
Text(String(localized: "settings_use_cloudkit_body"))
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
}
|
}
|
||||||
@@ -366,11 +367,11 @@ struct SettingsView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
Toggle(String(localized: "settings_use_delete_enable"),
|
Toggle(String(localized: "settings_use_delete_enable"),
|
||||||
isOn: $deleteEnabled)
|
isOn: $deleteEnabled)
|
||||||
.onChange(of: deleteEnabled) { newValue in
|
.onChange(of: deleteEnabled) { newValue in
|
||||||
EventLogger.log(event: "toggle_can_delete", withData: ["value": newValue])
|
EventLogger.log(event: "toggle_can_delete", withData: ["value": newValue])
|
||||||
}
|
}
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
@@ -387,12 +388,12 @@ struct SettingsView: View {
|
|||||||
Text("Export")
|
Text("Export")
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
}
|
}
|
||||||
|
|
||||||
private var importData: some View {
|
private var importData: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
theme.currentTheme.secondaryBGColor
|
theme.currentTheme.secondaryBGColor
|
||||||
@@ -403,7 +404,7 @@ struct SettingsView: View {
|
|||||||
Text("Import")
|
Text("Import")
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
@@ -414,17 +415,17 @@ struct SettingsView: View {
|
|||||||
theme.currentTheme.secondaryBGColor
|
theme.currentTheme.secondaryBGColor
|
||||||
Button(action: {
|
Button(action: {
|
||||||
var iconViews = [UIImage]()
|
var iconViews = [UIImage]()
|
||||||
|
|
||||||
// for _ in 0...300 {
|
// for _ in 0...300 {
|
||||||
// iconViews.append(
|
// iconViews.append(
|
||||||
// IconView(iconViewModel: IconViewModel(
|
// IconView(iconViewModel: IconViewModel(
|
||||||
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// bgColor: Color.random(),
|
// bgColor: Color.random(),
|
||||||
// bgOverlayColor: Color.random(),
|
// bgOverlayColor: Color.random(),
|
||||||
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// innerColor: Color.random())
|
// innerColor: Color.random())
|
||||||
// ).asImage(size: CGSize(width: 1024, height: 1024)))
|
// ).asImage(size: CGSize(width: 1024, height: 1024)))
|
||||||
// }
|
// }
|
||||||
|
|
||||||
iconViews.append(
|
iconViews.append(
|
||||||
IconView(iconViewModel: IconViewModel(
|
IconView(iconViewModel: IconViewModel(
|
||||||
@@ -433,7 +434,7 @@ struct SettingsView: View {
|
|||||||
bgOverlayColor: IconViewModel.great.bgOverlayColor,
|
bgOverlayColor: IconViewModel.great.bgOverlayColor,
|
||||||
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
innerColor: IconViewModel.great.innerColor)
|
innerColor: IconViewModel.great.innerColor)
|
||||||
).asImage(size: CGSize(width: 1024, height: 1024))
|
).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
)
|
)
|
||||||
|
|
||||||
iconViews.append(
|
iconViews.append(
|
||||||
@@ -443,7 +444,7 @@ struct SettingsView: View {
|
|||||||
bgOverlayColor: IconViewModel.good.bgOverlayColor,
|
bgOverlayColor: IconViewModel.good.bgOverlayColor,
|
||||||
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
innerColor: IconViewModel.good.innerColor)
|
innerColor: IconViewModel.good.innerColor)
|
||||||
).asImage(size: CGSize(width: 1024, height: 1024))
|
).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
)
|
)
|
||||||
|
|
||||||
iconViews.append(
|
iconViews.append(
|
||||||
@@ -453,7 +454,7 @@ struct SettingsView: View {
|
|||||||
bgOverlayColor: IconViewModel.average.bgOverlayColor,
|
bgOverlayColor: IconViewModel.average.bgOverlayColor,
|
||||||
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
innerColor: IconViewModel.average.innerColor)
|
innerColor: IconViewModel.average.innerColor)
|
||||||
).asImage(size: CGSize(width: 1024, height: 1024))
|
).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
)
|
)
|
||||||
|
|
||||||
iconViews.append(
|
iconViews.append(
|
||||||
@@ -463,7 +464,7 @@ struct SettingsView: View {
|
|||||||
bgOverlayColor: IconViewModel.bad.bgOverlayColor,
|
bgOverlayColor: IconViewModel.bad.bgOverlayColor,
|
||||||
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
innerColor: IconViewModel.bad.innerColor)
|
innerColor: IconViewModel.bad.innerColor)
|
||||||
).asImage(size: CGSize(width: 1024, height: 1024))
|
).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
)
|
)
|
||||||
|
|
||||||
iconViews.append(
|
iconViews.append(
|
||||||
@@ -473,49 +474,49 @@ struct SettingsView: View {
|
|||||||
bgOverlayColor: IconViewModel.horrible.bgOverlayColor,
|
bgOverlayColor: IconViewModel.horrible.bgOverlayColor,
|
||||||
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
innerColor: IconViewModel.horrible.innerColor)
|
innerColor: IconViewModel.horrible.innerColor)
|
||||||
).asImage(size: CGSize(width: 1024, height: 1024))
|
).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// iconViews.append(
|
// iconViews.append(
|
||||||
// IconView(iconViewModel: IconViewModel(
|
// IconView(iconViewModel: IconViewModel(
|
||||||
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// bgColor: Color(hex: "EF0CF3"),
|
// bgColor: Color(hex: "EF0CF3"),
|
||||||
// bgOverlayColor: Color(hex: "EF0CF3").darker(by: 40),
|
// bgOverlayColor: Color(hex: "EF0CF3").darker(by: 40),
|
||||||
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// innerColor: Color(hex: "EF0CF3"))
|
// innerColor: Color(hex: "EF0CF3"))
|
||||||
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// iconViews.append(
|
// iconViews.append(
|
||||||
// IconView(iconViewModel: IconViewModel(
|
// IconView(iconViewModel: IconViewModel(
|
||||||
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// bgColor: Color(hex: "1AE5D6"),
|
// bgColor: Color(hex: "1AE5D6"),
|
||||||
// bgOverlayColor: Color(hex: "1AE5D6").darker(by: 40),
|
// bgOverlayColor: Color(hex: "1AE5D6").darker(by: 40),
|
||||||
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// innerColor: Color(hex: "1AE5D6"))
|
// innerColor: Color(hex: "1AE5D6"))
|
||||||
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// iconViews.append(
|
// iconViews.append(
|
||||||
// IconView(iconViewModel: IconViewModel(
|
// IconView(iconViewModel: IconViewModel(
|
||||||
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// bgColor: Color(hex: "633EC1"),
|
// bgColor: Color(hex: "633EC1"),
|
||||||
// bgOverlayColor: Color(hex: "633EC1").darker(by: 40),
|
// bgOverlayColor: Color(hex: "633EC1").darker(by: 40),
|
||||||
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// innerColor: Color(hex: "633EC1"))
|
// innerColor: Color(hex: "633EC1"))
|
||||||
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
// )
|
// )
|
||||||
//
|
//
|
||||||
// iconViews.append(
|
// iconViews.append(
|
||||||
// IconView(iconViewModel: IconViewModel(
|
// IconView(iconViewModel: IconViewModel(
|
||||||
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// backgroundImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// bgColor: Color(hex: "10F30C"),
|
// bgColor: Color(hex: "10F30C"),
|
||||||
// bgOverlayColor: Color(hex: "10F30C").darker(by: 40),
|
// bgOverlayColor: Color(hex: "10F30C").darker(by: 40),
|
||||||
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
// centerImage: MoodImages.FontAwesome.icon(forMood: .great),
|
||||||
// innerColor: Color(hex: "10F30C"))
|
// innerColor: Color(hex: "10F30C"))
|
||||||
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
// ).asImage(size: CGSize(width: 1024, height: 1024))
|
||||||
// )
|
// )
|
||||||
|
|
||||||
for (idx, image) in iconViews.enumerated() {
|
for (idx, image) in iconViews.enumerated() {
|
||||||
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
||||||
@@ -534,7 +535,7 @@ struct SettingsView: View {
|
|||||||
Text("Create random icons")
|
Text("Create random icons")
|
||||||
.foregroundColor(textColor)
|
.foregroundColor(textColor)
|
||||||
})
|
})
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||||
@@ -555,10 +556,10 @@ struct SettingsView: View {
|
|||||||
struct TextFile: FileDocument {
|
struct TextFile: FileDocument {
|
||||||
// tell the system we support only plain text
|
// tell the system we support only plain text
|
||||||
static var readableContentTypes = [UTType.plainText]
|
static var readableContentTypes = [UTType.plainText]
|
||||||
|
|
||||||
// by default our document is empty
|
// by default our document is empty
|
||||||
var text = ""
|
var text = ""
|
||||||
|
|
||||||
// a simple initializer that creates new, empty documents
|
// a simple initializer that creates new, empty documents
|
||||||
init() {
|
init() {
|
||||||
let entries = PersistenceController.shared.getData(startDate: Date(timeIntervalSince1970: 0),
|
let entries = PersistenceController.shared.getData(startDate: Date(timeIntervalSince1970: 0),
|
||||||
@@ -576,19 +577,19 @@ struct TextFile: FileDocument {
|
|||||||
let weekDay = entry.weekDay
|
let weekDay = entry.weekDay
|
||||||
|
|
||||||
let dataString = "\(canDelete),\(canEdit),\(entryType),\(String(describing: forDate)),\(moodValue),\(String(describing:timestamp)),\(weekDay)\n"
|
let dataString = "\(canDelete),\(canEdit),\(entryType),\(String(describing: forDate)),\(moodValue),\(String(describing:timestamp)),\(weekDay)\n"
|
||||||
// print("DATA: \(dataString)")
|
// print("DATA: \(dataString)")
|
||||||
csvString = csvString.appending(dataString)
|
csvString = csvString.appending(dataString)
|
||||||
}
|
}
|
||||||
text = csvString
|
text = csvString
|
||||||
}
|
}
|
||||||
|
|
||||||
// this initializer loads data that has been saved previously
|
// this initializer loads data that has been saved previously
|
||||||
init(configuration: ReadConfiguration) throws {
|
init(configuration: ReadConfiguration) throws {
|
||||||
if let data = configuration.file.regularFileContents {
|
if let data = configuration.file.regularFileContents {
|
||||||
text = String(decoding: data, as: UTF8.self)
|
text = String(decoding: data, as: UTF8.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this will be called when the system wants to write our data to disk
|
// this will be called when the system wants to write our data to disk
|
||||||
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
|
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
|
||||||
let data = Data(text.utf8)
|
let data = Data(text.utf8)
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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?";
|
||||||
|
|||||||
Reference in New Issue
Block a user