create contentview view model
add background to content view make contentview list split by year / month test data will add 120 days instead of 25 closed #35 closed #36
This commit is contained in:
77
Shared/views/BGView.swift
Normal file
77
Shared/views/BGView.swift
Normal file
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// IconView.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct BGViewItem: View {
|
||||
let mood: Mood
|
||||
let size: CGSize
|
||||
var color: Color
|
||||
let animate: Bool
|
||||
let yRowPosition: Float
|
||||
|
||||
init(mood: Mood, size: CGSize, animate: Bool, yRowPosition: Float) {
|
||||
color = mood.color
|
||||
self.mood = mood
|
||||
self.size = size
|
||||
self.yRowPosition = yRowPosition
|
||||
self.animate = animate
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Mood.allValues.randomElement()?.icon
|
||||
.resizable()
|
||||
.frame(width: size.width, height: size.height)
|
||||
.foregroundColor(color)
|
||||
// .blur(radius: 3)
|
||||
.opacity(0.1)
|
||||
}
|
||||
}
|
||||
|
||||
struct BGView: View {
|
||||
var numAcross: Int
|
||||
var numDown: Int
|
||||
let iconSize = 35
|
||||
|
||||
init() {
|
||||
let screenWidth = UIScreen.main.bounds.width
|
||||
numAcross = Int(screenWidth)/iconSize
|
||||
|
||||
let screenHeight = UIScreen.main.bounds.height
|
||||
numDown = Int(screenHeight)/iconSize
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
ForEach(0...numDown, id: \.self) { row in
|
||||
HStack {
|
||||
ForEach(0...numAcross, id: \.self) { _ in
|
||||
BGViewItem(mood: Mood.allValues.randomElement()!,
|
||||
size: .init(width: iconSize,height: iconSize),
|
||||
animate: false,
|
||||
yRowPosition: Float(row)/Float(numDown))
|
||||
}.frame(minWidth: 0, maxWidth: .infinity)
|
||||
}
|
||||
.padding(.top, -8)
|
||||
}
|
||||
}
|
||||
.padding(.top, -50)
|
||||
}
|
||||
}
|
||||
|
||||
struct BGView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
BGView().environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
||||
.onAppear(perform: {
|
||||
PersistenceController.shared.populateMemory()
|
||||
})
|
||||
|
||||
BGView()
|
||||
.preferredColorScheme(.dark)
|
||||
.environment(\.managedObjectContext, PersistenceController.shared.container.viewContext)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user