mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Keep the home layout intact when the changelog is showing.
The subject grid no longer sits in a second scroller, so a tall what's-new card does not swallow scrolling or stretch the tiles. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
29bd0e63c7
commit
3b4e7b283a
2 changed files with 31 additions and 39 deletions
|
|
@ -61,6 +61,9 @@ struct MacFillGrid<Content: View>: View {
|
|||
var minHeight: CGFloat = 148
|
||||
var spacing: CGFloat = 16
|
||||
var inset: CGFloat = 28
|
||||
/// Home embeds the grid in its own scroll view. A second scroller here
|
||||
/// swallows the wheel once a banner (the changelog) makes the page taller.
|
||||
var scrolls = true
|
||||
@ViewBuilder var content: (Int) -> Content
|
||||
|
||||
var body: some View {
|
||||
|
|
@ -74,8 +77,7 @@ struct MacFillGrid<Content: View>: View {
|
|||
let tileH = max(minHeight, (gridH - spacing * CGFloat(max(rows - 1, 0))) / CGFloat(rows))
|
||||
let tileW = (innerW - spacing * CGFloat(max(cols - 1, 0))) / CGFloat(max(cols, 1))
|
||||
let lastCount = count - (rows - 1) * cols
|
||||
ScrollView {
|
||||
VStack(spacing: spacing) {
|
||||
let tiles = VStack(spacing: spacing) {
|
||||
ForEach(0..<rows, id: \.self) { row in
|
||||
let stretch = row < rows - 1 || lastCount > 1
|
||||
HStack(spacing: spacing) {
|
||||
|
|
@ -97,9 +99,14 @@ struct MacFillGrid<Content: View>: View {
|
|||
}
|
||||
.frame(height: gridH, alignment: .top)
|
||||
.padding(inset)
|
||||
.frame(maxWidth: .infinity, minHeight: geo.size.height, alignment: .top)
|
||||
}
|
||||
.frame(maxWidth: .infinity, minHeight: scrolls ? geo.size.height : nil, alignment: .top)
|
||||
|
||||
if scrolls {
|
||||
ScrollView { tiles }
|
||||
.scrollDisabled(floorH + inset * 2 <= geo.size.height + 1)
|
||||
} else {
|
||||
tiles
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ struct PracticeHome: View {
|
|||
Text(vm.tr("subjects_title"))
|
||||
.font(.title2.weight(.semibold))
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.background {
|
||||
GeometryReader { proxy in
|
||||
Color.clear.preference(key: MacHeaderHeight.self, value: proxy.size.height)
|
||||
|
|
@ -64,7 +65,8 @@ struct PracticeHome: View {
|
|||
minWidth: MacChrome.homeTileMin,
|
||||
minHeight: MacChrome.homeTileHeight,
|
||||
spacing: 16,
|
||||
inset: 0
|
||||
inset: 0,
|
||||
scrolls: false
|
||||
) { index in
|
||||
subjectTile(subjects[index])
|
||||
}
|
||||
|
|
@ -242,25 +244,8 @@ private struct ChangelogLines: View {
|
|||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
if index > 0 { Spacer().frame(height: 4) }
|
||||
#if os(macOS)
|
||||
if lines.count >= 4 {
|
||||
LazyVGrid(
|
||||
columns: [
|
||||
GridItem(.flexible(minimum: 240), spacing: 22, alignment: .topLeading),
|
||||
GridItem(.flexible(minimum: 240), spacing: 22, alignment: .topLeading),
|
||||
],
|
||||
alignment: .leading,
|
||||
spacing: 6
|
||||
) {
|
||||
lineList
|
||||
}
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 4) { lineList }
|
||||
}
|
||||
#else
|
||||
VStack(alignment: .leading, spacing: 4) { lineList }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue