closed #90
This commit is contained in:
@@ -45,7 +45,9 @@ class LocalNotification {
|
|||||||
let _ = LocalNotification.createNotificationCategory()
|
let _ = LocalNotification.createNotificationCategory()
|
||||||
|
|
||||||
let notificationContent = UNMutableNotificationContent()
|
let notificationContent = UNMutableNotificationContent()
|
||||||
notificationContent.title = UserDefaultsStore.personalityPackable().randomPushNotificationTitle()
|
let strings = UserDefaultsStore.personalityPackable().randomPushNotificationStrings()
|
||||||
|
notificationContent.title = strings.title
|
||||||
|
notificationContent.body = strings.body
|
||||||
|
|
||||||
notificationContent.badge = NSNumber(value: 1)
|
notificationContent.badge = NSNumber(value: 1)
|
||||||
notificationContent.sound = .default
|
notificationContent.sound = .default
|
||||||
@@ -65,7 +67,8 @@ class LocalNotification {
|
|||||||
print(theError.localizedDescription)
|
print(theError.localizedDescription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .failure(_):
|
case .failure(let error):
|
||||||
|
print(error)
|
||||||
// Todo: show enable this
|
// Todo: show enable this
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,10 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
protocol PersonalityPackable {
|
protocol PersonalityPackable {
|
||||||
static var notificationTitlesToday: [String] { get }
|
static var notificationTitles: [String] { get }
|
||||||
static var notificationTitlesYesterday: [String] { get }
|
static var notificationBodyToday: [String] { get }
|
||||||
static var notificationTitlesTwoDaysAgo: [String] { get }
|
static var notificationBodyYesterday: [String] { get }
|
||||||
|
static var notificationBodyTwoDaysAgo: [String] { get }
|
||||||
|
|
||||||
static var title: String { get }
|
static var title: String { get }
|
||||||
}
|
}
|
||||||
@@ -19,12 +20,12 @@ enum PersonalityPack: Int, CaseIterable {
|
|||||||
case Default
|
case Default
|
||||||
case Rude
|
case Rude
|
||||||
|
|
||||||
func randomPushNotificationTitle() -> String {
|
func randomPushNotificationStrings() -> (title: String, body: String) {
|
||||||
switch self {
|
switch self {
|
||||||
case .Default:
|
case .Default:
|
||||||
return DefaultTitles.notificationTitlesToday.randomElement()!
|
return (DefaultTitles.notificationTitles.randomElement()!, DefaultTitles.notificationBodyToday.randomElement()!)
|
||||||
case .Rude:
|
case .Rude:
|
||||||
return RudeTitles.notificationTitlesToday.randomElement()!
|
return (RudeTitles.notificationTitles.randomElement()!, RudeTitles.notificationBodyToday.randomElement()!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ enum PersonalityPack: Int, CaseIterable {
|
|||||||
final class DefaultTitles: PersonalityPackable {
|
final class DefaultTitles: PersonalityPackable {
|
||||||
static var title = "Nice"
|
static var title = "Nice"
|
||||||
|
|
||||||
static var notificationTitlesToday: [String] {
|
static var notificationTitles: [String] {
|
||||||
[
|
[
|
||||||
"How was your day",
|
"How was your day",
|
||||||
"Don't forget to rate your day",
|
"Don't forget to rate your day",
|
||||||
@@ -49,14 +50,22 @@ final class DefaultTitles: PersonalityPackable {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static var notificationTitlesYesterday: [String] {
|
static var notificationBodyToday: [String] {
|
||||||
|
[
|
||||||
|
"How was your day",
|
||||||
|
"Don't forget to rate your day",
|
||||||
|
"Please rate your day"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
static var notificationBodyYesterday: [String] {
|
||||||
[
|
[
|
||||||
"How was your day",
|
"How was your day",
|
||||||
"Don't forget to rate your day"
|
"Don't forget to rate your day"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static var notificationTitlesTwoDaysAgo: [String] {
|
static var notificationBodyTwoDaysAgo: [String] {
|
||||||
[
|
[
|
||||||
"How was your day",
|
"How was your day",
|
||||||
"Don't forget to rate your day"
|
"Don't forget to rate your day"
|
||||||
@@ -67,22 +76,29 @@ final class DefaultTitles: PersonalityPackable {
|
|||||||
final class RudeTitles: PersonalityPackable {
|
final class RudeTitles: PersonalityPackable {
|
||||||
static var title = "Rude"
|
static var title = "Rude"
|
||||||
|
|
||||||
static var notificationTitlesToday: [String] {
|
static var notificationTitles: [String] {
|
||||||
[
|
[
|
||||||
"How the fuck was your day",
|
"Hey asshat",
|
||||||
"Hey asshat, tell me how your day was",
|
"Hey lazy dickbag, "
|
||||||
"Hey, lazy dickbag, rate your day"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static var notificationTitlesYesterday: [String] {
|
static var notificationBodyToday: [String] {
|
||||||
|
[
|
||||||
|
"How the fuck was your day",
|
||||||
|
"tell me how your day was",
|
||||||
|
"rate your day"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
static var notificationBodyYesterday: [String] {
|
||||||
[
|
[
|
||||||
"How was your day",
|
"How was your day",
|
||||||
"Don't forget to rate your day"
|
"Don't forget to rate your day"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static var notificationTitlesTwoDaysAgo: [String] {
|
static var notificationBodyTwoDaysAgo: [String] {
|
||||||
[
|
[
|
||||||
"How was your day",
|
"How was your day",
|
||||||
"Don't forget to rate your day"
|
"Don't forget to rate your day"
|
||||||
|
|||||||
@@ -267,8 +267,10 @@ struct CustomizeView: View {
|
|||||||
.font(.body)
|
.font(.body)
|
||||||
.foregroundColor(theme.currentTheme.labelColor)
|
.foregroundColor(theme.currentTheme.labelColor)
|
||||||
|
|
||||||
|
Text(aPack.randomPushNotificationStrings().title)
|
||||||
Text(aPack.randomPushNotificationTitle())
|
.font(.body)
|
||||||
|
.foregroundColor(Color(UIColor.systemGray))
|
||||||
|
Text(aPack.randomPushNotificationStrings().body)
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.foregroundColor(Color(UIColor.systemGray))
|
.foregroundColor(Color(UIColor.systemGray))
|
||||||
}
|
}
|
||||||
@@ -279,7 +281,6 @@ struct CustomizeView: View {
|
|||||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||||
.fill(personalityPack == aPack ? theme.currentTheme.bgColor : .clear)
|
.fill(personalityPack == aPack ? theme.currentTheme.bgColor : .clear)
|
||||||
.padding(5)
|
.padding(5)
|
||||||
|
|
||||||
)
|
)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||||
|
|||||||
Reference in New Issue
Block a user