summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Extensions/View+Modifier.swift
blob: 70a40a2ed1a384fec5769c5b6aa9ed8dd9ab2faa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//
//  View+Modifier.swift
//  MullvadVPN
//
//  Created by Steffen Ernst on 2025-01-21.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import SwiftUI

extension View {
    /**
      A view modifier that can be used to conditionally apply other view modifiers.
      # Example #
     ```
     .apply {
        if #available(iOS 16.4, *) {
            $0.scrollBounceBehavior(.basedOnSize)
        } else {
            $0
        }
     }
     ```
     */
    func apply<V: View>(@ViewBuilder _ block: (Self) -> V) -> V { block(self) }
}