initial: old xcode

This commit is contained in:
2026-02-27 00:01:11 +01:00
parent 6e03523c4f
commit 0234f2c8ff
10 changed files with 252 additions and 452 deletions

View File

@@ -5,28 +5,6 @@
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {

View File

@@ -232,7 +232,8 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
cover:
UIImage(
contentsOfFile: dir.appendingPathComponent("cover.jpg").path)!,
metadata: try JSONDecoder().decode(
metadata:
try JSONDecoder().decode(
Metadata.self,
from:
Data(
@@ -241,9 +242,9 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
"metadata.json"
)
.path
).utf8),
).utf8)
),
path: dir,
path: dir
))
}
} catch {
@@ -261,25 +262,29 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
}
func convertColorToString(color: UIColor) -> String {
return switch color {
case .white: "white"
case .gray: "gray"
case .black: "black"
case .red: "red"
case .blue: "blue"
default: "black"
let r: String!
switch color {
case .white: r = "white"
case .gray: r = "gray"
case .black: r = "black"
case .red: r = "red"
case .blue: r = "blue"
default: r = "black"
}
return r
}
func convertStringToColor(str: String) -> UIColor {
return switch str {
case "white": .white
case "gray": .gray
case "black": .black
case "red": .red
case "blue": .blue
default: .black
let r: UIColor!
switch str {
case "white": r = .white
case "gray": r = .gray
case "black": r = .black
case "red": r = .red
case "blue": r = .blue
default: r = .black
}
return r
}
func getMetadataFromFileName(path: URL) {
@@ -426,23 +431,26 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
if screenSize.width > screenSize.height {
scrollOffset.y *= (screenSize.height / screenSize.width)
}
let progress: ReadProgress =
switch mode {
case .leftToRight:
var newProgress: ReadProgress =
ReadProgress.leftToRight(
volumeIndex: progress.v, chapterIndex: progress.c,
imageIndex: progress.i)
case .rightToLeft:
ReadProgress.rightToLeft(
switch mode {
case .leftToRight:
newProgress = ReadProgress.leftToRight(
volumeIndex: progress.v, chapterIndex: progress.c,
imageIndex: progress.i)
case .scroll: ReadProgress.scroll(scrollOffset)
}
case .rightToLeft: newProgress = ReadProgress.rightToLeft(
volumeIndex: progress.v, chapterIndex: progress.c,
imageIndex: progress.i)
case .scroll: newProgress = ReadProgress.scroll(scrollOffset)
}
queue.async {
do {
try JSONEncoder().encode(
LocalState(
progress: progress, backgroundColor: self.convertColorToString(color: color)
progress: newProgress, backgroundColor: self.convertColorToString(color: color)
)
).write(
to: self.currentPath.appendingPathComponent("state.json"))
@@ -1060,11 +1068,13 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
}
func metaValueToString(m: MetaValue) -> String {
var r = ""
if let bonus = m.bonus {
String(m.main) + "." + String(bonus)
r = String(m.main) + "." + String(bonus)
} else {
String(m.main)
r = String(m.main)
}
return r
}
func updateInfo() {
@@ -1094,20 +1104,20 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
let lastImage = metadata.volumes[progress.v].chapters[lastChapterIndex].images[
lastImageIndex]
let lastPageString =
if lastImage.doublePage {
String(lastImage.firstPage + 1)
} else {
String(lastImage.firstPage)
}
var lastPageString = ""
if lastImage.doublePage {
lastPageString = String(lastImage.firstPage + 1)
} else {
lastPageString = String(lastImage.firstPage)
}
let currentImage = metadata.volumes[progress.v].chapters[progress.c].images[progress.i]
let pageString =
if currentImage.doublePage {
String(currentImage.firstPage) + "-" + String(currentImage.firstPage + 1)
} else {
String(currentImage.firstPage)
}
var pageString = ""
if currentImage.doublePage {
pageString = String(currentImage.firstPage) + "-" + String(currentImage.firstPage + 1)
} else {
pageString = String(currentImage.firstPage)
}
text +=
"""
@@ -1194,10 +1204,10 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
}
func setImages(path: URL) {
let scaling: UIView.ContentMode =
let scaling: UIView.ContentMode!
if mode == .scroll {
.scaleAspectFill
} else { .scaleAspectFit }
scaling = UIView.ContentMode.scaleAspectFill
} else { scaling = UIView.ContentMode.scaleAspectFit }
imageLoader.loadImage(
at:
getImagePath(progress: progress),
@@ -1420,10 +1430,10 @@ class ImageLoader {
completion: ((UIImage?) -> Void)?
) {
let screenSize = UIScreen.main.bounds.size
let rotation: Rotation =
let rotation: Rotation!
if screenSize.width > screenSize.height {
.horizontal
} else { .vertical }
rotation = Rotation.horizontal
} else { rotation = Rotation.vertical }
if rotation == .vertical {
if let cached = cache.object(forKey: path.path as NSString) {
@@ -1510,12 +1520,12 @@ func aspectSize(for imageSize: CGSize, in boundingSize: CGSize, scaling: UIView.
{
let widthRatio = boundingSize.width / imageSize.width
let heightRatio = boundingSize.height / imageSize.height
let scale: CGFloat =
switch scaling {
case .scaleAspectFit: min(widthRatio, heightRatio)
case .scaleAspectFill: max(widthRatio, heightRatio)
default: 1
}
var scale = CGFloat()
switch scaling {
case .scaleAspectFit: scale = min(widthRatio, heightRatio)
case .scaleAspectFill: scale = max(widthRatio, heightRatio)
default: scale = 1
}
return CGSize(
width: imageSize.width * scale,