From 14aec1222ee9ece8271377124cc3dd94fd295396 Mon Sep 17 00:00:00 2001 From: Trey t Date: Mon, 14 Feb 2022 09:34:11 -0600 Subject: [PATCH] customize eye, mouth, face outline colors for custom icon --- .../custom_icon/bell.imageset/Contents.json | 3 + .../custom_icon/bolt2.imageset/Contents.json | 3 + .../custom_icon/bomb.imageset/Contents.json | 3 + .../custom_icon/btc.imageset/Contents.json | 3 + .../custom_icon/code.imageset/Contents.json | 3 + .../custom_icon/covid.imageset/Contents.json | 3 + .../custom_icon/crown.imageset/Contents.json | 3 + .../custom_icon/divide.imageset/Contents.json | 3 + .../custom_icon/dollar.imageset/Contents.json | 3 + .../exclamation.imageset/Contents.json | 3 + .../custom_icon/fan.imageset/Contents.json | 3 + .../custom_icon/fire.imageset/Contents.json | 3 + .../custom_icon/floppy.imageset/Contents.json | 3 + .../custom_icon/poo.imageset/Contents.json | 3 + .../custom_icon/skull.imageset/Contents.json | 3 + .../custom_icon/skull2.imageset/Contents.json | 3 + .../custom_icon/x.imageset/Contents.json | 3 + Shared/Models/CustomIcon.swift | 17 +++- Shared/views/CreateIconView.swift | 97 +++++++++++++------ Shared/views/IconView.swift | 11 ++- 20 files changed, 142 insertions(+), 34 deletions(-) diff --git a/Shared/Assets.xcassets/custom_icon/bell.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/bell.imageset/Contents.json index 7f9b6f4..96ef9c7 100644 --- a/Shared/Assets.xcassets/custom_icon/bell.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/bell.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/bolt2.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/bolt2.imageset/Contents.json index af1f790..e15231d 100644 --- a/Shared/Assets.xcassets/custom_icon/bolt2.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/bolt2.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/bomb.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/bomb.imageset/Contents.json index 086dd5a..ed251d3 100644 --- a/Shared/Assets.xcassets/custom_icon/bomb.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/bomb.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/btc.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/btc.imageset/Contents.json index 8b900ab..706f48b 100644 --- a/Shared/Assets.xcassets/custom_icon/btc.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/btc.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/code.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/code.imageset/Contents.json index ed03090..8e9f650 100644 --- a/Shared/Assets.xcassets/custom_icon/code.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/code.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/covid.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/covid.imageset/Contents.json index 10a6c82..2e06d53 100644 --- a/Shared/Assets.xcassets/custom_icon/covid.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/covid.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/crown.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/crown.imageset/Contents.json index 287993c..fa0a54b 100644 --- a/Shared/Assets.xcassets/custom_icon/crown.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/crown.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/divide.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/divide.imageset/Contents.json index 069d4d2..aca17bd 100644 --- a/Shared/Assets.xcassets/custom_icon/divide.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/divide.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/dollar.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/dollar.imageset/Contents.json index bdaf956..3ee36bc 100644 --- a/Shared/Assets.xcassets/custom_icon/dollar.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/dollar.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/exclamation.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/exclamation.imageset/Contents.json index c82dff9..3024f0d 100644 --- a/Shared/Assets.xcassets/custom_icon/exclamation.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/exclamation.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/fan.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/fan.imageset/Contents.json index 741d74c..a352b15 100644 --- a/Shared/Assets.xcassets/custom_icon/fan.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/fan.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/fire.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/fire.imageset/Contents.json index 95efb2c..42accce 100644 --- a/Shared/Assets.xcassets/custom_icon/fire.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/fire.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/floppy.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/floppy.imageset/Contents.json index f686d07..aea3ab6 100644 --- a/Shared/Assets.xcassets/custom_icon/floppy.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/floppy.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/poo.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/poo.imageset/Contents.json index 1a22f96..0285bef 100644 --- a/Shared/Assets.xcassets/custom_icon/poo.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/poo.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/skull.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/skull.imageset/Contents.json index b4597c4..c46da19 100644 --- a/Shared/Assets.xcassets/custom_icon/skull.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/skull.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/skull2.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/skull2.imageset/Contents.json index 5f338ee..761674e 100644 --- a/Shared/Assets.xcassets/custom_icon/skull2.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/skull2.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Assets.xcassets/custom_icon/x.imageset/Contents.json b/Shared/Assets.xcassets/custom_icon/x.imageset/Contents.json index 8e1cbc7..2c8ae1e 100644 --- a/Shared/Assets.xcassets/custom_icon/x.imageset/Contents.json +++ b/Shared/Assets.xcassets/custom_icon/x.imageset/Contents.json @@ -17,5 +17,8 @@ "info" : { "author" : "xcode", "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "template" } } diff --git a/Shared/Models/CustomIcon.swift b/Shared/Models/CustomIcon.swift index 7109780..69218cf 100644 --- a/Shared/Models/CustomIcon.swift +++ b/Shared/Models/CustomIcon.swift @@ -16,7 +16,12 @@ class CustomIcon: ObservableObject { background: [(Image, UUID)], bgColor: Color, innerColor: Color, - bgOverlayColor: Color) { + bgOverlayColor: Color, + rightEyeColor: Color, + leftEyeColor: Color, + mouthColor: Color, + circleStrokeColor: Color + ) { self.leftEye = leftEye self.rightEye = rightEye self.mouth = mouth @@ -24,6 +29,10 @@ class CustomIcon: ObservableObject { self.bgColor = bgColor self.innerColor = innerColor self.bgOverlayColor = bgOverlayColor + self.rightEyeColor = rightEyeColor + self.leftEyeColor = leftEyeColor + self.mouthColor = mouthColor + self.circleStrokeColor = circleStrokeColor } @Published var leftEye: Image @@ -34,6 +43,12 @@ class CustomIcon: ObservableObject { @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 BackGroundOptions: String, CaseIterable { diff --git a/Shared/views/CreateIconView.swift b/Shared/views/CreateIconView.swift index ca96d52..bbb6e76 100644 --- a/Shared/views/CreateIconView.swift +++ b/Shared/views/CreateIconView.swift @@ -28,7 +28,11 @@ struct CreateIconView: View { background: CreateIconView.iconViewBGs, bgColor: .red, innerColor: .green, - bgOverlayColor: .black) + bgOverlayColor: .black, + rightEyeColor: .orange, + leftEyeColor: .yellow, + mouthColor: .green, + circleStrokeColor: .pink) private var randomElements: [AnyView] = [ AnyView(Image(BackGroundOptions.selectable.randomElement()!.rawValue) .resizable() @@ -113,51 +117,83 @@ struct CreateIconView: View { Spacer() - VStack { - ColorPicker("Set the background color", selection: $customIcon.bgColor) - .padding([.leading, .trailing]) - ColorPicker("Set the inner color", selection: $customIcon.innerColor) - .padding([.leading, .trailing]) + ZStack { + Color(theme.currentTheme.secondaryBGColor) + HStack { + Spacer() + VStack(alignment: .center) { + Text("background") + ColorPicker("", selection: $customIcon.bgColor) + .labelsHidden() + } + Spacer() + VStack(alignment: .center) { + Text("Inner") + ColorPicker("", selection: $customIcon.innerColor) + .labelsHidden() + } + Spacer() + VStack(alignment: .center) { + Text("Face Outline") + ColorPicker("", selection: $customIcon.circleStrokeColor) + .labelsHidden() + } + Spacer() + } } + .frame(height: 75) + .frame(minWidth: 0, maxWidth: .infinity) ZStack { Color(theme.currentTheme.secondaryBGColor) HStack { Spacer() - Menu("Left Eye") { - ForEach(EyeOptions.allCases, id: \.self) { option in - Button(action: { - update(eye: .left, eyeOption: option) - }, label: { - Label(option.rawValue, image: option.rawValue) - }) + VStack { + Menu("Left Eye") { + ForEach(EyeOptions.allCases, id: \.self) { option in + Button(action: { + update(eye: .left, eyeOption: option) + }, label: { + Label(option.rawValue, image: option.rawValue) + }) + } } + ColorPicker("", selection: $customIcon.leftEyeColor) + .labelsHidden() } Spacer() - Menu("Right Eye") { - ForEach(EyeOptions.allCases, id: \.self) { option in - Button(action: { - update(eye: .right, eyeOption: option) - }, label: { - Label(option.rawValue, image: option.rawValue) - }) + VStack { + Menu("Right Eye") { + ForEach(EyeOptions.allCases, id: \.self) { option in + Button(action: { + update(eye: .right, eyeOption: option) + }, label: { + Label(option.rawValue, image: option.rawValue) + }) + } } + ColorPicker("", selection: $customIcon.rightEyeColor) + .labelsHidden() } Spacer() - Menu("Mouth") { - ForEach(MouthOptions.allCases, id: \.self) { option in - Button(action: { - update(mouthOption: option) - }, label: { - Label(option.rawValue, image: option.rawValue) - }) + VStack { + Menu("Mouth") { + ForEach(MouthOptions.allCases, id: \.self) { option in + Button(action: { + update(mouthOption: option) + }, label: { + Label(option.rawValue, image: option.rawValue) + }) + } } + ColorPicker("", selection: $customIcon.mouthColor) + .labelsHidden() } Spacer() } } - .frame(height: 44) - .padding(.top, 10) + .frame(height: 75) + .frame(minWidth: 0, maxWidth: .infinity) ZStack { Color(theme.currentTheme.secondaryBGColor) @@ -185,9 +221,8 @@ struct CreateIconView: View { .padding([.leading, .trailing]) } } - .frame(height: 88) + .frame(height: 75) .frame(minWidth: 0, maxWidth: .infinity) - .padding(.top, 10) ZStack { VStack{ diff --git a/Shared/views/IconView.swift b/Shared/views/IconView.swift index c8da9f0..36b0f37 100644 --- a/Shared/views/IconView.swift +++ b/Shared/views/IconView.swift @@ -70,7 +70,7 @@ struct IconView: View { ) Circle() - .strokeBorder(Color.black, lineWidth: geo.size.width * 0.045) + .strokeBorder(customIcon.circleStrokeColor, lineWidth: geo.size.width * 0.045) .background(Circle().fill(customIcon.innerColor)) .frame(width: geo.size.width*facePercSize, height: geo.size.height*facePercSize, @@ -85,6 +85,7 @@ struct IconView: View { alignment: .center) .position(x: geo.size.width*0.4, y: geo.size.height*0.4) + .foregroundColor(customIcon.leftEyeColor) customIcon.rightEye .resizable() @@ -94,6 +95,7 @@ struct IconView: View { alignment: .center) .position(x: geo.size.width*0.6, y: geo.size.height*0.4) + .foregroundColor(customIcon.rightEyeColor) customIcon.mouth .resizable() @@ -103,6 +105,7 @@ struct IconView: View { alignment: .center) .position(x: geo.size.width*0.5, y: geo.size.height*0.59) + .foregroundColor(customIcon.mouthColor) } .position(x: geo.size.width/2, y: geo.size.height/2 - entireFuckingViewOffset) @@ -127,7 +130,11 @@ struct IconView_Previews: PreviewProvider { background: IconView_Previews.backgrounds, bgColor: .red, innerColor: .green, - bgOverlayColor: .orange), + bgOverlayColor: .orange, + rightEyeColor: .orange, + leftEyeColor: .yellow, + mouthColor: .green, + circleStrokeColor: .pink), isPreview: true) .frame(width: 256, height: 256, alignment: .center)