wip
This commit is contained in:
93
Shared/Views/BGView.swift
Normal file
93
Shared/Views/BGView.swift
Normal file
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// IconView.swift
|
||||
// Feels (iOS)
|
||||
//
|
||||
// Created by Trey Tartt on 1/20/22.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct BGViewItem: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
|
||||
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: Color) {
|
||||
self.color = color
|
||||
self.mood = mood
|
||||
self.size = size
|
||||
self.yRowPosition = yRowPosition
|
||||
self.animate = animate
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
FontAwesomeMoodImages.icon(forMood: mood)
|
||||
.resizable()
|
||||
.frame(width: size.width, height: size.height)
|
||||
.foregroundColor(DefaultMoodTint.color(forMood: mood))
|
||||
// .blur(radius: 3)
|
||||
.opacity(0.1)
|
||||
}
|
||||
}
|
||||
|
||||
struct BGView: View, Equatable {
|
||||
@AppStorage(UserDefaultsStore.Keys.moodTint.rawValue, store: GroupUserDefaults.groupDefaults) private var moodTint: MoodTints = .Default
|
||||
|
||||
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 randomMood: Mood? {
|
||||
return Mood.allValues.randomElement()
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
ForEach(0...numDown, id: \.self) { row in
|
||||
HStack {
|
||||
ForEach(0...numAcross, id: \.self) { _ in
|
||||
if let randomMood = randomMood {
|
||||
BGViewItem(mood: randomMood,
|
||||
size: .init(width: iconSize,height: iconSize),
|
||||
animate: false,
|
||||
yRowPosition: Float(row)/Float(numDown),
|
||||
color: moodTint.color(forMood:randomMood))
|
||||
}
|
||||
}.frame(minWidth: 0, maxWidth: .infinity)
|
||||
.padding([.trailing, .leading], 13.5)
|
||||
}
|
||||
.padding(.top, -9)
|
||||
}
|
||||
}
|
||||
.padding(.top, -50)
|
||||
}
|
||||
|
||||
static func == (lhs: BGView, rhs: BGView) -> Bool {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
struct BGView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
BGView().environment(\.managedObjectContext, PersistenceController.shared.viewContext)
|
||||
.onAppear(perform: {
|
||||
PersistenceController.shared.populateMemory()
|
||||
})
|
||||
|
||||
BGView()
|
||||
.preferredColorScheme(.dark)
|
||||
.environment(\.managedObjectContext, PersistenceController.shared.viewContext)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user