mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[WIP] AppScreenshot view with ImageProcessor to automatically rotate landscape images. Possible through my fork of the AsyncImage framework.
This commit is contained in:
committed by
Joe Mattiello
parent
b3c4819e8d
commit
77f5844e4d
42
AltStore/View Components/AppScreenshot.swift
Normal file
42
AltStore/View Components/AppScreenshot.swift
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user