Sora/Sora/Utils/ViewModifiers/DeviceScaleModifier.swift
50/50 e63c27d649
Episodecell fixes + iPad scaling (not perfect) (#163)
* Fixed episodecells getting stuck sliding

* Enabled device scaling for ipad

not good enough yet, not applied everywhere cuz idk where to apply exactly 💯
2025-06-09 17:17:46 +02:00

45 lines
1 KiB
Swift

//
// MediaInfoView.swift
// Sora
//
// Created by paul on 28/05/25.
//
import SwiftUI
struct DeviceScaleModifier: ViewModifier {
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
private var scaleFactor: CGFloat {
if UIDevice.current.userInterfaceIdiom == .pad {
return horizontalSizeClass == .regular ? 1.3 : 1.1
}
return 1.0
}
func body(content: Content) -> some View {
GeometryReader { geo in
content
.scaleEffect(scaleFactor)
.frame(
width: geo.size.width / scaleFactor,
height: geo.size.height / scaleFactor
)
.position(x: geo.size.width / 2, y: geo.size.height / 2)
}
}
}
/*
struct DeviceScaleModifier: ViewModifier {
func body(content: Content) -> some View {
content // does nothing for now
}
}*/
extension View {
func deviceScaled() -> some View {
modifier(DeviceScaleModifier())
}
}