add shape picker for backgrounds
This commit is contained in:
@@ -11,6 +11,8 @@ struct SmallRollUpHeaderView: View {
|
||||
@Binding var viewType: MainSwitchableViewType
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.shape.rawValue, store: GroupUserDefaults.groupDefaults) private var shape: BGShape = .circle
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = .black
|
||||
|
||||
let entries: [MoodEntry]
|
||||
@@ -27,14 +29,14 @@ struct SmallRollUpHeaderView: View {
|
||||
switch viewType {
|
||||
case .total:
|
||||
return Text(String(model.total))
|
||||
case .percentageCircle:
|
||||
case .percentageShape:
|
||||
return Text("\(model.percent, specifier: "%.0f")%")
|
||||
case .percentage:
|
||||
return Text("\(model.percent, specifier: "%.0f")%")
|
||||
}
|
||||
}
|
||||
|
||||
private var textViews: some View {
|
||||
private var onlyTextView: some View {
|
||||
HStack() {
|
||||
ForEach(moodMetrics, id: \.id) { model in
|
||||
textView(forModel: model)
|
||||
@@ -49,25 +51,14 @@ struct SmallRollUpHeaderView: View {
|
||||
.padding([.top, .bottom])
|
||||
}
|
||||
|
||||
private var circularViews: some View {
|
||||
private var shapeView: some View {
|
||||
HStack {
|
||||
ForEach(moodMetrics, id: \.id) { model in
|
||||
ZStack {
|
||||
Circle().fill(moodTint.color(forMood: model.mood))
|
||||
.frame(minWidth: 5,
|
||||
maxWidth: 500,
|
||||
minHeight: 5,
|
||||
maxHeight: 500,
|
||||
alignment: .center)
|
||||
.overlay(
|
||||
textView(forModel: model)
|
||||
.font(.title3)
|
||||
.fontWeight(.bold)
|
||||
.lineLimit(1)
|
||||
.clipShape(ContainerRelativeShape())
|
||||
.foregroundColor(textColor)
|
||||
.minimumScaleFactor(0.7)
|
||||
)
|
||||
HStack {
|
||||
shape.view(withText: textView(forModel: model),
|
||||
bgColor: moodTint.color(forMood: model.mood),
|
||||
textColor: textColor)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,10 +68,10 @@ struct SmallRollUpHeaderView: View {
|
||||
private var viewOnViewtype : some View {
|
||||
HStack {
|
||||
switch viewType {
|
||||
case .total, .percentageCircle:
|
||||
circularViews
|
||||
case .total, .percentageShape:
|
||||
shapeView
|
||||
case .percentage:
|
||||
textViews
|
||||
onlyTextView
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +89,7 @@ struct SmallHeaderView_Previews: PreviewProvider {
|
||||
viewType: .constant(.total))
|
||||
|
||||
SmallRollUpHeaderView(entries: PersistenceController.shared.randomEntries(count: 10),
|
||||
viewType: .constant(.percentageCircle))
|
||||
viewType: .constant(.percentageShape))
|
||||
.background(.gray)
|
||||
|
||||
SmallRollUpHeaderView(entries: PersistenceController.shared.randomEntries(count: 10),
|
||||
|
||||
Reference in New Issue
Block a user