make all sheets on the main body
fix crash when backgrounding the app
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user