Files
WhiteNights_iOS/WhiteNights/Utils/View+Extensions.swift
2025-08-24 14:44:50 +03:00

40 lines
1.4 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import SwiftUI
struct BlockStyle: ViewModifier {
// Добавляем свойство для хранения радиуса скругления
let cornerRadius: CGFloat
func body(content: Content) -> some View {
content
.background(
ZStack {
Color(hex: 0x806C59)
LinearGradient(
stops: [
.init(color: .white.opacity(0.0), location: 0.0871),
.init(color: .white.opacity(0.16), location: 0.6969)
],
startPoint: .bottomLeading,
endPoint: .topTrailing
)
}
.cornerRadius(cornerRadius) // Применяем скругление к фону
)
.shadow(
color: Color.black.opacity(0.10),
radius: 8,
x: 0,
y: 2
)
// Применяем скругление к содержимому (опционально, но лучше для теней)
.cornerRadius(cornerRadius)
}
}
extension View {
// Изменяем расширение, чтобы оно принимало параметр cornerRadius
func blockStyle(cornerRadius: CGFloat) -> some View {
modifier(BlockStyle(cornerRadius: cornerRadius))
}
}