Compare commits

10 Commits

12 changed files with 429 additions and 607 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@
buildServer.json
.swiftlint.yml
/ImageViewer.xcodeproj/xcuserdata
/ImageViewer.xcodeproj/project.xcworkspace/xcuserdata

View File

@@ -4,7 +4,7 @@
<plist version="1.0">
<dict>
<key>method</key>
<string>debugging</string>
<string>development</string>
<key>signingStyle</key>
<string>automatic</string>
<key>destination</key>

View File

@@ -3,320 +3,142 @@
archiveVersion = 1;
classes = {
};
objectVersion = 90;
objectVersion = 56;
objects = {
/* Begin PBXContainerItemProxy section */
22FB3BA32E18135B00A9B407 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 22FB3B842E18135A00A9B407 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 22FB3B8B2E18135A00A9B407;
remoteInfo = ImageViewer;
};
22FB3BAD2E18135B00A9B407 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 22FB3B842E18135A00A9B407 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 22FB3B8B2E18135A00A9B407;
remoteInfo = ImageViewer;
};
/* End PBXContainerItemProxy section */
/* Begin PBXBuildFile section */
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 */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
22FB3B8C2E18135A00A9B407 /* ImageViewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageViewer.app; sourceTree = BUILT_PRODUCTS_DIR; };
22FB3BA22E18135B00A9B407 /* ImageViewerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageViewerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
22FB3BAC2E18135B00A9B407 /* ImageViewerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ImageViewerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
840F62652E7B65B700C8A64A /* ImageViewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ImageViewer.app; sourceTree = BUILT_PRODUCTS_DIR; };
840F62682E7B65B700C8A64A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
840F626C2E7B65B700C8A64A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
840F62712E7B65B900C8A64A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
840F62762E7B65B900C8A64A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
22FB3BB42E18135B00A9B407 /* Exceptions for "ImageViewer" folder in "ImageViewer" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Info.plist,
);
target = 22FB3B8B2E18135A00A9B407 /* ImageViewer */;
};
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
/* Begin PBXFileSystemSynchronizedRootGroup section */
22FB3B8E2E18135A00A9B407 /* ImageViewer */ = {
isa = PBXFileSystemSynchronizedRootGroup;
exceptions = (
22FB3BB42E18135B00A9B407 /* Exceptions for "ImageViewer" folder in "ImageViewer" target */,
);
path = ImageViewer;
sourceTree = "<group>";
};
22FB3BA52E18135B00A9B407 /* ImageViewerTests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = ImageViewerTests;
sourceTree = "<group>";
};
22FB3BAF2E18135B00A9B407 /* ImageViewerUITests */ = {
isa = PBXFileSystemSynchronizedRootGroup;
path = ImageViewerUITests;
sourceTree = "<group>";
};
/* End PBXFileSystemSynchronizedRootGroup section */
/* Begin PBXFrameworksBuildPhase section */
22FB3B892E18135A00A9B407 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
files = (
);
};
22FB3B9F2E18135B00A9B407 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
files = (
);
};
22FB3BA92E18135B00A9B407 /* Frameworks */ = {
840F62622E7B65B700C8A64A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
22FB3B832E18135A00A9B407 = {
840F625C2E7B65B700C8A64A = {
isa = PBXGroup;
children = (
22FB3B8E2E18135A00A9B407 /* ImageViewer */,
22FB3BA52E18135B00A9B407 /* ImageViewerTests */,
22FB3BAF2E18135B00A9B407 /* ImageViewerUITests */,
22FB3B8D2E18135A00A9B407 /* Products */,
840F62672E7B65B700C8A64A /* ImageViewer */,
840F62662E7B65B700C8A64A /* Products */,
);
sourceTree = "<group>";
};
22FB3B8D2E18135A00A9B407 /* Products */ = {
840F62662E7B65B700C8A64A /* Products */ = {
isa = PBXGroup;
children = (
22FB3B8C2E18135A00A9B407 /* ImageViewer.app */,
22FB3BA22E18135B00A9B407 /* ImageViewerTests.xctest */,
22FB3BAC2E18135B00A9B407 /* ImageViewerUITests.xctest */,
840F62652E7B65B700C8A64A /* ImageViewer.app */,
);
name = Products;
sourceTree = "<group>";
};
840F62672E7B65B700C8A64A /* ImageViewer */ = {
isa = PBXGroup;
children = (
840F62682E7B65B700C8A64A /* AppDelegate.swift */,
840F626C2E7B65B700C8A64A /* ViewController.swift */,
840F62712E7B65B900C8A64A /* Assets.xcassets */,
840F62762E7B65B900C8A64A /* Info.plist */,
);
path = ImageViewer;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
22FB3B8B2E18135A00A9B407 /* ImageViewer */ = {
840F62642E7B65B700C8A64A /* ImageViewer */ = {
isa = PBXNativeTarget;
buildConfigurationList = 22FB3BB52E18135B00A9B407 /* Build configuration list for PBXNativeTarget "ImageViewer" */;
buildConfigurationList = 840F62792E7B65B900C8A64A /* Build configuration list for PBXNativeTarget "ImageViewer" */;
buildPhases = (
22FB3B882E18135A00A9B407 /* Sources */,
22FB3B892E18135A00A9B407 /* Frameworks */,
22FB3B8A2E18135A00A9B407 /* Resources */,
840F62612E7B65B700C8A64A /* Sources */,
840F62622E7B65B700C8A64A /* Frameworks */,
840F62632E7B65B700C8A64A /* Resources */,
);
buildRules = (
);
fileSystemSynchronizedGroups = (
22FB3B8E2E18135A00A9B407 /* ImageViewer */,
dependencies = (
);
name = ImageViewer;
productName = ImageViewer;
productReference = 22FB3B8C2E18135A00A9B407 /* ImageViewer.app */;
productReference = 840F62652E7B65B700C8A64A /* ImageViewer.app */;
productType = "com.apple.product-type.application";
};
22FB3BA12E18135B00A9B407 /* ImageViewerTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 22FB3BBA2E18135B00A9B407 /* Build configuration list for PBXNativeTarget "ImageViewerTests" */;
buildPhases = (
22FB3B9E2E18135B00A9B407 /* Sources */,
22FB3B9F2E18135B00A9B407 /* Frameworks */,
22FB3BA02E18135B00A9B407 /* Resources */,
);
buildRules = (
);
dependencies = (
22FB3BA42E18135B00A9B407 /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
22FB3BA52E18135B00A9B407 /* ImageViewerTests */,
);
name = ImageViewerTests;
productName = ImageViewerTests;
productReference = 22FB3BA22E18135B00A9B407 /* ImageViewerTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
22FB3BAB2E18135B00A9B407 /* ImageViewerUITests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 22FB3BBD2E18135B00A9B407 /* Build configuration list for PBXNativeTarget "ImageViewerUITests" */;
buildPhases = (
22FB3BA82E18135B00A9B407 /* Sources */,
22FB3BA92E18135B00A9B407 /* Frameworks */,
22FB3BAA2E18135B00A9B407 /* Resources */,
);
buildRules = (
);
dependencies = (
22FB3BAE2E18135B00A9B407 /* PBXTargetDependency */,
);
fileSystemSynchronizedGroups = (
22FB3BAF2E18135B00A9B407 /* ImageViewerUITests */,
);
name = ImageViewerUITests;
productName = ImageViewerUITests;
productReference = 22FB3BAC2E18135B00A9B407 /* ImageViewerUITests.xctest */;
productType = "com.apple.product-type.bundle.ui-testing";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
22FB3B842E18135A00A9B407 /* Project object */ = {
840F625D2E7B65B700C8A64A /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1640;
LastUpgradeCheck = 1640;
LastSwiftUpdateCheck = 1420;
LastUpgradeCheck = 1420;
TargetAttributes = {
22FB3B8B2E18135A00A9B407 = {
CreatedOnToolsVersion = 16.4;
};
22FB3BA12E18135B00A9B407 = {
CreatedOnToolsVersion = 16.4;
TestTargetID = 22FB3B8B2E18135A00A9B407;
};
22FB3BAB2E18135B00A9B407 = {
CreatedOnToolsVersion = 16.4;
TestTargetID = 22FB3B8B2E18135A00A9B407;
840F62642E7B65B700C8A64A = {
CreatedOnToolsVersion = 14.2;
};
};
};
buildConfigurationList = 22FB3B872E18135A00A9B407 /* Build configuration list for PBXProject "ImageViewer" */;
buildConfigurationList = 840F62602E7B65B700C8A64A /* Build configuration list for PBXProject "ImageViewer" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 22FB3B832E18135A00A9B407;
minimizedProjectReferenceProxies = 1;
preferredProjectObjectVersion = 90;
productRefGroup = 22FB3B8D2E18135A00A9B407 /* Products */;
mainGroup = 840F625C2E7B65B700C8A64A;
productRefGroup = 840F62662E7B65B700C8A64A /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
22FB3B8B2E18135A00A9B407 /* ImageViewer */,
22FB3BA12E18135B00A9B407 /* ImageViewerTests */,
22FB3BAB2E18135B00A9B407 /* ImageViewerUITests */,
840F62642E7B65B700C8A64A /* ImageViewer */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
22FB3B8A2E18135A00A9B407 /* Resources */ = {
isa = PBXResourcesBuildPhase;
files = (
);
};
22FB3BA02E18135B00A9B407 /* Resources */ = {
isa = PBXResourcesBuildPhase;
files = (
);
};
22FB3BAA2E18135B00A9B407 /* Resources */ = {
840F62632E7B65B700C8A64A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
840F62722E7B65B900C8A64A /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
22FB3B882E18135A00A9B407 /* Sources */ = {
isa = PBXSourcesBuildPhase;
files = (
);
};
22FB3B9E2E18135B00A9B407 /* Sources */ = {
isa = PBXSourcesBuildPhase;
files = (
);
};
22FB3BA82E18135B00A9B407 /* Sources */ = {
840F62612E7B65B700C8A64A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
840F626D2E7B65B700C8A64A /* ViewController.swift in Sources */,
840F62692E7B65B700C8A64A /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
22FB3BA42E18135B00A9B407 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 22FB3B8B2E18135A00A9B407 /* ImageViewer */;
targetProxy = 22FB3BA32E18135B00A9B407 /* PBXContainerItemProxy */;
};
22FB3BAE2E18135B00A9B407 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 22FB3B8B2E18135A00A9B407 /* ImageViewer */;
targetProxy = 22FB3BAD2E18135B00A9B407 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
22FB3BB62E18135B00A9B407 /* Debug configuration for PBXNativeTarget "ImageViewer" */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = U5B4RH73LN;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ImageViewer/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
22FB3BB72E18135B00A9B407 /* Release configuration for PBXNativeTarget "ImageViewer" */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = U5B4RH73LN;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ImageViewer/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
22FB3BB82E18135B00A9B407 /* Debug configuration for PBXProject "ImageViewer" */ = {
840F62772E7B65B900C8A64A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -349,8 +171,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -364,22 +185,21 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
22FB3BB92E18135B00A9B407 /* Release configuration for PBXProject "ImageViewer" */ = {
840F62782E7B65B900C8A64A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
@@ -412,8 +232,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
@@ -421,120 +240,92 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
22FB3BBB2E18135B00A9B407 /* Debug configuration for PBXNativeTarget "ImageViewerTests" */ = {
840F627A2E7B65B900C8A64A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
INFOPLIST_FILE = ImageViewer/Info.plist;
INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewerTests;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ImageViewer.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/ImageViewer";
};
name = Debug;
};
22FB3BBC2E18135B00A9B407 /* Release configuration for PBXNativeTarget "ImageViewerTests" */ = {
840F627B2E7B65B900C8A64A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = U5B4RH73LN;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 18.5;
INFOPLIST_FILE = ImageViewer/Info.plist;
INFOPLIST_KEY_LSSupportsOpeningDocumentsInPlace = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewerTests;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewer;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ImageViewer.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/ImageViewer";
};
name = Release;
};
22FB3BBE2E18135B00A9B407 /* Debug configuration for PBXNativeTarget "ImageViewerUITests" */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewerUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = ImageViewer;
};
name = Debug;
};
22FB3BBF2E18135B00A9B407 /* Release configuration for PBXNativeTarget "ImageViewerUITests" */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = ImageViewer.ImageViewerUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TEST_TARGET_NAME = ImageViewer;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
22FB3B872E18135A00A9B407 /* Build configuration list for PBXProject "ImageViewer" */ = {
840F62602E7B65B700C8A64A /* Build configuration list for PBXProject "ImageViewer" */ = {
isa = XCConfigurationList;
buildConfigurations = (
22FB3BB82E18135B00A9B407 /* Debug configuration for PBXProject "ImageViewer" */,
22FB3BB92E18135B00A9B407 /* Release configuration for PBXProject "ImageViewer" */,
840F62772E7B65B900C8A64A /* Debug */,
840F62782E7B65B900C8A64A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
22FB3BB52E18135B00A9B407 /* Build configuration list for PBXNativeTarget "ImageViewer" */ = {
840F62792E7B65B900C8A64A /* Build configuration list for PBXNativeTarget "ImageViewer" */ = {
isa = XCConfigurationList;
buildConfigurations = (
22FB3BB62E18135B00A9B407 /* Debug configuration for PBXNativeTarget "ImageViewer" */,
22FB3BB72E18135B00A9B407 /* Release configuration for PBXNativeTarget "ImageViewer" */,
);
defaultConfigurationName = Release;
};
22FB3BBA2E18135B00A9B407 /* Build configuration list for PBXNativeTarget "ImageViewerTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
22FB3BBB2E18135B00A9B407 /* Debug configuration for PBXNativeTarget "ImageViewerTests" */,
22FB3BBC2E18135B00A9B407 /* Release configuration for PBXNativeTarget "ImageViewerTests" */,
);
defaultConfigurationName = Release;
};
22FB3BBD2E18135B00A9B407 /* Build configuration list for PBXNativeTarget "ImageViewerUITests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
22FB3BBE2E18135B00A9B407 /* Debug configuration for PBXNativeTarget "ImageViewerUITests" */,
22FB3BBF2E18135B00A9B407 /* Release configuration for PBXNativeTarget "ImageViewerUITests" */,
840F627A2E7B65B900C8A64A /* Debug */,
840F627B2E7B65B900C8A64A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 22FB3B842E18135A00A9B407 /* Project object */;
rootObject = 840F625D2E7B65B700C8A64A /* Project object */;
}

View File

@@ -2,13 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>ImageViewer.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "840F62642E7B65B700C8A64A"
BuildableName = "ImageViewer.app"
BlueprintName = "ImageViewer"
ReferencedContainer = "container:ImageViewer.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "840F62642E7B65B700C8A64A"
BuildableName = "ImageViewer.app"
BlueprintName = "ImageViewer"
ReferencedContainer = "container:ImageViewer.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "OS_ACTIVITY_MODE"
value = "disable"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "840F62642E7B65B700C8A64A"
BuildableName = "ImageViewer.app"
BlueprintName = "ImageViewer"
ReferencedContainer = "container:ImageViewer.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -2,12 +2,11 @@ import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = ViewController()

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

@@ -1,8 +1,7 @@
//TODO: Anilist support?
//TODO: Properly avoid swallowing of input from UICollectionView used for scrolling
//TODO: Convert between state for normal and scrolling page turn
//TODO: Support reading with scrolling and landscape mode
//FIXME: Update comicCollectionView when switching between landscape and portrait mode
// TODO: Anilist support?
// TODO: Properly avoid swallowing of input from UICollectionView used for scrolling
// TODO: Convert between state for normal and scrolling page turn
// TODO: Support reading with scrolling and landscape mode
import Foundation
import UIKit
@@ -102,9 +101,10 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
var imageView = UIImageView()
var mode = PageTurnMode.leftToRight
var metadataList: [URL: Metadata] = [:]
var metadata: Metadata!
var currentPage: Int! = nil
var progress = ProgressIndices.init(v: 0, c: 0, i: 0)
var currentPage: Int!
var progress = ProgressIndices(v: 0, c: 0, i: 0)
var currentPath: URL!
var changedOrientation = false
@@ -136,7 +136,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
var comics: [Comic] = []
@IBOutlet var comicCollectionView: UICollectionView!
let imageLoader = ImageLoader.init()
let imageLoader = ImageLoader()
override func viewDidLoad() {
super.viewDidLoad()
@@ -198,7 +198,8 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
comicCollectionView.delegate = self
comicCollectionView.backgroundColor = .white
comicCollectionView.register(
ComicImageCell.self, forCellWithReuseIdentifier: "ComicImageCell")
ComicImageCell.self, forCellWithReuseIdentifier: "ComicImageCell"
)
homeView.addSubview(comicCollectionView)
}
@@ -227,23 +228,26 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
getMetadataFromFileName(path: dir)
}
currentPath = dir
metadata = try JSONDecoder().decode(
Metadata.self,
from:
Data(
String(
contentsOfFile: dir.appendingPathComponent(
"metadata.json"
)
.path
).utf8)
)
metadataList[dir] = metadata
loadLocalState()
comics.append(
Comic(
cover:
UIImage(
contentsOfFile: dir.appendingPathComponent("cover.jpg").path)!,
metadata: try JSONDecoder().decode(
Metadata.self,
from:
Data(
try String(
contentsOfFile: dir.appendingPathComponent(
"metadata.json"
)
.path
).utf8),
),
path: dir,
cover: UIImage(contentsOfFile: getImagePath(progress: ProgressIndices(v: progress.v, c: 0, i: 0)).path)!,
metadata: metadata,
path: dir
))
}
} catch {
@@ -261,25 +265,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) {
@@ -298,11 +306,11 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
return
}
var metadata = Metadata.init(
var newMetadata = Metadata(
title: "",
original_language: "",
last_volume: MetaValue.init(main: 0, bonus: nil),
last_chapter: MetaValue.init(main: 0, bonus: nil),
last_volume: MetaValue(main: 0, bonus: nil),
last_chapter: MetaValue(main: 0, bonus: nil),
chapter_count: 0,
publication_demographic: "",
status: "",
@@ -342,61 +350,71 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
if currentVolume != nil {
if volume != currentVolume {
metadata.chapter_count += 1
newMetadata.chapter_count += 1
assert(volume > currentVolume)
metadata.volumes.append(
VolumeMetadata.init(
volume: MetaValue.init(main: volume, bonus: nil), name: nil,
newMetadata.volumes.append(
VolumeMetadata(
volume: MetaValue(main: volume, bonus: nil), name: nil,
chapters: [
ChapterMetadata.init(
chapter: MetaValue.init(
main: chapter.0, bonus: chapter.1),
ChapterMetadata(
chapter: MetaValue(
main: chapter.0, bonus: chapter.1
),
name: "",
images: [
ImageMetadata.init(
ImageMetadata(
doublePage: doublePage, fileName: fileName,
firstPage: page)
])
]))
firstPage: page
),
]
),
]
))
} else if chapter != currentChapter {
metadata.chapter_count += 1
newMetadata.chapter_count += 1
if chapter.0 == currentChapter.0 {
assert(chapter.1! == currentChapter.1 ?? 1)
} else {
assert(chapter.0 == currentChapter.0 + 1)
}
metadata.volumes[metadata.volumes.count - 1].chapters.append(
ChapterMetadata.init(
chapter: MetaValue.init(main: chapter.0, bonus: chapter.1),
newMetadata.volumes[newMetadata.volumes.count - 1].chapters.append(
ChapterMetadata(
chapter: MetaValue(main: chapter.0, bonus: chapter.1),
name: "",
images: [
ImageMetadata.init(
ImageMetadata(
doublePage: doublePage, fileName: fileName,
firstPage: page)
]))
firstPage: page
),
]
))
} else {
metadata.volumes[metadata.volumes.count - 1].chapters[
metadata.volumes[metadata.volumes.count - 1].chapters.count - 1
newMetadata.volumes[newMetadata.volumes.count - 1].chapters[
newMetadata.volumes[newMetadata.volumes.count - 1].chapters.count - 1
].images.append(
ImageMetadata.init(
doublePage: doublePage, fileName: fileName, firstPage: page)
ImageMetadata(
doublePage: doublePage, fileName: fileName, firstPage: page
)
)
}
} else {
metadata.chapter_count += 1
metadata.volumes.append(
VolumeMetadata.init(
volume: MetaValue.init(main: volume, bonus: nil), name: nil,
newMetadata.chapter_count += 1
newMetadata.volumes.append(
VolumeMetadata(
volume: MetaValue(main: volume, bonus: nil), name: nil,
chapters: [
ChapterMetadata.init(
chapter: MetaValue.init(main: chapter.0, bonus: chapter.1),
ChapterMetadata(
chapter: MetaValue(main: chapter.0, bonus: chapter.1),
name: "",
images: [
ImageMetadata.init(
ImageMetadata(
doublePage: doublePage, fileName: fileName,
firstPage: page)
])
]))
firstPage: page
),
]
),
]
))
}
currentVolume = volume
currentChapter = chapter
@@ -406,16 +424,18 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
print("failed reading image file names")
}
metadata = newMetadata
do {
let encoder = JSONEncoder()
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
encoder.outputFormatting = [.prettyPrinted]
encoder.keyEncodingStrategy = .useDefaultKeys
try encoder.encode(
metadata
newMetadata
).write(
to: path.appendingPathComponent(outFileName))
} catch {
print("failed to save metadata")
print("failed to save generated metadata")
}
}
@@ -426,23 +446,29 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
if screenSize.width > screenSize.height {
scrollOffset.y *= (screenSize.height / screenSize.width)
}
let progress: ReadProgress =
switch mode {
case .leftToRight:
ReadProgress.leftToRight(
volumeIndex: progress.v, chapterIndex: progress.c,
imageIndex: progress.i)
case .rightToLeft:
ReadProgress.rightToLeft(
volumeIndex: progress.v, chapterIndex: progress.c,
imageIndex: progress.i)
case .scroll: ReadProgress.scroll(scrollOffset)
}
var newProgress =
ReadProgress.leftToRight(
volumeIndex: progress.v, chapterIndex: progress.c,
imageIndex: progress.i
)
switch mode {
case .leftToRight:
newProgress = ReadProgress.leftToRight(
volumeIndex: progress.v, chapterIndex: progress.c,
imageIndex: progress.i
)
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"))
@@ -454,23 +480,23 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
func loadLocalState() {
do {
let json = Data(
try String(
let json = try Data(
String(
contentsOfFile: currentPath.appendingPathComponent("state.json").path
).utf8)
let local = try JSONDecoder().decode(LocalState.self, from: json)
switch local.progress {
case .leftToRight(let volumeIndex, let chapterIndex, let imageIndex):
case let .leftToRight(volumeIndex, chapterIndex, imageIndex):
progress.v = volumeIndex
progress.c = chapterIndex
progress.i = imageIndex
mode = .leftToRight
case .rightToLeft(let volumeIndex, let chapterIndex, let imageIndex):
case let .rightToLeft(volumeIndex, chapterIndex, imageIndex):
progress.v = volumeIndex
progress.c = chapterIndex
progress.i = imageIndex
mode = .rightToLeft
case .scroll(let point):
case let .scroll(point):
if scrollPos == nil {
scrollPos = point
let screenSize = UIScreen.main.bounds.size
@@ -480,13 +506,13 @@ 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)
turn: .next, progress: theProgress
)
}
progress = theProgress
}
}
mode = .scroll
}
@@ -510,11 +536,12 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
setupTapZones()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
func scrollViewDidScroll(_: UIScrollView) {
if scrollingCollectionView.isHidden { return }
let centerPoint = CGPoint(
x: scrollingCollectionView.bounds.midX + scrollingCollectionView.contentOffset.x,
y: scrollingCollectionView.bounds.midY + scrollingCollectionView.contentOffset.y)
y: scrollingCollectionView.bounds.midY + scrollingCollectionView.contentOffset.y
)
if let indexPath = scrollingCollectionView.indexPathForItem(at: centerPoint) {
let (chapter, page) = chapterAndPages[indexPath.item]
@@ -533,7 +560,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
{
return
}
if !hasSetContentOffset && scrollPos != nil {
if !hasSetContentOffset, scrollPos != nil {
let screenSize = UIScreen.main.bounds.size
var offset = scrollPos!
if screenSize.width > screenSize.height {
@@ -557,7 +584,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
if let path = getPathFromComicName(name: name) {
currentPath = path
metadata = getMetadata(path: path)!
metadata = metadataList[path]
globalState.comicName = metadata.title
saveGlobalState()
@@ -586,17 +613,17 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
var count = 0
if let enumerator = fileManager.enumerator(
at: currentPath, includingPropertiesForKeys: [.isDirectoryKey],
options: [.skipsHiddenFiles])
{
options: [.skipsHiddenFiles]
) {
for case let dir as URL in enumerator {
do {
if let enumerator = fileManager.enumerator(
at: dir, includingPropertiesForKeys: [.isRegularFileKey],
options: [.skipsHiddenFiles])
{
options: [.skipsHiddenFiles]
) {
for case let file as URL in enumerator {
let resourceValues = try file.resourceValues(forKeys: [
.isRegularFileKey
.isRegularFileKey,
])
if resourceValues.isRegularFile == true {
count += 1
@@ -617,14 +644,16 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
layout.minimumInteritemSpacing = 0
layout.minimumLineSpacing = 0
scrollingCollectionView = UICollectionView(
frame: view.bounds, collectionViewLayout: layout)
frame: view.bounds, collectionViewLayout: layout
)
scrollingCollectionView.translatesAutoresizingMaskIntoConstraints = false
scrollingCollectionView.dataSource = self
scrollingCollectionView.delegate = self
scrollingCollectionView.backgroundColor = .white
scrollingCollectionView.isHidden = true
scrollingCollectionView.register(
ScrollingImageCell.self, forCellWithReuseIdentifier: "ScrollingImageCell")
ScrollingImageCell.self, forCellWithReuseIdentifier: "ScrollingImageCell"
)
readerView.addSubview(scrollingCollectionView)
NSLayoutConstraint.activate([
@@ -690,7 +719,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
readerView.addSubview(bottomBarView)
NSLayoutConstraint.activate([
topBarView.topAnchor.constraint(equalTo: readerView.safeAreaLayoutGuide.topAnchor),
topBarView.topAnchor.constraint(equalTo: readerView.topAnchor),
topBarView.leadingAnchor.constraint(equalTo: readerView.leadingAnchor),
topBarView.trailingAnchor.constraint(equalTo: readerView.trailingAnchor),
topBarView.heightAnchor.constraint(equalToConstant: 64),
@@ -901,7 +930,8 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
} else {
imageLoader.loadImage(
at: getImagePath(progress: progress),
scaling: .scaleAspectFit
scaling: .scaleAspectFit,
screenSize: UIScreen.main.bounds.size
) { [weak self] image in
self?.imageView.image = image
}
@@ -938,8 +968,8 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
}
func gestureRecognizer(
_ gestureRecognizer: UIGestureRecognizer,
shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer
_: UIGestureRecognizer,
shouldRecognizeSimultaneouslyWith _: UIGestureRecognizer
) -> Bool {
return true
}
@@ -954,13 +984,13 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
}
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
func scrollViewDidEndDecelerating(_: UIScrollView) {
if scrollingCollectionView.isHidden { return }
updateInfo()
saveLocalState()
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
func scrollViewDidEndDragging(_: UIScrollView, willDecelerate decelerate: Bool) {
if scrollingCollectionView.isHidden { return }
if !decelerate {
updateInfo()
@@ -1033,13 +1063,12 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
let scaling = UIView.ContentMode.scaleAspectFit
var newProgress = progress
newProgress = getProgressIndicesFromTurn(turn: turn, progress: newProgress)
if newProgress.v == progress.v && newProgress.c == progress.c && newProgress.i == progress.i
{
if newProgress.v == progress.v, newProgress.c == progress.c, newProgress.i == progress.i {
return
}
progress = newProgress
if let path = getImagePath(progress: progress) {
imageLoader.loadImage(at: path, scaling: scaling) { [weak self] image in
imageLoader.loadImage(at: path, scaling: scaling, screenSize: UIScreen.main.bounds.size) { [weak self] image in
self?.imageView.image = image
self?.updateInfo()
}
@@ -1047,10 +1076,10 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
return
}
for _ in 0...preloadCount {
for _ in 0 ... preloadCount {
newProgress = getProgressIndicesFromTurn(turn: .next, progress: newProgress)
if let path = getImagePath(progress: newProgress) {
imageLoader.preloadImage(at: path, scaling: scaling)
imageLoader.preloadImage(at: path, scaling: scaling, screenSize: UIScreen.main.bounds.size)
} else {
print("could not preload image")
}
@@ -1060,11 +1089,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() {
@@ -1088,27 +1119,27 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
let lastVolumeValue = metadata.last_volume
let lastVolumeString = metaValueToString(m: lastVolumeValue)
let lastVolumeIndex = metadata.volumes.count - 1
let lastChapterIndex = metadata.volumes[lastVolumeIndex].chapters.count - 1
let lastChapterIndex = metadata.volumes[progress.v].chapters.count - 1
let lastImageIndex =
metadata.volumes[lastVolumeIndex].chapters[lastChapterIndex].images.count - 1
metadata.volumes[progress.v].chapters[lastChapterIndex].images.count - 1
let lastImage = metadata.volumes[lastVolumeIndex].chapters[lastChapterIndex].images[
lastImageIndex]
let lastPageString =
if lastImage.doublePage {
String(lastImage.firstPage + 1)
} else {
String(lastImage.firstPage)
}
let lastImage = metadata.volumes[progress.v].chapters[lastChapterIndex].images[
lastImageIndex
]
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 +=
"""
@@ -1122,19 +1153,6 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
info.text = text
}
func formatNumber(_ value: Float) -> String {
let integerPart = Int(value)
let fractionalPart = value - Float(integerPart)
if fractionalPart == 0 {
return String(format: "%04d", integerPart)
} else {
// Convert fractional part to string without leading "0"
let fractionalString = String(String(value).split(separator: ".")[1])
return String(format: "%04d.%@", integerPart, fractionalString)
}
}
func getImagePath(progress: ProgressIndices) -> URL! {
let (v, c, i) = (progress.v, progress.c, progress.i)
let modernPath = currentPath.appendingPathComponent("images").appendingPathComponent(
@@ -1151,37 +1169,39 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
switch turn {
case .next:
if metadata.volumes[v].chapters[c].images.count > i + 1 {
return ProgressIndices.init(v: v, c: c, i: i + 1)
return ProgressIndices(v: v, c: c, i: i + 1)
}
if metadata.volumes[v].chapters.count > c + 1 {
return ProgressIndices.init(v: v, c: c + 1, i: 0)
return ProgressIndices(v: v, c: c + 1, i: 0)
}
if metadata.volumes.count > v + 1 {
return ProgressIndices.init(v: v + 1, c: 0, i: 0)
return ProgressIndices(v: v + 1, c: 0, i: 0)
}
case .previous:
if i > 0 {
return ProgressIndices.init(v: v, c: c, i: i - 1)
return ProgressIndices(v: v, c: c, i: i - 1)
}
if c > 0 {
return ProgressIndices.init(
v: v, c: c - 1, i: metadata.volumes[v].chapters[c - 1].images.count - 1)
return ProgressIndices(
v: v, c: c - 1, i: metadata.volumes[v].chapters[c - 1].images.count - 1
)
}
if v > 0 {
return ProgressIndices.init(
return ProgressIndices(
v: v - 1, c: metadata.volumes[v - 1].chapters.count - 1,
i: metadata.volumes[v - 1].chapters[
metadata.volumes[v - 1].chapters.count - 1
].images.count - 1)
].images.count - 1
)
}
}
return ProgressIndices.init(v: v, c: c, i: i)
return ProgressIndices(v: v, c: c, i: i)
}
func getMetadata(path: URL) -> Metadata? {
do {
let json = Data(
try String(contentsOfFile: path.appendingPathComponent("metadata.json").path)
let json = try Data(
String(contentsOfFile: path.appendingPathComponent("metadata.json").path)
.utf8)
let metadata = try JSONDecoder().decode(Metadata.self, from: json)
return metadata
@@ -1194,24 +1214,25 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
return nil
}
func setImages(path: URL) {
let scaling: UIView.ContentMode =
if mode == .scroll {
.scaleAspectFill
} else { .scaleAspectFit }
func setImages(path _: URL) {
let scaling: UIView.ContentMode!
if mode == .scroll {
scaling = UIView.ContentMode.scaleAspectFill
} else { scaling = UIView.ContentMode.scaleAspectFit }
imageLoader.loadImage(
at:
getImagePath(progress: progress),
scaling: scaling
getImagePath(progress: progress),
scaling: scaling,
screenSize: UIScreen.main.bounds.size
) { [weak self] image in
self?.imageView.image = image
self?.updateInfo()
}
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)
imageLoader.preloadImage(at: getImagePath(progress: newProgress), scaling: scaling, screenSize: UIScreen.main.bounds.size)
}
}
@@ -1231,7 +1252,8 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
if mode != .scroll {
imageLoader.loadImage(
at: getImagePath(progress: progress),
scaling: .scaleAspectFit
scaling: .scaleAspectFit,
screenSize: size
) { image in
self.imageView.image = image
}
@@ -1246,8 +1268,8 @@ func getGlobalState() -> GlobalState {
let fileManager = FileManager.default
if let documentsURL = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first {
do {
let json = Data(
try String(
let json = try Data(
String(
contentsOfFile: documentsURL.appendingPathComponent("state.json").path
).utf8)
return try JSONDecoder().decode(GlobalState.self, from: json)
@@ -1269,9 +1291,8 @@ func getDocumentsURL() -> URL? {
}
extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
func collectionView(
_ collectionView: UICollectionView, numberOfItemsInSection section: Int
_ collectionView: UICollectionView, numberOfItemsInSection _: Int
)
-> Int
{
@@ -1288,7 +1309,8 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
if collectionView == comicCollectionView {
let cell =
collectionView.dequeueReusableCell(
withReuseIdentifier: "ComicImageCell", for: indexPath)
withReuseIdentifier: "ComicImageCell", for: indexPath
)
as! ComicImageCell
cell.imageView.image = comics[indexPath.item].cover
return cell
@@ -1296,7 +1318,8 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
// let scaling = UIView.ContentMode.scaleAspectFill
let cell =
collectionView.dequeueReusableCell(
withReuseIdentifier: "ScrollingImageCell", for: indexPath)
withReuseIdentifier: "ScrollingImageCell", for: indexPath
)
as! ScrollingImageCell
if metadata == nil {
return cell
@@ -1304,20 +1327,21 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
// TODO: Fix scrolling again
return cell
} else {
assert(false)
assertionFailure()
}
// Xcode profiling sucks:
return
collectionView.dequeueReusableCell(
withReuseIdentifier: "ScrollingImageCell", for: indexPath)
withReuseIdentifier: "ScrollingImageCell", for: indexPath
)
as! ScrollingImageCell
}
func collectionView(
_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath
layout _: UICollectionViewLayout,
sizeForItemAt _: IndexPath
) -> CGSize {
if collectionView == comicCollectionView {
let spacing: CGFloat = 8
@@ -1332,7 +1356,7 @@ extension ViewController: UICollectionViewDataSource, UICollectionViewDelegateFl
// TODO: Fix scrolling again
return CGSize()
} else {
assert(false)
assertionFailure()
}
// Xcode profiling sucks:
return CGSize()
@@ -1368,7 +1392,8 @@ class ScrollingImageCell: UICollectionViewCell {
])
}
required init?(coder: NSCoder) {
@available(*, unavailable)
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
@@ -1391,7 +1416,8 @@ class ComicImageCell: UICollectionViewCell {
])
}
required init?(coder: NSCoder) {
@available(*, unavailable)
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
@@ -1404,7 +1430,7 @@ enum Rotation {
class ImageLoader {
private let cache = NSCache<NSString, UIImage>()
private let horCache = NSCache<NSString, UIImage>()
private var loadingTasks: [String: [((UIImage?) -> Void)]] = [:]
private var loadingTasks: [String: [(UIImage?) -> Void]] = [:]
var size: [String: CGSize] = [:]
init() {
@@ -1412,19 +1438,19 @@ class ImageLoader {
cache.totalCostLimit = 128 * 1024 * 1024
}
func preloadImage(at path: URL, scaling: UIView.ContentMode) {
loadImage(at: path, scaling: scaling, completion: nil)
func preloadImage(at path: URL, scaling: UIView.ContentMode, screenSize: CGSize) {
loadImage(at: path, scaling: scaling, screenSize: screenSize, completion: nil)
}
func loadImage(
at path: URL, scaling: UIView.ContentMode,
screenSize: CGSize,
completion: ((UIImage?) -> Void)?
) {
let screenSize = UIScreen.main.bounds.size
let rotation: Rotation =
if screenSize.width > screenSize.height {
.horizontal
} else { .vertical }
let rotation: Rotation!
if screenSize.width > screenSize.height {
rotation = Rotation.horizontal
} else { rotation = Rotation.vertical }
if rotation == .vertical {
if let cached = cache.object(forKey: path.path as NSString) {
@@ -1456,9 +1482,11 @@ class ImageLoader {
if completion == nil || rotation == .vertical {
let vertical = CGSize(
width: min(screenSize.width, screenSize.height),
height: max(screenSize.height, screenSize.width))
height: max(screenSize.height, screenSize.width)
)
let vScaledSize = aspectSize(
for: image.size, in: vertical, scaling: scaling)
for: image.size, in: vertical, scaling: scaling
)
let vScaleImage = resizeImage(image, to: vScaledSize)
guard let cost = imageByteSize(vScaleImage) else { return }
self.cache.setObject(vScaleImage, forKey: path.path as NSString, cost: cost)
@@ -1470,9 +1498,11 @@ class ImageLoader {
if completion == nil || rotation == .horizontal {
let horizontal = CGSize(
width: max(screenSize.width, screenSize.height),
height: min(screenSize.height, screenSize.width))
height: min(screenSize.height, screenSize.width)
)
let hScaledSize = aspectSize(
for: image.size, in: horizontal, scaling: scaling)
for: image.size, in: horizontal, scaling: scaling
)
let hScaleImage = resizeImage(image, to: hScaledSize)
guard let cost = imageByteSize(hScaleImage) else { return }
self.horCache.setObject(hScaleImage, forKey: path.path as NSString, cost: cost)
@@ -1511,12 +1541,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,

View File

@@ -1,9 +0,0 @@
import Testing
@testable import ImageViewer
struct ImageViewerTests {
@Test func example() async throws {
}
}

View File

@@ -1,24 +0,0 @@
import XCTest
final class ImageViewerUITests: XCTestCase {
override func setUpWithError() throws {
continueAfterFailure = false
}
override func tearDownWithError() throws {
}
@MainActor
func testExample() throws {
let app = XCUIApplication()
app.launch()
}
@MainActor
func testLaunchPerformance() throws {
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}

View File

@@ -1,23 +0,0 @@
import XCTest
final class ImageViewerUITestsLaunchTests: XCTestCase {
override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
}
override func setUpWithError() throws {
continueAfterFailure = false
}
@MainActor
func testLaunch() throws {
let app = XCUIApplication()
app.launch()
let attachment = XCTAttachment(screenshot: app.screenshot())
attachment.name = "Launch Screen"
attachment.lifetime = .keepAlways
add(attachment)
}
}

2
run.sh
View File

@@ -1,7 +1,7 @@
#!/bin/sh
APP_NAME='ImageViewer'
SIM_DEVICE='iPad Air 11-inch (M3)'
SIM_DEVICE='iPad (10th generation)'
SCHEME='ImageViewer'
SIMULATOR='iOS Simulator'
COMPANY='ImageViewer'