Merge branch 'develop'
This commit is contained in:
@@ -45,7 +45,9 @@ class LocalNotification {
|
||||
let _ = LocalNotification.createNotificationCategory()
|
||||
|
||||
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.sound = .default
|
||||
@@ -65,7 +67,8 @@ class LocalNotification {
|
||||
print(theError.localizedDescription)
|
||||
}
|
||||
}
|
||||
case .failure(_):
|
||||
case .failure(let error):
|
||||
print(error)
|
||||
// Todo: show enable this
|
||||
break
|
||||
}
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
import Foundation
|
||||
|
||||
protocol PersonalityPackable {
|
||||
static var notificationTitlesToday: [String] { get }
|
||||
static var notificationTitlesYesterday: [String] { get }
|
||||
static var notificationTitlesTwoDaysAgo: [String] { get }
|
||||
static var notificationTitles: [String] { get }
|
||||
static var notificationBodyToday: [String] { get }
|
||||
static var notificationBodyYesterday: [String] { get }
|
||||
static var notificationBodyTwoDaysAgo: [String] { get }
|
||||
|
||||
static var title: String { get }
|
||||
}
|
||||
@@ -19,12 +20,12 @@ enum PersonalityPack: Int, CaseIterable {
|
||||
case Default
|
||||
case Rude
|
||||
|
||||
func randomPushNotificationTitle() -> String {
|
||||
func randomPushNotificationStrings() -> (title: String, body: String) {
|
||||
switch self {
|
||||
case .Default:
|
||||
return DefaultTitles.notificationTitlesToday.randomElement()!
|
||||
return (DefaultTitles.notificationTitles.randomElement()!, DefaultTitles.notificationBodyToday.randomElement()!)
|
||||
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 {
|
||||
static var title = "Nice"
|
||||
|
||||
static var notificationTitlesToday: [String] {
|
||||
static var notificationTitles: [String] {
|
||||
[
|
||||
"How was 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",
|
||||
"Don't forget to rate your day"
|
||||
]
|
||||
}
|
||||
|
||||
static var notificationTitlesTwoDaysAgo: [String] {
|
||||
static var notificationBodyTwoDaysAgo: [String] {
|
||||
[
|
||||
"How was your day",
|
||||
"Don't forget to rate your day"
|
||||
@@ -67,22 +76,29 @@ final class DefaultTitles: PersonalityPackable {
|
||||
final class RudeTitles: PersonalityPackable {
|
||||
static var title = "Rude"
|
||||
|
||||
static var notificationTitlesToday: [String] {
|
||||
static var notificationTitles: [String] {
|
||||
[
|
||||
"How the fuck was your day",
|
||||
"Hey asshat, tell me how your day was",
|
||||
"Hey, lazy dickbag, rate your day"
|
||||
"Hey asshat",
|
||||
"Hey lazy dickbag, "
|
||||
]
|
||||
}
|
||||
|
||||
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",
|
||||
"Don't forget to rate your day"
|
||||
]
|
||||
}
|
||||
|
||||
static var notificationTitlesTwoDaysAgo: [String] {
|
||||
static var notificationBodyTwoDaysAgo: [String] {
|
||||
[
|
||||
"How was your day",
|
||||
"Don't forget to rate your day"
|
||||
|
||||
@@ -10,11 +10,16 @@ import SwiftUI
|
||||
|
||||
struct Constants {
|
||||
static let groupShareId = "group.com.88oak.ifeel"
|
||||
static let groupShareIdDebug = "group.com.88oak.ifeelDebug"
|
||||
}
|
||||
|
||||
struct GroupUserDefaults {
|
||||
static var groupDefaults: UserDefaults {
|
||||
#if DEBUG
|
||||
return UserDefaults(suiteName: Constants.groupShareIdDebug)!
|
||||
#else
|
||||
return UserDefaults(suiteName: Constants.groupShareId)!
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,16 +13,10 @@ struct CreateWidgetView: View {
|
||||
|
||||
@StateObject private var customWidget: CustomWidgetModel
|
||||
|
||||
static var iconViewBGs: [(CustomWidgetBackGroundOptions, UUID)] = {
|
||||
var blah = [(CustomWidgetBackGroundOptions, UUID)]()
|
||||
for _ in 0...99 {
|
||||
blah.append((CustomWidgetBackGroundOptions.selectable.randomElement()!, UUID()))
|
||||
}
|
||||
return blah
|
||||
}()
|
||||
|
||||
@State private var mouth: CustomWidgetMouthOptions = CustomWidgetMouthOptions.defaultOption
|
||||
|
||||
@State var widgetView: CustomWidgetView
|
||||
|
||||
private var randomElements: [AnyView]
|
||||
|
||||
init(customWidget: CustomWidgetModel, randomElements: [AnyView] = [AnyView]()) {
|
||||
@@ -42,6 +36,8 @@ struct CreateWidgetView: View {
|
||||
]
|
||||
|
||||
_customWidget = StateObject(wrappedValue: customWidget)
|
||||
|
||||
_widgetView = State(initialValue:CustomWidgetView(customWidgetModel: customWidget))
|
||||
}
|
||||
|
||||
func update(eye: CustomWidgetEyes, eyeOption: CustomWidgetEyeOptions) {
|
||||
@@ -51,6 +47,8 @@ struct CreateWidgetView: View {
|
||||
case .right:
|
||||
customWidget.rightEye = eyeOption
|
||||
}
|
||||
|
||||
widgetView = CustomWidgetView(customWidgetModel: customWidget)
|
||||
}
|
||||
|
||||
func createRandom() {
|
||||
@@ -67,14 +65,18 @@ struct CreateWidgetView: View {
|
||||
update(mouthOption: CustomWidgetMouthOptions.allCases.randomElement()!)
|
||||
|
||||
update(background: CustomWidgetBackGroundOptions.allCases.randomElement()!)
|
||||
|
||||
widgetView = CustomWidgetView(customWidgetModel: customWidget)
|
||||
}
|
||||
|
||||
func update(mouthOption: CustomWidgetMouthOptions) {
|
||||
customWidget.mouth = mouthOption
|
||||
widgetView = CustomWidgetView(customWidgetModel: customWidget)
|
||||
}
|
||||
|
||||
func update(background: CustomWidgetBackGroundOptions) {
|
||||
customWidget.background = background
|
||||
widgetView = CustomWidgetView(customWidgetModel: customWidget)
|
||||
}
|
||||
|
||||
var mixBG: some View {
|
||||
@@ -90,10 +92,6 @@ struct CreateWidgetView: View {
|
||||
}
|
||||
}
|
||||
|
||||
var widgetView: some View {
|
||||
CustomWidgetView(customWidgetModel: customWidget)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 0) {
|
||||
widgetView
|
||||
@@ -245,13 +243,13 @@ struct CreateWidgetView: View {
|
||||
Button(action: {
|
||||
createRandom()
|
||||
}, label: {
|
||||
Text("Random")
|
||||
Image(systemName: "shuffle")
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
|
||||
})
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.frame(height: 40)
|
||||
.background(.blue)
|
||||
|
||||
Button(action: {
|
||||
@@ -267,24 +265,10 @@ struct CreateWidgetView: View {
|
||||
|
||||
})
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.frame(height: 40)
|
||||
.background(.green)
|
||||
|
||||
if customWidget.isSaved {
|
||||
Button(action: {
|
||||
UserDefaultsStore.deleteCustomWidget(withUUID: customWidget.uuid)
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactMed.impactOccurred()
|
||||
dismiss()
|
||||
}, label: {
|
||||
Text("Delete")
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
|
||||
})
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.background(.orange)
|
||||
|
||||
Button(action: {
|
||||
UserDefaultsStore.makeWidgetCurrent(withUUID: customWidget.uuid)
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
@@ -297,8 +281,25 @@ struct CreateWidgetView: View {
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
|
||||
})
|
||||
.frame(height: 40)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.background(.pink)
|
||||
|
||||
Button(action: {
|
||||
UserDefaultsStore.deleteCustomWidget(withUUID: customWidget.uuid)
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactMed.impactOccurred()
|
||||
dismiss()
|
||||
}, label: {
|
||||
Image(systemName: "trash")
|
||||
.font(.title)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
|
||||
})
|
||||
.frame(height: 40)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.background(.orange)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -307,9 +308,15 @@ struct CreateWidgetView: View {
|
||||
}
|
||||
|
||||
struct CreateIconView_Previews: PreviewProvider {
|
||||
static var widget: CustomWidgetModel {
|
||||
let _widget = CustomWidgetModel.randomWidget
|
||||
_widget.isSaved = true
|
||||
return _widget
|
||||
}
|
||||
|
||||
static var previews: some View {
|
||||
Group {
|
||||
CreateWidgetView(customWidget: CustomWidgetModel.randomWidget)
|
||||
CreateWidgetView(customWidget: CreateIconView_Previews.widget)
|
||||
|
||||
CreateWidgetView(customWidget: CustomWidgetModel.randomWidget)
|
||||
.preferredColorScheme(.dark)
|
||||
|
||||
@@ -267,8 +267,10 @@ struct CustomizeView: View {
|
||||
.font(.body)
|
||||
.foregroundColor(theme.currentTheme.labelColor)
|
||||
|
||||
|
||||
Text(aPack.randomPushNotificationTitle())
|
||||
Text(aPack.randomPushNotificationStrings().title)
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.systemGray))
|
||||
Text(aPack.randomPushNotificationStrings().body)
|
||||
.font(.body)
|
||||
.foregroundColor(Color(UIColor.systemGray))
|
||||
}
|
||||
@@ -279,7 +281,6 @@ struct CustomizeView: View {
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
.fill(personalityPack == aPack ? theme.currentTheme.bgColor : .clear)
|
||||
.padding(5)
|
||||
|
||||
)
|
||||
.onTapGesture {
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
|
||||
@@ -64,16 +64,6 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
|
||||
|
||||
private var circularViews: some View {
|
||||
VStack {
|
||||
|
||||
HStack {
|
||||
ForEach(Mood.allValues, id: \.self) { mood in
|
||||
mood.icon
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.foregroundColor(moodTint.color(forMood: mood))
|
||||
}
|
||||
}
|
||||
|
||||
VStack {
|
||||
HStack {
|
||||
ForEach(entries.prefix(2), id: \.mood) { model in
|
||||
@@ -140,22 +130,40 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.padding()
|
||||
|
||||
HStack {
|
||||
ForEach(Mood.allValues, id: \.self) { mood in
|
||||
Circle()
|
||||
.frame(minWidth: 10, idealWidth: 70, maxWidth: 100, minHeight: 10, idealHeight: 70, maxHeight: 100)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.foregroundColor(moodTint.color(forMood: mood))
|
||||
.overlay(
|
||||
mood.icon
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.foregroundColor(.white)
|
||||
.padding(9)
|
||||
)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
|
||||
circularViews
|
||||
.padding()
|
||||
|
||||
Spacer()
|
||||
}.padding()
|
||||
}
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
.padding()
|
||||
}
|
||||
|
||||
var mainView: some View {
|
||||
VStack {
|
||||
shareView
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
|
||||
HStack(alignment: .center) {
|
||||
Button(action: {
|
||||
let _image = self.image
|
||||
print(_image)
|
||||
self.shareImage.showFuckingSheet = true
|
||||
self.shareImage.fuckingWrappedShrable = _image
|
||||
}, label: {
|
||||
@@ -197,19 +205,22 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
|
||||
|
||||
var body: some View {
|
||||
if isPreview {
|
||||
preview
|
||||
.padding([.leading, .trailing], -20)
|
||||
shareView
|
||||
.scaleEffect(2)
|
||||
} else {
|
||||
mainView
|
||||
.padding([.leading, .trailing, .top])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AllMoodsSharingTemplate_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
AllMoodsTotalTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true)
|
||||
|
||||
AllMoodsTotalTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true)
|
||||
|
||||
AllMoodsTotalTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true).shareView
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CurrentStreakTemplate: View, SharingTemplate {
|
||||
var image: UIImage {
|
||||
return UIImage(systemName: "square.and.arrow.up")!
|
||||
}
|
||||
|
||||
static var description: String {
|
||||
"Last 10 Days"
|
||||
}
|
||||
@@ -22,6 +18,8 @@ struct CurrentStreakTemplate: View, SharingTemplate {
|
||||
let moodEntries: [MoodEntry]
|
||||
|
||||
@State var showSharingTemplate = false
|
||||
@StateObject private var shareImage = StupidAssShareObservableObject()
|
||||
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@@ -53,6 +51,11 @@ struct CurrentStreakTemplate: View, SharingTemplate {
|
||||
self.moodEntries = _moodEntries ?? [MoodEntry]()
|
||||
}
|
||||
|
||||
var image: UIImage {
|
||||
let image = shareView.asImage(size: CGSize(width: 666, height: 1190))
|
||||
return image
|
||||
}
|
||||
|
||||
var preview: some View {
|
||||
HStack {
|
||||
VStack {
|
||||
@@ -79,7 +82,7 @@ struct CurrentStreakTemplate: View, SharingTemplate {
|
||||
|
||||
HStack {
|
||||
VStack {
|
||||
LazyVGrid(columns: columns, spacing: 0) {
|
||||
LazyVGrid(columns: columns, spacing: 10) {
|
||||
ForEach(moodEntries) { entry in
|
||||
entry.mood.icon
|
||||
.resizable()
|
||||
@@ -91,17 +94,23 @@ struct CurrentStreakTemplate: View, SharingTemplate {
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
.padding()
|
||||
}
|
||||
|
||||
var mainView: some View {
|
||||
VStack {
|
||||
shareView
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
|
||||
Spacer()
|
||||
HStack(alignment: .center) {
|
||||
HStack(alignment: .center) {
|
||||
Button(action: {
|
||||
showSharingTemplate = true
|
||||
let _image = self.image
|
||||
print(_image)
|
||||
self.shareImage.showFuckingSheet = true
|
||||
self.shareImage.fuckingWrappedShrable = _image
|
||||
}, label: {
|
||||
Text("Share")
|
||||
.font(.title)
|
||||
@@ -109,6 +118,11 @@ struct CurrentStreakTemplate: View, SharingTemplate {
|
||||
.foregroundColor(Color.white)
|
||||
.padding(.top, 20)
|
||||
})
|
||||
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
|
||||
if let uiImage = self.shareImage.fuckingWrappedShrable {
|
||||
ShareSheet(photo: uiImage)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.background(
|
||||
Color.green
|
||||
@@ -131,19 +145,16 @@ struct CurrentStreakTemplate: View, SharingTemplate {
|
||||
.padding(.leading, -5)
|
||||
}
|
||||
.padding([.leading, .trailing], -20)
|
||||
}.sheet(isPresented: $showSharingTemplate) {
|
||||
ActivityViewController(activityItems: [self.image])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if isPreview {
|
||||
preview
|
||||
.padding([.leading, .trailing], -20)
|
||||
shareView
|
||||
.scaleEffect(2)
|
||||
} else {
|
||||
mainView
|
||||
.padding([.leading, .trailing, .top])
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,5 +164,7 @@ struct CurrentStreakTemplate_Previews: PreviewProvider {
|
||||
CurrentStreakTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true)
|
||||
|
||||
CurrentStreakTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true)
|
||||
|
||||
CurrentStreakTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true).shareView
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,6 @@ import SwiftUI
|
||||
import Algorithms
|
||||
|
||||
struct LongestStreakTemplate: View, SharingTemplate {
|
||||
var image: UIImage {
|
||||
return UIImage(systemName: "square.and.arrow.up")!
|
||||
}
|
||||
|
||||
static var description: String {
|
||||
"Longest Streak"
|
||||
}
|
||||
@@ -32,6 +28,8 @@ struct LongestStreakTemplate: View, SharingTemplate {
|
||||
@State var selectedMood: Mood = .great
|
||||
|
||||
@State var showSharingTemplate = false
|
||||
@StateObject private var shareImage = StupidAssShareObservableObject()
|
||||
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@@ -53,13 +51,17 @@ struct LongestStreakTemplate: View, SharingTemplate {
|
||||
configureData(fakeData: self.fakeData, mood: self.selectedMood)
|
||||
}
|
||||
|
||||
var image: UIImage {
|
||||
let image = shareView.asImage(size: CGSize(width: 650, height: 400))
|
||||
return image
|
||||
}
|
||||
|
||||
private func configureData(fakeData: Bool, mood: Mood) {
|
||||
var _moodEntries: [MoodEntry]?
|
||||
|
||||
if fakeData {
|
||||
_moodEntries = PersistenceController.shared.randomEntries(count: 10)
|
||||
} else {
|
||||
|
||||
_moodEntries = PersistenceController.shared.getData(startDate:startDate,
|
||||
endDate: endDate,
|
||||
includedDays: [1,2,3,4,5,6,7])
|
||||
@@ -117,7 +119,12 @@ struct LongestStreakTemplate: View, SharingTemplate {
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.padding()
|
||||
|
||||
HStack {
|
||||
selectedMood.icon
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 75, height: 75)
|
||||
|
||||
VStack {
|
||||
Text(self.moodEntries.first?.forDate ?? Date(), formatter: itemFormatter)
|
||||
.font(.title)
|
||||
.foregroundColor(theme.currentTheme.labelColor)
|
||||
@@ -137,31 +144,19 @@ struct LongestStreakTemplate: View, SharingTemplate {
|
||||
.padding(.top, 1)
|
||||
}
|
||||
.padding()
|
||||
|
||||
HStack {
|
||||
VStack {
|
||||
LazyVGrid(columns: columns, spacing: 0) {
|
||||
ForEach(moodEntries) { entry in
|
||||
entry.mood.icon
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.foregroundColor(moodTint.color(forMood: entry.mood))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.onAppear(perform: {
|
||||
self.configureData(fakeData: self.fakeData, mood: self.selectedMood)
|
||||
})
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
.padding()
|
||||
}
|
||||
|
||||
var mainView: some View {
|
||||
VStack {
|
||||
shareView
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
|
||||
Spacer()
|
||||
Menu(content: {
|
||||
ForEach(Mood.allValues) { mood in
|
||||
@@ -171,20 +166,25 @@ struct LongestStreakTemplate: View, SharingTemplate {
|
||||
})
|
||||
}
|
||||
}, label: {
|
||||
Text("Moods")
|
||||
Text("Pick Mood")
|
||||
.font(.title)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(Color(UIColor.white))
|
||||
.foregroundColor(theme.currentTheme.labelColor)
|
||||
.padding()
|
||||
})
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.background(
|
||||
Color.green
|
||||
theme.currentTheme.secondaryBGColor
|
||||
)
|
||||
.padding([.leading, .trailing], -5)
|
||||
.cornerRadius(10)
|
||||
.padding()
|
||||
|
||||
HStack(alignment: .center) {
|
||||
Button(action: {
|
||||
showSharingTemplate = true
|
||||
let _image = self.image
|
||||
print(_image)
|
||||
self.shareImage.showFuckingSheet = true
|
||||
self.shareImage.fuckingWrappedShrable = _image
|
||||
}, label: {
|
||||
Text("Share")
|
||||
.font(.title)
|
||||
@@ -192,6 +192,11 @@ struct LongestStreakTemplate: View, SharingTemplate {
|
||||
.foregroundColor(Color.white)
|
||||
.padding(.top, 20)
|
||||
})
|
||||
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
|
||||
if let uiImage = self.shareImage.fuckingWrappedShrable {
|
||||
ShareSheet(photo: uiImage)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.background(
|
||||
Color.green
|
||||
@@ -221,20 +226,22 @@ struct LongestStreakTemplate: View, SharingTemplate {
|
||||
|
||||
var body: some View {
|
||||
if isPreview {
|
||||
preview
|
||||
.padding([.leading, .trailing], -20)
|
||||
shareView
|
||||
.scaleEffect(2)
|
||||
} else {
|
||||
mainView
|
||||
.padding([.leading, .trailing, .top])
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CurrentStreakSharingTemplate_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
LongestStreakTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true)
|
||||
|
||||
LongestStreakTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true)
|
||||
|
||||
LongestStreakTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true)
|
||||
LongestStreakTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true).shareView
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ struct MonthTotalTemplate: View, SharingTemplate {
|
||||
private var month = Calendar.current.dateComponents([.month], from: Date()).month!
|
||||
|
||||
@State var showSharingTemplate = false
|
||||
@StateObject private var shareImage = StupidAssShareObservableObject()
|
||||
|
||||
@Environment(\.presentationMode) var presentationMode
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
@@ -68,7 +70,7 @@ struct MonthTotalTemplate: View, SharingTemplate {
|
||||
}
|
||||
|
||||
var image: UIImage {
|
||||
let image = shareView.snapshot()
|
||||
let image = shareView.asImage(size: CGSize(width: 666, height: 1190))
|
||||
return image
|
||||
}
|
||||
|
||||
@@ -106,6 +108,23 @@ struct MonthTotalTemplate: View, SharingTemplate {
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.padding()
|
||||
|
||||
HStack {
|
||||
ForEach(Mood.allValues, id: \.self) { mood in
|
||||
Circle()
|
||||
.frame(minWidth: 10, idealWidth: 70, maxWidth: 100, minHeight: 10, idealHeight: 70, maxHeight: 100)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.foregroundColor(moodTint.color(forMood: mood))
|
||||
.overlay(
|
||||
mood.icon
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.foregroundColor(.white)
|
||||
.padding(9)
|
||||
)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
|
||||
VStack {
|
||||
LazyVGrid(columns: columns, spacing: 10) {
|
||||
ForEach(moodEntries) { entry in
|
||||
@@ -119,19 +138,23 @@ struct MonthTotalTemplate: View, SharingTemplate {
|
||||
.padding()
|
||||
|
||||
circularViews
|
||||
.padding([.trailing, .leading, .top])
|
||||
.padding()
|
||||
}
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
.padding()
|
||||
}
|
||||
|
||||
var mainView: some View {
|
||||
VStack {
|
||||
shareView
|
||||
.background(Color(UIColor.secondarySystemBackground))
|
||||
.cornerRadius(10)
|
||||
|
||||
Spacer()
|
||||
HStack(alignment: .center) {
|
||||
Button(action: {
|
||||
showSharingTemplate = true
|
||||
let _image = self.image
|
||||
self.shareImage.showFuckingSheet = true
|
||||
self.shareImage.fuckingWrappedShrable = _image
|
||||
}, label: {
|
||||
Text("Share")
|
||||
.font(.title)
|
||||
@@ -139,6 +162,11 @@ struct MonthTotalTemplate: View, SharingTemplate {
|
||||
.foregroundColor(Color.white)
|
||||
.padding(.top, 20)
|
||||
})
|
||||
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
|
||||
if let uiImage = self.shareImage.fuckingWrappedShrable {
|
||||
ShareSheet(photo: uiImage)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.background(
|
||||
Color.green
|
||||
@@ -161,18 +189,15 @@ struct MonthTotalTemplate: View, SharingTemplate {
|
||||
.padding(.leading, -5)
|
||||
}
|
||||
.padding([.leading, .trailing], -20)
|
||||
}.sheet(isPresented: $showSharingTemplate) {
|
||||
ActivityViewController(activityItems: [self.image])
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if isPreview {
|
||||
preview
|
||||
.padding([.leading, .trailing], -20)
|
||||
shareView
|
||||
.scaleEffect(2)
|
||||
} else {
|
||||
mainView
|
||||
.padding([.leading, .trailing, .top])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,5 +207,7 @@ struct MonthTotalTemplate_Previews: PreviewProvider {
|
||||
MonthTotalTemplate(isPreview: true, startDate: Date().startOfMonth, endDate: Date().endOfMonth, fakeData: true)
|
||||
|
||||
MonthTotalTemplate(isPreview: false, startDate: Date().startOfMonth, endDate: Date().endOfMonth, fakeData: true)
|
||||
|
||||
MonthTotalTemplate(isPreview: false, startDate: Date().startOfMonth, endDate: Date().endOfMonth, fakeData: true).shareView
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user