Merge branch 'develop'

This commit is contained in:
Trey t
2022-02-26 16:21:47 -06:00
9 changed files with 233 additions and 143 deletions

View File

@@ -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
} }

View File

@@ -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] {
[
"Hey asshat",
"Hey lazy dickbag, "
]
}
static var notificationBodyToday: [String] {
[ [
"How the fuck was your day", "How the fuck was your day",
"Hey asshat, tell me how your day was", "tell me how your day was",
"Hey, lazy dickbag, rate your day" "rate your day"
] ]
} }
static var notificationTitlesYesterday: [String] { 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"

View File

@@ -10,11 +10,16 @@ import SwiftUI
struct Constants { struct Constants {
static let groupShareId = "group.com.88oak.ifeel" static let groupShareId = "group.com.88oak.ifeel"
static let groupShareIdDebug = "group.com.88oak.ifeelDebug"
} }
struct GroupUserDefaults { struct GroupUserDefaults {
static var groupDefaults: UserDefaults { static var groupDefaults: UserDefaults {
#if DEBUG
return UserDefaults(suiteName: Constants.groupShareIdDebug)!
#else
return UserDefaults(suiteName: Constants.groupShareId)! return UserDefaults(suiteName: Constants.groupShareId)!
#endif
} }
} }

View File

@@ -13,16 +13,10 @@ struct CreateWidgetView: View {
@StateObject private var customWidget: CustomWidgetModel @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 private var mouth: CustomWidgetMouthOptions = CustomWidgetMouthOptions.defaultOption
@State var widgetView: CustomWidgetView
private var randomElements: [AnyView] private var randomElements: [AnyView]
init(customWidget: CustomWidgetModel, randomElements: [AnyView] = [AnyView]()) { init(customWidget: CustomWidgetModel, randomElements: [AnyView] = [AnyView]()) {
@@ -42,6 +36,8 @@ struct CreateWidgetView: View {
] ]
_customWidget = StateObject(wrappedValue: customWidget) _customWidget = StateObject(wrappedValue: customWidget)
_widgetView = State(initialValue:CustomWidgetView(customWidgetModel: customWidget))
} }
func update(eye: CustomWidgetEyes, eyeOption: CustomWidgetEyeOptions) { func update(eye: CustomWidgetEyes, eyeOption: CustomWidgetEyeOptions) {
@@ -51,6 +47,8 @@ struct CreateWidgetView: View {
case .right: case .right:
customWidget.rightEye = eyeOption customWidget.rightEye = eyeOption
} }
widgetView = CustomWidgetView(customWidgetModel: customWidget)
} }
func createRandom() { func createRandom() {
@@ -67,14 +65,18 @@ struct CreateWidgetView: View {
update(mouthOption: CustomWidgetMouthOptions.allCases.randomElement()!) update(mouthOption: CustomWidgetMouthOptions.allCases.randomElement()!)
update(background: CustomWidgetBackGroundOptions.allCases.randomElement()!) update(background: CustomWidgetBackGroundOptions.allCases.randomElement()!)
widgetView = CustomWidgetView(customWidgetModel: customWidget)
} }
func update(mouthOption: CustomWidgetMouthOptions) { func update(mouthOption: CustomWidgetMouthOptions) {
customWidget.mouth = mouthOption customWidget.mouth = mouthOption
widgetView = CustomWidgetView(customWidgetModel: customWidget)
} }
func update(background: CustomWidgetBackGroundOptions) { func update(background: CustomWidgetBackGroundOptions) {
customWidget.background = background customWidget.background = background
widgetView = CustomWidgetView(customWidgetModel: customWidget)
} }
var mixBG: some View { var mixBG: some View {
@@ -90,10 +92,6 @@ struct CreateWidgetView: View {
} }
} }
var widgetView: some View {
CustomWidgetView(customWidgetModel: customWidget)
}
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
widgetView widgetView
@@ -245,13 +243,13 @@ struct CreateWidgetView: View {
Button(action: { Button(action: {
createRandom() createRandom()
}, label: { }, label: {
Text("Random") Image(systemName: "shuffle")
.font(.title) .font(.title)
.fontWeight(.bold)
.foregroundColor(Color(UIColor.white)) .foregroundColor(Color(UIColor.white))
}) })
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
.frame(height: 40)
.background(.blue) .background(.blue)
Button(action: { Button(action: {
@@ -267,24 +265,10 @@ struct CreateWidgetView: View {
}) })
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
.frame(height: 40)
.background(.green) .background(.green)
if customWidget.isSaved { 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: { Button(action: {
UserDefaultsStore.makeWidgetCurrent(withUUID: customWidget.uuid) UserDefaultsStore.makeWidgetCurrent(withUUID: customWidget.uuid)
let impactMed = UIImpactFeedbackGenerator(style: .heavy) let impactMed = UIImpactFeedbackGenerator(style: .heavy)
@@ -297,8 +281,25 @@ struct CreateWidgetView: View {
.foregroundColor(Color(UIColor.white)) .foregroundColor(Color(UIColor.white))
}) })
.frame(height: 40)
.frame(minWidth: 0, maxWidth: .infinity) .frame(minWidth: 0, maxWidth: .infinity)
.background(.pink) .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 { struct CreateIconView_Previews: PreviewProvider {
static var widget: CustomWidgetModel {
let _widget = CustomWidgetModel.randomWidget
_widget.isSaved = true
return _widget
}
static var previews: some View { static var previews: some View {
Group { Group {
CreateWidgetView(customWidget: CustomWidgetModel.randomWidget) CreateWidgetView(customWidget: CreateIconView_Previews.widget)
CreateWidgetView(customWidget: CustomWidgetModel.randomWidget) CreateWidgetView(customWidget: CustomWidgetModel.randomWidget)
.preferredColorScheme(.dark) .preferredColorScheme(.dark)

View File

@@ -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)

View File

@@ -64,16 +64,6 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
private var circularViews: some View { private var circularViews: some View {
VStack { VStack {
HStack {
ForEach(Mood.allValues, id: \.self) { mood in
mood.icon
.resizable()
.aspectRatio(contentMode: .fit)
.foregroundColor(moodTint.color(forMood: mood))
}
}
VStack { VStack {
HStack { HStack {
ForEach(entries.prefix(2), id: \.mood) { model in ForEach(entries.prefix(2), id: \.mood) { model in
@@ -140,22 +130,40 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding() .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 circularViews
.padding()
Spacer() Spacer()
}.padding() }
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
.padding()
} }
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {
let _image = self.image let _image = self.image
print(_image)
self.shareImage.showFuckingSheet = true self.shareImage.showFuckingSheet = true
self.shareImage.fuckingWrappedShrable = _image self.shareImage.fuckingWrappedShrable = _image
}, label: { }, label: {
@@ -197,19 +205,22 @@ struct AllMoodsTotalTemplate: View, SharingTemplate {
var body: some View { var body: some View {
if isPreview { if isPreview {
preview shareView
.padding([.leading, .trailing], -20) .scaleEffect(2)
} else { } else {
mainView mainView
.padding([.leading, .trailing, .top])
} }
} }
} }
struct AllMoodsSharingTemplate_Previews: PreviewProvider { struct AllMoodsSharingTemplate_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
Group {
AllMoodsTotalTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true) 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)
AllMoodsTotalTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true).shareView
}
} }
} }

View File

@@ -8,10 +8,6 @@
import SwiftUI import SwiftUI
struct CurrentStreakTemplate: View, SharingTemplate { struct CurrentStreakTemplate: View, SharingTemplate {
var image: UIImage {
return UIImage(systemName: "square.and.arrow.up")!
}
static var description: String { static var description: String {
"Last 10 Days" "Last 10 Days"
} }
@@ -22,6 +18,8 @@ struct CurrentStreakTemplate: View, SharingTemplate {
let moodEntries: [MoodEntry] let moodEntries: [MoodEntry]
@State var showSharingTemplate = false @State var showSharingTemplate = false
@StateObject private var shareImage = StupidAssShareObservableObject()
@Environment(\.presentationMode) var presentationMode @Environment(\.presentationMode) var presentationMode
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default @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 @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]() self.moodEntries = _moodEntries ?? [MoodEntry]()
} }
var image: UIImage {
let image = shareView.asImage(size: CGSize(width: 666, height: 1190))
return image
}
var preview: some View { var preview: some View {
HStack { HStack {
VStack { VStack {
@@ -79,7 +82,7 @@ struct CurrentStreakTemplate: View, SharingTemplate {
HStack { HStack {
VStack { VStack {
LazyVGrid(columns: columns, spacing: 0) { LazyVGrid(columns: columns, spacing: 10) {
ForEach(moodEntries) { entry in ForEach(moodEntries) { entry in
entry.mood.icon entry.mood.icon
.resizable() .resizable()
@@ -91,17 +94,23 @@ struct CurrentStreakTemplate: View, SharingTemplate {
} }
.padding() .padding()
} }
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
.padding()
} }
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
Spacer() Spacer()
HStack(alignment: .center) {
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {
showSharingTemplate = true let _image = self.image
print(_image)
self.shareImage.showFuckingSheet = true
self.shareImage.fuckingWrappedShrable = _image
}, label: { }, label: {
Text("Share") Text("Share")
.font(.title) .font(.title)
@@ -109,6 +118,11 @@ struct CurrentStreakTemplate: View, SharingTemplate {
.foregroundColor(Color.white) .foregroundColor(Color.white)
.padding(.top, 20) .padding(.top, 20)
}) })
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
if let uiImage = self.shareImage.fuckingWrappedShrable {
ShareSheet(photo: uiImage)
}
}
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.background( .background(
Color.green Color.green
@@ -131,19 +145,16 @@ struct CurrentStreakTemplate: View, SharingTemplate {
.padding(.leading, -5) .padding(.leading, -5)
} }
.padding([.leading, .trailing], -20) .padding([.leading, .trailing], -20)
}.sheet(isPresented: $showSharingTemplate) { }
ActivityViewController(activityItems: [self.image])
} }
} }
var body: some View { var body: some View {
if isPreview { if isPreview {
preview shareView
.padding([.leading, .trailing], -20) .scaleEffect(2)
} else { } else {
mainView mainView
.padding([.leading, .trailing, .top])
} }
} }
} }
@@ -153,5 +164,7 @@ struct CurrentStreakTemplate_Previews: PreviewProvider {
CurrentStreakTemplate(isPreview: true, startDate: Date(), endDate: Date(), fakeData: true) 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)
CurrentStreakTemplate(isPreview: false, startDate: Date(), endDate: Date(), fakeData: true).shareView
} }
} }

View File

@@ -9,10 +9,6 @@ import SwiftUI
import Algorithms import Algorithms
struct LongestStreakTemplate: View, SharingTemplate { struct LongestStreakTemplate: View, SharingTemplate {
var image: UIImage {
return UIImage(systemName: "square.and.arrow.up")!
}
static var description: String { static var description: String {
"Longest Streak" "Longest Streak"
} }
@@ -32,6 +28,8 @@ struct LongestStreakTemplate: View, SharingTemplate {
@State var selectedMood: Mood = .great @State var selectedMood: Mood = .great
@State var showSharingTemplate = false @State var showSharingTemplate = false
@StateObject private var shareImage = StupidAssShareObservableObject()
@Environment(\.presentationMode) var presentationMode @Environment(\.presentationMode) var presentationMode
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default @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 @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) 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) { private func configureData(fakeData: Bool, mood: Mood) {
var _moodEntries: [MoodEntry]? var _moodEntries: [MoodEntry]?
if fakeData { if fakeData {
_moodEntries = PersistenceController.shared.randomEntries(count: 10) _moodEntries = PersistenceController.shared.randomEntries(count: 10)
} else { } else {
_moodEntries = PersistenceController.shared.getData(startDate:startDate, _moodEntries = PersistenceController.shared.getData(startDate:startDate,
endDate: endDate, endDate: endDate,
includedDays: [1,2,3,4,5,6,7]) includedDays: [1,2,3,4,5,6,7])
@@ -117,7 +119,12 @@ struct LongestStreakTemplate: View, SharingTemplate {
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding() .padding()
HStack { selectedMood.icon
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 75, height: 75)
VStack {
Text(self.moodEntries.first?.forDate ?? Date(), formatter: itemFormatter) Text(self.moodEntries.first?.forDate ?? Date(), formatter: itemFormatter)
.font(.title) .font(.title)
.foregroundColor(theme.currentTheme.labelColor) .foregroundColor(theme.currentTheme.labelColor)
@@ -137,31 +144,19 @@ struct LongestStreakTemplate: View, SharingTemplate {
.padding(.top, 1) .padding(.top, 1)
} }
.padding() .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: { .onAppear(perform: {
self.configureData(fakeData: self.fakeData, mood: self.selectedMood) self.configureData(fakeData: self.fakeData, mood: self.selectedMood)
}) })
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
.padding()
} }
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
Spacer() Spacer()
Menu(content: { Menu(content: {
ForEach(Mood.allValues) { mood in ForEach(Mood.allValues) { mood in
@@ -171,20 +166,25 @@ struct LongestStreakTemplate: View, SharingTemplate {
}) })
} }
}, label: { }, label: {
Text("Moods") Text("Pick Mood")
.font(.title) .font(.title)
.fontWeight(.bold) .foregroundColor(theme.currentTheme.labelColor)
.foregroundColor(Color(UIColor.white)) .padding()
}) })
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.background( .background(
Color.green theme.currentTheme.secondaryBGColor
) )
.padding([.leading, .trailing], -5) .padding([.leading, .trailing], -5)
.cornerRadius(10)
.padding()
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {
showSharingTemplate = true let _image = self.image
print(_image)
self.shareImage.showFuckingSheet = true
self.shareImage.fuckingWrappedShrable = _image
}, label: { }, label: {
Text("Share") Text("Share")
.font(.title) .font(.title)
@@ -192,6 +192,11 @@ struct LongestStreakTemplate: View, SharingTemplate {
.foregroundColor(Color.white) .foregroundColor(Color.white)
.padding(.top, 20) .padding(.top, 20)
}) })
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
if let uiImage = self.shareImage.fuckingWrappedShrable {
ShareSheet(photo: uiImage)
}
}
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.background( .background(
Color.green Color.green
@@ -221,20 +226,22 @@ struct LongestStreakTemplate: View, SharingTemplate {
var body: some View { var body: some View {
if isPreview { if isPreview {
preview shareView
.padding([.leading, .trailing], -20) .scaleEffect(2)
} else { } else {
mainView mainView
.padding([.leading, .trailing, .top])
} }
} }
} }
struct CurrentStreakSharingTemplate_Previews: PreviewProvider { struct CurrentStreakSharingTemplate_Previews: PreviewProvider {
static var previews: some View { 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: 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
}
} }
} }

View File

@@ -20,6 +20,8 @@ struct MonthTotalTemplate: View, SharingTemplate {
private var month = Calendar.current.dateComponents([.month], from: Date()).month! private var month = Calendar.current.dateComponents([.month], from: Date()).month!
@State var showSharingTemplate = false @State var showSharingTemplate = false
@StateObject private var shareImage = StupidAssShareObservableObject()
@Environment(\.presentationMode) var presentationMode @Environment(\.presentationMode) var presentationMode
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default @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 @AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
@@ -68,7 +70,7 @@ struct MonthTotalTemplate: View, SharingTemplate {
} }
var image: UIImage { var image: UIImage {
let image = shareView.snapshot() let image = shareView.asImage(size: CGSize(width: 666, height: 1190))
return image return image
} }
@@ -106,6 +108,23 @@ struct MonthTotalTemplate: View, SharingTemplate {
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding() .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 { VStack {
LazyVGrid(columns: columns, spacing: 10) { LazyVGrid(columns: columns, spacing: 10) {
ForEach(moodEntries) { entry in ForEach(moodEntries) { entry in
@@ -119,19 +138,23 @@ struct MonthTotalTemplate: View, SharingTemplate {
.padding() .padding()
circularViews circularViews
.padding([.trailing, .leading, .top]) .padding()
} }
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
.padding()
} }
var mainView: some View { var mainView: some View {
VStack { VStack {
shareView shareView
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
Spacer() Spacer()
HStack(alignment: .center) { HStack(alignment: .center) {
Button(action: { Button(action: {
showSharingTemplate = true let _image = self.image
self.shareImage.showFuckingSheet = true
self.shareImage.fuckingWrappedShrable = _image
}, label: { }, label: {
Text("Share") Text("Share")
.font(.title) .font(.title)
@@ -139,6 +162,11 @@ struct MonthTotalTemplate: View, SharingTemplate {
.foregroundColor(Color.white) .foregroundColor(Color.white)
.padding(.top, 20) .padding(.top, 20)
}) })
.sheet(isPresented: self.$shareImage.showFuckingSheet) {
if let uiImage = self.shareImage.fuckingWrappedShrable {
ShareSheet(photo: uiImage)
}
}
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.background( .background(
Color.green Color.green
@@ -161,18 +189,15 @@ struct MonthTotalTemplate: View, SharingTemplate {
.padding(.leading, -5) .padding(.leading, -5)
} }
.padding([.leading, .trailing], -20) .padding([.leading, .trailing], -20)
}.sheet(isPresented: $showSharingTemplate) {
ActivityViewController(activityItems: [self.image])
} }
} }
var body: some View { var body: some View {
if isPreview { if isPreview {
preview shareView
.padding([.leading, .trailing], -20) .scaleEffect(2)
} else { } else {
mainView 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: 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)
MonthTotalTemplate(isPreview: false, startDate: Date().startOfMonth, endDate: Date().endOfMonth, fakeData: true).shareView
} }
} }