Compare commits
2 Commits
be5e513cbc
...
c1bb06a1b4
| Author | SHA1 | Date | |
|---|---|---|---|
|
c1bb06a1b4
|
|||
| a5c3a6d96e |
@@ -6,3 +6,4 @@ buildServer.json
|
||||
/ImageViewer.xcodeproj/xcuserdata
|
||||
/ImageViewer.xcodeproj/project.xcworkspace/xcuserdata
|
||||
/ImageViewer/flatc
|
||||
/worktrees
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "dependencies/flatbuffers"]
|
||||
path = dependencies/flatbuffers
|
||||
url = https://github.com/google/flatbuffers.git
|
||||
@@ -11,6 +11,8 @@
|
||||
228A32B12F849062008A980A /* metadata_generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 228A32B02F849062008A980A /* metadata_generated.swift */; };
|
||||
22B015A72F82A2DC0088F94F /* FlatBuffers in Frameworks */ = {isa = PBXBuildFile; productRef = 22B015A62F82A2DC0088F94F /* FlatBuffers */; };
|
||||
22B015A92F82A2DC0088F94F /* FlexBuffers in Frameworks */ = {isa = PBXBuildFile; productRef = 22B015A82F82A2DC0088F94F /* FlexBuffers */; };
|
||||
22EF4C5B2FFDC39600852A4F /* FlatBuffers in Frameworks */ = {isa = PBXBuildFile; productRef = 22EF4C5A2FFDC39600852A4F /* FlatBuffers */; };
|
||||
22EF4C5D2FFDC39600852A4F /* FlexBuffers in Frameworks */ = {isa = PBXBuildFile; productRef = 22EF4C5C2FFDC39600852A4F /* FlexBuffers */; };
|
||||
840F62692E7B65B700C8A64A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840F62682E7B65B700C8A64A /* AppDelegate.swift */; };
|
||||
840F626D2E7B65B700C8A64A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840F626C2E7B65B700C8A64A /* ViewController.swift */; };
|
||||
840F62722E7B65B900C8A64A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 840F62712E7B65B900C8A64A /* Assets.xcassets */; };
|
||||
@@ -31,8 +33,10 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22EF4C5B2FFDC39600852A4F /* FlatBuffers in Frameworks */,
|
||||
22B015A72F82A2DC0088F94F /* FlatBuffers in Frameworks */,
|
||||
22B015A92F82A2DC0088F94F /* FlexBuffers in Frameworks */,
|
||||
22EF4C5D2FFDC39600852A4F /* FlexBuffers in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -113,7 +117,7 @@
|
||||
);
|
||||
mainGroup = 840F625C2E7B65B700C8A64A;
|
||||
packageReferences = (
|
||||
22B015A52F82A2DC0088F94F /* XCLocalSwiftPackageReference "../flatbuffers" */,
|
||||
22EF4C592FFDC39600852A4F /* XCLocalSwiftPackageReference "dependencies/flatbuffers" */,
|
||||
);
|
||||
productRefGroup = 840F62662E7B65B700C8A64A /* Products */;
|
||||
projectDirPath = "";
|
||||
@@ -348,9 +352,9 @@
|
||||
/* End XCConfigurationList section */
|
||||
|
||||
/* Begin XCLocalSwiftPackageReference section */
|
||||
22B015A52F82A2DC0088F94F /* XCLocalSwiftPackageReference "../flatbuffers" */ = {
|
||||
22EF4C592FFDC39600852A4F /* XCLocalSwiftPackageReference "dependencies/flatbuffers" */ = {
|
||||
isa = XCLocalSwiftPackageReference;
|
||||
relativePath = ../flatbuffers;
|
||||
relativePath = dependencies/flatbuffers;
|
||||
};
|
||||
/* End XCLocalSwiftPackageReference section */
|
||||
|
||||
@@ -363,6 +367,14 @@
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = FlexBuffers;
|
||||
};
|
||||
22EF4C5A2FFDC39600852A4F /* FlatBuffers */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = FlatBuffers;
|
||||
};
|
||||
22EF4C5C2FFDC39600852A4F /* FlexBuffers */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = FlexBuffers;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 840F625D2E7B65B700C8A64A /* Project object */;
|
||||
|
||||
@@ -59,8 +59,6 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
var scrollPos: CGPoint!
|
||||
var hasSetContentOffset = false
|
||||
var pageCount = 0
|
||||
var pagesAvailable = 0
|
||||
var chapterAndPages: [(Int, Int)] = []
|
||||
|
||||
var imageView = UIImageView()
|
||||
var mode = PageTurnMode.leftToRight
|
||||
@@ -136,9 +134,9 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
readerView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||
readerView.widthAnchor.constraint(equalTo: view.widthAnchor),
|
||||
])
|
||||
setupScrollingCollectionView()
|
||||
loadComics()
|
||||
setupImageView()
|
||||
setupScrollingCollectionView()
|
||||
setupGestures()
|
||||
setupBar()
|
||||
setupHomeView()
|
||||
@@ -594,7 +592,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
}
|
||||
if let indexPath = scrollingCollectionView.indexPathForItem(at: scrollOffset) {
|
||||
var theProgress = ProgressIndices(v: 0, c: 0, i: 0)
|
||||
for _ in 0 ... indexPath.item {
|
||||
for _ in 0 ..< indexPath.item {
|
||||
theProgress = getProgressIndicesFromTurn(
|
||||
turn: .next, progress: theProgress
|
||||
)
|
||||
@@ -632,9 +630,11 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
)
|
||||
|
||||
if let indexPath = scrollingCollectionView.indexPathForItem(at: centerPoint) {
|
||||
let (chapter, page) = chapterAndPages[indexPath.item]
|
||||
progress.c = chapter
|
||||
progress.i = page
|
||||
var newProgress = ProgressIndices(v: 0, c: 0, i: 0)
|
||||
for _ in 0 ..< indexPath.item {
|
||||
newProgress = getProgressIndicesFromTurn(turn: .next, progress: newProgress)
|
||||
}
|
||||
progress = newProgress
|
||||
}
|
||||
if scrollingCollectionView.isHidden == false {
|
||||
saveLocalState()
|
||||
@@ -694,7 +694,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
leftView.isHidden = true
|
||||
rightView.isHidden = true
|
||||
scrollingCollectionView.isHidden = false
|
||||
// TODO: Fix scrolling again
|
||||
scrollingCollectionView.reloadData()
|
||||
}
|
||||
|
||||
func countFiles() -> Int {
|
||||
@@ -1028,6 +1028,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
scrollingCollectionView.isHidden = mode != .scroll
|
||||
leftView.isHidden = mode == .scroll
|
||||
rightView.isHidden = mode == .scroll
|
||||
imageView.isHidden = mode == .scroll
|
||||
togglePageTurnDropdown()
|
||||
saveLocalState()
|
||||
}
|
||||
@@ -1161,7 +1162,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
self?.updateInfo()
|
||||
}
|
||||
|
||||
for _ in 0 ... preloadCount {
|
||||
for _ in 0 ..< preloadCount {
|
||||
newProgress = getProgressIndicesFromTurn(turn: .next, progress: newProgress)
|
||||
let path = getImagePath(progress: newProgress)
|
||||
imageLoader.preloadImage(at: path, scaling: scaling, screenSize: UIScreen.main.bounds.size)
|
||||
@@ -1302,7 +1303,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
var newProgress = progress
|
||||
for _ in 0 ... preloadCount {
|
||||
for _ in 0 ..< preloadCount {
|
||||
newProgress = getProgressIndicesFromTurn(turn: .next, progress: newProgress)
|
||||
imageLoader.preloadImage(at: getImagePath(progress: newProgress), scaling: scaling, screenSize: UIScreen.main.bounds.size)
|
||||
}
|
||||
@@ -1375,7 +1376,13 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
|
||||
if collectionView == comicCollectionView {
|
||||
return comics.count
|
||||
} else {
|
||||
return pagesAvailable
|
||||
var sum = 0
|
||||
for volume in metadata.volumes {
|
||||
for chapter in volume.chapters {
|
||||
sum += chapter.images.count
|
||||
}
|
||||
}
|
||||
return sum
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1391,16 +1398,25 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
|
||||
cell.imageView.image = comics[indexPath.item].cover
|
||||
return cell
|
||||
} else if collectionView == scrollingCollectionView {
|
||||
// let scaling = UIView.ContentMode.scaleAspectFill
|
||||
let scaling = UIView.ContentMode.scaleAspectFill
|
||||
let cell =
|
||||
collectionView.dequeueReusableCell(
|
||||
withReuseIdentifier: "ScrollingImageCell", for: indexPath
|
||||
)
|
||||
as! ScrollingImageCell
|
||||
if metadata == nil {
|
||||
print("metadata is nil, should probably not be the case")
|
||||
return cell
|
||||
}
|
||||
// TODO: Fix scrolling again
|
||||
var newProgress = ProgressIndices(v: 0, c: 0, i: 0)
|
||||
if indexPath.item != 0 {
|
||||
for _ in 0 ..< indexPath.item {
|
||||
newProgress = getProgressIndicesFromTurn(turn: .next, progress: newProgress)
|
||||
}
|
||||
}
|
||||
imageLoader.loadImage(at: getImagePath(progress: newProgress), scaling: scaling, screenSize: UIScreen.main.bounds.size) { image in
|
||||
cell.imageView.image = image
|
||||
}
|
||||
return cell
|
||||
} else {
|
||||
assertionFailure()
|
||||
@@ -1417,7 +1433,7 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
|
||||
func collectionView(
|
||||
_ collectionView: UICollectionView,
|
||||
layout _: UICollectionViewLayout,
|
||||
sizeForItemAt _: IndexPath
|
||||
sizeForItemAt indexPath: IndexPath
|
||||
) -> CGSize {
|
||||
if collectionView == comicCollectionView {
|
||||
let spacing: CGFloat = 8
|
||||
@@ -1429,8 +1445,15 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
|
||||
if metadata == nil {
|
||||
return CGSize()
|
||||
}
|
||||
// TODO: Fix scrolling again
|
||||
return CGSize()
|
||||
var newProgress = ProgressIndices(v: 0, c: 0, i: 0)
|
||||
for _ in 0 ..< indexPath.item {
|
||||
newProgress = getProgressIndicesFromTurn(turn: .next, progress: newProgress)
|
||||
}
|
||||
let imageMetadata = metadata.volumes[newProgress.v].chapters[newProgress.c].images[newProgress.i]
|
||||
return CGSize(
|
||||
width: readerView.bounds.width,
|
||||
height: CGFloat(imageMetadata.size!.height) * readerView.bounds.width / CGFloat(imageMetadata.size!.width)
|
||||
)
|
||||
} else {
|
||||
assertionFailure()
|
||||
}
|
||||
|
||||
+1
Submodule dependencies/flatbuffers added at 81edeb17d9
Reference in New Issue
Block a user