Updated RecipeView

This commit is contained in:
VincentMeilinger
2024-03-01 14:17:24 +01:00
parent d3e0366ce6
commit 744ea76a34
41 changed files with 588 additions and 383 deletions

View File

@@ -0,0 +1,17 @@
//
// BottomClipper.swift
// Nextcloud Cookbook iOS Client
//
// Created by Vincent Meilinger on 27.02.24.
//
import Foundation
import SwiftUI
struct BottomClipper: Shape {
let bottom: CGFloat
func path(in rect: CGRect) -> Path {
Rectangle().path(in: CGRect(x: 0, y: rect.size.height - bottom, width: rect.size.width, height: bottom))
}
}

View File

@@ -0,0 +1,59 @@
//
// ParallaxHeaderView.swift
// Nextcloud Cookbook iOS Client
//
// Created by Vincent Meilinger on 26.02.24.
//
import Foundation
import SwiftUI
struct ParallaxHeader<Content: View, Space: Hashable>: View {
let content: () -> Content
let coordinateSpace: Space
let defaultHeight: CGFloat
init(
coordinateSpace: Space,
defaultHeight: CGFloat,
@ViewBuilder _ content: @escaping () -> Content
) {
self.content = content
self.coordinateSpace = coordinateSpace
self.defaultHeight = defaultHeight
}
var body: some View {
GeometryReader { proxy in
let offset = offset(for: proxy)
let heightModifier = heightModifier(for: proxy)
let blurRadius = min(
heightModifier / 20,
max(10, heightModifier / 20)
)
content()
.edgesIgnoringSafeArea(.horizontal)
.frame(
width: proxy.size.width,
height: proxy.size.height + heightModifier
)
.offset(y: offset)
.blur(radius: blurRadius)
}.frame(height: defaultHeight)
}
private func offset(for proxy: GeometryProxy) -> CGFloat {
let frame = proxy.frame(in: .named(coordinateSpace))
if frame.minY < 0 {
return -frame.minY * 0.8
}
return -frame.minY
}
private func heightModifier(for proxy: GeometryProxy) -> CGFloat {
let frame = proxy.frame(in: .named(coordinateSpace))
return max(0, frame.minY)
}
}

View File

@@ -58,8 +58,6 @@ struct ReorderableForEach<Item: Any, Content: View>: View {
} label: {
Text(allowDeletion ? "Disable deletion" : "Enable deletion")
.bold()
.padding(.vertical, 3)
.padding(.horizontal)
}
.tint(Color.red)
Spacer()
@@ -68,11 +66,11 @@ struct ReorderableForEach<Item: Any, Content: View>: View {
} label: {
Image(systemName: "plus")
.bold()
.padding(.vertical, 3)
.padding(.vertical, 2)
.padding(.horizontal)
}
.buttonStyle(.borderedProminent)
}
}.padding(.top, 3)
}.animation(.default, value: allowDeletion)
}
}