fix widget / icon view layout

This commit is contained in:
Trey t
2022-02-26 11:50:51 -06:00
parent 5357b4ffb8
commit 09e1e96a0a
4 changed files with 21 additions and 39 deletions

View File

@@ -267,11 +267,9 @@ struct SmallGraphicWidgetView: View {
IconView(iconViewModel: IconViewModel(backgroundImage: first.graphic, IconView(iconViewModel: IconViewModel(backgroundImage: first.graphic,
bgColor: first.color, bgColor: first.color,
bgOverlayColor: first.secondaryColor, bgOverlayColor: first.secondaryColor,
centerImage: first.graphic), centerImage: first.graphic))
isPreview: true)
} else { } else {
IconView(iconViewModel: IconViewModel.great, IconView(iconViewModel: IconViewModel.great)
isPreview: false)
} }
} }
} }

View File

@@ -75,9 +75,9 @@ final class EmojiMoodImages: MoodImagable {
case .great: case .great:
return Image(uiImage: "😀".textToImage()!) return Image(uiImage: "😀".textToImage()!)
case .missing: case .missing:
return Image(uiImage: "x".textToImage()!) return Image(uiImage: "X".textToImage()!)
case .placeholder: case .placeholder:
return Image(uiImage: "x".textToImage()!) return Image(uiImage: "X".textToImage()!)
} }
} }
} }
@@ -96,9 +96,9 @@ final class HandEmojiMoodImages: MoodImagable {
case .great: case .great:
return Image(uiImage: "🙏".textToImage()!) return Image(uiImage: "🙏".textToImage()!)
case .missing: case .missing:
return Image(uiImage: "x".textToImage()!) return Image(uiImage: "X".textToImage()!)
case .placeholder: case .placeholder:
return Image(uiImage: "x".textToImage()!) return Image(uiImage: "X".textToImage()!)
} }
} }
} }

View File

@@ -11,28 +11,6 @@ struct IconView: View {
@State public var iconViewModel: IconViewModel @State public var iconViewModel: IconViewModel
private let facePercSize = 0.6 private let facePercSize = 0.6
public let isPreview: Bool
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 = [ let columns = [
GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1), GridItem(.flexible(minimum: 1, maximum: 100), spacing: 1),
@@ -60,7 +38,7 @@ struct IconView: View {
ForEach(iconViewModel.background, id: \.self.1) { (bgOption, uuid) in ForEach(iconViewModel.background, id: \.self.1) { (bgOption, uuid) in
bgOption bgOption
.resizable() .resizable()
.aspectRatio(1, contentMode: .fill) .aspectRatio(contentMode: .fill)
.foregroundColor(iconViewModel.bgOverlayColor) .foregroundColor(iconViewModel.bgOverlayColor)
} }
} }
@@ -76,7 +54,9 @@ struct IconView: View {
.frame(width: geo.size.width*facePercSize, .frame(width: geo.size.width*facePercSize,
height: geo.size.height*facePercSize, height: geo.size.height*facePercSize,
alignment: .center) alignment: .center)
.position(x: geo.size.width/2, y: geo.size.height/2) .alignmentGuide(.top, computeValue: { _ in
return geo.size.width/2
})
iconViewModel.centerImage iconViewModel.centerImage
.resizable() .resizable()
@@ -85,11 +65,13 @@ struct IconView: View {
height: geo.size.height*facePercSize, height: geo.size.height*facePercSize,
alignment: .center) alignment: .center)
.foregroundColor(iconViewModel.bgOverlayColor) .foregroundColor(iconViewModel.bgOverlayColor)
.position(x: geo.size.width/2, y: geo.size.height/2) .alignmentGuide(.top, computeValue: { _ in
return geo.size.width/2
})
} }
.position(x: geo.size.width/2, .position(x: geo.size.width/2,
y: geo.size.height/2 - entireFuckingViewOffset) y: geo.size.height/2)
} }
} }
} }
@@ -97,7 +79,7 @@ struct IconView: View {
struct IconView_Previews: PreviewProvider { struct IconView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
Group { Group {
IconView(iconViewModel: IconViewModel.great, isPreview: false) IconView(iconViewModel: IconViewModel.great)
.frame(width: 256, height: 256, alignment: .center) .frame(width: 256, height: 256, alignment: .center)
// IconView(iconViewModel: IconViewModel.good, isPreview: true) // IconView(iconViewModel: IconViewModel.good, isPreview: true)

View File

@@ -54,7 +54,9 @@ struct CustomWidgetView: View {
.frame(width: geo.size.width*facePercSize, .frame(width: geo.size.width*facePercSize,
height: geo.size.height*facePercSize, height: geo.size.height*facePercSize,
alignment: .center) alignment: .center)
.position(x: geo.size.width/2, y: geo.size.height/2) .alignmentGuide(.top, computeValue: { _ in
return geo.size.width/2
})
customWidgetModel.leftEye.image customWidgetModel.leftEye.image
.resizable() .resizable()
@@ -63,7 +65,7 @@ struct CustomWidgetView: View {
height: geo.size.height*0.12, height: geo.size.height*0.12,
alignment: .center) alignment: .center)
.position(x: geo.size.width*0.4, .position(x: geo.size.width*0.4,
y: geo.size.height*0.4) y: geo.size.height*0.45)
.foregroundColor(customWidgetModel.leftEyeColor) .foregroundColor(customWidgetModel.leftEyeColor)
customWidgetModel.rightEye.image customWidgetModel.rightEye.image
@@ -73,7 +75,7 @@ struct CustomWidgetView: View {
height: geo.size.height*0.12, height: geo.size.height*0.12,
alignment: .center) alignment: .center)
.position(x: geo.size.width*0.6, .position(x: geo.size.width*0.6,
y: geo.size.height*0.4) y: geo.size.height*0.45)
.foregroundColor(customWidgetModel.rightEyeColor) .foregroundColor(customWidgetModel.rightEyeColor)
customWidgetModel.mouth.image customWidgetModel.mouth.image
@@ -83,7 +85,7 @@ struct CustomWidgetView: View {
height: geo.size.height*0.12, height: geo.size.height*0.12,
alignment: .center) alignment: .center)
.position(x: geo.size.width*0.5, .position(x: geo.size.width*0.5,
y: geo.size.height*0.59) y: geo.size.height*0.65)
.foregroundColor(customWidgetModel.mouthColor) .foregroundColor(customWidgetModel.mouthColor)
} }
.position(x: geo.size.width/2, .position(x: geo.size.width/2,