From ecb89e6afb9cf558674f98b297cd42cc1da59a35 Mon Sep 17 00:00:00 2001 From: dscyrescotti Date: Sun, 30 Jun 2024 17:42:51 +0700 Subject: [PATCH] feat: adjust cell size --- .../Features/Dashboard/Details/Shared/MemoGrid.swift | 11 ++++++++--- .../Dashboard/Details/Shared/MemoPreview.swift | 9 ++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Memola/Features/Dashboard/Details/Shared/MemoGrid.swift b/Memola/Features/Dashboard/Details/Shared/MemoGrid.swift index 09fb23e..e443f53 100644 --- a/Memola/Features/Dashboard/Details/Shared/MemoGrid.swift +++ b/Memola/Features/Dashboard/Details/Shared/MemoGrid.swift @@ -8,13 +8,18 @@ import SwiftUI struct MemoGrid: View { - let cellWidth: CGFloat = 250 - let cellHeight: CGFloat = 150 - + @Environment(\.horizontalSizeClass) var horizontalSizeClass let memoObjects: FetchedResults let placeholder: Placeholder.Info @ViewBuilder let card: (MemoObject) -> Card + var cellWidth: CGFloat { + if horizontalSizeClass == .compact { + return 180 + } + return 250 + } + var body: some View { if memoObjects.isEmpty { Placeholder(info: placeholder) diff --git a/Memola/Features/Dashboard/Details/Shared/MemoPreview.swift b/Memola/Features/Dashboard/Details/Shared/MemoPreview.swift index 2d0418c..6ec7f01 100644 --- a/Memola/Features/Dashboard/Details/Shared/MemoPreview.swift +++ b/Memola/Features/Dashboard/Details/Shared/MemoPreview.swift @@ -8,7 +8,14 @@ import SwiftUI struct MemoPreview: View { - let cellHeight: CGFloat = 150 + @Environment(\.horizontalSizeClass) var horizontalSizeClass + + var cellHeight: CGFloat { + if horizontalSizeClass == .compact { + return 120 + } + return 150 + } var body: some View { Rectangle()