Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript

feat(ios): add OpenReel Video iOS app — Phase 1 complete

Augustus Otue4885c63d76c
diff --git a/.gitignore b/.gitignore
index c07a4ca6..84184cf5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -62,4 +62,7 @@ CLAUDE.md
.wrangler/
-mobile-mockup/
\ No newline at end of file
+mobile-mockup/
+# Xcode user data
+xcuserdata/
+*.xcuserstate
diff --git a/Openreel Video/Openreel Video.xcodeproj/project.pbxproj b/Openreel Video/Openreel Video.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..5586ea5c
--- /dev/null
+++ b/Openreel Video/Openreel Video.xcodeproj/project.pbxproj
@@ -0,0 +1,583 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 77;
+ objects = {
+
+/* Begin PBXContainerItemProxy section */
+ 3EC4B4CD2FB9B94D00C2F92D /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 3EC4B4B72FB9B94B00C2F92D /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 3EC4B4BE2FB9B94B00C2F92D;
+ remoteInfo = "Openreel Video";
+ };
+ 3EC4B4D72FB9B94D00C2F92D /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 3EC4B4B72FB9B94B00C2F92D /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 3EC4B4BE2FB9B94B00C2F92D;
+ remoteInfo = "Openreel Video";
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+ 3EC4B4BF2FB9B94B00C2F92D /* Openreel Video.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Openreel Video.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 3EC4B4CC2FB9B94D00C2F92D /* Openreel VideoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Openreel VideoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 3EC4B4D62FB9B94D00C2F92D /* Openreel VideoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Openreel VideoUITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFileSystemSynchronizedRootGroup section */
+ 3EC4B4C12FB9B94B00C2F92D /* Openreel Video */ = {
+ isa = PBXFileSystemSynchronizedRootGroup;
+ path = "Openreel Video";
+ sourceTree = "<group>";
+ };
+ 3EC4B4CF2FB9B94D00C2F92D /* Openreel VideoTests */ = {
+ isa = PBXFileSystemSynchronizedRootGroup;
+ path = "Openreel VideoTests";
+ sourceTree = "<group>";
+ };
+ 3EC4B4D92FB9B94D00C2F92D /* Openreel VideoUITests */ = {
+ isa = PBXFileSystemSynchronizedRootGroup;
+ path = "Openreel VideoUITests";
+ sourceTree = "<group>";
+ };
+/* End PBXFileSystemSynchronizedRootGroup section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 3EC4B4BC2FB9B94B00C2F92D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 3EC4B4C92FB9B94D00C2F92D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 3EC4B4D32FB9B94D00C2F92D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 3EC4B4B62FB9B94B00C2F92D = {
+ isa = PBXGroup;
+ children = (
+ 3EC4B4C12FB9B94B00C2F92D /* Openreel Video */,
+ 3EC4B4CF2FB9B94D00C2F92D /* Openreel VideoTests */,
+ 3EC4B4D92FB9B94D00C2F92D /* Openreel VideoUITests */,
+ 3EC4B4C02FB9B94B00C2F92D /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ 3EC4B4C02FB9B94B00C2F92D /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 3EC4B4BF2FB9B94B00C2F92D /* Openreel Video.app */,
+ 3EC4B4CC2FB9B94D00C2F92D /* Openreel VideoTests.xctest */,
+ 3EC4B4D62FB9B94D00C2F92D /* Openreel VideoUITests.xctest */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 3EC4B4BE2FB9B94B00C2F92D /* Openreel Video */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 3EC4B4E02FB9B94D00C2F92D /* Build configuration list for PBXNativeTarget "Openreel Video" */;
+ buildPhases = (
+ 3EC4B4BB2FB9B94B00C2F92D /* Sources */,
+ 3EC4B4BC2FB9B94B00C2F92D /* Frameworks */,
+ 3EC4B4BD2FB9B94B00C2F92D /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ fileSystemSynchronizedGroups = (
+ 3EC4B4C12FB9B94B00C2F92D /* Openreel Video */,
+ );
+ name = "Openreel Video";
+ packageProductDependencies = (
+ );
+ productName = "Openreel Video";
+ productReference = 3EC4B4BF2FB9B94B00C2F92D /* Openreel Video.app */;
+ productType = "com.apple.product-type.application";
+ };
+ 3EC4B4CB2FB9B94D00C2F92D /* Openreel VideoTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 3EC4B4E32FB9B94D00C2F92D /* Build configuration list for PBXNativeTarget "Openreel VideoTests" */;
+ buildPhases = (
+ 3EC4B4C82FB9B94D00C2F92D /* Sources */,
+ 3EC4B4C92FB9B94D00C2F92D /* Frameworks */,
+ 3EC4B4CA2FB9B94D00C2F92D /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 3EC4B4CE2FB9B94D00C2F92D /* PBXTargetDependency */,
+ );
+ fileSystemSynchronizedGroups = (
+ 3EC4B4CF2FB9B94D00C2F92D /* Openreel VideoTests */,
+ );
+ name = "Openreel VideoTests";
+ packageProductDependencies = (
+ );
+ productName = "Openreel VideoTests";
+ productReference = 3EC4B4CC2FB9B94D00C2F92D /* Openreel VideoTests.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+ 3EC4B4D52FB9B94D00C2F92D /* Openreel VideoUITests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 3EC4B4E62FB9B94D00C2F92D /* Build configuration list for PBXNativeTarget "Openreel VideoUITests" */;
+ buildPhases = (
+ 3EC4B4D22FB9B94D00C2F92D /* Sources */,
+ 3EC4B4D32FB9B94D00C2F92D /* Frameworks */,
+ 3EC4B4D42FB9B94D00C2F92D /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 3EC4B4D82FB9B94D00C2F92D /* PBXTargetDependency */,
+ );
+ fileSystemSynchronizedGroups = (
+ 3EC4B4D92FB9B94D00C2F92D /* Openreel VideoUITests */,
+ );
+ name = "Openreel VideoUITests";
+ packageProductDependencies = (
+ );
+ productName = "Openreel VideoUITests";
+ productReference = 3EC4B4D62FB9B94D00C2F92D /* Openreel VideoUITests.xctest */;
+ productType = "com.apple.product-type.bundle.ui-testing";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 3EC4B4B72FB9B94B00C2F92D /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ BuildIndependentTargetsInParallel = 1;
+ LastSwiftUpdateCheck = 2650;
+ LastUpgradeCheck = 2650;
+ TargetAttributes = {
+ 3EC4B4BE2FB9B94B00C2F92D = {
+ CreatedOnToolsVersion = 26.5;
+ };
+ 3EC4B4CB2FB9B94D00C2F92D = {
+ CreatedOnToolsVersion = 26.5;
+ TestTargetID = 3EC4B4BE2FB9B94B00C2F92D;
+ };
+ 3EC4B4D52FB9B94D00C2F92D = {
+ CreatedOnToolsVersion = 26.5;
+ TestTargetID = 3EC4B4BE2FB9B94B00C2F92D;
+ };
+ };
+ };
+ buildConfigurationList = 3EC4B4BA2FB9B94B00C2F92D /* Build configuration list for PBXProject "Openreel Video" */;
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 3EC4B4B62FB9B94B00C2F92D;
+ minimizedProjectReferenceProxies = 1;
+ preferredProjectObjectVersion = 77;
+ productRefGroup = 3EC4B4C02FB9B94B00C2F92D /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 3EC4B4BE2FB9B94B00C2F92D /* Openreel Video */,
+ 3EC4B4CB2FB9B94D00C2F92D /* Openreel VideoTests */,
+ 3EC4B4D52FB9B94D00C2F92D /* Openreel VideoUITests */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 3EC4B4BD2FB9B94B00C2F92D /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 3EC4B4CA2FB9B94D00C2F92D /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 3EC4B4D42FB9B94D00C2F92D /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 3EC4B4BB2FB9B94B00C2F92D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 3EC4B4C82FB9B94D00C2F92D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 3EC4B4D22FB9B94D00C2F92D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 3EC4B4CE2FB9B94D00C2F92D /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 3EC4B4BE2FB9B94B00C2F92D /* Openreel Video */;
+ targetProxy = 3EC4B4CD2FB9B94D00C2F92D /* PBXContainerItemProxy */;
+ };
+ 3EC4B4D82FB9B94D00C2F92D /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 3EC4B4BE2FB9B94B00C2F92D /* Openreel Video */;
+ targetProxy = 3EC4B4D72FB9B94D00C2F92D /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ 3EC4B4DE2FB9B94D00C2F92D /* 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";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ DEVELOPMENT_TEAM = 864H636QW4;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ ENABLE_USER_SCRIPT_SANDBOXING = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu17;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 26.5;
+ LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ };
+ name = Debug;
+ };
+ 3EC4B4DF2FB9B94D00C2F92D /* 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";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DEVELOPMENT_TEAM = 864H636QW4;
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_USER_SCRIPT_SANDBOXING = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu17;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 26.5;
+ LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ MTL_FAST_MATH = YES;
+ SDKROOT = iphoneos;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 3EC4B4E12FB9B94D00C2F92D /* Debug */ = {
+ 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 = 864H636QW4;
+ ENABLE_PREVIEWS = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
+ INFOPLIST_KEY_UILaunchScreen_Generation = 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 = "com.pythonxi.Openreel-Video";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ STRING_CATALOG_GENERATE_SYMBOLS = YES;
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 3EC4B4E22FB9B94D00C2F92D /* Release */ = {
+ 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 = 864H636QW4;
+ ENABLE_PREVIEWS = YES;
+ GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
+ INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
+ INFOPLIST_KEY_UILaunchScreen_Generation = 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 = "com.pythonxi.Openreel-Video";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ STRING_CATALOG_GENERATE_SYMBOLS = YES;
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+ 3EC4B4E42FB9B94D00C2F92D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ BUNDLE_LOADER = "$(TEST_HOST)";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_TEAM = 864H636QW4;
+ GENERATE_INFOPLIST_FILE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 26.5;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pythonxi.Openreel-VideoTests";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ STRING_CATALOG_GENERATE_SYMBOLS = NO;
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_EMIT_LOC_STRINGS = NO;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Openreel Video.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Openreel Video";
+ };
+ name = Debug;
+ };
+ 3EC4B4E52FB9B94D00C2F92D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ BUNDLE_LOADER = "$(TEST_HOST)";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_TEAM = 864H636QW4;
+ GENERATE_INFOPLIST_FILE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 26.5;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pythonxi.Openreel-VideoTests";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ STRING_CATALOG_GENERATE_SYMBOLS = NO;
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_EMIT_LOC_STRINGS = NO;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Openreel Video.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Openreel Video";
+ };
+ name = Release;
+ };
+ 3EC4B4E72FB9B94D00C2F92D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_TEAM = 864H636QW4;
+ GENERATE_INFOPLIST_FILE = YES;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pythonxi.Openreel-VideoUITests";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ STRING_CATALOG_GENERATE_SYMBOLS = NO;
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_EMIT_LOC_STRINGS = NO;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ TEST_TARGET_NAME = "Openreel Video";
+ };
+ name = Debug;
+ };
+ 3EC4B4E82FB9B94D00C2F92D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 1;
+ DEVELOPMENT_TEAM = 864H636QW4;
+ GENERATE_INFOPLIST_FILE = YES;
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = "com.pythonxi.Openreel-VideoUITests";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ STRING_CATALOG_GENERATE_SYMBOLS = NO;
+ SWIFT_APPROACHABLE_CONCURRENCY = YES;
+ SWIFT_EMIT_LOC_STRINGS = NO;
+ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ TEST_TARGET_NAME = "Openreel Video";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 3EC4B4BA2FB9B94B00C2F92D /* Build configuration list for PBXProject "Openreel Video" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 3EC4B4DE2FB9B94D00C2F92D /* Debug */,
+ 3EC4B4DF2FB9B94D00C2F92D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 3EC4B4E02FB9B94D00C2F92D /* Build configuration list for PBXNativeTarget "Openreel Video" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 3EC4B4E12FB9B94D00C2F92D /* Debug */,
+ 3EC4B4E22FB9B94D00C2F92D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 3EC4B4E32FB9B94D00C2F92D /* Build configuration list for PBXNativeTarget "Openreel VideoTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 3EC4B4E42FB9B94D00C2F92D /* Debug */,
+ 3EC4B4E52FB9B94D00C2F92D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 3EC4B4E62FB9B94D00C2F92D /* Build configuration list for PBXNativeTarget "Openreel VideoUITests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 3EC4B4E72FB9B94D00C2F92D /* Debug */,
+ 3EC4B4E82FB9B94D00C2F92D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 3EC4B4B72FB9B94B00C2F92D /* Project object */;
+}
diff --git a/Openreel Video/Openreel Video.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Openreel Video/Openreel Video.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 00000000..919434a6
--- /dev/null
+++ b/Openreel Video/Openreel Video.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:">
+ </FileRef>
+</Workspace>
diff --git a/Openreel Video/Openreel Video/AppState.swift b/Openreel Video/Openreel Video/AppState.swift
new file mode 100644
index 00000000..5b23b19d
--- /dev/null
+++ b/Openreel Video/Openreel Video/AppState.swift
@@ -0,0 +1,374 @@
+import Foundation
+import Observation
+import SwiftUI
+
+@MainActor
+@Observable
+final class AppState {
+ enum Screen: Equatable {
+ case home
+ case projects
+ case editor
+ }
+
+ enum EditorTab: String, CaseIterable, Identifiable {
+ case edit = "Edit"
+ case media = "Media"
+ case text = "Text"
+ case effects = "Effects"
+ case audio = "Audio"
+
+ var id: String { rawValue }
+ }
+
+ enum AspectRatio: String, CaseIterable, Identifiable {
+ case landscape = "16:9"
+ case portrait = "9:16"
+ case square = "1:1"
+ case vertical = "4:5"
+ case standard = "4:3"
+
+ var id: String { rawValue }
+
+ var value: CGFloat {
+ switch self {
+ case .landscape:
+ return 16 / 9
+ case .portrait:
+ return 9 / 16
+ case .square:
+ return 1
+ case .vertical:
+ return 4 / 5
+ case .standard:
+ return 4 / 3
+ }
+ }
+ }
+
+ enum ProjectStyle: String, CaseIterable, Hashable {
+ case emerald
+ case cobalt
+ case amber
+ case coral
+ }
+
+ var activeScreen: Screen = .home
+ var editorTab: EditorTab = .edit
+ var selectedAspectRatio: AspectRatio = .landscape
+ var selectedProjectID: String?
+ var selectedClipID: String?
+ var projects: [OpenReelProject] = []
+ var isBootstrapping = false
+ var hasBootstrapped = false
+ var isShowingNewProjectSheet = false
+ var newProjectConfiguration = NewProjectConfiguration(name: "Project 1")
+ var isMediaPickerPresented = false
+ var isImportingMedia = false
+ var importErrorMessage: String?
+ var timelineZoom: Double = 72
+ var lastSavedAt: Date?
+
+ @ObservationIgnored private let projectStore: ProjectStore
+ @ObservationIgnored private let mediaImportService: MediaImportService
+ @ObservationIgnored private let history = ActionHistory<OpenReelProject>()
+
+ init(
+ projectStore: ProjectStore = ProjectStore(),
+ mediaImportService: MediaImportService = MediaImportService()
+ ) {
+ self.projectStore = projectStore
+ self.mediaImportService = mediaImportService
+ }
+
+ var currentProject: OpenReelProject? {
+ guard let selectedProjectID else {
+ return projects.first
+ }
+
+ return projects.first(where: { $0.id == selectedProjectID })
+ }
+
+ var currentProjectDuration: TimeInterval {
+ currentProject?.timeline.duration ?? 0
+ }
+
+ var canUndo: Bool {
+ history.canUndo
+ }
+
+ var canRedo: Bool {
+ history.canRedo
+ }
+
+ var playbackReloadToken: String {
+ let projectID = selectedProjectID ?? "none"
+ let modifiedAt = currentProject?.modifiedAt ?? 0
+ return "\(projectID)-\(modifiedAt)"
+ }
+
+ func bootstrap() async {
+ guard !hasBootstrapped else {
+ return
+ }
+
+ isBootstrapping = true
+ defer {
+ isBootstrapping = false
+ hasBootstrapped = true
+ }
+
+ do {
+ projects = try await projectStore.loadProjects()
+ selectedProjectID = projects.first?.id
+ if let project = currentProject {
+ syncAspectRatio(to: project)
+ selectedClipID = primaryVisualClip(in: project)?.id
+ }
+ } catch {
+ importErrorMessage = error.localizedDescription
+ }
+
+ prepareNewProjectDefaults()
+ }
+
+ func showHome() {
+ activeScreen = .home
+ }
+
+ func showProjects() {
+ activeScreen = .projects
+ }
+
+ func openProject(_ project: OpenReelProject) {
+ selectedProjectID = project.id
+ selectedClipID = primaryVisualClip(in: project)?.id
+ syncAspectRatio(to: project)
+ editorTab = .edit
+ activeScreen = .editor
+ }
+
+ func closeEditor() {
+ activeScreen = .home
+ editorTab = .edit
+ isMediaPickerPresented = false
+ isImportingMedia = false
+ }
+
+ func presentNewProjectSheet() {
+ prepareNewProjectDefaults()
+ isShowingNewProjectSheet = true
+ }
+
+ func dismissNewProjectSheet() {
+ isShowingNewProjectSheet = false
+ }
+
+ func createProject() async {
+ let trimmedName = newProjectConfiguration.name.trimmingCharacters(in: .whitespacesAndNewlines)
+ newProjectConfiguration.name = trimmedName.isEmpty ? suggestedProjectName() : trimmedName
+
+ let project = OpenReelProject.blank(configuration: newProjectConfiguration)
+ projects.insert(project, at: 0)
+ selectedProjectID = project.id
+ selectedClipID = nil
+ activeScreen = .editor
+ editorTab = .edit
+ syncAspectRatio(to: project)
+ history.clear()
+ isShowingNewProjectSheet = false
+
+ do {
+ try await projectStore.save(project: project)
+ lastSavedAt = .now
+ } catch {
+ importErrorMessage = error.localizedDescription
+ }
+
+ prepareNewProjectDefaults()
+ }
+
+ func presentMediaPicker() {
+ isMediaPickerPresented = true
+ }
+
+ func dismissMediaPicker() {
+ isMediaPickerPresented = false
+ }
+
+ func selectClip(_ clip: OpenReelProject.Clip) {
+ selectedClipID = clip.id
+ }
+
+ func importMedia(_ assets: [ImportedMediaAsset], playbackController: PlaybackController) async {
+ guard let project = currentProject, !assets.isEmpty else {
+ return
+ }
+
+ isImportingMedia = true
+ defer {
+ isImportingMedia = false
+ isMediaPickerPresented = false
+ }
+
+ do {
+ let updatedProject = try await mediaImportService.importAssets(assets, into: project, store: projectStore)
+ await replaceCurrentProject(with: updatedProject, captureHistory: true)
+ selectedClipID = primaryVisualClip(in: updatedProject)?.id
+ syncPlayback(with: playbackController)
+ } catch {
+ importErrorMessage = error.localizedDescription
+ }
+ }
+
+ func undo(playbackController: PlaybackController) async {
+ guard let currentProject,
+ let previous = history.undo(current: currentProject)
+ else {
+ return
+ }
+
+ await replaceCurrentProject(with: previous, captureHistory: false)
+ selectedClipID = primaryVisualClip(in: previous)?.id
+ syncPlayback(with: playbackController)
+ }
+
+ func redo(playbackController: PlaybackController) async {
+ guard let currentProject,
+ let next = history.redo(current: currentProject)
+ else {
+ return
+ }
+
+ await replaceCurrentProject(with: next, captureHistory: false)
+ selectedClipID = primaryVisualClip(in: next)?.id
+ syncPlayback(with: playbackController)
+ }
+
+ func advanceAspectRatio() {
+ guard let currentIndex = AspectRatio.allCases.firstIndex(of: selectedAspectRatio) else {
+ selectedAspectRatio = .landscape
+ return
+ }
+
+ let nextIndex = AspectRatio.allCases.index(after: currentIndex)
+ selectedAspectRatio = nextIndex == AspectRatio.allCases.endIndex ? AspectRatio.allCases[0] : AspectRatio.allCases[nextIndex]
+ }
+
+ func style(for project: OpenReelProject) -> ProjectStyle {
+ let styles = ProjectStyle.allCases
+ let index = abs(project.id.hashValue) % styles.count
+ return styles[index]
+ }
+
+ func primaryVisualClip(in project: OpenReelProject? = nil) -> OpenReelProject.Clip? {
+ let project = project ?? currentProject
+ return project?.timeline.tracks
+ .first(where: { $0.type == .video || $0.type == .image })?
+ .clips
+ .sorted(by: { $0.startTime < $1.startTime })
+ .first
+ }
+
+ func selectedVisualClip(in project: OpenReelProject? = nil) -> OpenReelProject.Clip? {
+ let project = project ?? currentProject
+ guard let project, let selectedClipID else {
+ return primaryVisualClip(in: project)
+ }
+
+ return project.timeline.tracks
+ .filter { $0.type == .video || $0.type == .image }
+ .flatMap(\.clips)
+ .first { $0.id == selectedClipID } ?? primaryVisualClip(in: project)
+ }
+
+ func clips(for trackType: OpenReelProject.TrackType, in project: OpenReelProject? = nil) -> [OpenReelProject.Clip] {
+ let project = project ?? currentProject
+ return project?.timeline.tracks.first(where: { $0.type == trackType })?.clips ?? []
+ }
+
+ func mediaItem(for mediaID: String, in project: OpenReelProject? = nil) -> OpenReelProject.MediaItem? {
+ let project = project ?? currentProject
+ return project?.mediaLibrary.items.first(where: { $0.id == mediaID })
+ }
+
+ func mediaURL(for mediaItem: OpenReelProject.MediaItem, in project: OpenReelProject? = nil) -> URL? {
+ let project = project ?? currentProject
+ guard let project, let localFileName = mediaItem.localFileName else {
+ return nil
+ }
+
+ return projectStore.mediaDirectoryURL(for: project.id).appendingPathComponent(localFileName, isDirectory: false)
+ }
+
+ func thumbnailURL(for relativePath: String?, in project: OpenReelProject? = nil) -> URL? {
+ let project = project ?? currentProject
+ guard let project, let relativePath else {
+ return nil
+ }
+
+ return projectStore.relativeResourceURL(projectID: project.id, relativePath: relativePath)
+ }
+
+ func syncPlayback(with playbackController: PlaybackController) {
+ guard let project = currentProject,
+ let clip = selectedVisualClip(in: project),
+ let mediaItem = mediaItem(for: clip.mediaId, in: project),
+ let mediaURL = mediaURL(for: mediaItem, in: project)
+ else {
+ playbackController.loadVideo(url: nil, duration: 0, frameRate: 30)
+ return
+ }
+
+ playbackController.loadVideo(
+ url: mediaURL,
+ duration: clip.duration,
+ frameRate: project.settings.frameRate
+ )
+ }
+
+ func dismissError() {
+ importErrorMessage = nil
+ }
+
+ private func replaceProject(_ project: OpenReelProject) {
+ if let index = projects.firstIndex(where: { $0.id == project.id }) {
+ projects[index] = project
+ } else {
+ projects.insert(project, at: 0)
+ }
+ projects.sort { $0.modifiedAt > $1.modifiedAt }
+ selectedProjectID = project.id
+ }
+
+ private func replaceCurrentProject(with project: OpenReelProject, captureHistory: Bool) async {
+ if captureHistory, let currentProject {
+ history.capture(currentProject)
+ }
+
+ replaceProject(project)
+
+ do {
+ try await projectStore.save(project: project)
+ lastSavedAt = .now
+ } catch {
+ importErrorMessage = error.localizedDescription
+ }
+ }
+
+ private func syncAspectRatio(to project: OpenReelProject) {
+ let ratio = Double(project.settings.width) / Double(max(project.settings.height, 1))
+ let closest = AspectRatio.allCases.min { lhs, rhs in
+ abs(Double(lhs.value) - ratio) < abs(Double(rhs.value) - ratio)
+ }
+ selectedAspectRatio = closest ?? .landscape
+ }
+
+ private func prepareNewProjectDefaults() {
+ newProjectConfiguration = NewProjectConfiguration(name: suggestedProjectName())
+ }
+
+ private func suggestedProjectName() -> String {
+ "Project \(projects.count + 1)"
+ }
+}
diff --git a/Openreel Video/Openreel Video/Assets.xcassets/AccentColor.colorset/Contents.json b/Openreel Video/Openreel Video/Assets.xcassets/AccentColor.colorset/Contents.json
new file mode 100644
index 00000000..eb878970
--- /dev/null
+++ b/Openreel Video/Openreel Video/Assets.xcassets/AccentColor.colorset/Contents.json
@@ -0,0 +1,11 @@
+{
+ "colors" : [
+ {
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Openreel Video/Openreel Video/Assets.xcassets/AppIcon.appiconset/Contents.json b/Openreel Video/Openreel Video/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 00000000..23058801
--- /dev/null
+++ b/Openreel Video/Openreel Video/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,35 @@
+{
+ "images" : [
+ {
+ "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" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Openreel Video/Openreel Video/Assets.xcassets/Contents.json b/Openreel Video/Openreel Video/Assets.xcassets/Contents.json
new file mode 100644
index 00000000..73c00596
--- /dev/null
+++ b/Openreel Video/Openreel Video/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/Openreel Video/Openreel Video/ContentView.swift b/Openreel Video/Openreel Video/ContentView.swift
new file mode 100644
index 00000000..579cb5ca
--- /dev/null
+++ b/Openreel Video/Openreel Video/ContentView.swift
@@ -0,0 +1,20 @@
+//
+// ContentView.swift
+// Openreel Video
+//
+// Created by Augustus Otu on 17/05/2026.
+//
+
+import SwiftUI
+
+struct ContentView: View {
+ var body: some View {
+ RootView()
+ }
+}
+
+#Preview {
+ ContentView()
+ .environment(AppState())
+ .environment(PlaybackController())
+}
diff --git a/Openreel Video/Openreel Video/Core/Media/MediaImportService.swift b/Openreel Video/Openreel Video/Core/Media/MediaImportService.swift
new file mode 100644
index 00000000..0e7c73b2
--- /dev/null
+++ b/Openreel Video/Openreel Video/Core/Media/MediaImportService.swift
@@ -0,0 +1,541 @@
+import AVFoundation
+import Foundation
+import UIKit
+
+enum ImportedMediaType: Sendable, Equatable {
+ case video
+ case image
+ case audio
+}
+
+struct ImportedMediaAsset: Sendable, Equatable {
+ var sourceURL: URL
+ var fileName: String
+ var assetIdentifier: String?
+ var mediaType: ImportedMediaType
+}
+
+actor MediaImportService {
+ enum ImportError: LocalizedError {
+ case missingVideoTrack
+ case missingThumbnailData
+ case missingImageData
+ case noSuitableTrack
+
+ var errorDescription: String? {
+ switch self {
+ case .missingVideoTrack:
+ return "The selected file does not contain a playable video track."
+ case .missingThumbnailData:
+ return "A preview thumbnail could not be generated for this clip."
+ case .missingImageData:
+ return "The selected image could not be read."
+ case .noSuitableTrack:
+ return "No suitable track found on the timeline for this media type."
+ }
+ }
+ }
+
+ func importAssets(
+ _ assets: [ImportedMediaAsset],
+ into project: OpenReelProject,
+ store: ProjectStore
+ ) async throws -> OpenReelProject {
+ var updatedProject = project
+
+ let videoAssets = assets.filter { $0.mediaType == .video }
+ let imageAssets = assets.filter { $0.mediaType == .image }
+ let audioAssets = assets.filter { $0.mediaType == .audio }
+
+ if !videoAssets.isEmpty {
+ updatedProject = try await importVideos(videoAssets, into: updatedProject, store: store)
+ }
+
+ if !imageAssets.isEmpty {
+ updatedProject = try await importImages(imageAssets, into: updatedProject, store: store)
+ }
+
+ if !audioAssets.isEmpty {
+ updatedProject = try await importAudio(audioAssets, into: updatedProject, store: store)
+ }
+
+ updatedProject.modifiedAt = Int(Date().timeIntervalSince1970 * 1000)
+ return updatedProject
+ }
+
+ func importVideos(
+ _ assets: [ImportedMediaAsset],
+ into project: OpenReelProject,
+ store: ProjectStore
+ ) async throws -> OpenReelProject {
+ guard let videoTrackIndex = project.timeline.tracks.firstIndex(where: { $0.type == .video }) else {
+ return project
+ }
+
+ var updatedProject = project
+ var nextStartTime = updatedProject.timeline.tracks[videoTrackIndex].clips
+ .filter { !$0.mediaId.isEmpty }
+ .map { $0.startTime + $0.duration }
+ .max() ?? 0
+
+ for asset in assets {
+ let prepared = try await prepareImportedVideo(
+ asset,
+ projectID: updatedProject.id,
+ trackID: updatedProject.timeline.tracks[videoTrackIndex].id,
+ startTime: nextStartTime,
+ store: store
+ )
+
+ updatedProject.mediaLibrary.items.append(prepared.mediaItem)
+ updatedProject.timeline.tracks[videoTrackIndex].clips.append(prepared.clip)
+ nextStartTime = prepared.clip.startTime + prepared.clip.duration
+ }
+
+ updatedProject.timeline.tracks[videoTrackIndex].clips = updatedProject.timeline.tracks[videoTrackIndex].clips
+ .filter { !$0.mediaId.isEmpty }
+ .sorted { $0.startTime < $1.startTime }
+ updatedProject.timeline.duration = max(updatedProject.timeline.duration, nextStartTime)
+ return updatedProject
+ }
+
+ private func importImages(
+ _ assets: [ImportedMediaAsset],
+ into project: OpenReelProject,
+ store: ProjectStore
+ ) async throws -> OpenReelProject {
+ let trackIndex: Int
+ if let existing = project.timeline.tracks.firstIndex(where: { $0.type == .image }) {
+ trackIndex = existing
+ } else if let videoIndex = project.timeline.tracks.firstIndex(where: { $0.type == .video }) {
+ trackIndex = videoIndex
+ } else {
+ return project
+ }
+
+ var updatedProject = project
+ var nextStartTime = updatedProject.timeline.tracks[trackIndex].clips
+ .filter { !$0.mediaId.isEmpty }
+ .map { $0.startTime + $0.duration }
+ .max() ?? 0
+
+ let defaultImageDuration: Double = 5.0
+
+ for asset in assets {
+ let prepared = try await prepareImportedImage(
+ asset,
+ projectID: updatedProject.id,
+ trackID: updatedProject.timeline.tracks[trackIndex].id,
+ startTime: nextStartTime,
+ duration: defaultImageDuration,
+ store: store
+ )
+
+ updatedProject.mediaLibrary.items.append(prepared.mediaItem)
+ updatedProject.timeline.tracks[trackIndex].clips.append(prepared.clip)
+ nextStartTime += defaultImageDuration
+ }
+
+ updatedProject.timeline.tracks[trackIndex].clips = updatedProject.timeline.tracks[trackIndex].clips
+ .filter { !$0.mediaId.isEmpty }
+ .sorted { $0.startTime < $1.startTime }
+ updatedProject.timeline.duration = max(updatedProject.timeline.duration, nextStartTime)
+ return updatedProject
+ }
+
+ private func importAudio(
+ _ assets: [ImportedMediaAsset],
+ into project: OpenReelProject,
+ store: ProjectStore
+ ) async throws -> OpenReelProject {
+ guard let audioTrackIndex = project.timeline.tracks.firstIndex(where: { $0.type == .audio }) else {
+ return project
+ }
+
+ var updatedProject = project
+ var nextStartTime = updatedProject.timeline.tracks[audioTrackIndex].clips
+ .filter { !$0.mediaId.isEmpty }
+ .map { $0.startTime + $0.duration }
+ .max() ?? 0
+
+ for asset in assets {
+ let prepared = try await prepareImportedAudio(
+ asset,
+ projectID: updatedProject.id,
+ trackID: updatedProject.timeline.tracks[audioTrackIndex].id,
+ startTime: nextStartTime,
+ store: store
+ )
+
+ updatedProject.mediaLibrary.items.append(prepared.mediaItem)
+ updatedProject.timeline.tracks[audioTrackIndex].clips.append(prepared.clip)
+ nextStartTime = prepared.clip.startTime + prepared.clip.duration
+ }
+
+ updatedProject.timeline.tracks[audioTrackIndex].clips = updatedProject.timeline.tracks[audioTrackIndex].clips
+ .filter { !$0.mediaId.isEmpty }
+ .sorted { $0.startTime < $1.startTime }
+ updatedProject.timeline.duration = max(updatedProject.timeline.duration, nextStartTime)
+ return updatedProject
+ }
+
+ private func prepareImportedVideo(
+ _ asset: ImportedMediaAsset,
+ projectID: String,
+ trackID: String,
+ startTime: Double,
+ store: ProjectStore
+ ) async throws -> PreparedImportedMedia {
+ let avAsset = AVURLAsset(url: asset.sourceURL)
+ guard let videoTrack = try await avAsset.loadTracks(withMediaType: .video).first else {
+ throw ImportError.missingVideoTrack
+ }
+
+ let durationTime = try await avAsset.load(.duration)
+ let duration = max(durationTime.seconds, 0)
+ let naturalSize = try await videoTrack.load(.naturalSize)
+ let preferredTransform = try await videoTrack.load(.preferredTransform)
+ let nominalFrameRate = try await videoTrack.load(.nominalFrameRate)
+ let formatDescriptions = try await videoTrack.load(.formatDescriptions)
+ let audioTracks = try await avAsset.loadTracks(withMediaType: .audio)
+
+ let transformedRect = CGRect(origin: .zero, size: naturalSize).applying(preferredTransform)
+ let width = Int(abs(transformedRect.width).rounded())
+ let height = Int(abs(transformedRect.height).rounded())
+ let frameRate = nominalFrameRate > 0 ? Double(nominalFrameRate) : 30
+ let codec = fourCharacterCode(from: formatDescriptions.first)
+ let attributes = try FileManager.default.attributesOfItem(atPath: asset.sourceURL.path)
+ let fileSize = (attributes[.size] as? NSNumber)?.int64Value ?? 0
+ let modifiedDate = (attributes[.modificationDate] as? Date) ?? .now
+ let sourceFile = OpenReelProject.SourceFile(
+ name: asset.fileName,
+ size: fileSize,
+ lastModified: Int64(modifiedDate.timeIntervalSince1970 * 1000),
+ folder: nil
+ )
+
+ let imageGenerator = AVAssetImageGenerator(asset: avAsset)
+ imageGenerator.appliesPreferredTrackTransform = true
+ imageGenerator.maximumSize = CGSize(width: 720, height: 720)
+ imageGenerator.requestedTimeToleranceAfter = .zero
+ imageGenerator.requestedTimeToleranceBefore = .zero
+
+ let posterData = try await jpegData(from: imageGenerator, at: 0)
+ let persisted = try await store.persistMedia(
+ projectID: projectID,
+ sourceURL: asset.sourceURL,
+ preferredFileName: asset.fileName,
+ thumbnailData: posterData,
+ thumbnailFileName: UUID().uuidString + ".jpg"
+ )
+
+ let filmstrip = try await persistFilmstrip(
+ imageGenerator: imageGenerator,
+ duration: duration,
+ projectID: projectID,
+ store: store
+ )
+
+ let mediaItemID = UUID().uuidString
+ let clipID = UUID().uuidString
+
+ let mediaItem = OpenReelProject.MediaItem(
+ id: mediaItemID,
+ name: asset.fileName,
+ type: .video,
+ metadata: OpenReelProject.MediaMetadata(
+ duration: duration,
+ width: width,
+ height: height,
+ frameRate: frameRate,
+ codec: codec,
+ sampleRate: 48_000,
+ channels: audioTracks.isEmpty ? 0 : 2,
+ fileSize: fileSize,
+ audioTrackCount: audioTracks.count
+ ),
+ thumbnailUrl: persisted.thumbnailRelativePath,
+ waveformData: nil,
+ filmstripThumbnails: filmstrip,
+ isPlaceholder: false,
+ originalUrl: nil,
+ sourceFile: sourceFile,
+ localFileName: persisted.mediaFileName,
+ localAssetIdentifier: asset.assetIdentifier
+ )
+
+ let clip = OpenReelProject.Clip(
+ id: clipID,
+ mediaId: mediaItemID,
+ trackId: trackID,
+ startTime: startTime,
+ duration: duration,
+ inPoint: 0,
+ outPoint: duration,
+ effects: [],
+ audioEffects: [],
+ transform: OpenReelProject.Transform(
+ position: OpenReelProject.Point(x: 0.5, y: 0.5),
+ scale: OpenReelProject.Point(x: 1, y: 1),
+ rotation: 0,
+ anchor: OpenReelProject.Point(x: 0.5, y: 0.5),
+ opacity: 1,
+ borderRadius: nil,
+ fitMode: .contain,
+ crop: nil
+ ),
+ volume: 1,
+ keyframes: [],
+ speed: 1,
+ reversed: false,
+ audioTrackIndex: audioTracks.isEmpty ? nil : 0
+ )
+
+ return PreparedImportedMedia(mediaItem: mediaItem, clip: clip)
+ }
+
+ private func prepareImportedImage(
+ _ asset: ImportedMediaAsset,
+ projectID: String,
+ trackID: String,
+ startTime: Double,
+ duration: Double,
+ store: ProjectStore
+ ) async throws -> PreparedImportedMedia {
+ guard let imageData = try? Data(contentsOf: asset.sourceURL),
+ let uiImage = UIImage(data: imageData) else {
+ throw ImportError.missingImageData
+ }
+
+ let width = Int(uiImage.size.width * uiImage.scale)
+ let height = Int(uiImage.size.height * uiImage.scale)
+ let attributes = try FileManager.default.attributesOfItem(atPath: asset.sourceURL.path)
+ let fileSize = (attributes[.size] as? NSNumber)?.int64Value ?? 0
+
+ guard let thumbnailData = uiImage.jpegData(compressionQuality: 0.82) else {
+ throw ImportError.missingThumbnailData
+ }
+
+ let persisted = try await store.persistMedia(
+ projectID: projectID,
+ sourceURL: asset.sourceURL,
+ preferredFileName: asset.fileName,
+ thumbnailData: thumbnailData,
+ thumbnailFileName: UUID().uuidString + ".jpg"
+ )
+
+ let mediaItemID = UUID().uuidString
+ let clipID = UUID().uuidString
+
+ let mediaItem = OpenReelProject.MediaItem(
+ id: mediaItemID,
+ name: asset.fileName,
+ type: .image,
+ metadata: OpenReelProject.MediaMetadata(
+ duration: duration,
+ width: width,
+ height: height,
+ frameRate: 0,
+ codec: "jpeg",
+ sampleRate: 0,
+ channels: 0,
+ fileSize: fileSize,
+ audioTrackCount: 0
+ ),
+ thumbnailUrl: persisted.thumbnailRelativePath,
+ waveformData: nil,
+ filmstripThumbnails: [],
+ isPlaceholder: false,
+ originalUrl: nil,
+ sourceFile: OpenReelProject.SourceFile(
+ name: asset.fileName,
+ size: fileSize,
+ lastModified: Int64(Date().timeIntervalSince1970 * 1000),
+ folder: nil
+ ),
+ localFileName: persisted.mediaFileName,
+ localAssetIdentifier: asset.assetIdentifier
+ )
+
+ let clip = OpenReelProject.Clip(
+ id: clipID,
+ mediaId: mediaItemID,
+ trackId: trackID,
+ startTime: startTime,
+ duration: duration,
+ inPoint: 0,
+ outPoint: duration,
+ effects: [],
+ audioEffects: [],
+ transform: OpenReelProject.Transform(
+ position: OpenReelProject.Point(x: 0.5, y: 0.5),
+ scale: OpenReelProject.Point(x: 1, y: 1),
+ rotation: 0,
+ anchor: OpenReelProject.Point(x: 0.5, y: 0.5),
+ opacity: 1,
+ borderRadius: nil,
+ fitMode: .contain,
+ crop: nil
+ ),
+ volume: 0,
+ keyframes: [],
+ speed: 1,
+ reversed: false,
+ audioTrackIndex: nil
+ )
+
+ return PreparedImportedMedia(mediaItem: mediaItem, clip: clip)
+ }
+
+ private func prepareImportedAudio(
+ _ asset: ImportedMediaAsset,
+ projectID: String,
+ trackID: String,
+ startTime: Double,
+ store: ProjectStore
+ ) async throws -> PreparedImportedMedia {
+ let avAsset = AVURLAsset(url: asset.sourceURL)
+ let durationTime = try await avAsset.load(.duration)
+ let duration = max(durationTime.seconds, 0)
+ let audioTracks = try await avAsset.loadTracks(withMediaType: .audio)
+ let attributes = try FileManager.default.attributesOfItem(atPath: asset.sourceURL.path)
+ let fileSize = (attributes[.size] as? NSNumber)?.int64Value ?? 0
+
+ let persisted = try await store.persistMedia(
+ projectID: projectID,
+ sourceURL: asset.sourceURL,
+ preferredFileName: asset.fileName,
+ thumbnailData: nil,
+ thumbnailFileName: nil
+ )
+
+ let mediaItemID = UUID().uuidString
+ let clipID = UUID().uuidString
+
+ let mediaItem = OpenReelProject.MediaItem(
+ id: mediaItemID,
+ name: asset.fileName,
+ type: .audio,
+ metadata: OpenReelProject.MediaMetadata(
+ duration: duration,
+ width: 0,
+ height: 0,
+ frameRate: 0,
+ codec: "aac",
+ sampleRate: 44_100,
+ channels: audioTracks.isEmpty ? 1 : 2,
+ fileSize: fileSize,
+ audioTrackCount: audioTracks.count
+ ),
+ thumbnailUrl: nil,
+ waveformData: nil,
+ filmstripThumbnails: [],
+ isPlaceholder: false,
+ originalUrl: nil,
+ sourceFile: OpenReelProject.SourceFile(
+ name: asset.fileName,
+ size: fileSize,
+ lastModified: Int64(Date().timeIntervalSince1970 * 1000),
+ folder: nil
+ ),
+ localFileName: persisted.mediaFileName,
+ localAssetIdentifier: asset.assetIdentifier
+ )
+
+ let clip = OpenReelProject.Clip(
+ id: clipID,
+ mediaId: mediaItemID,
+ trackId: trackID,
+ startTime: startTime,
+ duration: duration,
+ inPoint: 0,
+ outPoint: duration,
+ effects: [],
+ audioEffects: [],
+ transform: OpenReelProject.Transform(
+ position: OpenReelProject.Point(x: 0.5, y: 0.5),
+ scale: OpenReelProject.Point(x: 1, y: 1),
+ rotation: 0,
+ anchor: OpenReelProject.Point(x: 0.5, y: 0.5),
+ opacity: 1,
+ borderRadius: nil,
+ fitMode: .contain,
+ crop: nil
+ ),
+ volume: 1,
+ keyframes: [],
+ speed: 1,
+ reversed: false,
+ audioTrackIndex: 0
+ )
+
+ return PreparedImportedMedia(mediaItem: mediaItem, clip: clip)
+ }
+
+ private func persistFilmstrip(
+ imageGenerator: AVAssetImageGenerator,
+ duration: Double,
+ projectID: String,
+ store: ProjectStore
+ ) async throws -> [OpenReelProject.FilmstripThumbnail] {
+ guard duration > 0 else {
+ return []
+ }
+
+ let frameCount = max(4, min(8, Int(duration.rounded(.up))))
+ let step = duration / Double(frameCount)
+ var thumbnails: [OpenReelProject.FilmstripThumbnail] = []
+
+ for index in 0..<frameCount {
+ let timestamp = min(Double(index) * step, max(duration - 0.05, 0))
+ guard let data = try? await jpegData(from: imageGenerator, at: timestamp) else {
+ continue
+ }
+ let relativePath = try await store.persistThumbnail(
+ projectID: projectID,
+ fileName: UUID().uuidString + ".jpg",
+ data: data
+ )
+ thumbnails.append(OpenReelProject.FilmstripThumbnail(timestamp: timestamp, url: relativePath))
+ }
+
+ return thumbnails
+ }
+
+ private func jpegData(from imageGenerator: AVAssetImageGenerator, at time: Double) async throws -> Data {
+ let cgImage = try await imageGenerator.image(at: CMTime(seconds: time, preferredTimescale: 600)).image
+ guard let data = UIImage(cgImage: cgImage).jpegData(compressionQuality: 0.82) else {
+ throw ImportError.missingThumbnailData
+ }
+ return data
+ }
+
+ private func fourCharacterCode(from formatDescription: Any?) -> String {
+ guard let formatDescription else {
+ return "unknown"
+ }
+
+ let cfFormatDescription = formatDescription as AnyObject
+ guard CFGetTypeID(cfFormatDescription) == CMFormatDescriptionGetTypeID() else {
+ return "unknown"
+ }
+
+ let mediaDescription = unsafeBitCast(cfFormatDescription, to: CMFormatDescription.self)
+ let subtype = CMFormatDescriptionGetMediaSubType(mediaDescription)
+ let bytes: [CChar] = [
+ CChar((subtype >> 24) & 0xff),
+ CChar((subtype >> 16) & 0xff),
+ CChar((subtype >> 8) & 0xff),
+ CChar(subtype & 0xff),
+ 0
+ ]
+ return String(cString: bytes)
+ .trimmingCharacters(in: .controlCharacters)
+ .trimmingCharacters(in: .whitespacesAndNewlines)
+ }
+}
+
+private struct PreparedImportedMedia {
+ var mediaItem: OpenReelProject.MediaItem
+ var clip: OpenReelProject.Clip
+}
diff --git a/Openreel Video/Openreel Video/Core/Models/OpenReelProject.swift b/Openreel Video/Openreel Video/Core/Models/OpenReelProject.swift
new file mode 100644
index 00000000..61c52cbf
--- /dev/null
+++ b/Openreel Video/Openreel Video/Core/Models/OpenReelProject.swift
@@ -0,0 +1,337 @@
+import Foundation
+
+struct OpenReelProjectFile: Codable, Equatable {
+ static let schemaVersion = "1.0.0"
+
+ var version: String
+ var project: OpenReelProject
+
+ init(project: OpenReelProject, version: String = OpenReelProjectFile.schemaVersion) {
+ self.version = version
+ self.project = project
+ }
+}
+
+struct OpenReelProject: Codable, Identifiable, Equatable {
+ var id: String
+ var name: String
+ var createdAt: Int
+ var modifiedAt: Int
+ var settings: ProjectSettings
+ var mediaLibrary: MediaLibrary
+ var timeline: Timeline
+
+ struct ProjectSettings: Codable, Equatable {
+ var width: Int
+ var height: Int
+ var frameRate: Double
+ var sampleRate: Int
+ var channels: Int
+ }
+
+ struct MediaLibrary: Codable, Equatable {
+ var items: [MediaItem]
+ }
+
+ struct MediaItem: Codable, Identifiable, Equatable {
+ var id: String
+ var name: String
+ var type: MediaType
+ var metadata: MediaMetadata
+ var thumbnailUrl: String?
+ var waveformData: [Float]?
+ var filmstripThumbnails: [FilmstripThumbnail]?
+ var isPlaceholder: Bool?
+ var originalUrl: String?
+ var sourceFile: SourceFile?
+ var localFileName: String?
+ var localAssetIdentifier: String?
+ }
+
+ struct FilmstripThumbnail: Codable, Equatable {
+ var timestamp: Double
+ var url: String
+ }
+
+ struct SourceFile: Codable, Equatable {
+ var name: String
+ var size: Int64
+ var lastModified: Int64
+ var folder: String?
+ }
+
+ enum MediaType: String, Codable, Equatable {
+ case video
+ case audio
+ case image
+ }
+
+ struct MediaMetadata: Codable, Equatable {
+ var duration: Double
+ var width: Int
+ var height: Int
+ var frameRate: Double
+ var codec: String
+ var sampleRate: Int
+ var channels: Int
+ var fileSize: Int64
+ var audioTrackCount: Int?
+ }
+
+ struct Timeline: Codable, Equatable {
+ var tracks: [Track]
+ var subtitles: [Subtitle]
+ var duration: Double
+ var markers: [Marker]
+ }
+
+ struct Track: Codable, Identifiable, Equatable {
+ var id: String
+ var type: TrackType
+ var name: String
+ var clips: [Clip]
+ var transitions: [Transition]
+ var locked: Bool
+ var hidden: Bool
+ var muted: Bool
+ var solo: Bool
+ }
+
+ enum TrackType: String, Codable, Equatable {
+ case video
+ case audio
+ case image
+ case text
+ case graphics
+ }
+
+ struct Clip: Codable, Identifiable, Equatable {
+ var id: String
+ var mediaId: String
+ var trackId: String
+ var startTime: Double
+ var duration: Double
+ var inPoint: Double
+ var outPoint: Double
+ var effects: [Effect]
+ var audioEffects: [Effect]
+ var transform: Transform
+ var volume: Double
+ var keyframes: [Keyframe]
+ var speed: Double?
+ var reversed: Bool?
+ var audioTrackIndex: Int?
+ }
+
+ struct Effect: Codable, Identifiable, Equatable {
+ var id: String
+ var type: String
+ var params: [String: JSONValue]
+ var enabled: Bool
+ }
+
+ struct Transform: Codable, Equatable {
+ var position: Point
+ var scale: Point
+ var rotation: Double
+ var anchor: Point
+ var opacity: Double
+ var borderRadius: Double?
+ var fitMode: FitMode?
+ var crop: Crop?
+ }
+
+ struct Point: Codable, Equatable {
+ var x: Double
+ var y: Double
+ }
+
+ struct Crop: Codable, Equatable {
+ var x: Double
+ var y: Double
+ var width: Double
+ var height: Double
+ }
+
+ enum FitMode: String, Codable, Equatable {
+ case contain
+ case cover
+ case stretch
+ case none
+ }
+
+ struct Keyframe: Codable, Identifiable, Equatable {
+ var id: String
+ var time: Double
+ var property: String
+ var value: JSONValue
+ var easing: String
+ }
+
+ struct Marker: Codable, Identifiable, Equatable {
+ var id: String
+ var time: Double
+ var label: String
+ var color: String
+ }
+
+ struct Transition: Codable, Identifiable, Equatable {
+ var id: String
+ var clipAId: String
+ var clipBId: String
+ var type: String
+ var duration: Double
+ var params: [String: JSONValue]
+ }
+
+ struct Subtitle: Codable, Identifiable, Equatable {
+ var id: String
+ var text: String
+ var startTime: Double
+ var endTime: Double
+ }
+}
+
+enum JSONValue: Codable, Equatable {
+ case string(String)
+ case number(Double)
+ case bool(Bool)
+ case object([String: JSONValue])
+ case array([JSONValue])
+ case null
+
+ init(from decoder: Decoder) throws {
+ let container = try decoder.singleValueContainer()
+
+ if container.decodeNil() {
+ self = .null
+ } else if let value = try? container.decode(Bool.self) {
+ self = .bool(value)
+ } else if let value = try? container.decode(Double.self) {
+ self = .number(value)
+ } else if let value = try? container.decode(String.self) {
+ self = .string(value)
+ } else if let value = try? container.decode([String: JSONValue].self) {
+ self = .object(value)
+ } else if let value = try? container.decode([JSONValue].self) {
+ self = .array(value)
+ } else {
+ throw DecodingError.dataCorruptedError(in: container, debugDescription: "Unsupported JSON value")
+ }
+ }
+
+ func encode(to encoder: Encoder) throws {
+ var container = encoder.singleValueContainer()
+
+ switch self {
+ case .string(let value):
+ try container.encode(value)
+ case .number(let value):
+ try container.encode(value)
+ case .bool(let value):
+ try container.encode(value)
+ case .object(let value):
+ try container.encode(value)
+ case .array(let value):
+ try container.encode(value)
+ case .null:
+ try container.encodeNil()
+ }
+ }
+}
+
+struct NewProjectConfiguration: Equatable {
+ struct Preset: Identifiable, Equatable {
+ var id: String { name }
+ var name: String
+ var width: Int
+ var height: Int
+ }
+
+ static let presets: [Preset] = [
+ Preset(name: "1080p", width: 1920, height: 1080),
+ Preset(name: "Square", width: 1080, height: 1080),
+ Preset(name: "Portrait", width: 1080, height: 1920),
+ Preset(name: "4K", width: 3840, height: 2160)
+ ]
+
+ static let supportedFrameRates: [Double] = [24, 30, 60]
+
+ var name: String = "Project"
+ var preset: Preset = Self.presets[0]
+ var frameRate: Double = 30
+
+ var settings: OpenReelProject.ProjectSettings {
+ OpenReelProject.ProjectSettings(
+ width: preset.width,
+ height: preset.height,
+ frameRate: frameRate,
+ sampleRate: 48_000,
+ channels: 2
+ )
+ }
+}
+
+extension OpenReelProject {
+ static func blank(configuration: NewProjectConfiguration) -> Self {
+ let now = Int(Date().timeIntervalSince1970 * 1000)
+ let videoTrackID = UUID().uuidString
+ let audioTrackID = UUID().uuidString
+
+ return OpenReelProject(
+ id: UUID().uuidString,
+ name: configuration.name,
+ createdAt: now,
+ modifiedAt: now,
+ settings: configuration.settings,
+ mediaLibrary: MediaLibrary(items: []),
+ timeline: Timeline(
+ tracks: [
+ Track(
+ id: videoTrackID,
+ type: .video,
+ name: "Video 1",
+ clips: [],
+ transitions: [],
+ locked: false,
+ hidden: false,
+ muted: false,
+ solo: false
+ ),
+ Track(
+ id: audioTrackID,
+ type: .audio,
+ name: "Audio 1",
+ clips: [],
+ transitions: [],
+ locked: false,
+ hidden: false,
+ muted: false,
+ solo: false
+ )
+ ],
+ subtitles: [],
+ duration: 0,
+ markers: []
+ )
+ )
+ }
+
+ var sortedTracks: [Track] {
+ timeline.tracks
+ }
+
+ var allClips: [Clip] {
+ timeline.tracks
+ .flatMap(\.clips)
+ .sorted { $0.startTime < $1.startTime }
+ }
+
+ var primaryVisualTrack: Track? {
+ timeline.tracks.first(where: { $0.type == .video || $0.type == .image })
+ }
+
+ var primaryAudioTrack: Track? {
+ timeline.tracks.first(where: { $0.type == .audio })
+ }
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/Core/Playback/PlaybackController.swift b/Openreel Video/Openreel Video/Core/Playback/PlaybackController.swift
new file mode 100644
index 00000000..24471549
--- /dev/null
+++ b/Openreel Video/Openreel Video/Core/Playback/PlaybackController.swift
@@ -0,0 +1,181 @@
+import AVFoundation
+import Foundation
+import Observation
+
+@MainActor
+@Observable
+final class PlaybackController {
+ var player: AVPlayer?
+ var currentTime: TimeInterval = 0
+ var duration: TimeInterval = 0
+ var isPlaying = false
+ var volume: Float = 1
+ var frameRate: Double = 30
+ var loadedMediaURL: URL?
+
+ @ObservationIgnored private var timeObserver: Any?
+ @ObservationIgnored private var endObserver: NSObjectProtocol?
+ @ObservationIgnored private var rateObserver: NSKeyValueObservation?
+ @ObservationIgnored private var itemStatusObserver: NSKeyValueObservation?
+ @ObservationIgnored private var playWhenReadyObserver: NSKeyValueObservation?
+
+ deinit {
+ Task { @MainActor [weak self] in
+ self?.tearDownObservers()
+ }
+ }
+
+ func loadVideo(url: URL?, duration: TimeInterval, frameRate: Double) {
+ if url == loadedMediaURL, player != nil {
+ self.duration = max(duration, 0)
+ self.frameRate = frameRate > 0 ? frameRate : 30
+ return
+ }
+
+ tearDownObservers()
+ loadedMediaURL = url
+ self.duration = max(duration, 0)
+ self.frameRate = frameRate > 0 ? frameRate : 30
+ currentTime = 0
+ isPlaying = false
+
+ guard let url else {
+ player = nil
+ return
+ }
+
+ let asset = AVURLAsset(url: url)
+ let item = AVPlayerItem(asset: asset)
+ let newPlayer = AVPlayer(playerItem: item)
+ newPlayer.actionAtItemEnd = .pause
+ newPlayer.volume = volume
+ self.player = newPlayer
+
+ itemStatusObserver = item.observe(\.status, options: [.new]) { [weak self] observedItem, _ in
+ Task { @MainActor in
+ guard let self else { return }
+ if observedItem.status == .readyToPlay {
+ self.itemStatusObserver = nil
+ }
+ }
+ }
+
+ timeObserver = newPlayer.addPeriodicTimeObserver(
+ forInterval: CMTime(seconds: 1.0 / 30.0, preferredTimescale: 600),
+ queue: .main
+ ) { [weak self] time in
+ guard let self else { return }
+ Task { @MainActor in
+ let seconds = max(time.seconds, 0)
+ if self.player?.rate ?? 0 > 0 {
+ self.currentTime = seconds
+ }
+ }
+ }
+
+ rateObserver = newPlayer.observe(\.rate, options: [.new]) { [weak self] observedPlayer, _ in
+ Task { @MainActor in
+ guard let self else { return }
+ self.isPlaying = observedPlayer.rate > 0
+ }
+ }
+
+ endObserver = NotificationCenter.default.addObserver(
+ forName: .AVPlayerItemDidPlayToEndTime,
+ object: item,
+ queue: .main
+ ) { [weak self] _ in
+ guard let self else { return }
+ Task { @MainActor in
+ self.isPlaying = false
+ self.currentTime = self.duration
+ }
+ }
+ }
+
+ func play() {
+ guard let player else { return }
+ playWhenReadyObserver = nil
+
+ if player.currentItem?.status != .readyToPlay {
+ isPlaying = true
+ playWhenReadyObserver = player.currentItem?.observe(\.status, options: [.new]) { [weak self] item, _ in
+ Task { @MainActor in
+ guard let self, item.status == .readyToPlay else { return }
+ self.playWhenReadyObserver = nil
+ self.startPlayback()
+ }
+ }
+ return
+ }
+
+ startPlayback()
+ }
+
+ private func startPlayback() {
+ guard let player else { return }
+
+ if currentTime >= duration - 0.05 {
+ let cmTime = CMTime.zero
+ currentTime = 0
+ player.seek(to: cmTime, toleranceBefore: .zero, toleranceAfter: .zero) { [weak self] finished in
+ guard finished else { return }
+ Task { @MainActor in
+ self?.player?.rate = 1.0
+ }
+ }
+ return
+ }
+
+ player.rate = 1.0
+ }
+
+ func pause() {
+ playWhenReadyObserver = nil
+ player?.rate = 0.0
+ isPlaying = false
+ }
+
+ func togglePlayback() {
+ guard let player else { return }
+ if player.rate > 0 {
+ pause()
+ } else {
+ play()
+ }
+ }
+
+ func seek(to time: TimeInterval) {
+ let clampedTime = max(0, min(time, duration))
+ currentTime = clampedTime
+
+ guard let player else { return }
+ let cmTime = CMTime(seconds: clampedTime, preferredTimescale: 600)
+ player.seek(to: cmTime, toleranceBefore: .zero, toleranceAfter: .zero)
+ }
+
+ func step(frames: Int) {
+ let delta = Double(frames) / max(frameRate, 1)
+ seek(to: currentTime + delta)
+ }
+
+ func setVolume(_ value: Float) {
+ volume = min(max(value, 0), 1)
+ player?.volume = volume
+ }
+
+ private func tearDownObservers() {
+ if let timeObserver, let player {
+ player.removeTimeObserver(timeObserver)
+ }
+ timeObserver = nil
+
+ if let endObserver {
+ NotificationCenter.default.removeObserver(endObserver)
+ }
+ endObserver = nil
+ rateObserver = nil
+ itemStatusObserver = nil
+ playWhenReadyObserver = nil
+ }
+}
diff --git a/Openreel Video/Openreel Video/Core/Storage/ProjectStore.swift b/Openreel Video/Openreel Video/Core/Storage/ProjectStore.swift
new file mode 100644
index 00000000..9ab0bbc1
--- /dev/null
+++ b/Openreel Video/Openreel Video/Core/Storage/ProjectStore.swift
@@ -0,0 +1,193 @@
+import Foundation
+
+actor ProjectStore {
+ enum StoreError: LocalizedError {
+ case applicationSupportUnavailable
+ case projectNotFound
+
+ var errorDescription: String? {
+ switch self {
+ case .applicationSupportUnavailable:
+ return "The app support directory is unavailable."
+ case .projectNotFound:
+ return "The selected project could not be found."
+ }
+ }
+ }
+
+ private let fileManager: FileManager
+ nonisolated private let baseURL: URL
+ private let encoder: JSONEncoder
+ private let decoder: JSONDecoder
+
+ init(fileManager: FileManager = .default, baseURL: URL? = nil) {
+ self.fileManager = fileManager
+ if let baseURL {
+ self.baseURL = baseURL
+ } else {
+ let appSupportURL = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
+ self.baseURL = (appSupportURL ?? URL(fileURLWithPath: NSTemporaryDirectory()))
+ .appendingPathComponent("OpenReel", isDirectory: true)
+ .appendingPathComponent("Projects", isDirectory: true)
+ }
+
+ let encoder = JSONEncoder()
+ encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
+ self.encoder = encoder
+ self.decoder = JSONDecoder()
+ }
+
+ func loadProjects() throws -> [OpenReelProject] {
+ try ensureBaseDirectories()
+
+ let projectDirectories = try fileManager.contentsOfDirectory(
+ at: baseURL,
+ includingPropertiesForKeys: [.isDirectoryKey],
+ options: [.skipsHiddenFiles]
+ )
+
+ let projects = try projectDirectories.compactMap { directoryURL -> OpenReelProject? in
+ let values = try directoryURL.resourceValues(forKeys: [.isDirectoryKey])
+ guard values.isDirectory == true else {
+ return nil
+ }
+
+ let jsonURL = directoryURL.appendingPathComponent("project.json", isDirectory: false)
+ guard fileManager.fileExists(atPath: jsonURL.path) else {
+ return nil
+ }
+
+ let data = try Data(contentsOf: jsonURL)
+ let file = try decoder.decode(OpenReelProjectFile.self, from: data)
+ return file.project
+ }
+
+ return projects.sorted { $0.modifiedAt > $1.modifiedAt }
+ }
+
+ func loadProject(id: String) throws -> OpenReelProject? {
+ try ensureBaseDirectories()
+
+ let jsonURL = projectDirectoryURL(for: id).appendingPathComponent("project.json", isDirectory: false)
+ guard fileManager.fileExists(atPath: jsonURL.path) else {
+ return nil
+ }
+
+ let data = try Data(contentsOf: jsonURL)
+ return try decoder.decode(OpenReelProjectFile.self, from: data).project
+ }
+
+ func save(project: OpenReelProject) throws {
+ try ensureProjectDirectories(for: project.id)
+
+ let projectFile = OpenReelProjectFile(project: project)
+ let data = try encoder.encode(projectFile)
+ let jsonURL = projectDirectoryURL(for: project.id).appendingPathComponent("project.json", isDirectory: false)
+ try data.write(to: jsonURL, options: [.atomic])
+ }
+
+ func deleteProject(id: String) throws {
+ let directoryURL = projectDirectoryURL(for: id)
+ guard fileManager.fileExists(atPath: directoryURL.path) else {
+ throw StoreError.projectNotFound
+ }
+
+ try fileManager.removeItem(at: directoryURL)
+ }
+
+ nonisolated func projectDirectoryURL(for projectID: String) -> URL {
+ baseURL.appendingPathComponent(projectID, isDirectory: true)
+ }
+
+ nonisolated func mediaDirectoryURL(for projectID: String) -> URL {
+ projectDirectoryURL(for: projectID).appendingPathComponent("media", isDirectory: true)
+ }
+
+ nonisolated func thumbnailsDirectoryURL(for projectID: String) -> URL {
+ projectDirectoryURL(for: projectID).appendingPathComponent("thumbnails", isDirectory: true)
+ }
+
+ nonisolated func relativeResourceURL(projectID: String, relativePath: String) -> URL {
+ projectDirectoryURL(for: projectID).appendingPathComponent(relativePath, isDirectory: false)
+ }
+
+ func persistMedia(
+ projectID: String,
+ sourceURL: URL,
+ preferredFileName: String,
+ thumbnailData: Data? = nil,
+ thumbnailFileName: String? = nil
+ ) throws -> (mediaFileName: String, thumbnailRelativePath: String?) {
+ try ensureProjectDirectories(for: projectID)
+
+ let safeMediaFileName = makeUniqueFileName(
+ preferredFileName,
+ in: mediaDirectoryURL(for: projectID)
+ )
+ let mediaDestination = mediaDirectoryURL(for: projectID).appendingPathComponent(safeMediaFileName, isDirectory: false)
+
+ if fileManager.fileExists(atPath: mediaDestination.path) {
+ try fileManager.removeItem(at: mediaDestination)
+ }
+ try fileManager.copyItem(at: sourceURL, to: mediaDestination)
+
+ var thumbnailRelativePath: String?
+ if let thumbnailData, let thumbnailFileName {
+ let safeThumbnailFileName = makeUniqueFileName(thumbnailFileName, in: thumbnailsDirectoryURL(for: projectID))
+ let thumbnailDestination = thumbnailsDirectoryURL(for: projectID).appendingPathComponent(safeThumbnailFileName, isDirectory: false)
+ try thumbnailData.write(to: thumbnailDestination, options: [.atomic])
+ thumbnailRelativePath = "thumbnails/\(safeThumbnailFileName)"
+ }
+
+ return (safeMediaFileName, thumbnailRelativePath)
+ }
+
+ func persistThumbnail(projectID: String, fileName: String, data: Data) throws -> String {
+ try ensureProjectDirectories(for: projectID)
+ let safeFileName = makeUniqueFileName(fileName, in: thumbnailsDirectoryURL(for: projectID))
+ let outputURL = thumbnailsDirectoryURL(for: projectID).appendingPathComponent(safeFileName, isDirectory: false)
+ try data.write(to: outputURL, options: [.atomic])
+ return "thumbnails/\(safeFileName)"
+ }
+
+ private func ensureBaseDirectories() throws {
+ try fileManager.createDirectory(at: baseURL, withIntermediateDirectories: true)
+ }
+
+ private func ensureProjectDirectories(for projectID: String) throws {
+ try ensureBaseDirectories()
+ try fileManager.createDirectory(at: projectDirectoryURL(for: projectID), withIntermediateDirectories: true)
+ try fileManager.createDirectory(at: mediaDirectoryURL(for: projectID), withIntermediateDirectories: true)
+ try fileManager.createDirectory(at: thumbnailsDirectoryURL(for: projectID), withIntermediateDirectories: true)
+ }
+
+ private func makeUniqueFileName(_ preferredFileName: String, in directoryURL: URL) -> String {
+ let sanitizedBaseName = sanitizeFileName(preferredFileName)
+ let candidateURL = directoryURL.appendingPathComponent(sanitizedBaseName, isDirectory: false)
+ guard fileManager.fileExists(atPath: candidateURL.path) else {
+ return sanitizedBaseName
+ }
+
+ let base = candidateURL.deletingPathExtension().lastPathComponent
+ let ext = candidateURL.pathExtension
+ var index = 1
+
+ while true {
+ let nextName = ext.isEmpty ? "\(base)-\(index)" : "\(base)-\(index).\(ext)"
+ let nextURL = directoryURL.appendingPathComponent(nextName, isDirectory: false)
+ if !fileManager.fileExists(atPath: nextURL.path) {
+ return nextName
+ }
+ index += 1
+ }
+ }
+
+ private func sanitizeFileName(_ fileName: String) -> String {
+ let cleaned = fileName
+ .trimmingCharacters(in: .whitespacesAndNewlines)
+ .replacingOccurrences(of: "/", with: "-")
+ .replacingOccurrences(of: ":", with: "-")
+
+ return cleaned.isEmpty ? UUID().uuidString : cleaned
+ }
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/Core/Timeline/ActionHistory.swift b/Openreel Video/Openreel Video/Core/Timeline/ActionHistory.swift
new file mode 100644
index 00000000..5237fb64
--- /dev/null
+++ b/Openreel Video/Openreel Video/Core/Timeline/ActionHistory.swift
@@ -0,0 +1,52 @@
+import Foundation
+
+@MainActor
+final class ActionHistory<State> {
+ private(set) var undoStack: [State] = []
+ private(set) var redoStack: [State] = []
+
+ private let limit: Int
+
+ init(limit: Int = 50) {
+ self.limit = limit
+ }
+
+ var canUndo: Bool {
+ !undoStack.isEmpty
+ }
+
+ var canRedo: Bool {
+ !redoStack.isEmpty
+ }
+
+ func clear() {
+ undoStack.removeAll()
+ redoStack.removeAll()
+ }
+
+ func capture(_ state: State) {
+ undoStack.append(state)
+ if undoStack.count > limit {
+ undoStack.removeFirst(undoStack.count - limit)
+ }
+ redoStack.removeAll()
+ }
+
+ func undo(current: State) -> State? {
+ guard let previous = undoStack.popLast() else {
+ return nil
+ }
+
+ redoStack.append(current)
+ return previous
+ }
+
+ func redo(current: State) -> State? {
+ guard let next = redoStack.popLast() else {
+ return nil
+ }
+
+ undoStack.append(current)
+ return next
+ }
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/EditorView.swift b/Openreel Video/Openreel Video/EditorView.swift
new file mode 100644
index 00000000..07819906
--- /dev/null
+++ b/Openreel Video/Openreel Video/EditorView.swift
@@ -0,0 +1,1132 @@
+import SwiftUI
+
+struct EditorView: View {
+ @Environment(AppState.self) private var appState
+ @Environment(PlaybackController.self) private var playbackController
+
+ @State private var showsVolumeControl = false
+ @State private var playheadDragStartTime: TimeInterval?
+ @State private var showsMediaLibrarySheet = false
+ @State private var showsPhotoPickerInSheet = false
+
+ private let editActions = [
+ (title: "Split", symbol: "scissors"),
+ (title: "Delete", symbol: "trash"),
+ (title: "Volume", symbol: "speaker.wave.2"),
+ (title: "Speed", symbol: "gauge.with.dots.needle.33percent"),
+ (title: "Crop", symbol: "crop"),
+ (title: "Filters", symbol: "camera.filters"),
+ (title: "Adjust", symbol: "slider.horizontal.3")
+ ]
+
+ var body: some View {
+ Group {
+ if let project = appState.currentProject {
+ editorContent(for: project)
+ } else {
+ emptyState
+ }
+ }
+ .background(OpenReelTheme.background.ignoresSafeArea())
+ .task(id: appState.playbackReloadToken) {
+ appState.syncPlayback(with: playbackController)
+ }
+ .sheet(isPresented: $showsMediaLibrarySheet) {
+ if let project = appState.currentProject {
+ mediaLibrarySheet(for: project)
+ }
+ }
+ .fullScreenCover(
+ isPresented: Binding(
+ get: { appState.isMediaPickerPresented },
+ set: { isPresented in
+ if !isPresented {
+ appState.dismissMediaPicker()
+ }
+ }
+ )
+ ) {
+ MediaPicker(
+ onCancel: {
+ appState.dismissMediaPicker()
+ },
+ onPick: { assets in
+ appState.dismissMediaPicker()
+ Task {
+ await appState.importMedia(assets, playbackController: playbackController)
+ }
+ }
+ )
+ .ignoresSafeArea()
+ }
+ .overlay {
+ if appState.isImportingMedia {
+ ZStack {
+ Color.black.opacity(0.35)
+ .ignoresSafeArea()
+ VStack(spacing: 12) {
+ ProgressView()
+ .tint(OpenReelTheme.accent)
+ Text("Importing video")
+ .font(.reelBody)
+ .foregroundStyle(.white)
+ }
+ .padding(20)
+ .background(OpenReelTheme.surfaceElevated, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
+ }
+ }
+ }
+ .sheet(isPresented: $showsVolumeControl) {
+ volumeSheet
+ .presentationDetents([.height(180)])
+ .presentationDragIndicator(.visible)
+ }
+ }
+
+ private var displayedTab: AppState.EditorTab {
+ appState.editorTab == .media ? .edit : appState.editorTab
+ }
+
+ private func editorContent(for project: OpenReelProject) -> some View {
+ VStack(spacing: 0) {
+ topBar(project: project)
+ .padding(.top, 4)
+ .padding(.bottom, 6)
+
+ previewStage(for: project)
+
+ timecodeBar(for: project)
+ .padding(.top, 6)
+ .padding(.bottom, 4)
+
+ transportBar(for: project)
+ .padding(.bottom, 6)
+
+ timeline(for: project)
+
+ lowerPanel()
+ }
+ }
+
+ private var emptyState: some View {
+ VStack(spacing: 18) {
+ Image(systemName: "film.stack")
+ .font(.system(size: 32, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.accent)
+ Text("Create a project to start editing")
+ .font(.system(size: 20, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ Button("New Project") {
+ appState.presentNewProjectSheet()
+ }
+ .buttonStyle(.plain)
+ .font(.system(size: 14, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.accent)
+ }
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
+ }
+
+ private func topBar(project: OpenReelProject) -> some View {
+ HStack(spacing: 12) {
+ Button {
+ playbackController.pause()
+ appState.closeEditor()
+ } label: {
+ Image(systemName: "chevron.left")
+ .font(.system(size: 16, weight: .bold))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .frame(width: 42, height: 42)
+ .background(OpenReelTheme.surfaceElevated, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
+ }
+ .buttonStyle(.plain)
+
+ VStack(alignment: .leading, spacing: 4) {
+ Text(project.name)
+ .font(.system(size: 18, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .lineLimit(1)
+
+ Text(projectSubtitle(project))
+ .font(.system(size: 11, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ .lineLimit(1)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+
+ HStack(spacing: 8) {
+ historyButton(symbol: "arrow.uturn.backward", isEnabled: appState.canUndo) {
+ Task {
+ await appState.undo(playbackController: playbackController)
+ }
+ }
+ historyButton(symbol: "arrow.uturn.forward", isEnabled: appState.canRedo) {
+ Task {
+ await appState.redo(playbackController: playbackController)
+ }
+ }
+
+ Button {
+ } label: {
+ Image(systemName: "square.and.arrow.up.fill")
+ .font(.system(size: 16, weight: .bold))
+ .foregroundStyle(.white)
+ .frame(width: 44, height: 44)
+ .background(OpenReelTheme.accent, in: RoundedRectangle(cornerRadius: 15, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ .padding(.horizontal, 16)
+ .padding(.vertical, 12)
+ .background(OpenReelTheme.surface.opacity(0.96), in: RoundedRectangle(cornerRadius: 20, style: .continuous))
+ .overlay {
+ RoundedRectangle(cornerRadius: 20, style: .continuous)
+ .strokeBorder(Color.white.opacity(0.05), lineWidth: 1)
+ }
+ .padding(.horizontal, 16)
+ }
+
+ private func previewStage(for project: OpenReelProject) -> some View {
+ ZStack {
+ RoundedRectangle(cornerRadius: 12, style: .continuous)
+ .fill(Color.black)
+ .overlay {
+ if playbackController.player != nil {
+ MetalVideoView(player: playbackController.player)
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
+ .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
+ } else {
+ placeholderPreview(project: project)
+ }
+ }
+ .overlay {
+ RoundedRectangle(cornerRadius: 12, style: .continuous)
+ .strokeBorder(Color.white.opacity(0.08), lineWidth: 1)
+ }
+ .aspectRatio(appState.selectedAspectRatio.value, contentMode: .fit)
+ }
+ .frame(maxWidth: .infinity)
+ .frame(maxHeight: 240)
+ .padding(.horizontal, 16)
+ }
+
+ private func placeholderPreview(project: OpenReelProject) -> some View {
+ ZStack {
+ appState.style(for: project).gradient
+ .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
+
+ VStack(spacing: 10) {
+ Image(systemName: "video.badge.plus")
+ .font(.system(size: 28, weight: .semibold))
+ .foregroundStyle(.white)
+ Text("Import a video from Media")
+ .font(.system(size: 14, weight: .semibold, design: .rounded))
+ .foregroundStyle(.white)
+ Text("Preview activates after first import.")
+ .font(.system(size: 12, weight: .medium, design: .rounded))
+ .foregroundStyle(Color.white.opacity(0.7))
+ }
+ }
+ }
+
+ private func timecodeBar(for project: OpenReelProject) -> some View {
+ HStack {
+ Text(playbackController.currentTime.openReelClock(frameRate: project.settings.frameRate))
+ .font(.system(size: 13, weight: .bold, design: .monospaced))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .fixedSize(horizontal: true, vertical: false)
+
+ Spacer()
+
+ Menu {
+ ForEach(AppState.AspectRatio.allCases) { aspectRatio in
+ Button {
+ appState.selectedAspectRatio = aspectRatio
+ } label: {
+ Label(aspectRatio.rawValue, systemImage: aspectRatioSymbol(for: aspectRatio))
+ }
+ }
+ } label: {
+ HStack(spacing: 4) {
+ Text(appState.selectedAspectRatio.rawValue)
+ .font(.system(size: 12, weight: .semibold, design: .rounded))
+ Image(systemName: "chevron.up.chevron.down")
+ .font(.system(size: 9, weight: .bold))
+ }
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ .fixedSize(horizontal: true, vertical: false)
+ }
+ }
+ .padding(.horizontal, 20)
+ }
+
+ private var hasTimelineContent: Bool {
+ guard let project = appState.currentProject else { return false }
+ return project.allClips.contains { !$0.mediaId.isEmpty }
+ }
+
+ private func transportBar(for project: OpenReelProject) -> some View {
+ HStack(spacing: 0) {
+ transportButton(symbol: "backward.frame.fill", isEnabled: hasTimelineContent) {
+ if playbackController.player == nil {
+ appState.syncPlayback(with: playbackController)
+ }
+ playbackController.step(frames: -1)
+ }
+
+ Spacer()
+
+ Button {
+ if playbackController.player == nil {
+ appState.syncPlayback(with: playbackController)
+ }
+ playbackController.togglePlayback()
+ } label: {
+ Image(systemName: playbackController.isPlaying ? "pause.fill" : "play.fill")
+ .font(.system(size: 16, weight: .bold))
+ .foregroundStyle(.white)
+ .frame(width: 44, height: 44)
+ .background(OpenReelTheme.accent, in: Circle())
+ }
+ .buttonStyle(.plain)
+ .disabled(!hasTimelineContent)
+
+ Spacer()
+
+ transportButton(symbol: "forward.frame.fill", isEnabled: hasTimelineContent) {
+ if playbackController.player == nil {
+ appState.syncPlayback(with: playbackController)
+ }
+ playbackController.step(frames: 1)
+ }
+
+ Spacer()
+
+ Button {
+ if playbackController.volume > 0 {
+ playbackController.setVolume(0)
+ } else {
+ playbackController.setVolume(1)
+ }
+ } label: {
+ Image(systemName: volumeIcon)
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .frame(width: 36, height: 36)
+ }
+ .buttonStyle(.plain)
+ .simultaneousGesture(
+ LongPressGesture(minimumDuration: 0.4).onEnded { _ in
+ showsVolumeControl = true
+ }
+ )
+
+ Spacer()
+
+ Button {
+ showsVolumeControl = true
+ } label: {
+ Text("\(Int(playbackController.volume * 100))%")
+ .font(.system(size: 11, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ .frame(width: 36, height: 36)
+ }
+ .buttonStyle(.plain)
+ }
+ .padding(.horizontal, 20)
+ .padding(.vertical, 4)
+ .frame(maxWidth: .infinity)
+ }
+
+ @State private var timelineScrollPosition = ScrollPosition(edge: .leading)
+
+ private func timeline(for project: OpenReelProject) -> some View {
+ GeometryReader { proxy in
+ let badgeWidth = 48.0
+ let badgeGap = 10.0
+ let duration = max(project.timeline.duration, 8)
+ let trackAreaWidth = proxy.size.width - badgeWidth - badgeGap - 24
+ let contentWidth = max(duration * appState.timelineZoom + 120, trackAreaWidth)
+ let rowSpacing = 8.0
+ let rulerHeight = 34.0
+ let trackHeights = project.sortedTracks.map(timelineLaneHeight(for:))
+ let tracksHeight = trackHeights.reduce(0, +) + Double(max(project.sortedTracks.count - 1, 0)) * rowSpacing
+ let playheadX = playbackController.currentTime * appState.timelineZoom
+
+ ScrollView(.vertical, showsIndicators: false) {
+ HStack(alignment: .top, spacing: badgeGap) {
+ VStack(spacing: rowSpacing) {
+ Color.clear.frame(height: rulerHeight)
+ ForEach(project.sortedTracks) { track in
+ trackBadge(for: track)
+ }
+ }
+ .frame(width: badgeWidth)
+
+ ScrollView(.horizontal, showsIndicators: false) {
+ ZStack(alignment: .topLeading) {
+ VStack(alignment: .leading, spacing: rowSpacing) {
+ timelineRuler(duration: duration, contentWidth: contentWidth, laneInset: 0, frameRate: project.settings.frameRate)
+ .frame(height: rulerHeight)
+
+ ForEach(project.sortedTracks) { track in
+ timelineTrackLane(for: project, track: track, contentWidth: contentWidth)
+ }
+ }
+ .frame(width: contentWidth, alignment: .leading)
+
+ playheadView(x: playheadX, height: rulerHeight + rowSpacing + tracksHeight)
+ .offset(y: rulerHeight)
+ }
+ .frame(width: contentWidth, alignment: .topLeading)
+ .contentShape(Rectangle())
+ .onTapGesture { location in
+ let tappedTime = max(0, location.x / appState.timelineZoom)
+ playbackController.pause()
+ playbackController.seek(to: min(tappedTime, duration))
+ }
+ }
+ .scrollPosition($timelineScrollPosition)
+ .onChange(of: playbackController.currentTime) { _, newTime in
+ guard playbackController.isPlaying else { return }
+ let targetX = newTime * appState.timelineZoom
+ let visibleCenter = trackAreaWidth * 0.5
+ let scrollOffset = max(0, targetX - visibleCenter)
+ timelineScrollPosition.scrollTo(x: scrollOffset)
+ }
+ }
+ .padding(.bottom, 8)
+ }
+ .padding(.horizontal, 12)
+ .gesture(
+ MagnifyGesture()
+ .onChanged { value in
+ let newZoom = appState.timelineZoom * value.magnification
+ appState.timelineZoom = min(max(newZoom, 20), 300)
+ }
+ )
+ }
+ .frame(maxHeight: .infinity)
+ .background(OpenReelTheme.surface.opacity(0.5))
+ .overlay(alignment: .top) {
+ Rectangle()
+ .fill(Color.white.opacity(0.04))
+ .frame(height: 1)
+ }
+ }
+
+ private func timelineRuler(duration: Double, contentWidth: Double, laneInset: Double, frameRate: Double) -> some View {
+ let step = duration <= 15 ? 2.0 : duration <= 45 ? 5.0 : 10.0
+ let marks = stride(from: 0.0, through: max(duration, step), by: step).map { $0 }
+
+ return ZStack(alignment: .topLeading) {
+ Rectangle()
+ .fill(Color.clear)
+ .frame(width: contentWidth, height: 34)
+
+ ForEach(marks, id: \.self) { mark in
+ VStack(alignment: .leading, spacing: 4) {
+ Text(mark.shortClock())
+ .font(.system(size: 11, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ Rectangle()
+ .fill(Color.white.opacity(0.14))
+ .frame(width: 1, height: 12)
+ }
+ .offset(x: laneInset + mark * appState.timelineZoom, y: 8)
+ }
+
+ Text(playbackController.currentTime.openReelClock(frameRate: frameRate))
+ .font(.system(size: 11, weight: .bold, design: .monospaced))
+ .foregroundStyle(.black)
+ .padding(.horizontal, 8)
+ .padding(.vertical, 4)
+ .background(OpenReelTheme.accent, in: Capsule())
+ .offset(x: max(laneInset + playbackController.currentTime * appState.timelineZoom - 34, laneInset), y: 0)
+ }
+ }
+
+ @ViewBuilder
+ private func timelineTrackLane(for project: OpenReelProject, track: OpenReelProject.Track, contentWidth: Double) -> some View {
+ if track.type == .audio {
+ audioTrackLane(track: track, contentWidth: contentWidth)
+ } else {
+ visualTrackLane(for: project, track: track, contentWidth: contentWidth)
+ }
+ }
+
+ @ViewBuilder
+ private func visualTrackLane(for project: OpenReelProject, track: OpenReelProject.Track, contentWidth: Double) -> some View {
+ let clips = track.clips.sorted { $0.startTime < $1.startTime }
+
+ if clips.isEmpty {
+ Button {
+ showsMediaLibrarySheet = true
+ } label: {
+ HStack(spacing: 10) {
+ Image(systemName: emptyLaneSymbol(for: track.type))
+ .font(.system(size: 15, weight: .bold))
+ .foregroundStyle(OpenReelTheme.accent)
+ Text(emptyLaneTitle(for: track.type))
+ .font(.system(size: 13, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ .frame(width: contentWidth, height: timelineLaneHeight(for: track), alignment: .leading)
+ .padding(.horizontal, 18)
+ .background(OpenReelTheme.surfaceElevated, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ } else {
+ ZStack(alignment: .leading) {
+ RoundedRectangle(cornerRadius: 16, style: .continuous)
+ .fill(Color.white.opacity(0.02))
+ .frame(width: contentWidth, height: timelineLaneHeight(for: track))
+
+ ForEach(clips) { clip in
+ TimelineClipBlock(
+ project: project,
+ clip: clip,
+ pixelsPerSecond: appState.timelineZoom,
+ isSelected: appState.selectedClipID == clip.id
+ )
+ .offset(x: clip.startTime * appState.timelineZoom)
+ .onTapGesture {
+ appState.selectClip(clip)
+ if let mediaItem = appState.mediaItem(for: clip.mediaId, in: project),
+ let url = appState.mediaURL(for: mediaItem, in: project) {
+ playbackController.loadVideo(url: url, duration: clip.duration, frameRate: project.settings.frameRate)
+ playbackController.seek(to: 0)
+ }
+ }
+ }
+ }
+ .frame(width: contentWidth, height: timelineLaneHeight(for: track), alignment: .leading)
+ }
+ }
+
+ @ViewBuilder
+ private func audioTrackLane(track: OpenReelProject.Track, contentWidth: Double) -> some View {
+ let audioClips = track.clips.sorted { $0.startTime < $1.startTime }
+
+ if audioClips.isEmpty {
+ HStack(spacing: 10) {
+ Image(systemName: "waveform.badge.plus")
+ .font(.system(size: 15, weight: .bold))
+ .foregroundStyle(OpenReelTheme.accent)
+ Text("Add Audio")
+ .font(.system(size: 13, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ .frame(width: contentWidth, height: timelineLaneHeight(for: track), alignment: .leading)
+ .padding(.horizontal, 18)
+ .background(OpenReelTheme.surfaceElevated, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ } else {
+ ZStack(alignment: .leading) {
+ RoundedRectangle(cornerRadius: 16, style: .continuous)
+ .fill(Color.white.opacity(0.02))
+ .frame(width: contentWidth, height: timelineLaneHeight(for: track))
+
+ ForEach(audioClips) { clip in
+ TimelineAudioClipBlock(
+ clip: clip,
+ pixelsPerSecond: appState.timelineZoom,
+ isSelected: appState.selectedClipID == clip.id
+ )
+ .offset(x: clip.startTime * appState.timelineZoom)
+ .onTapGesture {
+ appState.selectClip(clip)
+ }
+ }
+ }
+ .frame(width: contentWidth, height: timelineLaneHeight(for: track), alignment: .leading)
+ }
+ }
+
+ private func trackBadge(for track: OpenReelProject.Track) -> some View {
+ Image(systemName: trackSymbol(for: track.type))
+ .font(.system(size: 17, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.accent)
+ .frame(width: 48, height: timelineLaneHeight(for: track))
+ .background(OpenReelTheme.surfaceElevated, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ }
+
+ private func playheadView(x: Double, height: Double) -> some View {
+ VStack(spacing: 0) {
+ RoundedRectangle(cornerRadius: 4, style: .continuous)
+ .fill(OpenReelTheme.accent)
+ .frame(width: 14, height: 18)
+ Rectangle()
+ .fill(OpenReelTheme.accent)
+ .frame(width: 2, height: max(height - 18, 0))
+ }
+ .offset(x: x, y: 8)
+ .contentShape(Rectangle())
+ .gesture(
+ DragGesture(minimumDistance: 0)
+ .onChanged { value in
+ if playheadDragStartTime == nil {
+ playheadDragStartTime = playbackController.currentTime
+ playbackController.pause()
+ }
+
+ let baseTime = playheadDragStartTime ?? 0
+ let targetTime = baseTime + Double(value.translation.width) / appState.timelineZoom
+ playbackController.seek(to: targetTime)
+ }
+ .onEnded { _ in
+ playheadDragStartTime = nil
+ }
+ )
+ }
+
+ private func lowerPanel() -> some View {
+ VStack(spacing: 0) {
+ if displayedTab == .edit {
+ GeometryReader { geo in
+ ScrollView(.horizontal, showsIndicators: false) {
+ HStack(spacing: 0) {
+ ForEach(editActions, id: \.title) { action in
+ VStack(spacing: 6) {
+ Image(systemName: action.symbol)
+ .font(.system(size: 20, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ Text(action.title)
+ .font(.system(size: 10, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ .frame(maxWidth: .infinity)
+ .frame(height: 56)
+ }
+ }
+ .frame(minWidth: geo.size.width)
+ .padding(.vertical, 6)
+ }
+ }
+ .frame(height: 68)
+ } else {
+ genericTabPanel(for: displayedTab)
+ .padding(.horizontal, 16)
+ .padding(.vertical, 10)
+ }
+
+ Divider()
+ .overlay(Color.white.opacity(0.04))
+
+ HStack(spacing: 0) {
+ ForEach(AppState.EditorTab.allCases) { tab in
+ Button {
+ if tab == .media {
+ showsMediaLibrarySheet = true
+ } else {
+ appState.editorTab = tab
+ }
+ } label: {
+ VStack(spacing: 8) {
+ Image(systemName: symbol(for: tab))
+ .font(.system(size: 18, weight: .semibold))
+ Text(tab.rawValue)
+ .font(.system(size: 10, weight: .medium, design: .rounded))
+ }
+ .foregroundStyle(isTabSelected(tab) ? OpenReelTheme.accent : OpenReelTheme.textSecondary)
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 12)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+ .background(OpenReelTheme.surfaceElevated)
+ .overlay(alignment: .top) {
+ Rectangle()
+ .fill(Color.white.opacity(0.04))
+ .frame(height: 1)
+ }
+ }
+
+ private func mediaLibrarySheet(for project: OpenReelProject) -> some View {
+ NavigationStack {
+ ScrollView {
+ VStack(alignment: .leading, spacing: 16) {
+ Button {
+ openMediaImporterFromSheet()
+ } label: {
+ HStack(spacing: 10) {
+ Image(systemName: "plus.circle.fill")
+ .font(.system(size: 18, weight: .semibold))
+ Text("Import From Photos")
+ .font(.system(size: 15, weight: .semibold, design: .rounded))
+ Spacer()
+ Image(systemName: "chevron.right")
+ .font(.system(size: 12, weight: .bold))
+ .foregroundStyle(.white.opacity(0.6))
+ }
+ .foregroundStyle(.white)
+ .padding(.horizontal, 16)
+ .padding(.vertical, 14)
+ .background(OpenReelTheme.accent, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
+ }
+ .buttonStyle(.plain)
+
+ if project.mediaLibrary.items.isEmpty {
+ VStack(spacing: 16) {
+ Image(systemName: "photo.on.rectangle.angled")
+ .font(.system(size: 36, weight: .light))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ Text("No media imported yet")
+ .font(.system(size: 15, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ Text("Import videos from your Photo Library to start editing.")
+ .font(.system(size: 13, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ .multilineTextAlignment(.center)
+ }
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 40)
+ } else {
+ LazyVGrid(columns: [GridItem(.flexible(), spacing: 10), GridItem(.flexible(), spacing: 10)], spacing: 10) {
+ ForEach(project.mediaLibrary.items) { mediaItem in
+ VStack(alignment: .leading, spacing: 0) {
+ mediaTile(project: project, mediaItem: mediaItem)
+ .frame(maxWidth: .infinity)
+ .aspectRatio(16.0 / 10.0, contentMode: .fit)
+ .clipped()
+ .overlay(alignment: .bottomTrailing) {
+ Text(TimeInterval(mediaItem.metadata.duration).shortClock())
+ .font(.system(size: 10, weight: .bold, design: .monospaced))
+ .foregroundStyle(.white)
+ .padding(.horizontal, 6)
+ .padding(.vertical, 3)
+ .background(Color.black.opacity(0.6), in: Capsule())
+ .padding(6)
+ }
+
+ VStack(alignment: .leading, spacing: 3) {
+ Text(mediaItem.name)
+ .font(.system(size: 12, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .lineLimit(1)
+
+ Text(mediaItem.metadata.codec.uppercased())
+ .font(.system(size: 10, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ .padding(.horizontal, 8)
+ .padding(.vertical, 8)
+ }
+ .background(OpenReelTheme.surfaceElevated)
+ .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
+ }
+ }
+ }
+ }
+ .padding(16)
+ }
+ .navigationTitle("Media")
+ .navigationBarTitleDisplayMode(.inline)
+ .background(OpenReelTheme.background.ignoresSafeArea())
+ .toolbar {
+ ToolbarItem(placement: .topBarLeading) {
+ Button {
+ showsMediaLibrarySheet = false
+ } label: {
+ Image(systemName: "xmark")
+ .font(.system(size: 13, weight: .bold))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ }
+ }
+ }
+ .presentationDetents([.medium, .large])
+ .presentationDragIndicator(.visible)
+ .fullScreenCover(isPresented: $showsPhotoPickerInSheet) {
+ MediaPicker(
+ onCancel: {
+ showsPhotoPickerInSheet = false
+ },
+ onPick: { assets in
+ showsPhotoPickerInSheet = false
+ showsMediaLibrarySheet = false
+ Task {
+ await appState.importMedia(assets, playbackController: playbackController)
+ }
+ }
+ )
+ .ignoresSafeArea()
+ }
+ }
+
+ private func openMediaImporterFromSheet() {
+ showsPhotoPickerInSheet = true
+ }
+
+ @ViewBuilder
+ private func mediaTile(project: OpenReelProject, mediaItem: OpenReelProject.MediaItem) -> some View {
+ if let thumbnailURL = appState.thumbnailURL(for: mediaItem.thumbnailUrl, in: project) {
+ AsyncImage(url: thumbnailURL) { phase in
+ switch phase {
+ case .success(let image):
+ image
+ .resizable()
+ .scaledToFill()
+ case .empty, .failure:
+ appState.style(for: project).gradient
+ @unknown default:
+ appState.style(for: project).gradient
+ }
+ }
+ .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
+ } else {
+ appState.style(for: project).gradient
+ .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
+ }
+ }
+
+ private func genericTabPanel(for tab: AppState.EditorTab) -> some View {
+ ScrollView(.horizontal, showsIndicators: false) {
+ HStack(spacing: 12) {
+ ForEach(panelItems(for: tab), id: \.title) { item in
+ VStack(alignment: .leading, spacing: 10) {
+ HStack {
+ Image(systemName: item.symbol)
+ .font(.system(size: 16, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.accent)
+ Spacer()
+ Text(item.tag)
+ .font(.system(size: 10, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ Text(item.title)
+ .font(.system(size: 14, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ Text(item.subtitle)
+ .font(.system(size: 12, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ .lineLimit(2)
+ }
+ .padding(14)
+ .frame(width: 168, alignment: .leading)
+ .background(OpenReelTheme.surface, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ }
+ }
+ }
+ }
+
+ private var volumeIcon: String {
+ if playbackController.volume == 0 {
+ return "speaker.slash.fill"
+ } else if playbackController.volume < 0.4 {
+ return "speaker.wave.1.fill"
+ } else {
+ return "speaker.wave.2.fill"
+ }
+ }
+
+ private var volumeSheet: some View {
+ VStack(spacing: 20) {
+ HStack {
+ Text("Volume")
+ .font(.system(size: 17, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ Spacer()
+ Text("\(Int(playbackController.volume * 100))%")
+ .font(.system(size: 15, weight: .semibold, design: .monospaced))
+ .foregroundStyle(OpenReelTheme.accent)
+ }
+
+ HStack(spacing: 12) {
+ Image(systemName: "speaker.fill")
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+
+ Slider(
+ value: Binding(
+ get: { Double(playbackController.volume) },
+ set: { playbackController.setVolume(Float($0)) }
+ ),
+ in: 0...1
+ )
+ .tint(OpenReelTheme.accent)
+
+ Image(systemName: "speaker.wave.3.fill")
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+
+ HStack(spacing: 12) {
+ volumePresetButton(label: "Mute", value: 0)
+ volumePresetButton(label: "50%", value: 0.5)
+ volumePresetButton(label: "100%", value: 1)
+ }
+ }
+ .padding(20)
+ .background(OpenReelTheme.background.ignoresSafeArea())
+ }
+
+ private func volumePresetButton(label: String, value: Float) -> some View {
+ Button {
+ playbackController.setVolume(value)
+ } label: {
+ Text(label)
+ .font(.system(size: 13, weight: .semibold, design: .rounded))
+ .foregroundStyle(abs(playbackController.volume - value) < 0.01 ? OpenReelTheme.accent : OpenReelTheme.textSecondary)
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 10)
+ .background(
+ abs(playbackController.volume - value) < 0.01 ? OpenReelTheme.accent.opacity(0.12) : OpenReelTheme.surfaceElevated,
+ in: RoundedRectangle(cornerRadius: 10, style: .continuous)
+ )
+ }
+ .buttonStyle(.plain)
+ }
+
+ private func historyButton(symbol: String, isEnabled: Bool, action: @escaping () -> Void) -> some View {
+ Button(action: action) {
+ Image(systemName: symbol)
+ .font(.system(size: 15, weight: .semibold))
+ .foregroundStyle(isEnabled ? OpenReelTheme.textPrimary : OpenReelTheme.textSecondary.opacity(0.35))
+ .frame(width: 38, height: 38)
+ .background(OpenReelTheme.surfaceElevated, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ .disabled(!isEnabled)
+ }
+
+ private func transportButton(symbol: String, isEnabled: Bool, action: @escaping () -> Void) -> some View {
+ Button(action: action) {
+ Image(systemName: symbol)
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(isEnabled ? OpenReelTheme.textPrimary : OpenReelTheme.textSecondary.opacity(0.35))
+ .frame(width: 36, height: 36)
+ .background(OpenReelTheme.surfaceElevated, in: Circle())
+ }
+ .buttonStyle(.plain)
+ .disabled(!isEnabled)
+ }
+
+ private func isTabSelected(_ tab: AppState.EditorTab) -> Bool {
+ if tab == .media {
+ return showsMediaLibrarySheet
+ }
+ return displayedTab == tab
+ }
+
+ private func symbol(for tab: AppState.EditorTab) -> String {
+ switch tab {
+ case .edit:
+ return "scissors"
+ case .media:
+ return "photo.on.rectangle"
+ case .text:
+ return "textformat"
+ case .effects:
+ return "wand.and.stars"
+ case .audio:
+ return "music.note"
+ }
+ }
+
+ private func panelItems(for tab: AppState.EditorTab) -> [(title: String, subtitle: String, symbol: String, tag: String)] {
+ switch tab {
+ case .edit:
+ return []
+ case .media:
+ return []
+ case .text:
+ return [
+ ("Title Presets", "Phase 1 keeps the shell ready for text overlays and captions.", "character.textbox", "TEXT"),
+ ("Captions", "Subtitles and text clips arrive in the next phase.", "captions.bubble", "NEXT"),
+ ("Animation", "The editor already reserves the bottom tab surface for text tooling.", "sparkles.square.filled.on.square", "READY")
+ ]
+ case .effects:
+ return [
+ ("Looks", "Color pipelines and LUTs land after the foundation milestone.", "camera.filters", "FX"),
+ ("Adjust", "Exposure and contrast controls are staged on this tab shell.", "dial.high", "COLOR"),
+ ("Stack", "Effect ordering will plug into the same project model later.", "square.stack.3d.down.right", "PLAN")
+ ]
+ case .audio:
+ return [
+ ("Music", "Phase 1 preserves video audio through AVPlayer playback.", "music.note.list", "AUDIO"),
+ ("Voiceover", "Dedicated recording arrives after the timeline foundation.", "mic", "NEXT"),
+ ("Cleanup", "Noise reduction and ducking build on the stored media model next.", "waveform.path.ecg.rectangle", "PLAN")
+ ]
+ }
+ }
+
+ private func projectSubtitle(_ project: OpenReelProject) -> String {
+ let resolution = "\(project.settings.width)x\(project.settings.height)"
+ let fps = "\(Int(project.settings.frameRate))fps"
+ if let lastSavedAt = appState.lastSavedAt {
+ return "\(resolution) · \(fps) · Saved \(lastSavedAt.formatted(date: .omitted, time: .shortened))"
+ }
+ return "\(resolution) · \(fps)"
+ }
+
+ private func timelineLaneHeight(for track: OpenReelProject.Track) -> Double {
+ track.type == .audio ? 64 : 74
+ }
+
+ private func trackSymbol(for type: OpenReelProject.TrackType) -> String {
+ switch type {
+ case .video:
+ return "film.stack"
+ case .audio:
+ return "waveform"
+ case .image:
+ return "photo.stack"
+ case .text:
+ return "textformat"
+ case .graphics:
+ return "sparkles"
+ }
+ }
+
+ private func emptyLaneSymbol(for type: OpenReelProject.TrackType) -> String {
+ switch type {
+ case .video:
+ return "plus.rectangle.on.folder"
+ case .audio:
+ return "waveform.badge.plus"
+ case .image:
+ return "photo.badge.plus"
+ case .text:
+ return "plus.bubble"
+ case .graphics:
+ return "sparkles.square.filled.on.square"
+ }
+ }
+
+ private func emptyLaneTitle(for type: OpenReelProject.TrackType) -> String {
+ switch type {
+ case .video:
+ return "Open Media Sheet"
+ case .audio:
+ return "Add Audio"
+ case .image:
+ return "Open Media Sheet"
+ case .text:
+ return "Add Text"
+ case .graphics:
+ return "Add Graphic"
+ }
+ }
+
+ private func aspectRatioSymbol(for aspectRatio: AppState.AspectRatio) -> String {
+ switch aspectRatio {
+ case .landscape:
+ return "rectangle.ratio.16.to.9"
+ case .portrait:
+ return "rectangle.portrait"
+ case .square:
+ return "square"
+ case .vertical:
+ return "rectangle.portrait.and.arrow.right"
+ case .standard:
+ return "rectangle"
+ }
+ }
+}
+
+private struct TimelineClipBlock: View {
+ @Environment(AppState.self) private var appState
+
+ let project: OpenReelProject
+ let clip: OpenReelProject.Clip
+ let pixelsPerSecond: Double
+ let isSelected: Bool
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 6) {
+ Text(mediaItem?.name ?? "Clip")
+ .font(.system(size: 12, weight: .semibold, design: .rounded))
+ .foregroundStyle(.white)
+ .lineLimit(1)
+
+ Text(TimeInterval(clip.duration).shortClock())
+ .font(.system(size: 10, weight: .medium, design: .rounded))
+ .foregroundStyle(Color.white.opacity(0.82))
+
+ HStack(spacing: 3) {
+ if thumbnailURLs.isEmpty {
+ ForEach(0..<8) { index in
+ RoundedRectangle(cornerRadius: 4, style: .continuous)
+ .fill(Color.white.opacity(index.isMultiple(of: 2) ? 0.16 : 0.28))
+ .frame(width: thumbnailWidth, height: 22)
+ }
+ } else {
+ ForEach(Array(thumbnailURLs.enumerated()), id: \.offset) { _, url in
+ AsyncImage(url: url) { phase in
+ switch phase {
+ case .success(let image):
+ image
+ .resizable()
+ .scaledToFill()
+ case .empty, .failure:
+ Rectangle()
+ .fill(Color.white.opacity(0.18))
+ @unknown default:
+ Rectangle()
+ .fill(Color.white.opacity(0.18))
+ }
+ }
+ .frame(width: thumbnailWidth, height: 22)
+ .clipShape(RoundedRectangle(cornerRadius: 4, style: .continuous))
+ }
+ }
+ }
+ }
+ .padding(12)
+ .frame(width: clipWidth, height: 72, alignment: .leading)
+ .background(appState.style(for: project).gradient, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
+ .overlay {
+ RoundedRectangle(cornerRadius: 14, style: .continuous)
+ .strokeBorder(isSelected ? OpenReelTheme.accent : Color.white.opacity(0.06), lineWidth: isSelected ? 2 : 1)
+ }
+ }
+
+ private var mediaItem: OpenReelProject.MediaItem? {
+ appState.mediaItem(for: clip.mediaId, in: project)
+ }
+
+ private var thumbnailURLs: [URL] {
+ mediaItem?.filmstripThumbnails?
+ .compactMap { appState.thumbnailURL(for: $0.url, in: project) } ?? []
+ }
+
+ private var clipWidth: CGFloat {
+ max(CGFloat(clip.duration * pixelsPerSecond), 160)
+ }
+
+ private var thumbnailWidth: CGFloat {
+ let count = max(thumbnailURLs.count, 8)
+ return max((clipWidth - 24 - CGFloat(count - 1) * 3) / CGFloat(count), 18)
+ }
+}
+
+private struct TimelineAudioClipBlock: View {
+ let clip: OpenReelProject.Clip
+ let pixelsPerSecond: Double
+ let isSelected: Bool
+
+ var body: some View {
+ HStack(spacing: 3) {
+ ForEach(0..<24) { index in
+ Capsule()
+ .fill(Color.white.opacity(0.28))
+ .frame(width: 4, height: index.isMultiple(of: 3) ? 14 : 24)
+ }
+ }
+ .padding(12)
+ .frame(width: max(CGFloat(clip.duration * pixelsPerSecond), 160), height: 60, alignment: .leading)
+ .background(Color(red: 0.36, green: 0.24, blue: 0.10), in: RoundedRectangle(cornerRadius: 14, style: .continuous))
+ .overlay {
+ RoundedRectangle(cornerRadius: 14, style: .continuous)
+ .strokeBorder(isSelected ? OpenReelTheme.accent : Color.white.opacity(0.06), lineWidth: isSelected ? 2 : 1)
+ }
+ }
+}
+
+#Preview {
+ EditorView()
+ .environment(AppState())
+ .environment(PlaybackController())
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/Features/Media/MediaPicker.swift b/Openreel Video/Openreel Video/Features/Media/MediaPicker.swift
new file mode 100644
index 00000000..314ed5f7
--- /dev/null
+++ b/Openreel Video/Openreel Video/Features/Media/MediaPicker.swift
@@ -0,0 +1,164 @@
+import AVFoundation
+import Foundation
+import PhotosUI
+import SwiftUI
+import UniformTypeIdentifiers
+
+struct MediaPicker: UIViewControllerRepresentable {
+ var selectionLimit: Int = 0
+ var onCancel: () -> Void
+ var onPick: ([ImportedMediaAsset]) -> Void
+
+ func makeUIViewController(context: Context) -> PHPickerViewController {
+ var configuration = PHPickerConfiguration(photoLibrary: .shared())
+ configuration.filter = .any(of: [.videos, .images, .livePhotos])
+ configuration.selectionLimit = selectionLimit
+ configuration.preferredAssetRepresentationMode = .current
+ configuration.selection = .ordered
+
+ let controller = PHPickerViewController(configuration: configuration)
+ controller.delegate = context.coordinator
+ return controller
+ }
+
+ func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) {}
+
+ func makeCoordinator() -> Coordinator {
+ Coordinator(onCancel: onCancel, onPick: onPick)
+ }
+
+ final class Coordinator: NSObject, PHPickerViewControllerDelegate {
+ private let onCancel: () -> Void
+ private let onPick: ([ImportedMediaAsset]) -> Void
+
+ init(onCancel: @escaping () -> Void, onPick: @escaping ([ImportedMediaAsset]) -> Void) {
+ self.onCancel = onCancel
+ self.onPick = onPick
+ }
+
+ func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {
+ picker.dismiss(animated: true)
+
+ guard !results.isEmpty else {
+ onCancel()
+ return
+ }
+
+ Task {
+ var importedAssets: [ImportedMediaAsset] = []
+
+ for result in results {
+ guard let asset = try? await loadAsset(from: result) else {
+ continue
+ }
+ importedAssets.append(asset)
+ }
+
+ await MainActor.run {
+ if importedAssets.isEmpty {
+ onCancel()
+ } else {
+ onPick(importedAssets)
+ }
+ }
+ }
+ }
+
+ private func loadAsset(from result: PHPickerResult) async throws -> ImportedMediaAsset {
+ let provider = result.itemProvider
+
+ if provider.hasItemConformingToTypeIdentifier(UTType.movie.identifier) {
+ return try await loadFileAsset(from: provider, typeIdentifier: UTType.movie.identifier, mediaType: .video)
+ } else if provider.hasItemConformingToTypeIdentifier(UTType.video.identifier) {
+ return try await loadFileAsset(from: provider, typeIdentifier: UTType.video.identifier, mediaType: .video)
+ } else if provider.hasItemConformingToTypeIdentifier(UTType.image.identifier) {
+ return try await loadFileAsset(from: provider, typeIdentifier: UTType.image.identifier, mediaType: .image)
+ } else if provider.hasItemConformingToTypeIdentifier(UTType.audio.identifier) {
+ return try await loadFileAsset(from: provider, typeIdentifier: UTType.audio.identifier, mediaType: .audio)
+ }
+
+ throw MediaPickerError.unsupportedType
+ }
+
+ private func loadFileAsset(
+ from provider: NSItemProvider,
+ typeIdentifier: String,
+ mediaType: ImportedMediaType
+ ) async throws -> ImportedMediaAsset {
+ let tempURL = try await provider.loadFileRepresentation(forTypeIdentifier: typeIdentifier)
+ let suggestedName = provider.suggestedName ?? tempURL.lastPathComponent
+ let fileName = Self.fileNameWithExtension(suggestedName, fallbackURL: tempURL, typeIdentifier: typeIdentifier)
+
+ return ImportedMediaAsset(
+ sourceURL: tempURL,
+ fileName: fileName,
+ assetIdentifier: provider.suggestedName,
+ mediaType: mediaType
+ )
+ }
+
+ private static func fileNameWithExtension(
+ _ suggestedName: String,
+ fallbackURL: URL,
+ typeIdentifier: String
+ ) -> String {
+ let nameURL = URL(fileURLWithPath: suggestedName)
+ if !nameURL.pathExtension.isEmpty {
+ return suggestedName
+ }
+
+ let fallbackExtension = fallbackURL.pathExtension
+ if !fallbackExtension.isEmpty {
+ return suggestedName + "." + fallbackExtension
+ }
+
+ if let type = UTType(typeIdentifier),
+ let preferredExtension = type.preferredFilenameExtension {
+ return suggestedName + "." + preferredExtension
+ }
+
+ return suggestedName
+ }
+ }
+}
+
+enum MediaPickerError: LocalizedError {
+ case unsupportedType
+
+ var errorDescription: String? {
+ switch self {
+ case .unsupportedType:
+ return "The selected file type is not supported."
+ }
+ }
+}
+
+private extension NSItemProvider {
+ func loadFileRepresentation(forTypeIdentifier typeIdentifier: String) async throws -> URL {
+ try await withCheckedThrowingContinuation { continuation in
+ _ = loadFileRepresentation(forTypeIdentifier: typeIdentifier) { url, error in
+ if let error {
+ continuation.resume(throwing: error)
+ return
+ }
+
+ guard let url else {
+ continuation.resume(throwing: CocoaError(.fileNoSuchFile))
+ return
+ }
+
+ let tempDirectory = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
+ let copiedURL = tempDirectory
+ .appendingPathComponent(UUID().uuidString, isDirectory: false)
+ .appendingPathExtension(url.pathExtension)
+
+ do {
+ try FileManager.default.copyItem(at: url, to: copiedURL)
+ continuation.resume(returning: copiedURL)
+ } catch {
+ continuation.resume(throwing: error)
+ }
+ }
+ }
+ }
+}
diff --git a/Openreel Video/Openreel Video/Features/Preview/MetalVideoView.swift b/Openreel Video/Openreel Video/Features/Preview/MetalVideoView.swift
new file mode 100644
index 00000000..b923f88c
--- /dev/null
+++ b/Openreel Video/Openreel Video/Features/Preview/MetalVideoView.swift
@@ -0,0 +1,46 @@
+import AVFoundation
+import SwiftUI
+import UIKit
+
+struct MetalVideoView: UIViewRepresentable {
+ var player: AVPlayer?
+
+ func makeUIView(context: Context) -> VideoPlayerUIView {
+ let view = VideoPlayerUIView()
+ view.setPlayer(player)
+ return view
+ }
+
+ func updateUIView(_ uiView: VideoPlayerUIView, context: Context) {
+ uiView.setPlayer(player)
+ }
+}
+
+final class VideoPlayerUIView: UIView {
+ private let playerLayer = AVPlayerLayer()
+ private weak var currentPlayer: AVPlayer?
+
+ override init(frame: CGRect) {
+ super.init(frame: frame)
+ backgroundColor = .black
+ playerLayer.videoGravity = .resizeAspect
+ playerLayer.backgroundColor = UIColor.black.cgColor
+ layer.addSublayer(playerLayer)
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ override func layoutSubviews() {
+ super.layoutSubviews()
+ playerLayer.frame = bounds
+ }
+
+ func setPlayer(_ player: AVPlayer?) {
+ guard currentPlayer !== player else { return }
+ currentPlayer = player
+ playerLayer.player = player
+ playerLayer.frame = bounds
+ }
+}
diff --git a/Openreel Video/Openreel Video/Features/Projects/NewProjectSheet.swift b/Openreel Video/Openreel Video/Features/Projects/NewProjectSheet.swift
new file mode 100644
index 00000000..0955e6c0
--- /dev/null
+++ b/Openreel Video/Openreel Video/Features/Projects/NewProjectSheet.swift
@@ -0,0 +1,121 @@
+import SwiftUI
+
+struct NewProjectSheet: View {
+ @Environment(AppState.self) private var appState
+
+ var body: some View {
+ @Bindable var appState = appState
+
+ NavigationStack {
+ ScrollView(showsIndicators: false) {
+ VStack(alignment: .leading, spacing: 24) {
+ VStack(alignment: .leading, spacing: 8) {
+ Text("New Project")
+ .font(.system(size: 24, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ Text("Pick a canvas and frame rate for your first edit.")
+ .font(.reelBody)
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+
+ VStack(alignment: .leading, spacing: 12) {
+ Text("Project Name")
+ .font(.reelSection)
+ .foregroundStyle(OpenReelTheme.textPrimary)
+
+ TextField("Project Name", text: $appState.newProjectConfiguration.name)
+ .textInputAutocapitalization(.words)
+ .padding(.horizontal, 16)
+ .frame(height: 52)
+ .background(OpenReelTheme.surface, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ }
+
+ VStack(alignment: .leading, spacing: 12) {
+ Text("Resolution")
+ .font(.reelSection)
+ .foregroundStyle(OpenReelTheme.textPrimary)
+
+ LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())], spacing: 12) {
+ ForEach(NewProjectConfiguration.presets) { preset in
+ Button {
+ appState.newProjectConfiguration.preset = preset
+ } label: {
+ VStack(alignment: .leading, spacing: 6) {
+ Text(preset.name)
+ .font(.system(size: 15, weight: .semibold, design: .rounded))
+ Text("\(preset.width) × \(preset.height)")
+ .font(.reelCaption)
+ }
+ .foregroundStyle(appState.newProjectConfiguration.preset == preset ? Color.black : OpenReelTheme.textPrimary)
+ .frame(maxWidth: .infinity, minHeight: 76, alignment: .leading)
+ .padding(.horizontal, 14)
+ .background(
+ appState.newProjectConfiguration.preset == preset ?
+ AnyShapeStyle(OpenReelTheme.accent) :
+ AnyShapeStyle(OpenReelTheme.surface)
+ , in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+
+ VStack(alignment: .leading, spacing: 12) {
+ Text("Frame Rate")
+ .font(.reelSection)
+ .foregroundStyle(OpenReelTheme.textPrimary)
+
+ HStack(spacing: 10) {
+ ForEach(NewProjectConfiguration.supportedFrameRates, id: \.self) { frameRate in
+ Button {
+ appState.newProjectConfiguration.frameRate = frameRate
+ } label: {
+ Text("\(Int(frameRate)) fps")
+ .font(.system(size: 13, weight: .semibold, design: .rounded))
+ .foregroundStyle(appState.newProjectConfiguration.frameRate == frameRate ? Color.black : OpenReelTheme.textPrimary)
+ .padding(.horizontal, 14)
+ .frame(height: 42)
+ .background(
+ appState.newProjectConfiguration.frameRate == frameRate ?
+ AnyShapeStyle(OpenReelTheme.accent) :
+ AnyShapeStyle(OpenReelTheme.surfaceElevated)
+ , in: Capsule())
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+
+ Button {
+ Task {
+ await appState.createProject()
+ }
+ } label: {
+ Text("Create Project")
+ .font(.system(size: 16, weight: .bold, design: .rounded))
+ .foregroundStyle(.white)
+ .frame(maxWidth: .infinity)
+ .frame(height: 54)
+ .background(OpenReelTheme.accent, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ }
+ .padding(20)
+ }
+ .background(OpenReelTheme.background.ignoresSafeArea())
+ .toolbar {
+ ToolbarItem(placement: .topBarTrailing) {
+ Button("Close") {
+ appState.dismissNewProjectSheet()
+ }
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ }
+ }
+ }
+}
+
+#Preview {
+ NewProjectSheet()
+ .environment(AppState())
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/HomeView.swift b/Openreel Video/Openreel Video/HomeView.swift
new file mode 100644
index 00000000..637b7f7a
--- /dev/null
+++ b/Openreel Video/Openreel Video/HomeView.swift
@@ -0,0 +1,328 @@
+import SwiftUI
+
+struct HomeView: View {
+ @Environment(AppState.self) private var appState
+
+ private let quickTools = [
+ (title: "Trim", symbol: "scissors"),
+ (title: "Crop", symbol: "crop"),
+ (title: "Speed", symbol: "gauge.with.dots.needle.33percent"),
+ (title: "Import", symbol: "square.and.arrow.down"),
+ (title: "Timeline", symbol: "timeline.selection")
+ ]
+
+ var body: some View {
+ ZStack {
+ OpenReelTheme.background
+ .ignoresSafeArea()
+
+ ScrollView(showsIndicators: false) {
+ VStack(alignment: .leading, spacing: 28) {
+ hero
+ recentProjectsSection
+ quickToolsSection
+ }
+ .padding(.horizontal, 20)
+ .padding(.top, 8)
+ .padding(.bottom, 52)
+ }
+ }
+ .navigationTitle("OpenReel")
+ .navigationBarTitleDisplayMode(.large)
+ .toolbarBackground(.visible, for: .navigationBar)
+ .toolbarBackground(OpenReelTheme.background, for: .navigationBar)
+ .toolbar {
+ ToolbarItem(placement: .topBarTrailing) {
+ Button {
+ appState.presentNewProjectSheet()
+ } label: {
+ Image(systemName: "plus")
+ .font(.system(size: 18, weight: .bold))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+
+ private var hero: some View {
+ HStack(alignment: .center, spacing: 18) {
+ VStack(alignment: .leading, spacing: 12) {
+ Text("Create\nwithout limits.")
+ .font(.reelDisplay)
+ .foregroundStyle(OpenReelTheme.textPrimary)
+
+ Text("Import a clip, build a timeline, and keep editing where you left off.")
+ .font(.reelBody)
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ .lineSpacing(2)
+ }
+
+ Spacer(minLength: 0)
+
+ HeroAnimation()
+ }
+ }
+
+ private var newProjectButton: some View {
+ Button {
+ appState.presentNewProjectSheet()
+ } label: {
+ VStack(spacing: 8) {
+ Image(systemName: "plus")
+ .font(.system(size: 22, weight: .bold))
+ .foregroundStyle(OpenReelTheme.accent)
+ .frame(width: 34, height: 34)
+ .background(Color.white, in: RoundedRectangle(cornerRadius: 10, style: .continuous))
+
+ Text("New Project")
+ .font(.system(size: 16, weight: .semibold, design: .rounded))
+ .foregroundStyle(Color.white)
+
+ Text("Resolution, frame rate, and ready to import")
+ .font(.reelCaption)
+ .foregroundStyle(Color.white.opacity(0.82))
+ }
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 18)
+ .background(OpenReelTheme.accent, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
+ }
+ .buttonStyle(.plain)
+ }
+
+ private var recentProjectsSection: some View {
+ VStack(alignment: .leading, spacing: 14) {
+ HStack(alignment: .center) {
+ Text("Recent Projects")
+ .font(.reelSection)
+ .foregroundStyle(OpenReelTheme.textPrimary)
+
+ Spacer()
+
+ if !appState.projects.isEmpty {
+ Button {
+ appState.showProjects()
+ } label: {
+ HStack(spacing: 4) {
+ Text("See all")
+ Image(systemName: "chevron.right")
+ .font(.system(size: 10, weight: .bold))
+ }
+ .font(.system(size: 13, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.accent)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+
+ if appState.projects.isEmpty {
+ emptyProjectsState
+ } else {
+ ScrollView(.horizontal, showsIndicators: false) {
+ HStack(spacing: 14) {
+ ForEach(appState.projects) { project in
+ Button {
+ appState.openProject(project)
+ } label: {
+ ProjectShowcaseCard(project: project)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private var emptyProjectsState: some View {
+ VStack(alignment: .leading, spacing: 14) {
+ Label("No projects yet", systemImage: "film.stack")
+ .font(.system(size: 16, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+
+ Text("Create a project, import a video from Photos, and the timeline will auto-save into Application Support.")
+ .font(.reelBody)
+ .foregroundStyle(OpenReelTheme.textSecondary)
+
+ Button("Create First Project") {
+ appState.presentNewProjectSheet()
+ }
+ .buttonStyle(.plain)
+ .font(.system(size: 13, weight: .semibold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.accent)
+ }
+ .padding(18)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(OpenReelTheme.surface, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
+ }
+
+ private var quickToolsSection: some View {
+ VStack(alignment: .leading, spacing: 16) {
+ Text("Phase 1 Tools")
+ .font(.reelSection)
+ .foregroundStyle(OpenReelTheme.textPrimary)
+
+ ScrollView(.horizontal, showsIndicators: false) {
+ HStack(spacing: 12) {
+ ForEach(quickTools, id: \.title) { tool in
+ HStack(spacing: 10) {
+ Image(systemName: tool.symbol)
+ .font(.system(size: 17, weight: .medium))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ Text(tool.title)
+ .font(.system(size: 13, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ }
+ .padding(.horizontal, 16)
+ .frame(height: 48)
+ .background(OpenReelTheme.surface, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
+ .overlay {
+ RoundedRectangle(cornerRadius: 14, style: .continuous)
+ .strokeBorder(Color.white.opacity(0.04), lineWidth: 1)
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
+
+private struct HeroAnimation: View {
+ @State private var phase: Double = 0
+ @State private var morphPhase: Int = 0
+
+ private let size: CGFloat = 120
+ private let particleCount = 12
+
+ var body: some View {
+ TimelineView(.animation(minimumInterval: 1.0 / 30.0)) { timeline in
+ let now = timeline.date.timeIntervalSinceReferenceDate
+ Canvas { context, canvasSize in
+ let center = CGPoint(x: canvasSize.width / 2, y: canvasSize.height / 2)
+ let time = now.truncatingRemainder(dividingBy: 20)
+
+ drawGlowBackground(context: &context, center: center, time: time)
+ drawMorphingShape(context: &context, center: center, time: time)
+ drawOrbitingParticles(context: &context, center: center, time: time)
+ drawPulsingCore(context: &context, center: center, time: time)
+ }
+ .frame(width: size, height: size)
+ }
+ .onAppear {
+ withAnimation(.linear(duration: 8).repeatForever(autoreverses: false)) {
+ phase = .pi * 2
+ }
+ }
+ }
+
+ private func drawGlowBackground(context: inout GraphicsContext, center: CGPoint, time: Double) {
+ let radius = 48 + sin(time * 0.8) * 6
+ let gradient = Gradient(colors: [
+ Color(red: 0.29, green: 0.87, blue: 0.5).opacity(0.25),
+ Color(red: 0.29, green: 0.87, blue: 0.5).opacity(0)
+ ])
+ let shading = GraphicsContext.Shading.radialGradient(
+ gradient,
+ center: center,
+ startRadius: 0,
+ endRadius: radius
+ )
+ context.fill(Circle().path(in: CGRect(
+ x: center.x - radius,
+ y: center.y - radius,
+ width: radius * 2,
+ height: radius * 2
+ )), with: shading)
+ }
+
+ private func drawMorphingShape(context: inout GraphicsContext, center: CGPoint, time: Double) {
+ let points = 6
+ let baseRadius: CGFloat = 32
+ var path = Path()
+
+ for i in 0...points * 4 {
+ let t = Double(i) / Double(points * 4)
+ let angle = t * .pi * 2
+ let wobble1 = sin(angle * 3 + time * 1.2) * 8
+ let wobble2 = cos(angle * 2 + time * 0.7) * 5
+ let wobble3 = sin(angle * 5 + time * 2.1) * 3
+ let r = baseRadius + wobble1 + wobble2 + wobble3
+ let x = center.x + cos(angle) * r
+ let y = center.y + sin(angle) * r
+
+ if i == 0 {
+ path.move(to: CGPoint(x: x, y: y))
+ } else {
+ path.addLine(to: CGPoint(x: x, y: y))
+ }
+ }
+ path.closeSubpath()
+
+ let hue = (time * 0.05).truncatingRemainder(dividingBy: 1.0)
+ let fillColor = Color(
+ hue: 0.38 + hue * 0.08,
+ saturation: 0.75,
+ brightness: 0.85
+ )
+
+ context.fill(path, with: .color(fillColor.opacity(0.6)))
+ context.stroke(path, with: .color(fillColor.opacity(0.9)), lineWidth: 1.5)
+ }
+
+ private func drawOrbitingParticles(context: inout GraphicsContext, center: CGPoint, time: Double) {
+ for i in 0..<particleCount {
+ let baseAngle = Double(i) / Double(particleCount) * .pi * 2
+ let speed = 0.4 + Double(i % 3) * 0.2
+ let angle = baseAngle + time * speed
+ let orbitRadius: CGFloat = 38 + CGFloat(i % 4) * 5
+ let particleSize: CGFloat = 2 + CGFloat(i % 3) * 1.5
+
+ let x = center.x + cos(angle) * orbitRadius
+ let y = center.y + sin(angle) * orbitRadius
+
+ let opacity = 0.4 + sin(time * 2 + Double(i)) * 0.4
+ let color = Color(
+ hue: 0.38 + Double(i) / Double(particleCount) * 0.1,
+ saturation: 0.8,
+ brightness: 0.95
+ ).opacity(opacity)
+
+ let rect = CGRect(
+ x: x - particleSize / 2,
+ y: y - particleSize / 2,
+ width: particleSize,
+ height: particleSize
+ )
+ context.fill(Circle().path(in: rect), with: .color(color))
+ }
+ }
+
+ private func drawPulsingCore(context: inout GraphicsContext, center: CGPoint, time: Double) {
+ let pulse = 6 + sin(time * 2.5) * 2.5
+ let coreGradient = Gradient(colors: [
+ .white.opacity(0.9),
+ Color(red: 0.29, green: 0.87, blue: 0.5).opacity(0.7),
+ Color(red: 0.29, green: 0.87, blue: 0.5).opacity(0)
+ ])
+ let shading = GraphicsContext.Shading.radialGradient(
+ coreGradient,
+ center: center,
+ startRadius: 0,
+ endRadius: pulse
+ )
+ context.fill(Circle().path(in: CGRect(
+ x: center.x - pulse,
+ y: center.y - pulse,
+ width: pulse * 2,
+ height: pulse * 2
+ )), with: shading)
+ }
+}
+
+#Preview {
+ NavigationStack {
+ HomeView()
+ .environment(AppState())
+ }
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/Openreel_VideoApp.swift b/Openreel Video/Openreel Video/Openreel_VideoApp.swift
new file mode 100644
index 00000000..2fc15f3c
--- /dev/null
+++ b/Openreel Video/Openreel Video/Openreel_VideoApp.swift
@@ -0,0 +1,37 @@
+//
+// Openreel_VideoApp.swift
+// Openreel Video
+//
+// Created by Augustus Otu on 17/05/2026.
+//
+
+import AVFoundation
+import SwiftUI
+
+@main
+struct Openreel_VideoApp: App {
+ @State private var appState = AppState()
+ @State private var playbackController = PlaybackController()
+
+ init() {
+ configureAudioSession()
+ }
+
+ var body: some Scene {
+ WindowGroup {
+ ContentView()
+ .environment(appState)
+ .environment(playbackController)
+ }
+ }
+
+ private func configureAudioSession() {
+ let session = AVAudioSession.sharedInstance()
+ do {
+ try session.setCategory(.playback, mode: .moviePlayback)
+ try session.setActive(true)
+ } catch {
+ print("Audio session configuration failed: \(error)")
+ }
+ }
+}
diff --git a/Openreel Video/Openreel Video/ProjectsView.swift b/Openreel Video/Openreel Video/ProjectsView.swift
new file mode 100644
index 00000000..661bd451
--- /dev/null
+++ b/Openreel Video/Openreel Video/ProjectsView.swift
@@ -0,0 +1,131 @@
+import SwiftUI
+
+struct ProjectsView: View {
+ @Environment(AppState.self) private var appState
+ @State private var showsGrid = true
+
+ var body: some View {
+ ZStack {
+ OpenReelTheme.background
+ .ignoresSafeArea()
+
+ ScrollView(showsIndicators: false) {
+ VStack(alignment: .leading, spacing: 20) {
+ if appState.projects.isEmpty {
+ emptyState
+ } else if showsGrid {
+ gridContent
+ } else {
+ listContent
+ }
+ }
+ .padding(.horizontal, 16)
+ .padding(.top, 12)
+ .padding(.bottom, 40)
+ }
+ }
+ .navigationTitle("Projects")
+ .navigationBarTitleDisplayMode(.large)
+ .toolbarBackground(.visible, for: .navigationBar)
+ .toolbarBackground(OpenReelTheme.background, for: .navigationBar)
+ .toolbar {
+ ToolbarItem(placement: .topBarTrailing) {
+ HStack(spacing: 2) {
+ toggleButton(symbol: "square.grid.2x2", isSelected: showsGrid) {
+ showsGrid = true
+ }
+ toggleButton(symbol: "list.bullet", isSelected: !showsGrid) {
+ showsGrid = false
+ }
+ }
+ }
+
+ ToolbarItem(placement: .topBarTrailing) {
+ Button {
+ appState.presentNewProjectSheet()
+ } label: {
+ Image(systemName: "plus")
+ .font(.system(size: 14, weight: .bold))
+ .foregroundStyle(.white)
+ .frame(width: 32, height: 32)
+ .background(OpenReelTheme.accent, in: Circle())
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+
+ private var emptyState: some View {
+ VStack(spacing: 20) {
+ Image(systemName: "film.stack")
+ .font(.system(size: 40, weight: .light))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+
+ VStack(spacing: 8) {
+ Text("No projects yet")
+ .font(.system(size: 18, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ Text("Create a project to start editing video.")
+ .font(.system(size: 14, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+
+ Button {
+ appState.presentNewProjectSheet()
+ } label: {
+ Text("New Project")
+ .font(.system(size: 14, weight: .semibold, design: .rounded))
+ .foregroundStyle(.white)
+ .padding(.horizontal, 20)
+ .padding(.vertical, 12)
+ .background(OpenReelTheme.accent, in: Capsule())
+ }
+ .buttonStyle(.plain)
+ }
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 60)
+ }
+
+ private var listContent: some View {
+ LazyVStack(spacing: 10) {
+ ForEach(appState.projects) { project in
+ Button {
+ appState.openProject(project)
+ } label: {
+ ProjectBrowserRowCard(project: project)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+
+ private var gridContent: some View {
+ LazyVGrid(columns: [GridItem(.flexible(), spacing: 12), GridItem(.flexible(), spacing: 12)], spacing: 12) {
+ ForEach(appState.projects) { project in
+ Button {
+ appState.openProject(project)
+ } label: {
+ ProjectBrowserGridCard(project: project)
+ }
+ .buttonStyle(.plain)
+ }
+ }
+ }
+
+ private func toggleButton(symbol: String, isSelected: Bool, action: @escaping () -> Void) -> some View {
+ Button(action: action) {
+ Image(systemName: symbol)
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(isSelected ? OpenReelTheme.accent : OpenReelTheme.textSecondary.opacity(0.4))
+ .frame(width: 32, height: 32)
+ }
+ .buttonStyle(.plain)
+ }
+}
+
+#Preview {
+ NavigationStack {
+ ProjectsView()
+ .environment(AppState())
+ }
+}
diff --git a/Openreel Video/Openreel Video/RootView.swift b/Openreel Video/Openreel Video/RootView.swift
new file mode 100644
index 00000000..eb7f9bcc
--- /dev/null
+++ b/Openreel Video/Openreel Video/RootView.swift
@@ -0,0 +1,121 @@
+import SwiftUI
+
+struct RootView: View {
+ @Environment(AppState.self) private var appState
+
+ var body: some View {
+ Group {
+ if appState.isBootstrapping && !appState.hasBootstrapped {
+ loadingView
+ } else {
+ if appState.activeScreen == .editor {
+ EditorView()
+ } else {
+ LibraryTabView()
+ }
+ }
+ }
+ .background(OpenReelTheme.background.ignoresSafeArea())
+ .task {
+ await appState.bootstrap()
+ }
+ .sheet(
+ isPresented: Binding(
+ get: { appState.isShowingNewProjectSheet },
+ set: { isPresented in
+ if !isPresented {
+ appState.dismissNewProjectSheet()
+ }
+ }
+ )
+ ) {
+ NewProjectSheet()
+ .presentationDetents([.medium, .large])
+ .presentationDragIndicator(.visible)
+ }
+ .alert(
+ "OpenReel",
+ isPresented: Binding(
+ get: { appState.importErrorMessage != nil },
+ set: { isPresented in
+ if !isPresented {
+ appState.dismissError()
+ }
+ }
+ )
+ ) {
+ Button("OK", role: .cancel) {
+ appState.dismissError()
+ }
+ } message: {
+ Text(appState.importErrorMessage ?? "")
+ }
+ }
+
+ private var loadingView: some View {
+ VStack(spacing: 16) {
+ ProgressView()
+ .tint(OpenReelTheme.accent)
+ Text("Loading projects")
+ .font(.reelBody)
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
+ }
+}
+
+private struct LibraryTabView: View {
+ @Environment(AppState.self) private var appState
+
+ var body: some View {
+ TabView(selection: selection) {
+ NavigationStack {
+ HomeView()
+ }
+ .tag(AppState.Screen.home)
+ .tabItem {
+ Label("Home", systemImage: "house.fill")
+ }
+
+ NavigationStack {
+ ProjectsView()
+ }
+ .tag(AppState.Screen.projects)
+ .tabItem {
+ Label("Projects", systemImage: "film.stack")
+ }
+ }
+ .tint(OpenReelTheme.accent)
+ .toolbarBackground(.visible, for: .tabBar)
+ .toolbarBackground(OpenReelTheme.surfaceElevated, for: .tabBar)
+ }
+
+ private var selection: Binding<AppState.Screen> {
+ Binding(
+ get: {
+ switch appState.activeScreen {
+ case .projects:
+ return .projects
+ case .home, .editor:
+ return .home
+ }
+ },
+ set: { newValue in
+ switch newValue {
+ case .home:
+ appState.showHome()
+ case .projects:
+ appState.showProjects()
+ case .editor:
+ appState.showHome()
+ }
+ }
+ )
+ }
+}
+
+#Preview {
+ RootView()
+ .environment(AppState())
+ .environment(PlaybackController())
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/Shared/Components/ProjectArtworkView.swift b/Openreel Video/Openreel Video/Shared/Components/ProjectArtworkView.swift
new file mode 100644
index 00000000..d507d916
--- /dev/null
+++ b/Openreel Video/Openreel Video/Shared/Components/ProjectArtworkView.swift
@@ -0,0 +1,42 @@
+import SwiftUI
+
+struct ProjectArtworkView: View {
+ @Environment(AppState.self) private var appState
+
+ let project: OpenReelProject
+ var cornerRadius: CGFloat = 18
+
+ var body: some View {
+ GeometryReader { geo in
+ ZStack {
+ RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)
+ .fill(appState.style(for: project).gradient)
+
+ if let clip = appState.primaryVisualClip(in: project),
+ let mediaItem = appState.mediaItem(for: clip.mediaId, in: project),
+ let url = appState.thumbnailURL(for: mediaItem.thumbnailUrl, in: project) {
+ AsyncImage(url: url) { phase in
+ switch phase {
+ case .success(let image):
+ image
+ .resizable()
+ .scaledToFill()
+ .frame(width: geo.size.width, height: geo.size.height)
+ .clipped()
+ case .empty, .failure:
+ appState.style(for: project).gradient
+ @unknown default:
+ appState.style(for: project).gradient
+ }
+ }
+ }
+ }
+ }
+ .clipShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))
+ }
+}
+
+#Preview {
+ ProjectArtworkView(project: OpenReelProject.blank(configuration: NewProjectConfiguration(name: "Preview")))
+ .environment(AppState())
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/Shared/Components/ProjectCards.swift b/Openreel Video/Openreel Video/Shared/Components/ProjectCards.swift
new file mode 100644
index 00000000..735a694c
--- /dev/null
+++ b/Openreel Video/Openreel Video/Shared/Components/ProjectCards.swift
@@ -0,0 +1,238 @@
+import Foundation
+import SwiftUI
+
+struct ProjectShowcaseCard: View {
+ @Environment(AppState.self) private var appState
+ let project: OpenReelProject
+ var width: CGFloat = 280
+
+ private var summary: ProjectCardSummary {
+ ProjectCardSummary(project: project)
+ }
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 0) {
+ ProjectArtworkView(project: project, cornerRadius: 0)
+ .frame(width: width, height: 148)
+ .clipped()
+ .overlay(alignment: .bottomLeading) {
+ LinearGradient(
+ colors: [.clear, .black.opacity(0.6)],
+ startPoint: .top,
+ endPoint: .bottom
+ )
+ .frame(height: 60)
+ }
+ .overlay(alignment: .bottomLeading) {
+ ProjectDurationPill(text: summary.duration)
+ .padding(12)
+ }
+ .overlay(alignment: .topTrailing) {
+ ProjectOptionsButton(inverse: true)
+ .padding(10)
+ }
+
+ VStack(alignment: .leading, spacing: 8) {
+ Text(project.name)
+ .font(.system(size: 16, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .lineLimit(1)
+
+ HStack(spacing: 12) {
+ ProjectMetaItem(symbol: "film.stack", text: summary.clipCount)
+ ProjectMetaItem(symbol: "rectangle", text: summary.resolution)
+ Spacer(minLength: 0)
+ Text(summary.workedRelative)
+ .font(.system(size: 11, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ }
+ .padding(.horizontal, 14)
+ .padding(.vertical, 12)
+ }
+ .frame(width: width, alignment: .leading)
+ .background(OpenReelTheme.surfaceElevated)
+ .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
+ .overlay {
+ RoundedRectangle(cornerRadius: 16, style: .continuous)
+ .strokeBorder(Color.white.opacity(0.06), lineWidth: 1)
+ }
+ }
+}
+
+struct ProjectBrowserRowCard: View {
+ @Environment(AppState.self) private var appState
+ let project: OpenReelProject
+
+ private var summary: ProjectCardSummary {
+ ProjectCardSummary(project: project)
+ }
+
+ var body: some View {
+ HStack(spacing: 14) {
+ ProjectArtworkView(project: project, cornerRadius: 12)
+ .frame(width: 96, height: 68)
+ .overlay(alignment: .bottomTrailing) {
+ ProjectDurationPill(text: summary.duration)
+ .padding(6)
+ }
+
+ VStack(alignment: .leading, spacing: 6) {
+ Text(project.name)
+ .font(.system(size: 15, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .lineLimit(1)
+
+ HStack(spacing: 10) {
+ ProjectMetaItem(symbol: "film.stack", text: summary.clipCount)
+ ProjectMetaItem(symbol: "rectangle", text: summary.resolution)
+ }
+
+ Text(summary.workedRelative)
+ .font(.system(size: 11, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+
+ Spacer(minLength: 0)
+
+ Image(systemName: "chevron.right")
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(OpenReelTheme.textSecondary.opacity(0.5))
+ }
+ .padding(12)
+ .background(OpenReelTheme.surfaceElevated, in: RoundedRectangle(cornerRadius: 16, style: .continuous))
+ .overlay {
+ RoundedRectangle(cornerRadius: 16, style: .continuous)
+ .strokeBorder(Color.white.opacity(0.06), lineWidth: 1)
+ }
+ }
+}
+
+struct ProjectBrowserGridCard: View {
+ @Environment(AppState.self) private var appState
+ let project: OpenReelProject
+
+ private var summary: ProjectCardSummary {
+ ProjectCardSummary(project: project)
+ }
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 0) {
+ ProjectArtworkView(project: project, cornerRadius: 0)
+ .frame(maxWidth: .infinity)
+ .aspectRatio(16.0 / 10.0, contentMode: .fit)
+ .clipped()
+ .overlay(alignment: .bottomLeading) {
+ ProjectDurationPill(text: summary.duration)
+ .padding(8)
+ }
+
+ VStack(alignment: .leading, spacing: 6) {
+ Text(project.name)
+ .font(.system(size: 14, weight: .bold, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textPrimary)
+ .lineLimit(1)
+
+ HStack(spacing: 8) {
+ ProjectMetaItem(symbol: "film.stack", text: summary.clipCount)
+ Spacer(minLength: 0)
+ Text(summary.workedRelative)
+ .font(.system(size: 10, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+ }
+ .padding(.horizontal, 10)
+ .padding(.vertical, 10)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(OpenReelTheme.surfaceElevated)
+ .clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
+ .overlay {
+ RoundedRectangle(cornerRadius: 14, style: .continuous)
+ .strokeBorder(Color.white.opacity(0.06), lineWidth: 1)
+ }
+ }
+}
+
+private struct ProjectCardSummary {
+ let project: OpenReelProject
+
+ var modifiedDate: Date {
+ Date(timeIntervalSince1970: TimeInterval(project.modifiedAt) / 1000)
+ }
+
+ var workedRelative: String {
+ ProjectDateFormatter.relative.localizedString(for: modifiedDate, relativeTo: .now)
+ }
+
+ var workedExact: String {
+ modifiedDate.formatted(date: .abbreviated, time: .shortened)
+ }
+
+ var resolution: String {
+ "\(project.settings.width)x\(project.settings.height)"
+ }
+
+ var duration: String {
+ TimeInterval(project.timeline.duration).shortClock()
+ }
+
+ var clipCount: String {
+ let count = project.allClips.count
+ return count == 1 ? "1 clip" : "\(count) clips"
+ }
+
+ var stateLabel: String {
+ project.allClips.isEmpty ? "Draft" : "Ready"
+ }
+}
+
+private enum ProjectDateFormatter {
+ static let relative: RelativeDateTimeFormatter = {
+ let formatter = RelativeDateTimeFormatter()
+ formatter.unitsStyle = .abbreviated
+ formatter.dateTimeStyle = .named
+ return formatter
+ }()
+}
+
+private struct ProjectOptionsButton: View {
+ var inverse: Bool = false
+
+ var body: some View {
+ Image(systemName: "ellipsis")
+ .font(.system(size: 12, weight: .bold))
+ .foregroundStyle(inverse ? Color.white : OpenReelTheme.textPrimary)
+ .frame(width: 28, height: 28)
+ .background(inverse ? Color.black.opacity(0.4) : OpenReelTheme.surface, in: Circle())
+ }
+}
+
+private struct ProjectDurationPill: View {
+ let text: String
+
+ var body: some View {
+ Text(text)
+ .font(.system(size: 10, weight: .bold, design: .monospaced))
+ .foregroundStyle(.white)
+ .padding(.horizontal, 7)
+ .padding(.vertical, 4)
+ .background(Color.black.opacity(0.6), in: Capsule())
+ }
+}
+
+private struct ProjectMetaItem: View {
+ let symbol: String
+ let text: String
+
+ var body: some View {
+ HStack(spacing: 4) {
+ Image(systemName: symbol)
+ .font(.system(size: 9, weight: .semibold))
+ Text(text)
+ .lineLimit(1)
+ }
+ .font(.system(size: 11, weight: .medium, design: .rounded))
+ .foregroundStyle(OpenReelTheme.textSecondary)
+ }
+}
diff --git a/Openreel Video/Openreel Video/Shared/Extensions/TimeInterval+Format.swift b/Openreel Video/Openreel Video/Shared/Extensions/TimeInterval+Format.swift
new file mode 100644
index 00000000..9eea5d0a
--- /dev/null
+++ b/Openreel Video/Openreel Video/Shared/Extensions/TimeInterval+Format.swift
@@ -0,0 +1,21 @@
+import Foundation
+
+extension TimeInterval {
+ func openReelClock(frameRate: Double = 30) -> String {
+ let totalSeconds = max(self, 0)
+ let hours = Int(totalSeconds) / 3600
+ let minutes = (Int(totalSeconds) % 3600) / 60
+ let seconds = Int(totalSeconds) % 60
+ let fractional = totalSeconds - floor(totalSeconds)
+ let frames = Int((fractional * frameRate).rounded(.down))
+
+ return String(format: "%02d:%02d:%02d:%02d", hours, minutes, seconds, frames)
+ }
+
+ func shortClock() -> String {
+ let totalSeconds = max(Int(self.rounded(.down)), 0)
+ let minutes = totalSeconds / 60
+ let seconds = totalSeconds % 60
+ return String(format: "%02d:%02d", minutes, seconds)
+ }
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel Video/Theme.swift b/Openreel Video/Openreel Video/Theme.swift
new file mode 100644
index 00000000..049422f0
--- /dev/null
+++ b/Openreel Video/Openreel Video/Theme.swift
@@ -0,0 +1,57 @@
+import SwiftUI
+import UIKit
+
+enum OpenReelTheme {
+ static let background = dynamicColor(light: 0xFFFFFF, dark: 0x0D0D0D)
+ static let surface = dynamicColor(light: 0xF5F5F5, dark: 0x1A1A1A)
+ static let surfaceElevated = dynamicColor(light: 0xFFFFFF, dark: 0x262626)
+ static let accent = dynamicColor(light: 0x16A34A, dark: 0x4ADE80)
+ static let accentSecondary = dynamicColor(light: 0x059669, dark: 0x00E676)
+ static let textPrimary = dynamicColor(light: 0x1A1A1A, dark: 0xFFFFFF)
+ static let textSecondary = dynamicColor(light: 0x737373, dark: 0xA3A3A3)
+ static let destructive = dynamicColor(light: 0xDC2626, dark: 0xEF4444)
+
+ static func dynamicColor(light: Int, dark: Int) -> Color {
+ Color(
+ uiColor: UIColor { traitCollection in
+ UIColor(hex: traitCollection.userInterfaceStyle == .dark ? dark : light)
+ }
+ )
+ }
+}
+
+extension UIColor {
+ convenience init(hex: Int) {
+ let red = CGFloat((hex >> 16) & 0xFF) / 255
+ let green = CGFloat((hex >> 8) & 0xFF) / 255
+ let blue = CGFloat(hex & 0xFF) / 255
+ self.init(red: red, green: green, blue: blue, alpha: 1)
+ }
+}
+
+extension Font {
+ static let reelDisplay = Font.system(size: 34, weight: .bold, design: .rounded)
+ static let reelSection = Font.system(size: 16, weight: .semibold, design: .rounded)
+ static let reelBody = Font.system(size: 15, weight: .medium, design: .rounded)
+ static let reelCaption = Font.system(size: 12, weight: .medium, design: .rounded)
+ static let reelMono = Font.system(size: 13, weight: .medium, design: .monospaced)
+}
+
+extension AppState.ProjectStyle {
+ var colors: [Color] {
+ switch self {
+ case .emerald:
+ return [Color(red: 0.08, green: 0.32, blue: 0.20), Color(red: 0.14, green: 0.79, blue: 0.47)]
+ case .cobalt:
+ return [Color(red: 0.11, green: 0.18, blue: 0.37), Color(red: 0.27, green: 0.49, blue: 0.98)]
+ case .amber:
+ return [Color(red: 0.32, green: 0.21, blue: 0.09), Color(red: 0.98, green: 0.73, blue: 0.20)]
+ case .coral:
+ return [Color(red: 0.40, green: 0.14, blue: 0.17), Color(red: 0.97, green: 0.43, blue: 0.39)]
+ }
+ }
+
+ var gradient: LinearGradient {
+ LinearGradient(colors: colors, startPoint: .topLeading, endPoint: .bottomTrailing)
+ }
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel VideoTests/Openreel_VideoTests.swift b/Openreel Video/Openreel VideoTests/Openreel_VideoTests.swift
new file mode 100644
index 00000000..e8e305c3
--- /dev/null
+++ b/Openreel Video/Openreel VideoTests/Openreel_VideoTests.swift
@@ -0,0 +1,195 @@
+import Foundation
+import Testing
+@testable import Openreel_Video
+
+@MainActor
+struct Openreel_VideoTests {
+
+ @Test func createProjectPersistsAndOpensEditor() async throws {
+ let harness = try makeHarness()
+ defer { harness.cleanup() }
+
+ let portraitPreset = try #require(NewProjectConfiguration.presets.first(where: { $0.name == "Portrait" }))
+ harness.appState.newProjectConfiguration = NewProjectConfiguration(
+ name: " Launch Cut ",
+ preset: portraitPreset,
+ frameRate: 60
+ )
+
+ await harness.appState.createProject()
+
+ let project = try #require(harness.appState.currentProject)
+ let persistedProject = try await harness.projectStore.loadProject(id: project.id)
+
+ #expect(harness.appState.projects.count == 1)
+ #expect(harness.appState.activeScreen == .editor)
+ #expect(harness.appState.selectedProjectID == project.id)
+ #expect(harness.appState.selectedAspectRatio == .portrait)
+ #expect(project.name == "Launch Cut")
+ #expect(project.settings.width == 1080)
+ #expect(project.settings.height == 1920)
+ #expect(project.settings.frameRate == 60)
+ #expect(harness.appState.isShowingNewProjectSheet == false)
+ #expect(persistedProject == project)
+ }
+
+ @Test func bootstrapLoadsPersistedProjectsAndSelectsPrimaryClip() async throws {
+ let harness = try makeHarness()
+ defer { harness.cleanup() }
+
+ var olderProject = makeProject(name: "Older Draft")
+ olderProject.modifiedAt = 10
+
+ let portraitPreset = try #require(NewProjectConfiguration.presets.first(where: { $0.name == "Portrait" }))
+ var newerProject = makeProject(name: "Phone Cut", preset: portraitPreset, frameRate: 60)
+ let newerClip = try #require(addVideoClip(to: &newerProject, duration: 12))
+ newerProject.modifiedAt = 20
+
+ try await harness.projectStore.save(project: olderProject)
+ try await harness.projectStore.save(project: newerProject)
+
+ let appState = AppState(projectStore: harness.projectStore, mediaImportService: MediaImportService())
+ await appState.bootstrap()
+
+ #expect(appState.hasBootstrapped)
+ #expect(appState.isBootstrapping == false)
+ #expect(appState.projects.count == 2)
+ #expect(appState.currentProject?.id == newerProject.id)
+ #expect(appState.selectedProjectID == newerProject.id)
+ #expect(appState.selectedClipID == newerClip.id)
+ #expect(appState.selectedAspectRatio == .portrait)
+ #expect(appState.currentProjectDuration == 12)
+ }
+
+ @Test func openProjectSelectsProjectAndPrimaryClip() throws {
+ let appState = AppState(projectStore: ProjectStore(baseURL: temporaryDirectoryURL()), mediaImportService: MediaImportService())
+ var firstProject = makeProject(name: "Landscape Cut")
+ var secondProject = makeProject(name: "Vertical Cut", preset: NewProjectConfiguration.presets[2], frameRate: 30)
+ let secondClip = try #require(addVideoClip(to: &secondProject, duration: 8))
+ _ = addVideoClip(to: &firstProject, duration: 4)
+
+ appState.projects = [firstProject, secondProject]
+
+ appState.openProject(secondProject)
+
+ #expect(appState.activeScreen == .editor)
+ #expect(appState.selectedProjectID == secondProject.id)
+ #expect(appState.currentProject?.id == secondProject.id)
+ #expect(appState.selectedClipID == secondClip.id)
+ #expect(appState.selectedAspectRatio == .portrait)
+ #expect(appState.editorTab == .edit)
+ }
+
+ @Test func advanceAspectRatioCyclesForward() {
+ let appState = AppState(projectStore: ProjectStore(baseURL: temporaryDirectoryURL()), mediaImportService: MediaImportService())
+ let first = appState.selectedAspectRatio
+
+ appState.advanceAspectRatio()
+
+ #expect(first == .landscape)
+ #expect(appState.selectedAspectRatio == .portrait)
+ }
+
+ private func makeHarness() throws -> TestHarness {
+ let directoryURL = temporaryDirectoryURL()
+ try FileManager.default.createDirectory(at: directoryURL, withIntermediateDirectories: true)
+ let projectStore = ProjectStore(baseURL: directoryURL)
+ let appState = AppState(projectStore: projectStore, mediaImportService: MediaImportService())
+ return TestHarness(appState: appState, projectStore: projectStore, directoryURL: directoryURL)
+ }
+
+ private func makeProject(
+ name: String,
+ preset: NewProjectConfiguration.Preset? = nil,
+ frameRate: Double = 30
+ ) -> OpenReelProject {
+ let resolvedPreset = preset ?? NewProjectConfiguration.presets[0]
+ return OpenReelProject.blank(
+ configuration: NewProjectConfiguration(
+ name: name,
+ preset: resolvedPreset,
+ frameRate: frameRate
+ )
+ )
+ }
+
+ private func addVideoClip(to project: inout OpenReelProject, duration: Double) -> OpenReelProject.Clip? {
+ guard let videoTrackIndex = project.timeline.tracks.firstIndex(where: { $0.type == .video }) else {
+ return nil
+ }
+
+ let mediaID = UUID().uuidString
+ let trackID = project.timeline.tracks[videoTrackIndex].id
+ let mediaItem = OpenReelProject.MediaItem(
+ id: mediaID,
+ name: "Sample.mov",
+ type: .video,
+ metadata: OpenReelProject.MediaMetadata(
+ duration: duration,
+ width: project.settings.width,
+ height: project.settings.height,
+ frameRate: project.settings.frameRate,
+ codec: "h264",
+ sampleRate: 48_000,
+ channels: 2,
+ fileSize: 1_024,
+ audioTrackCount: 1
+ ),
+ thumbnailUrl: nil,
+ waveformData: nil,
+ filmstripThumbnails: nil,
+ isPlaceholder: false,
+ originalUrl: nil,
+ sourceFile: nil,
+ localFileName: "sample.mov",
+ localAssetIdentifier: nil
+ )
+
+ let clip = OpenReelProject.Clip(
+ id: UUID().uuidString,
+ mediaId: mediaID,
+ trackId: trackID,
+ startTime: 0,
+ duration: duration,
+ inPoint: 0,
+ outPoint: duration,
+ effects: [],
+ audioEffects: [],
+ transform: OpenReelProject.Transform(
+ position: OpenReelProject.Point(x: 0.5, y: 0.5),
+ scale: OpenReelProject.Point(x: 1, y: 1),
+ rotation: 0,
+ anchor: OpenReelProject.Point(x: 0.5, y: 0.5),
+ opacity: 1,
+ borderRadius: nil,
+ fitMode: .contain,
+ crop: nil
+ ),
+ volume: 1,
+ keyframes: [],
+ speed: 1,
+ reversed: false,
+ audioTrackIndex: 0
+ )
+
+ project.mediaLibrary.items = [mediaItem]
+ project.timeline.tracks[videoTrackIndex].clips = [clip]
+ project.timeline.duration = duration
+ return clip
+ }
+}
+
+private struct TestHarness {
+ let appState: AppState
+ let projectStore: ProjectStore
+ let directoryURL: URL
+
+ func cleanup() {
+ try? FileManager.default.removeItem(at: directoryURL)
+ }
+}
+
+private func temporaryDirectoryURL() -> URL {
+ URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
+ .appendingPathComponent(UUID().uuidString, isDirectory: true)
+}
\ No newline at end of file
diff --git a/Openreel Video/Openreel VideoUITests/Openreel_VideoUITests.swift b/Openreel Video/Openreel VideoUITests/Openreel_VideoUITests.swift
new file mode 100644
index 00000000..65a7fc32
--- /dev/null
+++ b/Openreel Video/Openreel VideoUITests/Openreel_VideoUITests.swift
@@ -0,0 +1,43 @@
+//
+// Openreel_VideoUITests.swift
+// Openreel VideoUITests
+//
+// Created by Augustus Otu on 17/05/2026.
+//
+
+import XCTest
+
+final class Openreel_VideoUITests: XCTestCase {
+
+ override func setUpWithError() throws {
+ // Put setup code here. This method is called before the invocation of each test method in the class.
+
+ // In UI tests it is usually best to stop immediately when a failure occurs.
+ continueAfterFailure = false
+
+ // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
+ }
+
+ override func tearDownWithError() throws {
+ // Put teardown code here. This method is called after the invocation of each test method in the class.
+ }
+
+ @MainActor
+ func testExample() throws {
+ // UI tests must launch the application that they test.
+ let app = XCUIApplication()
+ app.launch()
+
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
+ // XCUIAutomation Documentation
+ // https://developer.apple.com/documentation/xcuiautomation
+ }
+
+ @MainActor
+ func testLaunchPerformance() throws {
+ // This measures how long it takes to launch your application.
+ measure(metrics: [XCTApplicationLaunchMetric()]) {
+ XCUIApplication().launch()
+ }
+ }
+}
diff --git a/Openreel Video/Openreel VideoUITests/Openreel_VideoUITestsLaunchTests.swift b/Openreel Video/Openreel VideoUITests/Openreel_VideoUITestsLaunchTests.swift
new file mode 100644
index 00000000..bddada5d
--- /dev/null
+++ b/Openreel Video/Openreel VideoUITests/Openreel_VideoUITestsLaunchTests.swift
@@ -0,0 +1,35 @@
+//
+// Openreel_VideoUITestsLaunchTests.swift
+// Openreel VideoUITests
+//
+// Created by Augustus Otu on 17/05/2026.
+//
+
+import XCTest
+
+final class Openreel_VideoUITestsLaunchTests: XCTestCase {
+
+ override class var runsForEachTargetApplicationUIConfiguration: Bool {
+ true
+ }
+
+ override func setUpWithError() throws {
+ continueAfterFailure = false
+ }
+
+ @MainActor
+ func testLaunch() throws {
+ let app = XCUIApplication()
+ app.launch()
+
+ // Insert steps here to perform after app launch but before taking a screenshot,
+ // such as logging into a test account or navigating somewhere in the app
+ // XCUIAutomation Documentation
+ // https://developer.apple.com/documentation/xcuiautomation
+
+ let attachment = XCTAttachment(screenshot: app.screenshot())
+ attachment.name = "Launch Screen"
+ attachment.lifetime = .keepAlways
+ add(attachment)
+ }
+}