make all sheets on the main body

fix crash when backgrounding the app
This commit is contained in:
Trey t
2022-03-17 14:57:32 -05:00
parent 0113e2304a
commit f87d216e65
6 changed files with 46 additions and 47 deletions

View File

@@ -15,7 +15,9 @@ enum PercViewType {
struct HeaderPercView: View {
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
var entries = [MoodMetrics]()
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = .black
@State private var entries = [MoodMetrics]()
let backDays: Int
let type: PercViewType
@@ -34,11 +36,11 @@ struct HeaderPercView: View {
}
if let moodEntries = moodEntries {
entries = Random.createTotalPerc(fromEntries: moodEntries)
let moodMetrics = Random.createTotalPerc(fromEntries: moodEntries)
entries = entries.sorted(by: {
_entries = State(initialValue: moodMetrics.sorted(by: {
$0.mood.rawValue > $1.mood.rawValue
})
}))
}
}
@@ -76,11 +78,9 @@ struct HeaderPercView: View {
Text("\(model.percent, specifier: "%.0f")%")
.font(.title2)
.fontWeight(.bold)
.multilineTextAlignment(.center)
.padding()
.frame(maxWidth: .infinity)
.background(Circle().fill(moodTint.color(forMood: model.mood)))
.foregroundColor(Color(UIColor.white))
.frame(maxWidth: .infinity)
}
}
Spacer()
@@ -89,15 +89,14 @@ struct HeaderPercView: View {
Text("\(model.percent, specifier: "%.0f")%")
.font(.title2)
.fontWeight(.bold)
.multilineTextAlignment(.center)
.padding()
.frame(maxWidth: .infinity)
.background(Circle().fill(moodTint.color(forMood: model.mood)))
.foregroundColor(Color(UIColor.white))
.frame(maxWidth: .infinity)
}
}
Spacer()
}
.foregroundColor(textColor)
}
var body: some View {