From 3c9e5a6d46b55654467baa59693294a0ea3416b9 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Fri, 9 Feb 2024 13:00:02 -0300 Subject: [PATCH] chore: ios sample app --- .gitignore | 3 +- samples/ios-sample/.gitignore | 24 ++ .../ios-sample.xcodeproj/project.pbxproj | 402 ++++++++++++++++++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 13 + .../ios-sample/Assets.xcassets/Contents.json | 6 + .../ios-sample/ios-sample/ContentView.swift | 38 ++ .../Preview Assets.xcassets/Contents.json | 6 + .../ios-sample/RoutingController.swift | 50 +++ .../ios-sample/SwiftUIController.swift | 24 ++ .../ios-sample/ios-sample/ios_sampleApp.swift | 118 +++++ 11 files changed, 693 insertions(+), 2 deletions(-) create mode 100644 samples/ios-sample/.gitignore create mode 100644 samples/ios-sample/ios-sample.xcodeproj/project.pbxproj create mode 100644 samples/ios-sample/ios-sample/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 samples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 samples/ios-sample/ios-sample/Assets.xcassets/Contents.json create mode 100644 samples/ios-sample/ios-sample/ContentView.swift create mode 100644 samples/ios-sample/ios-sample/Preview Content/Preview Assets.xcassets/Contents.json create mode 100644 samples/ios-sample/ios-sample/RoutingController.swift create mode 100644 samples/ios-sample/ios-sample/SwiftUIController.swift create mode 100644 samples/ios-sample/ios-sample/ios_sampleApp.swift diff --git a/.gitignore b/.gitignore index 5b49e04..7a9c646 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,4 @@ captures .gradle *.iml *.focus -venv -samples/ios-sample \ No newline at end of file +venv \ No newline at end of file diff --git a/samples/ios-sample/.gitignore b/samples/ios-sample/.gitignore new file mode 100644 index 0000000..0dd1b63 --- /dev/null +++ b/samples/ios-sample/.gitignore @@ -0,0 +1,24 @@ +# Mac OS X +*.DS_Store + +# Xcode +.build +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 +*.xcuserstate +project.xcworkspace/ +xcuserdata/ +Pods/*.xcodeproj/xcuserdata/ + +# Generated files +*.o +*.pyc + +# Backup files +*~.nib +\#*# +.#* + +.swiftpm \ No newline at end of file diff --git a/samples/ios-sample/ios-sample.xcodeproj/project.pbxproj b/samples/ios-sample/ios-sample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..821aca9 --- /dev/null +++ b/samples/ios-sample/ios-sample.xcodeproj/project.pbxproj @@ -0,0 +1,402 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 6064E7942B767D1B00F65D52 /* UIKitShared.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6064E7932B767D1B00F65D52 /* UIKitShared.framework */; }; + 6064E7952B767D1B00F65D52 /* UIKitShared.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6064E7932B767D1B00F65D52 /* UIKitShared.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 606654F42B75A69E00786DA1 /* RoutingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606654F32B75A69E00786DA1 /* RoutingController.swift */; }; + 606655182B75B21300786DA1 /* SwiftUIController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606655172B75B21300786DA1 /* SwiftUIController.swift */; }; + 609CFD7F2B73A0600079F82D /* ios_sampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 609CFD7E2B73A0600079F82D /* ios_sampleApp.swift */; }; + 609CFD812B73A0600079F82D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 609CFD802B73A0600079F82D /* ContentView.swift */; }; + 609CFD832B73A0610079F82D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 609CFD822B73A0610079F82D /* Assets.xcassets */; }; + 609CFD862B73A0610079F82D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 609CFD852B73A0610079F82D /* Preview Assets.xcassets */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 6064E7962B767D1B00F65D52 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 6064E7952B767D1B00F65D52 /* UIKitShared.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 6064E7932B767D1B00F65D52 /* UIKitShared.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKitShared.framework; path = "../../integration/uikit/build/xcode-frameworks/Debug/iphonesimulator16.4/UIKitShared.framework"; sourceTree = ""; }; + 606654F32B75A69E00786DA1 /* RoutingController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoutingController.swift; sourceTree = ""; }; + 606655172B75B21300786DA1 /* SwiftUIController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIController.swift; sourceTree = ""; }; + 609CFD7B2B73A0600079F82D /* ios-sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ios-sample.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 609CFD7E2B73A0600079F82D /* ios_sampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ios_sampleApp.swift; sourceTree = ""; }; + 609CFD802B73A0600079F82D /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 609CFD822B73A0610079F82D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 609CFD852B73A0610079F82D /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 609CFD782B73A0600079F82D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6064E7942B767D1B00F65D52 /* UIKitShared.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 609CFD722B73A0600079F82D = { + isa = PBXGroup; + children = ( + 609CFD7D2B73A0600079F82D /* ios-sample */, + 609CFD7C2B73A0600079F82D /* Products */, + 609CFD8D2B73A1050079F82D /* Frameworks */, + ); + sourceTree = ""; + }; + 609CFD7C2B73A0600079F82D /* Products */ = { + isa = PBXGroup; + children = ( + 609CFD7B2B73A0600079F82D /* ios-sample.app */, + ); + name = Products; + sourceTree = ""; + }; + 609CFD7D2B73A0600079F82D /* ios-sample */ = { + isa = PBXGroup; + children = ( + 609CFD7E2B73A0600079F82D /* ios_sampleApp.swift */, + 609CFD802B73A0600079F82D /* ContentView.swift */, + 609CFD822B73A0610079F82D /* Assets.xcassets */, + 609CFD842B73A0610079F82D /* Preview Content */, + 606654F32B75A69E00786DA1 /* RoutingController.swift */, + 606655172B75B21300786DA1 /* SwiftUIController.swift */, + ); + path = "ios-sample"; + sourceTree = ""; + }; + 609CFD842B73A0610079F82D /* Preview Content */ = { + isa = PBXGroup; + children = ( + 609CFD852B73A0610079F82D /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 609CFD8D2B73A1050079F82D /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6064E7932B767D1B00F65D52 /* UIKitShared.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 609CFD7A2B73A0600079F82D /* ios-sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 609CFD892B73A0610079F82D /* Build configuration list for PBXNativeTarget "ios-sample" */; + buildPhases = ( + 609CFD8C2B73A0700079F82D /* Compile Kotlin */, + 609CFD772B73A0600079F82D /* Sources */, + 609CFD782B73A0600079F82D /* Frameworks */, + 609CFD792B73A0600079F82D /* Resources */, + 6064E7962B767D1B00F65D52 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "ios-sample"; + productName = "ios-sample"; + productReference = 609CFD7B2B73A0600079F82D /* ios-sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 609CFD732B73A0600079F82D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1430; + LastUpgradeCheck = 1430; + TargetAttributes = { + 609CFD7A2B73A0600079F82D = { + CreatedOnToolsVersion = 14.3.1; + }; + }; + }; + buildConfigurationList = 609CFD762B73A0600079F82D /* Build configuration list for PBXProject "ios-sample" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 609CFD722B73A0600079F82D; + productRefGroup = 609CFD7C2B73A0600079F82D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 609CFD7A2B73A0600079F82D /* ios-sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 609CFD792B73A0600079F82D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 609CFD862B73A0610079F82D /* Preview Assets.xcassets in Resources */, + 609CFD832B73A0610079F82D /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 609CFD8C2B73A0700079F82D /* Compile Kotlin */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Compile Kotlin"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cd \"$SRCROOT/../..\"\n./gradlew :integration:uikit:embedAndSignAppleFrameworkForXcode\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 609CFD772B73A0600079F82D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 609CFD812B73A0600079F82D /* ContentView.swift in Sources */, + 609CFD7F2B73A0600079F82D /* ios_sampleApp.swift in Sources */, + 606655182B75B21300786DA1 /* SwiftUIController.swift in Sources */, + 606654F42B75A69E00786DA1 /* RoutingController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 609CFD872B73A0610079F82D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + 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 = 16.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 609CFD882B73A0610079F82D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + 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"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 609CFD8A2B73A0610079F82D /* 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_ASSET_PATHS = "\"ios-sample/Preview Content\""; + ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = "../../integration/uikit/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"; + 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 = "dev.programadorthi.routing.ios-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 609CFD8B2B73A0610079F82D /* 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_ASSET_PATHS = "\"ios-sample/Preview Content\""; + ENABLE_PREVIEWS = YES; + FRAMEWORK_SEARCH_PATHS = "../../integration/uikit/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"; + 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 = "dev.programadorthi.routing.ios-sample"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 609CFD762B73A0600079F82D /* Build configuration list for PBXProject "ios-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 609CFD872B73A0610079F82D /* Debug */, + 609CFD882B73A0610079F82D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 609CFD892B73A0610079F82D /* Build configuration list for PBXNativeTarget "ios-sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 609CFD8A2B73A0610079F82D /* Debug */, + 609CFD8B2B73A0610079F82D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 609CFD732B73A0600079F82D /* Project object */; +} diff --git a/samples/ios-sample/ios-sample/Assets.xcassets/AccentColor.colorset/Contents.json b/samples/ios-sample/ios-sample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/samples/ios-sample/ios-sample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/samples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json b/samples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/samples/ios-sample/ios-sample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/samples/ios-sample/ios-sample/Assets.xcassets/Contents.json b/samples/ios-sample/ios-sample/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/samples/ios-sample/ios-sample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/samples/ios-sample/ios-sample/ContentView.swift b/samples/ios-sample/ios-sample/ContentView.swift new file mode 100644 index 0000000..7cf1704 --- /dev/null +++ b/samples/ios-sample/ios-sample/ContentView.swift @@ -0,0 +1,38 @@ +// +// ContentView.swift +// ios-sample +// +// Created by Thiago dos Santos on 07/02/24. +// + +import SwiftUI +import UIKitShared + +struct ContentView: View { + + var router: Routing? + + init(router: Routing? = nil) { + self.router = router + } + + var body: some View { + VStack { + Image(systemName: "globe") + .imageScale(.large) + .foregroundColor(.accentColor) + Text("Hello, world!") + Text("I am the initial content") + } + .padding() + .onTapGesture { + router?.callUri(uri: "/login", routeMethod: RouteMethodCompanion().Push) + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/samples/ios-sample/ios-sample/Preview Content/Preview Assets.xcassets/Contents.json b/samples/ios-sample/ios-sample/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/samples/ios-sample/ios-sample/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/samples/ios-sample/ios-sample/RoutingController.swift b/samples/ios-sample/ios-sample/RoutingController.swift new file mode 100644 index 0000000..49cfde4 --- /dev/null +++ b/samples/ios-sample/ios-sample/RoutingController.swift @@ -0,0 +1,50 @@ +// +// RoutingController.swift +// ios-sample +// +// Created by Thiago dos Santos on 08/02/24. +// + +import Foundation +import SwiftUI +import UIKitShared + +public struct RoutingController { + + let prefersLargeTitles: Bool + + let router: Routing + + public init( + router: Routing, + prefersLargeTitles: Bool = false + ) { + self.router = router + self.prefersLargeTitles = prefersLargeTitles + } +} + +extension RoutingController: UIViewControllerRepresentable { + + public func makeUIViewController(context _: Context) -> UINavigationController { + router.application_.logger?.debug(message: ">>>> makeUIViewController") + let navigationController = UINavigationController() + navigationController.navigationBar.prefersLargeTitles = prefersLargeTitles + + let rootController = SwiftUIController { + ContentView(router: router) + } + + router.install(plugin: UIKItPluginKt.UIKitPlugin) { setup in + guard let config = setup as? UIKitPluginConfig else { return } + config.navigationController = navigationController + } + + navigationController.setViewControllers([rootController], animated: false) + return navigationController + } + + public func updateUIViewController(_ uiViewController: UINavigationController, context _: Context) { + router.application_.logger?.debug(message: ">>>> updateUIViewController: \(uiViewController)") + } +} diff --git a/samples/ios-sample/ios-sample/SwiftUIController.swift b/samples/ios-sample/ios-sample/SwiftUIController.swift new file mode 100644 index 0000000..7b3fa91 --- /dev/null +++ b/samples/ios-sample/ios-sample/SwiftUIController.swift @@ -0,0 +1,24 @@ +// +// SwiftUIController.swift +// ios-sample +// +// Created by Thiago dos Santos on 08/02/24. +// + +import SwiftUI + +public final class SwiftUIController: UIHostingController { + + public init( + title: String? = nil, + @ViewBuilder content: () -> Content + ) { + super.init(rootView: content()) + super.title = title + } + + required init?(coder _: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/samples/ios-sample/ios-sample/ios_sampleApp.swift b/samples/ios-sample/ios-sample/ios_sampleApp.swift new file mode 100644 index 0000000..f284f96 --- /dev/null +++ b/samples/ios-sample/ios-sample/ios_sampleApp.swift @@ -0,0 +1,118 @@ +// +// ios_sampleApp.swift +// ios-sample +// +// Created by Thiago dos Santos on 07/02/24. +// + +import os +import SwiftUI +import UIKitShared + +@main +struct ios_sampleApp: App { + + let router = Routing_iosKt.routing( + rootPath: "/", + parent: nil, + logger: MyLogger(), + developmentMode: true, + configuration: { _ in } + ) + + var body: some Scene { + WindowGroup { + RoutingController(router: router) + .onAppear { + router.controller(path: "/home", animated: true) { call in + router.application_.logger?.debug(message: ">>>> home controller: \(call)") + return SwiftUIController { + VStack { + Text("Hello, Home! Go to Login") + .onTapGesture { + router.callUri(uri: "/login", routeMethod: RouteMethodCompanion().Push) + } + Text("Pop Home!") + .onTapGesture { + router.popController(animated: true) + } + } + } + } + + router.controller(path: "/login", animated: true) { call in + router.application_.logger?.debug(message: ">>>> login controller: \(call)") + return SwiftUIController { + VStack { + Text("Hello, Login! Go to Home") + .onTapGesture { + router.callUri(uri: "/home", routeMethod: RouteMethodCompanion().ReplaceAll) + } + Text("Pop Login!") + .onTapGesture { + router.popController(animated: true) + } + } + } + } + + router.handle(path: "/home") { call in + router.application_.logger?.debug(message: ">>>> home handle: \(call)") + } + + router.handle(path: "/login") { call in + router.application_.logger?.debug(message: ">>>> login handle: \(call)") + } + } + } + } +} + +private class MyLogger : UIKitShared.Logger { + + private let logger = Logger() + + var level: UIKitShared.LogLevel = .trace + + init() {} + + func debug(message: String) { + logger.debug("\(message)") + } + + func debug(message: String, cause: KotlinThrowable) { + logger.debug("\(message) -> \(cause)") + } + + func error(message: String) { + logger.error("\(message)") + } + + func error(message: String, cause: KotlinThrowable) { + logger.error("\(message) -> \(cause)") + } + + func info(message: String) { + logger.info("\(message)") + } + + func info(message: String, cause: KotlinThrowable) { + logger.info("\(message) -> \(cause)") + } + + func trace(message: String) { + logger.trace("\(message)") + } + + func trace(message: String, cause: KotlinThrowable) { + logger.trace("\(message) -> \(cause)") + } + + func warn(message: String) { + logger.warning("\(message)") + } + + func warn(message: String, cause: KotlinThrowable) { + logger.warning("\(message) -> \(cause)") + } +}