spacing on custom icon widget
create color extension for random widget 512x512 ... 1024x1024 didn't work clean up Icon Widget View
This commit is contained in:
@@ -145,3 +145,13 @@ extension Date {
|
|||||||
return dates
|
return dates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Color {
|
||||||
|
static func random() -> Self {
|
||||||
|
Self(
|
||||||
|
red: .random(in: 0...1),
|
||||||
|
green: .random(in: 0...1),
|
||||||
|
blue: .random(in: 0...1)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -55,17 +55,9 @@ struct CreateIconView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createRandom() {
|
func createRandom() {
|
||||||
customIcon.bgColor = Color(
|
customIcon.bgColor = Color.random()
|
||||||
red: .random(in: 0...1),
|
customIcon.innerColor = Color.random()
|
||||||
green: .random(in: 0...1),
|
customIcon.bgOverlayColor = Color.random()
|
||||||
blue: .random(in: 0...1)
|
|
||||||
)
|
|
||||||
|
|
||||||
customIcon.innerColor = Color(
|
|
||||||
red: .random(in: 0...1),
|
|
||||||
green: .random(in: 0...1),
|
|
||||||
blue: .random(in: 0...1)
|
|
||||||
)
|
|
||||||
|
|
||||||
update(eye: .left, eyeOption: EyeOptions.allCases.randomElement()!)
|
update(eye: .left, eyeOption: EyeOptions.allCases.randomElement()!)
|
||||||
update(eye: .right, eyeOption: EyeOptions.allCases.randomElement()!)
|
update(eye: .right, eyeOption: EyeOptions.allCases.randomElement()!)
|
||||||
@@ -214,8 +206,8 @@ struct CreateIconView: View {
|
|||||||
|
|
||||||
Button(action: {
|
Button(action: {
|
||||||
let bigIconView = IconView(customIcon: customIcon, isPreview: false)
|
let bigIconView = IconView(customIcon: customIcon, isPreview: false)
|
||||||
.frame(width: 1024, height: 1024, alignment: .center)
|
.frame(width: 512, height: 512, alignment: .center)
|
||||||
.aspectRatio(contentMode: .fit)
|
.aspectRatio(contentMode: .fill)
|
||||||
let icon = bigIconView.snapshot()
|
let icon = bigIconView.snapshot()
|
||||||
if let data = icon.pngData() {
|
if let data = icon.pngData() {
|
||||||
savedCustomIcon = data
|
savedCustomIcon = data
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ struct IconView: View {
|
|||||||
return CGFloat(-8)
|
return CGFloat(-8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var entireFuckingViewOffset: CGFloat {
|
||||||
|
if isPreview {
|
||||||
|
return CGFloat(0)
|
||||||
|
}
|
||||||
|
return CGFloat(25)
|
||||||
|
}
|
||||||
|
|
||||||
let columns = [
|
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),
|
||||||
@@ -47,8 +54,7 @@ struct IconView: View {
|
|||||||
.fill(
|
.fill(
|
||||||
customIcon.bgColor
|
customIcon.bgColor
|
||||||
)
|
)
|
||||||
.frame(width: geo.size.width, height: geo.size.height, alignment: .center)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.position(x: geo.size.width/2, y: geo.size.height/2)
|
|
||||||
|
|
||||||
LazyVGrid(columns: columns, alignment: .leading, spacing: 0) {
|
LazyVGrid(columns: columns, alignment: .leading, spacing: 0) {
|
||||||
ForEach(customIcon.background, id: \.self.1) { (image, uuid) in
|
ForEach(customIcon.background, id: \.self.1) { (image, uuid) in
|
||||||
@@ -58,12 +64,7 @@ struct IconView: View {
|
|||||||
.foregroundColor(customIcon.bgOverlayColor)
|
.foregroundColor(customIcon.bgOverlayColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.frame(width: geo.size.width,
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
height: geo.size.height,
|
|
||||||
alignment: .center)
|
|
||||||
.position(x: geo.size.width/2 + gridXOffset,
|
|
||||||
y: geo.size.height/2 + gridYOffset)
|
|
||||||
|
|
||||||
.background(
|
.background(
|
||||||
.clear
|
.clear
|
||||||
)
|
)
|
||||||
@@ -104,7 +105,7 @@ struct IconView: View {
|
|||||||
y: geo.size.height*0.59)
|
y: geo.size.height*0.59)
|
||||||
}
|
}
|
||||||
.position(x: geo.size.width/2,
|
.position(x: geo.size.width/2,
|
||||||
y: geo.size.height/2)
|
y: geo.size.height/2 - entireFuckingViewOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user