|
| 1 | +// |
| 2 | +// GrayBackgroundDecorationView.swift |
| 3 | +// RakuyoKit |
| 4 | +// |
| 5 | +// Created by Rakuyo on 2025/2/17. |
| 6 | +// Copyright © 2024 RakuyoKit. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +#if !os(watchOS) && !os(tvOS) |
| 10 | +import UIKit |
| 11 | + |
| 12 | +import RAKConfig |
| 13 | + |
| 14 | +// MARK: - WhiteBackgroundDecorationVGray |
| 15 | + |
| 16 | +/// Set a gray background View for UICollectionView Section |
| 17 | +open class GrayBackgroundDecorationView: BaseDecorationView { |
| 18 | + override open var decorationViewConfig: DecorationViewConfig { |
| 19 | + .customDecorationViewConfig(cornerRadius: nil) |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +// MARK: - GrayBackgroundAndCornerRadiusDecorationView |
| 24 | + |
| 25 | +open class GrayBackgroundAndCornerRadiusDecorationView: BaseDecorationView { |
| 26 | + /// The default rounded corners. |
| 27 | + /// The caller can modify this property globally to achieve the purpose of modifying the global configuration. |
| 28 | + public static let defaultCornerRadius: CGFloat = 12 |
| 29 | + |
| 30 | + override open var decorationViewConfig: DecorationViewConfig { |
| 31 | + .customDecorationViewConfig() |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +// MARK: - GrayBackgroundAndTopCornerRadiusDecorationView |
| 36 | + |
| 37 | +open class GrayBackgroundAndTopCornerRadiusDecorationView: BaseDecorationView { |
| 38 | + override open var decorationViewConfig: DecorationViewConfig { |
| 39 | + .customDecorationViewConfig(maskedCorners: [ |
| 40 | + .layerMinXMinYCorner, |
| 41 | + .layerMaxXMinYCorner, |
| 42 | + ]) |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +// MARK: - GrayBackgroundAndBottomCornerRadiusDecorationView |
| 47 | + |
| 48 | +open class GrayBackgroundAndBottomCornerRadiusDecorationView: BaseDecorationView { |
| 49 | + override open var decorationViewConfig: DecorationViewConfig { |
| 50 | + .customDecorationViewConfig(maskedCorners: [ |
| 51 | + .layerMinXMaxYCorner, |
| 52 | + .layerMaxXMaxYCorner, |
| 53 | + ]) |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +extension DecorationViewConfig { |
| 58 | + fileprivate static func customDecorationViewConfig( |
| 59 | + cornerRadius: CGFloat? = GrayBackgroundAndCornerRadiusDecorationView.defaultCornerRadius, |
| 60 | + maskedCorners: CACornerMask = [] |
| 61 | + ) -> Self { |
| 62 | + .init( |
| 63 | + backgroundColor: Config.color.white, |
| 64 | + cornerRadius: cornerRadius, |
| 65 | + maskedCorners: maskedCorners |
| 66 | + ) |
| 67 | + } |
| 68 | +} |
| 69 | +#endif |
0 commit comments