re-do the way a custom icon is generated / stored

fix small roll up header text going outside of circle view
This commit is contained in:
Trey t
2022-02-14 17:02:56 -06:00
parent 0ca2e9b1be
commit fce13af84e
4 changed files with 71 additions and 59 deletions

View File

@@ -9,11 +9,24 @@ import SwiftUI
class CustomIcon: ObservableObject {
static let numberOfBGItems = 99
init(leftEye: Image,
rightEye: Image,
mouth: Image,
background: [(Image, UUID)],
static let defaultCustomIcon = CustomIcon(leftEye: EyeOptions.defaultOption,
rightEye: EyeOptions.defaultOption,
mouth: MouthOptions.defaultOption,
background: IconView_Previews.backgrounds,
bgColor: .red,
innerColor: .green,
bgOverlayColor: .orange,
rightEyeColor: .orange,
leftEyeColor: .yellow,
mouthColor: .green,
circleStrokeColor: .pink)
init(leftEye: EyeOptions,
rightEye: EyeOptions,
mouth: MouthOptions,
background: [(BackGroundOptions, UUID)],
bgColor: Color,
innerColor: Color,
bgOverlayColor: Color,
@@ -35,11 +48,11 @@ class CustomIcon: ObservableObject {
self.circleStrokeColor = circleStrokeColor
}
@Published var leftEye: Image
@Published var rightEye: Image
@Published var mouth: Image
@Published var leftEye: EyeOptions
@Published var rightEye: EyeOptions
@Published var mouth: MouthOptions
@Published var background: [(Image, UUID)]
@Published var background: [(BackGroundOptions, UUID)]
@Published var bgColor: Color
@Published var innerColor: Color
@Published var bgOverlayColor: Color
@@ -51,7 +64,7 @@ class CustomIcon: ObservableObject {
@Published var circleStrokeColor: Color
}
enum BackGroundOptions: String, CaseIterable {
enum BackGroundOptions: String, CaseIterable, Codable {
case horrible
case bad
case average
@@ -62,14 +75,22 @@ enum BackGroundOptions: String, CaseIterable {
static var selectable: [BackGroundOptions] {
return [.great, .good, .average, .bad, .horrible]
}
static public var defaultOption: BackGroundOptions {
BackGroundOptions.random
}
public var image: Image {
return Image(self.rawValue, bundle: .main)
}
}
enum Eyes {
enum Eyes: String, Codable {
case left
case right
}
enum EyeOptions: String, CaseIterable {
enum EyeOptions: String, CaseIterable, Codable {
case fire = "fire"
case bolt = "bolt2"
case dollar = "dollar"
@@ -88,13 +109,16 @@ enum EyeOptions: String, CaseIterable {
case skull2 = "skull2"
case poo = "poo"
static public var defaultOption: Image {
let image = Image(EyeOptions.fire.rawValue, bundle: .main)
return image
static public var defaultOption: EyeOptions {
EyeOptions.fire
}
public var image: Image {
return Image(self.rawValue, bundle: .main)
}
}
enum MouthOptions: String, CaseIterable {
enum MouthOptions: String, CaseIterable, Codable {
case fire = "fire"
case bolt = "bolt2"
case dollar = "dollar"
@@ -113,8 +137,11 @@ enum MouthOptions: String, CaseIterable {
case skull2 = "skull2"
case poo = "poo"
static public var defaultOption: Image {
let image = Image(MouthOptions.bomb.rawValue, bundle: .main)
return image
static public var defaultOption: MouthOptions {
MouthOptions.bomb
}
public var image: Image {
return Image(self.rawValue, bundle: .main)
}
}