From 80146c1e038ce354094b56dd890d850092235bba Mon Sep 17 00:00:00 2001 From: Fabian Thies Date: Fri, 13 Jan 2023 12:04:10 +0100 Subject: [PATCH] [WIP] AppScreenshot view with ImageProcessor to automatically rotate landscape images. Possible through my fork of the AsyncImage framework. --- AltStore/View Components/AppScreenshot.swift | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 AltStore/View Components/AppScreenshot.swift diff --git a/AltStore/View Components/AppScreenshot.swift b/AltStore/View Components/AppScreenshot.swift new file mode 100644 index 00000000..74a2b1cb --- /dev/null +++ b/AltStore/View Components/AppScreenshot.swift @@ -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 + } + } +}