mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-24 02:11:16 +01:00
feat: update padding
This commit is contained in:
@@ -62,9 +62,9 @@ final class PreviewRenderPass: RenderPass {
|
||||
}
|
||||
}
|
||||
}
|
||||
let padding = calculatePadding(bounds)
|
||||
let padding: CGFloat = 20
|
||||
let origin = CGPoint(x: bounds[0] - padding, y: bounds[1] - padding)
|
||||
let size = CGSize(width: bounds[2] - origin.x + padding, height: bounds[3] - origin.y + padding)
|
||||
let size = CGSize(width: (bounds[2] - origin.x) + padding, height: (bounds[3] - origin.y) + padding)
|
||||
previewTexture = createPreviewTexture(for: size, with: renderer)
|
||||
descriptor?.colorAttachments[0].texture = previewTexture
|
||||
descriptor?.colorAttachments[0].clearColor = MTLClearColor(red: 1, green: 1, blue: 1, alpha: 0)
|
||||
@@ -84,18 +84,6 @@ final class PreviewRenderPass: RenderPass {
|
||||
return true
|
||||
}
|
||||
|
||||
private func calculatePadding(_ bounds: [CGFloat]) -> CGFloat {
|
||||
let maxDifference = max(bounds[2] - bounds[0], bounds[3] - bounds[1])
|
||||
|
||||
let minPadding: CGFloat = 10.0
|
||||
let maxPadding: CGFloat = 50.0
|
||||
|
||||
let normalizedDifference = min(maxDifference, 1.0)
|
||||
let inverseDifference = 1.0 / normalizedDifference
|
||||
let paddingRange = maxPadding - minPadding
|
||||
return minPadding + (inverseDifference * paddingRange)
|
||||
}
|
||||
|
||||
private func createPreviewTexture(for size: CGSize, with renderer: Renderer) -> MTLTexture? {
|
||||
let ratio = size.width / size.height
|
||||
let dimension: CGFloat = 800
|
||||
|
||||
@@ -152,7 +152,7 @@ struct MemosView: View {
|
||||
.animation(.easeInOut, value: memoObject.isFavorite)
|
||||
.frame(width: 20, height: 20)
|
||||
.padding(5)
|
||||
.background(.gray)
|
||||
.background(.gray.tertiary)
|
||||
.cornerRadius(5)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture {
|
||||
|
||||
@@ -17,7 +17,7 @@ struct MemoGrid<Card: View>: View {
|
||||
if horizontalSizeClass == .compact {
|
||||
return 180
|
||||
}
|
||||
return 250
|
||||
return 200
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
|
||||
@@ -24,13 +24,14 @@ struct MemoPreview: View {
|
||||
if let preview, let previewImage = UIImage(data: preview) {
|
||||
Image(uiImage: previewImage)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.aspectRatio(contentMode: .fit)
|
||||
} else {
|
||||
Rectangle()
|
||||
.fill(.white)
|
||||
}
|
||||
}
|
||||
.frame(width: cellWidth, height: cellHeight)
|
||||
.background(.white)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 10))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user