add shape picker for backgrounds
This commit is contained in:
@@ -81,6 +81,10 @@
|
||||
1C747CC9279F06EB00762CBD /* CloudKitSyncMonitor in Frameworks */ = {isa = PBXBuildFile; productRef = 1C747CC8279F06EB00762CBD /* CloudKitSyncMonitor */; };
|
||||
1C76E86E27C882A400ADEE1F /* SharingImageModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C76E86D27C882A400ADEE1F /* SharingImageModels.swift */; };
|
||||
1C76E86F27C882A400ADEE1F /* SharingImageModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C76E86D27C882A400ADEE1F /* SharingImageModels.swift */; };
|
||||
1C95ABC927E6F73A00509BD3 /* Shapes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C95ABC827E6F73A00509BD3 /* Shapes.swift */; };
|
||||
1C95ABCA27E6F73A00509BD3 /* Shapes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C95ABC827E6F73A00509BD3 /* Shapes.swift */; };
|
||||
1C95ABCC27E6FA7200509BD3 /* DiamondView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */; };
|
||||
1C95ABCD27E6FA7200509BD3 /* DiamondView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */; };
|
||||
1CA037702799FFA600D26164 /* HomeViewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA0376F2799FFA600D26164 /* HomeViewViewModel.swift */; };
|
||||
1CA03773279A293D00D26164 /* OnboardingTime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03772279A293D00D26164 /* OnboardingTime.swift */; };
|
||||
1CA03775279A294800D26164 /* OnboardingDay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1CA03774279A294800D26164 /* OnboardingDay.swift */; };
|
||||
@@ -220,6 +224,8 @@
|
||||
1C7352B827DD02760024B5D2 /* ImagePickerGridView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePickerGridView.swift; sourceTree = "<group>"; };
|
||||
1C744F2B278CE15600953A57 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
1C76E86D27C882A400ADEE1F /* SharingImageModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingImageModels.swift; sourceTree = "<group>"; };
|
||||
1C95ABC827E6F73A00509BD3 /* Shapes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shapes.swift; sourceTree = "<group>"; };
|
||||
1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiamondView.swift; sourceTree = "<group>"; };
|
||||
1CA0376F2799FFA600D26164 /* HomeViewViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewViewModel.swift; sourceTree = "<group>"; };
|
||||
1CA03772279A293D00D26164 /* OnboardingTime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTime.swift; sourceTree = "<group>"; };
|
||||
1CA03774279A294800D26164 /* OnboardingDay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingDay.swift; sourceTree = "<group>"; };
|
||||
@@ -594,6 +600,8 @@
|
||||
1C76E86D27C882A400ADEE1F /* SharingImageModels.swift */,
|
||||
1C358FAC27ADD0C3002C83A6 /* Theme.swift */,
|
||||
1C5F4977279C945E0092F1B4 /* UserDefaultsStore.swift */,
|
||||
1C95ABC827E6F73A00509BD3 /* Shapes.swift */,
|
||||
1C95ABCB27E6FA7200509BD3 /* DiamondView.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@@ -825,6 +833,7 @@
|
||||
1C04488727C1C81D00D22444 /* PersonalityPackable.swift in Sources */,
|
||||
1C4FF3BE27BEDF9100BE8F34 /* PersistenceHelper.swift in Sources */,
|
||||
1CC469AA278F30A0003E0C6E /* BGTask.swift in Sources */,
|
||||
1C95ABC927E6F73A00509BD3 /* Shapes.swift in Sources */,
|
||||
1CAD603B27A5C1C800C520BD /* HomeView.swift in Sources */,
|
||||
1C5F4976279C84090092F1B4 /* OnboardingData.swift in Sources */,
|
||||
1CAD603427A5C1C800C520BD /* SmallRollUpHeaderView.swift in Sources */,
|
||||
@@ -871,6 +880,7 @@
|
||||
1C361F0A27C0356000E832FC /* MonthView.swift in Sources */,
|
||||
1C361F1427C03C8600E832FC /* OnboardingDataDataManager.swift in Sources */,
|
||||
1C358FAD27ADD0C3002C83A6 /* Theme.swift in Sources */,
|
||||
1C95ABCC27E6FA7200509BD3 /* DiamondView.swift in Sources */,
|
||||
1C2162EB27C14EFA004353D1 /* Date+Extensions.swift in Sources */,
|
||||
1C02589C27B9677A00EB91AC /* CreateWidgetView.swift in Sources */,
|
||||
1C04489927C3F24000D22444 /* Color+Codable.swift in Sources */,
|
||||
@@ -919,6 +929,7 @@
|
||||
1C76E86F27C882A400ADEE1F /* SharingImageModels.swift in Sources */,
|
||||
1CEC967227B9C9FB00CC8688 /* CustomWidgetView.swift in Sources */,
|
||||
1C2162F827C16E3C004353D1 /* MoodTintable.swift in Sources */,
|
||||
1C95ABCA27E6F73A00509BD3 /* Shapes.swift in Sources */,
|
||||
1C4FF3BC27BEDF6600BE8F34 /* ShowBasedOnVoteLogics.swift in Sources */,
|
||||
1C4FF3C927BEE0C300BE8F34 /* PersistenceHelper.swift in Sources */,
|
||||
1CA2662D2793908700C0E12C /* Persistence.swift in Sources */,
|
||||
@@ -942,6 +953,7 @@
|
||||
1C4FF3C127BEE06900BE8F34 /* PersistenceGET.swift in Sources */,
|
||||
1C361F0D27C03BDF00E832FC /* OnboardingData.swift in Sources */,
|
||||
1CD90B52278C7E7A001C4FEA /* FeelsWidget.intentdefinition in Sources */,
|
||||
1C95ABCD27E6FA7200509BD3 /* DiamondView.swift in Sources */,
|
||||
1CD90B4D278C7E7A001C4FEA /* FeelsWidget.swift in Sources */,
|
||||
1C04489627C2DB0100D22444 /* Theme.swift in Sources */,
|
||||
1C361F0F27C03C0E00E832FC /* LocalNotification.swift in Sources */,
|
||||
|
||||
31
Shared/Models/DiamondView.swift
Normal file
31
Shared/Models/DiamondView.swift
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// DiamondView.swift
|
||||
// Feels
|
||||
//
|
||||
// Created by Trey Tartt on 3/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct Diamond:Shape {
|
||||
|
||||
func path(in rect: CGRect) -> Path {
|
||||
var path = Path()
|
||||
// get the center of the rect
|
||||
let center = CGPoint(x: rect.midX, y: rect.midY)
|
||||
// get the starting of our drawing the right side of our diamond
|
||||
let startingPoint = CGPoint(x: rect.maxX, y: center.y)
|
||||
// move our start of drawing to the beggining point
|
||||
path.move(to: startingPoint)
|
||||
// distance / 2 is our height
|
||||
// create all our points
|
||||
let secondPoint = CGPoint(x: center.x, y: rect.maxY)
|
||||
let thirdPoint = CGPoint(x: rect.minX , y: center.y)
|
||||
let fourthPoint = CGPoint(x: center.x, y: rect.minY)
|
||||
path.addLine(to: secondPoint)
|
||||
path.addLine(to: thirdPoint)
|
||||
path.addLine(to: fourthPoint)
|
||||
path.addLine(to: startingPoint)
|
||||
return path
|
||||
}
|
||||
}
|
||||
65
Shared/Models/Shapes.swift
Normal file
65
Shared/Models/Shapes.swift
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Shapes.swift
|
||||
// Feels
|
||||
//
|
||||
// Created by Trey Tartt on 3/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum BGShape: Int, CaseIterable {
|
||||
case circle
|
||||
case diamond
|
||||
case rectangle
|
||||
case roundedRectangle
|
||||
|
||||
func view(withText text: Text, bgColor: Color, textColor: Color) -> some View{
|
||||
return AnyView(
|
||||
ZStack {
|
||||
switch self {
|
||||
case .circle:
|
||||
Circle()
|
||||
.fill(bgColor)
|
||||
.frame(minWidth: 5,
|
||||
maxWidth: 500,
|
||||
minHeight: 5,
|
||||
maxHeight: 500,
|
||||
alignment: .center)
|
||||
|
||||
case .diamond:
|
||||
Diamond()
|
||||
.fill(bgColor)
|
||||
.frame(minWidth: 5,
|
||||
maxWidth: 500,
|
||||
minHeight: 5,
|
||||
maxHeight: 500)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
|
||||
case .rectangle:
|
||||
Rectangle()
|
||||
.fill(bgColor)
|
||||
.frame(minWidth: 5,
|
||||
maxWidth: 500,
|
||||
minHeight: 5,
|
||||
maxHeight: 500,
|
||||
alignment: .center)
|
||||
case .roundedRectangle:
|
||||
RoundedRectangle(cornerRadius: 8, style: .continuous)
|
||||
.fill(bgColor)
|
||||
.frame(minWidth: 5,
|
||||
maxWidth: 500,
|
||||
minHeight: 5,
|
||||
maxHeight: 500,
|
||||
alignment: .center)
|
||||
}
|
||||
text
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.lineLimit(1)
|
||||
.foregroundColor(textColor)
|
||||
.minimumScaleFactor(0.7)
|
||||
.padding(10)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ class UserDefaultsStore {
|
||||
case customMoodTintUpdateNumber
|
||||
case textColor
|
||||
case showNSFW
|
||||
case shape
|
||||
|
||||
case contentViewCurrentSelectedHeaderViewBackDays
|
||||
case contentViewHeaderTag
|
||||
@@ -190,6 +191,15 @@ class UserDefaultsStore {
|
||||
return SavedMoodTint()
|
||||
}
|
||||
|
||||
static func getCustomBGShape() -> BGShape {
|
||||
if let data = GroupUserDefaults.groupDefaults.object(forKey: UserDefaultsStore.Keys.shape.rawValue) as? Int,
|
||||
let model = BGShape.init(rawValue: data) {
|
||||
return model
|
||||
} else {
|
||||
return BGShape.circle
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
static func saveCustomMoodTint(customTint: SavedMoodTint) -> SavedMoodTint {
|
||||
do {
|
||||
|
||||
@@ -81,13 +81,13 @@ extension ChartDataBuildable {
|
||||
|
||||
let view = ChartType(color: moodTint.color(forMood: item.mood),
|
||||
weekDay: Int(item.weekDay),
|
||||
viewType: .square)
|
||||
shape: UserDefaultsStore.getCustomBGShape())
|
||||
filledOutArray.append(view)
|
||||
} else {
|
||||
let thisDate = Calendar.current.date(bySetting: .day, value: day, of: month)!
|
||||
let view = ChartType(color: Mood.placeholder.color,
|
||||
weekDay: Calendar.current.component(.weekday, from: thisDate),
|
||||
viewType: .square)
|
||||
shape: UserDefaultsStore.getCustomBGShape())
|
||||
filledOutArray.append(view)
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ extension ChartDataBuildable {
|
||||
for _ in filledOutArray.count...32 {
|
||||
let view = ChartType(color: Mood.placeholder.color,
|
||||
weekDay: 2,
|
||||
viewType: .cicle)
|
||||
shape: UserDefaultsStore.getCustomBGShape())
|
||||
filledOutArray.append(view)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,16 +7,10 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
enum ViewType: Hashable {
|
||||
case cicle
|
||||
case square
|
||||
case text(String)
|
||||
}
|
||||
|
||||
protocol ChartViewItemBuildable: View {
|
||||
var color: Color { get }
|
||||
var weekDay: Int { get }
|
||||
var viewType: ViewType { get }
|
||||
var shape: BGShape { get }
|
||||
|
||||
init(color: Color, weekDay: Int, viewType: ViewType)
|
||||
init(color: Color, weekDay: Int, shape: BGShape)
|
||||
}
|
||||
|
||||
@@ -11,13 +11,15 @@ struct CustomizeView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.moodImages.rawValue, store: GroupUserDefaults.groupDefaults) private var imagePack: MoodImages = .FontAwesome
|
||||
|
||||
|
||||
@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.personalityPack.rawValue, store: GroupUserDefaults.groupDefaults) private var personalityPack: PersonalityPack = .Default
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.customMoodTintUpdateNumber.rawValue, store: GroupUserDefaults.groupDefaults) private var customMoodTintUpdateNumber: Int = 0
|
||||
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = .black
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.showNSFW.rawValue, store: GroupUserDefaults.groupDefaults) private var showNSFW: Bool = false
|
||||
@@ -27,13 +29,15 @@ struct CustomizeView: View {
|
||||
|
||||
@StateObject private var customMoodTint = UserDefaultsStore.getCustomMoodTint()
|
||||
|
||||
@State var shapeRefreshToggleThing: Bool = false
|
||||
|
||||
class StupidAssCustomWidgetObservableObject: ObservableObject {
|
||||
@Published var fuckingWrapped: CustomWidgetModel? = nil
|
||||
@Published var showFuckingSheet = false
|
||||
}
|
||||
|
||||
@StateObject private var selectedWidget = StupidAssCustomWidgetObservableObject()
|
||||
|
||||
|
||||
let iconSets: [(String,String)] = [
|
||||
("AppIconGoodImage", "AppIconGood"),
|
||||
("AppIconAverageImage", "AppIconAverage"),
|
||||
@@ -47,17 +51,21 @@ struct CustomizeView: View {
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack {
|
||||
createCustomWidget
|
||||
changeIcon
|
||||
themePicker
|
||||
Divider()
|
||||
sampleEntryView
|
||||
pickMoodImagePack
|
||||
Group {
|
||||
createCustomWidget
|
||||
changeIcon
|
||||
themePicker
|
||||
Divider()
|
||||
sampleEntryView
|
||||
pickMoodImagePack
|
||||
}
|
||||
Group {
|
||||
pickMoodTintPack
|
||||
pickTextColor
|
||||
}
|
||||
Divider()
|
||||
shapePicker
|
||||
Divider()
|
||||
pickPeronsalityPack
|
||||
}
|
||||
}
|
||||
@@ -91,7 +99,7 @@ struct CustomizeView: View {
|
||||
.frame(width: 50, height:50)
|
||||
.cornerRadius(10)
|
||||
})
|
||||
|
||||
|
||||
|
||||
ForEach(iconSets, id: \.self.0){ iconSet in
|
||||
Button(action: {
|
||||
@@ -140,13 +148,13 @@ struct CustomizeView: View {
|
||||
.font(.body)
|
||||
}
|
||||
})
|
||||
.contentShape(Rectangle())
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
.fill(theme == aTheme ? theme.currentTheme.bgColor : .clear)
|
||||
.padding(-5)
|
||||
|
||||
)
|
||||
.contentShape(Rectangle())
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
.fill(theme == aTheme ? theme.currentTheme.bgColor : .clear)
|
||||
.padding(-5)
|
||||
|
||||
)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
@@ -450,6 +458,60 @@ struct CustomizeView: View {
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var shapePicker: some View {
|
||||
ZStack {
|
||||
theme.currentTheme.secondaryBGColor
|
||||
|
||||
VStack {
|
||||
HStack {
|
||||
Spacer()
|
||||
Text(shapeRefreshToggleThing.description.localizedLowercase)
|
||||
.hidden()
|
||||
Image(systemName: "arrow.triangle.2.circlepath.circle")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20, alignment: .trailing)
|
||||
.foregroundColor(Color(UIColor.systemGray))
|
||||
.onTapGesture {
|
||||
shapeRefreshToggleThing.toggle()
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
|
||||
VStack(alignment:.leading) {
|
||||
Text(String(localized: "customize_view_view_pick_shape"))
|
||||
.padding([.leading])
|
||||
.foregroundColor(textColor)
|
||||
Divider()
|
||||
|
||||
HStack {
|
||||
ForEach(BGShape.allCases, id: \.rawValue) { ashape in
|
||||
ashape.view(withText: Text("20"),
|
||||
bgColor: moodTint.color(forMood: Mood.allValues.randomElement()!), textColor: textColor)
|
||||
.frame(height: 50)
|
||||
.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.onTapGesture {
|
||||
let impactMed = UIImpactFeedbackGenerator(style: .heavy)
|
||||
impactMed.impactOccurred()
|
||||
shape = ashape
|
||||
EventLogger.log(event: "change_mood_shape_id", withData: ["id": shape.rawValue])
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 10, style: .continuous)
|
||||
.fill(shape == ashape ? theme.currentTheme.bgColor : .clear)
|
||||
.padding(-5)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
}
|
||||
|
||||
struct CustomizeView_Previews: PreviewProvider {
|
||||
|
||||
@@ -9,32 +9,22 @@ import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct DayChartView: ChartViewItemBuildable, View, Hashable {
|
||||
init(color: Color, weekDay: Int, viewType: ViewType) {
|
||||
init(color: Color, weekDay: Int, shape: BGShape) {
|
||||
self.color = color
|
||||
self.weekDay = weekDay
|
||||
self.viewType = viewType
|
||||
self.shape = shape
|
||||
}
|
||||
|
||||
var id = UUID()
|
||||
var color: Color
|
||||
var weekDay: Int
|
||||
var viewType: ViewType
|
||||
var shape: BGShape
|
||||
|
||||
var body: some View {
|
||||
switch viewType {
|
||||
case .cicle:
|
||||
Circle()
|
||||
.fill(color)
|
||||
.frame(minWidth: 5, idealWidth: 50, maxWidth: 50, minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||
.opacity(color == Mood.missing.color ? 0.5 : 1.0)
|
||||
case .square:
|
||||
Rectangle()
|
||||
.fill(color)
|
||||
.frame(minWidth: 5, idealWidth: 50, maxWidth: 50, minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||
case .text(let value):
|
||||
Text(value)
|
||||
.font(.footnote)
|
||||
.frame(minWidth: 5, idealWidth: 50, maxWidth: 50, minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||
}
|
||||
shape.view(withText: Text(""), bgColor: color, textColor: .clear)
|
||||
.frame(minWidth: 5, idealWidth: 50, maxWidth: 50,
|
||||
minHeight: 5, idealHeight: 20, maxHeight: 50,
|
||||
alignment: .center)
|
||||
.opacity(color == Mood.missing.color ? 0.5 : 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ struct HeaderPercView: View {
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = .black
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.shape.rawValue, store: GroupUserDefaults.groupDefaults) private var shape: BGShape = .circle
|
||||
|
||||
@State private var entries = [MoodMetrics]()
|
||||
let backDays: Int
|
||||
let type: PercViewType
|
||||
@@ -75,23 +77,19 @@ struct HeaderPercView: View {
|
||||
Spacer()
|
||||
HStack {
|
||||
ForEach(entries.prefix(3), id: \.id) { model in
|
||||
Text("\(model.percent, specifier: "%.0f")%")
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.padding()
|
||||
.background(Circle().fill(moodTint.color(forMood: model.mood)))
|
||||
.frame(maxWidth: .infinity)
|
||||
shape.view(withText: Text("\(model.percent, specifier: "%.0f")%"),
|
||||
bgColor: moodTint.color(forMood: model.mood),
|
||||
textColor: textColor)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
HStack {
|
||||
ForEach(entries.suffix(2), id: \.id) { model in
|
||||
Text("\(model.percent, specifier: "%.0f")%")
|
||||
.font(.title2)
|
||||
.fontWeight(.bold)
|
||||
.padding()
|
||||
.background(Circle().fill(moodTint.color(forMood: model.mood)))
|
||||
.frame(maxWidth: .infinity)
|
||||
shape.view(withText: Text("\(model.percent, specifier: "%.0f")%"),
|
||||
bgColor: moodTint.color(forMood: model.mood),
|
||||
textColor: textColor)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
|
||||
@@ -211,7 +211,7 @@ struct MonthDetailView: View {
|
||||
.frame(minHeight: 0, maxHeight: 100)
|
||||
|
||||
SmallRollUpHeaderView(entries: entries,
|
||||
viewType: .constant(.percentageCircle))
|
||||
viewType: .constant(.percentageShape))
|
||||
.frame(minHeight: 0, maxHeight: 100)
|
||||
.padding(.top, -20)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ struct MonthView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = .black
|
||||
|
||||
@AppStorage(UserDefaultsStore.Keys.shape.rawValue, store: GroupUserDefaults.groupDefaults) private var shape: BGShape = .circle
|
||||
|
||||
@StateObject private var shareImage = StupidAssShareObservableObject()
|
||||
|
||||
// store a value that gets changed when user updates custom colors to update the view since the moodTint doesn't change
|
||||
@@ -155,9 +157,9 @@ extension MonthView {
|
||||
Divider()
|
||||
LazyVGrid(columns: columns, spacing: 15) {
|
||||
ForEach(entries, id: \.self) { entry in
|
||||
Circle()
|
||||
.foregroundColor(entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood))
|
||||
.frame(minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||
shape.view(withText: Text(""), bgColor: entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood),
|
||||
textColor: .clear)
|
||||
.frame(minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
@@ -194,11 +196,11 @@ extension MonthView {
|
||||
}
|
||||
}
|
||||
Divider()
|
||||
LazyVGrid(columns: columns, spacing: 15) {
|
||||
LazyVGrid(columns: columns, spacing: 25) {
|
||||
ForEach(entries, id: \.self) { entry in
|
||||
Circle()
|
||||
.foregroundColor(entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood))
|
||||
.frame(minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||
shape.view(withText: Text(""), bgColor: entry.mood == .placeholder ? .clear : moodTint.color(forMood: entry.mood),
|
||||
textColor: .clear)
|
||||
.frame(minHeight: 5, idealHeight: 20, maxHeight: 50, alignment: .center)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -9,7 +9,7 @@ import SwiftUI
|
||||
|
||||
enum MainSwitchableViewType: Int, CaseIterable {
|
||||
case total
|
||||
case percentageCircle
|
||||
case percentageShape
|
||||
case percentage
|
||||
|
||||
func next() -> MainSwitchableViewType {
|
||||
@@ -57,7 +57,7 @@ struct SwitchableView: View {
|
||||
.padding([.leading, .trailing], -15)
|
||||
.padding([.top, .bottom], 8)
|
||||
.allowsHitTesting(false)
|
||||
case .percentageCircle:
|
||||
case .percentageShape:
|
||||
HeaderPercView(fakeData: false, backDays: daysBack, type: .circular)
|
||||
.allowsHitTesting(false)
|
||||
case .percentage:
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
"customize_view_over18alert_body" = "Some of this is explicit, are you over 18?";
|
||||
"customize_view_over18alert_ok" = "Sure";
|
||||
"customize_view_over18alert_no" = "Nah, I'm good";
|
||||
"customize_view_view_pick_shape" = "Pick a shape";
|
||||
|
||||
"create_widget_view_left_eye" = "Left Eye";
|
||||
"create_widget_view_right_eye" = "Right Eye";
|
||||
|
||||
Reference in New Issue
Block a user