everything changed

This commit is contained in:
Trey t
2022-02-20 14:33:58 -06:00
parent 1cf38cb854
commit 0035f61204
50 changed files with 2155 additions and 875 deletions

View File

@@ -0,0 +1,147 @@
//
// CustomIcon.swift
// Feels (iOS)
//
// Created by Trey Tartt on 2/13/22.
//
import SwiftUI
class CustomWidgetModel: ObservableObject {
static let numberOfBGItems = 109
static let defaultCustomIcon = CustomWidgetModel(leftEye: CustomWidgetEyeOptions.defaultOption,
rightEye: CustomWidgetEyeOptions.defaultOption,
mouth: CustomWidgetMouthOptions.defaultOption,
background: WidgetView_Previews.backgrounds,
bgColor: .red,
innerColor: .green,
bgOverlayColor: .orange,
rightEyeColor: .orange,
leftEyeColor: .yellow,
mouthColor: .green,
circleStrokeColor: .pink)
init(leftEye: CustomWidgetEyeOptions,
rightEye: CustomWidgetEyeOptions,
mouth: CustomWidgetMouthOptions,
background: [(CustomWidgetBackGroundOptions, UUID)],
bgColor: Color,
innerColor: Color,
bgOverlayColor: Color,
rightEyeColor: Color,
leftEyeColor: Color,
mouthColor: Color,
circleStrokeColor: Color
) {
self.leftEye = leftEye
self.rightEye = rightEye
self.mouth = mouth
self.background = background
self.bgColor = bgColor
self.innerColor = innerColor
self.bgOverlayColor = bgOverlayColor
self.rightEyeColor = rightEyeColor
self.leftEyeColor = leftEyeColor
self.mouthColor = mouthColor
self.circleStrokeColor = circleStrokeColor
}
@Published var leftEye: CustomWidgetEyeOptions
@Published var rightEye: CustomWidgetEyeOptions
@Published var mouth: CustomWidgetMouthOptions
@Published var background: [(CustomWidgetBackGroundOptions, UUID)]
@Published var bgColor: Color
@Published var innerColor: Color
@Published var bgOverlayColor: Color
@Published var leftEyeColor: Color
@Published var rightEyeColor: Color
@Published var mouthColor: Color
@Published var circleStrokeColor: Color
}
enum CustomWidgetBackGroundOptions: String, CaseIterable, Codable {
case horrible
case bad
case average
case good
case great
case random
static var selectable: [CustomWidgetBackGroundOptions] {
return [.great, .good, .average, .bad, .horrible]
}
static public var defaultOption: CustomWidgetBackGroundOptions {
CustomWidgetBackGroundOptions.random
}
public var image: Image {
return Image(self.rawValue, bundle: .main)
}
}
enum CustomWidgetEyes: String, Codable {
case left
case right
}
enum CustomWidgetEyeOptions: String, CaseIterable, Codable {
case fire = "fire"
case bolt = "bolt2"
case dollar = "dollar"
case bell = "bell"
case btc = "btc"
case code = "code"
case crown = "crown"
case divide = "divide"
case exclamation = "exclamation"
case fan = "fan"
case floppy = "floppy"
case x = "x"
case skull = "skull"
case covid = "covid"
case bomb = "bomb"
case skull2 = "skull2"
case poo = "poo"
static public var defaultOption: CustomWidgetEyeOptions {
CustomWidgetEyeOptions.fire
}
public var image: Image {
return Image(self.rawValue, bundle: .main)
}
}
enum CustomWidgetMouthOptions: String, CaseIterable, Codable {
case fire = "fire"
case bolt = "bolt2"
case dollar = "dollar"
case bell = "bell"
case btc = "btc"
case code = "code"
case crown = "crown"
case divide = "divide"
case exclamation = "exclamation"
case fan = "fan"
case floppy = "floppy"
case x = "x"
case skull = "skull"
case covid = "covid"
case bomb = "bomb"
case skull2 = "skull2"
case poo = "poo"
static public var defaultOption: CustomWidgetMouthOptions {
CustomWidgetMouthOptions.bomb
}
public var image: Image {
return Image(self.rawValue, bundle: .main)
}
}

View File

@@ -0,0 +1,130 @@
//
// IconView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 2/13/22.
//
import SwiftUI
struct CustomWidgetView: View {
@State public var customWidgetModel: CustomWidgetModel
private let facePercSize = 0.6
// private var gridXOffset: CGFloat {
// if isPreview {
// return CGFloat(0)
// }
// return CGFloat(6)
// }
//
// private var gridYOffset: CGFloat {
// if isPreview {
// return CGFloat(0)
// }
// return CGFloat(-8)
// }
//
// private var entireFuckingViewOffset: CGFloat {
// if isPreview {
// return CGFloat(0)
// }
// return CGFloat(25)
// }
let columns = [
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1)
]
var body: some View {
GeometryReader { geo in
ZStack {
Rectangle()
.fill(
customWidgetModel.bgColor
)
.frame(maxWidth: .infinity, maxHeight: .infinity)
LazyVGrid(columns: columns, alignment: .leading, spacing: 0) {
ForEach(customWidgetModel.background, id: \.self.1) { (bgOption, uuid) in
bgOption.image
.resizable()
.aspectRatio(1, contentMode: .fill)
.foregroundColor(customWidgetModel.bgOverlayColor)
}
}
.scaleEffect(1.1)
.clipped()
.background(
.clear
)
Circle()
.strokeBorder(customWidgetModel.circleStrokeColor, lineWidth: geo.size.width * 0.045)
.background(Circle().fill(customWidgetModel.innerColor))
.frame(width: geo.size.width*facePercSize,
height: geo.size.height*facePercSize,
alignment: .center)
.position(x: geo.size.width/2, y: geo.size.height/2)
customWidgetModel.leftEye.image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: geo.size.width*0.12,
height: geo.size.height*0.12,
alignment: .center)
.position(x: geo.size.width*0.4,
y: geo.size.height*0.4)
.foregroundColor(customWidgetModel.leftEyeColor)
customWidgetModel.rightEye.image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: geo.size.width*0.12,
height: geo.size.height*0.12,
alignment: .center)
.position(x: geo.size.width*0.6,
y: geo.size.height*0.4)
.foregroundColor(customWidgetModel.rightEyeColor)
customWidgetModel.mouth.image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: geo.size.width*0.12,
height: geo.size.height*0.12,
alignment: .center)
.position(x: geo.size.width*0.5,
y: geo.size.height*0.59)
.foregroundColor(customWidgetModel.mouthColor)
}
.position(x: geo.size.width/2,
y: geo.size.height/2)
}
}
}
struct WidgetView_Previews: PreviewProvider {
static var backgrounds: [(CustomWidgetBackGroundOptions, UUID)] = {
var blah = [(CustomWidgetBackGroundOptions, UUID)]()
for _ in 0...CustomWidgetModel.numberOfBGItems {
blah.append((CustomWidgetBackGroundOptions.selectable.randomElement()!, UUID()))
}
return blah
}()
static var previews: some View {
CustomWidgetView(customWidgetModel: CustomWidgetModel.defaultCustomIcon)
.frame(width: 256, height: 256, alignment: .center)
}
}