[WIP] AppScreenshot view with ImageProcessor to automatically rotate landscape images. Possible through my fork of the AsyncImage framework.

This commit is contained in:
Fabian Thies
2023-01-13 12:04:10 +01:00
committed by Joe Mattiello
parent b3c4819e8d
commit 77f5844e4d

View File

@@ -0,0 +1,42 @@
//
// AppScreenshot.swift
// SideStore
//
// Created by Fabian Thies on 20.12.22.
// Copyright © 2022 SideStore. All rights reserved.
//
import SwiftUI
import UIKit
import AsyncImage
struct AppScreenshot: View {
let url: URL
var apectRatio: CGFloat = 9/16
static let processor = Self.ScreenshotProcessor()
var body: some View {
Text("")
// AsyncImage(url: self.url, processor: Self.processor) { image in
// image
// .resizable()
// } placeholder: {
// Rectangle()
// .foregroundColor(.secondary)
// }
// .aspectRatio(aspectRatio, contentMode: .fit)
// .cornerRadius(8)
}
}
extension AppScreenshot {
class ScreenshotProcessor: ImageProcessor {
func process(image: UIImage) -> UIImage {
guard let cgImage = image.cgImage, image.size.width > image.size.height else { return image }
let rotatedImage = UIImage(cgImage: cgImage, scale: image.scale, orientation: .right)
return rotatedImage
}
}
}