feat: Kisani UI overhaul — brand identity, gallery, visual polish
- Rename app to Kisani (CFBundleDisplayName, xcodeproj → Kisani.xcodeproj)
- BackupView: kisani. wordmark + SwiftUI-drawn server logo mark (no asset,
adaptive ink/bg), 206pt progress ring with active-state glow, 4-page
swipeable ring (progress/pending/failed/uploaded), 4-metric stats strip,
friendly NAS card (Home Server label), hamburger → AppMenuView sheet
- GalleryView: new NAS + local photo grid with source picker chip, 3-col
lazy grid, ThumbnailCache, sync-status dots (green = backed up)
- MainTabView: Browse tab → Gallery tab; tab bar uses ultraThinMaterial
blur background (systemGray3 icons, 9.5pt labels)
- All app icon sizes regenerated from 1024pt source via sips
- LANMonitor: nasReachable Bool?, checkNASReachability(host:port:) TCP ping
- project.yml: photo library usage description updated to Kisani branding
Co-Authored-By: Kutesir <kutesir@provoc.ug>
Co-Authored-By: Sentry <sentry@provoc.ug>
2026-05-17 11:17:13 +03:00
|
|
|
import UIKit
|
|
|
|
|
|
|
|
|
|
final class ThumbnailCache {
|
|
|
|
|
static let shared = ThumbnailCache()
|
|
|
|
|
|
|
|
|
|
private let memory = NSCache<NSString, UIImage>()
|
|
|
|
|
private let diskDir: URL
|
|
|
|
|
|
|
|
|
|
private init() {
|
|
|
|
|
let caches = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
|
|
|
|
|
diskDir = caches.appendingPathComponent("NASThumb", isDirectory: true)
|
|
|
|
|
try? FileManager.default.createDirectory(at: diskDir, withIntermediateDirectories: true)
|
|
|
|
|
memory.countLimit = 300
|
|
|
|
|
memory.totalCostLimit = 80 * 1024 * 1024 // 80 MB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func get(for path: String) -> UIImage? {
|
|
|
|
|
let key = cacheKey(path)
|
|
|
|
|
if let img = memory.object(forKey: key as NSString) { return img }
|
|
|
|
|
let url = diskDir.appendingPathComponent(key)
|
|
|
|
|
guard let data = try? Data(contentsOf: url),
|
|
|
|
|
let img = UIImage(data: data) else { return nil }
|
|
|
|
|
memory.setObject(img, forKey: key as NSString, cost: data.count)
|
|
|
|
|
return img
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func set(_ image: UIImage, for path: String) {
|
|
|
|
|
let key = cacheKey(path)
|
|
|
|
|
let data = image.jpegData(compressionQuality: 0.7) ?? Data()
|
|
|
|
|
memory.setObject(image, forKey: key as NSString, cost: data.count)
|
|
|
|
|
let url = diskDir.appendingPathComponent(key)
|
|
|
|
|
try? data.write(to: url, options: .atomic)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private func cacheKey(_ path: String) -> String {
|
|
|
|
|
path
|
|
|
|
|
.replacingOccurrences(of: "/", with: "_")
|
|
|
|
|
.replacingOccurrences(of: ":", with: "-")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat: redesign Gallery as photo timeline with sync state, deduplication, and detail view
- GalleryItem: unified model with phone/nas/synced source, sync state enum
- GalleryViewModel: off-actor PHFetchResult + manifest merge, Phone/NAS/All tab filtering, date section grouping, Combine-driven reactivity
- GalleryView: sticky date section headers, 3-col grid, shimmer placeholders, sync dots (green/orange/blue), video duration badge, search bar, context menu (Share, Save to Photos, Delete from Device)
- GalleryDetailView: full-screen swipeable photo viewer (TabView page mode), pinch-to-zoom, double-tap zoom toggle, bottom metadata sheet with file info and actions
- BackupStatusService: expose lastManifest for gallery deduplication without extra NAS connection
- ThumbnailCache: add decodeOffThread static helper for off-actor JPEG decode
- BackupManifest: Sendable conformance for safe Task.detached capture
- ThumbnailCache: synced items load from PHImageManager (instant) instead of NAS
Co-Authored-By: Kutesir <kutesir@provoc.ug>
Co-Authored-By: Sentry <sentry@provoc.ug>
2026-05-17 21:30:31 +03:00
|
|
|
extension ThumbnailCache {
|
|
|
|
|
static func decodeOffThread(data: Data, size: CGFloat) async -> UIImage? {
|
|
|
|
|
await Task.detached(priority: .userInitiated) {
|
|
|
|
|
UIImage(data: data)?.thumbnailScaled(to: size)
|
|
|
|
|
}.value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat: Kisani UI overhaul — brand identity, gallery, visual polish
- Rename app to Kisani (CFBundleDisplayName, xcodeproj → Kisani.xcodeproj)
- BackupView: kisani. wordmark + SwiftUI-drawn server logo mark (no asset,
adaptive ink/bg), 206pt progress ring with active-state glow, 4-page
swipeable ring (progress/pending/failed/uploaded), 4-metric stats strip,
friendly NAS card (Home Server label), hamburger → AppMenuView sheet
- GalleryView: new NAS + local photo grid with source picker chip, 3-col
lazy grid, ThumbnailCache, sync-status dots (green = backed up)
- MainTabView: Browse tab → Gallery tab; tab bar uses ultraThinMaterial
blur background (systemGray3 icons, 9.5pt labels)
- All app icon sizes regenerated from 1024pt source via sips
- LANMonitor: nasReachable Bool?, checkNASReachability(host:port:) TCP ping
- project.yml: photo library usage description updated to Kisani branding
Co-Authored-By: Kutesir <kutesir@provoc.ug>
Co-Authored-By: Sentry <sentry@provoc.ug>
2026-05-17 11:17:13 +03:00
|
|
|
extension UIImage {
|
|
|
|
|
func thumbnailScaled(to size: CGFloat) -> UIImage {
|
|
|
|
|
let scale = min(size / self.size.width, size / self.size.height)
|
|
|
|
|
guard scale < 1 else { return self }
|
|
|
|
|
let newSize = CGSize(width: self.size.width * scale, height: self.size.height * scale)
|
|
|
|
|
let renderer = UIGraphicsImageRenderer(size: newSize)
|
|
|
|
|
return renderer.image { _ in self.draw(in: CGRect(origin: .zero, size: newSize)) }
|
|
|
|
|
}
|
|
|
|
|
}
|