element-ios/RiotSwiftUI/Modules/Common/ViewFrameReader/FramePreferenceKey.swift

18 lines
443 B
Swift

//
// Copyright 2021-2024 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
//
import SwiftUI
/// A SwiftUI `PreferenceKey` for `CGRect` values such as a view's frame.
struct FramePreferenceKey: PreferenceKey {
static var defaultValue: CGRect = .zero
static func reduce(value: inout CGRect, nextValue: () -> CGRect) {
value = nextValue()
}
}