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