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
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
customIcon.bgColor = Color(
|
||||
red: .random(in: 0...1),
|
||||
green: .random(in: 0...1),
|
||||
blue: .random(in: 0...1)
|
||||
)
|
||||
|
||||
customIcon.innerColor = Color(
|
||||
red: .random(in: 0...1),
|
||||
green: .random(in: 0...1),
|
||||
blue: .random(in: 0...1)
|
||||
)
|
||||
customIcon.bgColor = Color.random()
|
||||
customIcon.innerColor = Color.random()
|
||||
customIcon.bgOverlayColor = Color.random()
|
||||
|
||||
update(eye: .left, eyeOption: EyeOptions.allCases.randomElement()!)
|
||||
update(eye: .right, eyeOption: EyeOptions.allCases.randomElement()!)
|
||||
@@ -214,8 +206,8 @@ struct CreateIconView: View {
|
||||
|
||||
Button(action: {
|
||||
let bigIconView = IconView(customIcon: customIcon, isPreview: false)
|
||||
.frame(width: 1024, height: 1024, alignment: .center)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 512, height: 512, alignment: .center)
|
||||
.aspectRatio(contentMode: .fill)
|
||||
let icon = bigIconView.snapshot()
|
||||
if let data = icon.pngData() {
|
||||
savedCustomIcon = data
|
||||
|
||||
@@ -27,6 +27,13 @@ struct IconView: View {
|
||||
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),
|
||||
@@ -47,8 +54,7 @@ struct IconView: View {
|
||||
.fill(
|
||||
customIcon.bgColor
|
||||
)
|
||||
.frame(width: geo.size.width, height: geo.size.height, alignment: .center)
|
||||
.position(x: geo.size.width/2, y: geo.size.height/2)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
|
||||
LazyVGrid(columns: columns, alignment: .leading, spacing: 0) {
|
||||
ForEach(customIcon.background, id: \.self.1) { (image, uuid) in
|
||||
@@ -58,12 +64,7 @@ struct IconView: View {
|
||||
.foregroundColor(customIcon.bgOverlayColor)
|
||||
}
|
||||
}
|
||||
.frame(width: geo.size.width,
|
||||
height: geo.size.height,
|
||||
alignment: .center)
|
||||
.position(x: geo.size.width/2 + gridXOffset,
|
||||
y: geo.size.height/2 + gridYOffset)
|
||||
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.background(
|
||||
.clear
|
||||
)
|
||||
@@ -104,7 +105,7 @@ struct IconView: View {
|
||||
y: geo.size.height*0.59)
|
||||
}
|
||||
.position(x: geo.size.width/2,
|
||||
y: geo.size.height/2)
|
||||
y: geo.size.height/2 - entireFuckingViewOffset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user