feat: ios mobil arayüz tasarımı

This commit is contained in:
2026-02-11 18:06:35 +03:00
parent 69884db0ab
commit 261b2f58cc
42 changed files with 2501 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import Foundation
import UIKit
protocol ImageCacheProtocol {
func image(for url: URL) async throws -> UIImage
}
final class ImageCache: ImageCacheProtocol {
static let shared = ImageCache()
private let cache = NSCache<NSURL, UIImage>()
private let session: URLSession
init(session: URLSession = .shared) {
self.session = session
cache.countLimit = 200
}
func image(for url: URL) async throws -> UIImage {
if let existing = cache.object(forKey: url as NSURL) {
return existing
}
let request = URLRequest(url: url, cachePolicy: .returnCacheDataElseLoad, timeoutInterval: 20)
let (data, _) = try await session.data(for: request)
guard let image = UIImage(data: data) else {
throw APIError.invalidResponse
}
cache.setObject(image, forKey: url as NSURL)
return image
}
}