mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Update compound iOS (#3532)
* update * removed functions that have been migrated in compound
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// Copyright 2023, 2024 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Please see LICENSE in the repository root for full details.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension View {
|
||||
func scaledFrame(size: CGFloat, alignment: Alignment = .center, relativeTo textStyle: Font.TextStyle = .body) -> some View {
|
||||
scaledFrame(width: size, height: size, alignment: alignment, relativeTo: textStyle)
|
||||
}
|
||||
|
||||
func scaledFrame(width: CGFloat, height: CGFloat, alignment: Alignment = .center, relativeTo textStyle: Font.TextStyle = .body) -> some View {
|
||||
modifier(ScaledFrameModifier(width: width, height: height, alignment: alignment, relativeTo: textStyle))
|
||||
}
|
||||
}
|
||||
|
||||
private struct ScaledFrameModifier: ViewModifier {
|
||||
@ScaledMetric var width: CGFloat
|
||||
@ScaledMetric var height: CGFloat
|
||||
let alignment: Alignment
|
||||
|
||||
init(width: CGFloat, height: CGFloat, alignment: Alignment, relativeTo textStyle: Font.TextStyle) {
|
||||
_width = ScaledMetric(wrappedValue: width, relativeTo: textStyle)
|
||||
_height = ScaledMetric(wrappedValue: height, relativeTo: textStyle)
|
||||
self.alignment = alignment
|
||||
}
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content.frame(width: width, height: height, alignment: alignment)
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// Copyright 2024 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Please see LICENSE in the repository root for full details.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension View {
|
||||
func scaledOffset(x: CGFloat = 0, y: CGFloat = 0, relativeTo textStyle: Font.TextStyle = .body) -> some View {
|
||||
modifier(ScaledOffsetModifier(x: x, y: y, relativeTo: textStyle))
|
||||
}
|
||||
}
|
||||
|
||||
private struct ScaledOffsetModifier: ViewModifier {
|
||||
@ScaledMetric var x: CGFloat
|
||||
@ScaledMetric var y: CGFloat
|
||||
|
||||
init(x: CGFloat, y: CGFloat, relativeTo textStyle: Font.TextStyle) {
|
||||
_x = ScaledMetric(wrappedValue: x, relativeTo: textStyle)
|
||||
_y = ScaledMetric(wrappedValue: y, relativeTo: textStyle)
|
||||
}
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content.offset(x: x, y: y)
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// Copyright 2023, 2024 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Please see LICENSE in the repository root for full details.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension View {
|
||||
func scaledPadding(_ length: CGFloat, relativeTo textStyle: Font.TextStyle = .body) -> some View {
|
||||
scaledPadding(.all, length, relativeTo: textStyle)
|
||||
}
|
||||
|
||||
func scaledPadding(_ edges: Edge.Set, _ length: CGFloat, relativeTo textStyle: Font.TextStyle = .body) -> some View {
|
||||
modifier(ScaledPaddingModifier(edges: edges, length: length, textStyle: textStyle))
|
||||
}
|
||||
}
|
||||
|
||||
private struct ScaledPaddingModifier: ViewModifier {
|
||||
let edges: Edge.Set
|
||||
@ScaledMetric var length: CGFloat
|
||||
|
||||
init(edges: Edge.Set, length: CGFloat, textStyle: Font.TextStyle) {
|
||||
self.edges = edges
|
||||
_length = ScaledMetric(wrappedValue: length, relativeTo: textStyle)
|
||||
}
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
content.padding(edges, length)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user