Skip to content

Commit

Permalink
Update iosApp
Browse files Browse the repository at this point in the history
  • Loading branch information
syxc committed May 16, 2024
1 parent 975595f commit 86b5a2d
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 147 deletions.
25 changes: 22 additions & 3 deletions iosApp/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
source 'https://cdn.cocoapods.org/'
source 'https://github.com/CocoaPods/Specs.git'
target 'iosApp' do
use_frameworks!
platform :ios, '14.0'

use_frameworks!
platform :ios, '13.0'

# ignore all warnings from all pods
inhibit_all_warnings!

def shared_pods
pod 'shared', :path => '../shared'
end

target 'iosApp' do
shared_pods
end

# https://github.com/nicklockwood/SwiftFormat
pod 'SwiftFormat/CLI', '~> 0.53.9'

post_install do |installer|
installer.pods_project.targets.each do |target|
puts target.name
end
end
11 changes: 9 additions & 2 deletions iosApp/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
PODS:
- shared (1.0)
- SwiftFormat/CLI (0.53.9)

DEPENDENCIES:
- shared (from `../shared`)
- SwiftFormat/CLI (~> 0.53.9)

SPEC REPOS:
trunk:
- SwiftFormat

EXTERNAL SOURCES:
shared:
:path: "../shared"

SPEC CHECKSUMS:
shared: be96e957c615a90e6b37a5fe0b691b64ce27be2a
shared: 825978f2a80ce00aa0d9e76613eb649352d916b5
SwiftFormat: d30e6e1c9a85f4bce83394af184e2c1d03032605

PODFILE CHECKSUM: c53d60b950ac768cddc374c4bcbbb4566765a415
PODFILE CHECKSUM: c865212f162b25efab1f4c3a7c4b85bdb722c41e

COCOAPODS: 1.15.2
32 changes: 26 additions & 6 deletions iosApp/iosApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
42799AB246E5F90AF97AA0EF /* Frameworks */,
7245235AAA33464F666589E3 /* Pods */,
);
indentWidth = 2;
indentWidth = 4;
sourceTree = "<group>";
tabWidth = 2;
tabWidth = 4;
};
7555FF7C242A565900829871 /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -129,6 +129,7 @@
buildPhases = (
206F7568628FF9BCAB606D32 /* [CP] Check Pods Manifest.lock */,
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin Framework */,
4CECD50E2BF5F18E00E08607 /* SwiftFormat */,
7555FF77242A565900829871 /* Sources */,
B92378962B6B1156000C7307 /* Frameworks */,
7555FF79242A565900829871 /* Resources */,
Expand Down Expand Up @@ -231,6 +232,25 @@
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n\"$SRCROOT/../gradlew\" -p \"$SRCROOT/../\" :shared:copyPodFrameworkResourcesToApp \\\n -Pmoko.resources.BUILT_PRODUCTS_DIR=\"$BUILT_PRODUCTS_DIR\" \\\n -Pmoko.resources.CONTENTS_FOLDER_PATH=\"$CONTENTS_FOLDER_PATH\" \\\n -Pkotlin.native.cocoapods.platform=\"$PLATFORM_NAME\" \\\n -Pkotlin.native.cocoapods.archs=\"$ARCHS\" \\\n -Pkotlin.native.cocoapods.configuration=\"$CONFIGURATION\"\n\n";
};
4CECD50E2BF5F18E00E08607 /* SwiftFormat */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftFormat;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat\" \"$SRCROOT\"\n";
};
F36B1CEA2AD836FC00CB74D5 /* Compile Kotlin Framework */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -321,7 +341,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -378,7 +398,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -406,7 +426,7 @@
);
INFOPLIST_FILE = iosApp/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = iosApp;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -445,7 +465,7 @@
);
INFOPLIST_FILE = iosApp/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = iosApp;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
78 changes: 39 additions & 39 deletions iosApp/iosApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,58 @@ import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var window: UIWindow?

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Override point for customization after application launch.
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Override point for customization after application launch.

UITabBarItem.appearance().setTitleTextAttributes(
[NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)], for: .normal
)
UITabBarItem.appearance().setTitleTextAttributes(
[NSAttributedString.Key.font: UIFont.systemFont(ofSize: 15)], for: .normal
)

let homeViewController = HomeViewController()
homeViewController.title = "SwiftUI"
let homeViewController = HomeViewController()
homeViewController.title = "SwiftUI"

let mokoViewController = MokoViewController()
mokoViewController.title = "Moko Resource"
let mokoViewController = MokoViewController()
mokoViewController.title = "Moko Resource"

let anotherViewController = CounterViewController()
// anotherViewController.view.backgroundColor = .white
anotherViewController.title = "Redwood UI"
let anotherViewController = CounterViewController()
// anotherViewController.view.backgroundColor = .white
anotherViewController.title = "Redwood UI"

// Set up the UITabBarController
let tabBarController = UITabBarController()
tabBarController.viewControllers = [
// Wrap them in a UINavigationController for the titles
UINavigationController(rootViewController: homeViewController),
UINavigationController(rootViewController: mokoViewController),
UINavigationController(rootViewController: anotherViewController),
]
tabBarController.tabBar.items?[0].title = "Home"
tabBarController.tabBar.items?[1].title = "Moko"
tabBarController.tabBar.items?[2].title = "Redwood"
// Set up the UITabBarController
let tabBarController = UITabBarController()
tabBarController.viewControllers = [
// Wrap them in a UINavigationController for the titles
UINavigationController(rootViewController: homeViewController),
UINavigationController(rootViewController: mokoViewController),
UINavigationController(rootViewController: anotherViewController),
]
tabBarController.tabBar.items?[0].title = "Home"
tabBarController.tabBar.items?[1].title = "Moko"
tabBarController.tabBar.items?[2].title = "Redwood"

// Set the tab bar controller as the window's root view controller and make it visible
window = UIWindow(frame: UIScreen.main.bounds)
window?.backgroundColor = .white
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()
// Set the tab bar controller as the window's root view controller and make it visible
window = UIWindow(frame: UIScreen.main.bounds)
window?.backgroundColor = .systemBackground
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()

return true
}
return true
}

func applicationWillResignActive(_ application: UIApplication) {}
func applicationWillResignActive(_: UIApplication) {}

func applicationDidEnterBackground(_ application: UIApplication) {}
func applicationDidEnterBackground(_: UIApplication) {}

func applicationWillEnterForeground(_ application: UIApplication) {}
func applicationWillEnterForeground(_: UIApplication) {}

func applicationDidBecomeActive(_ application: UIApplication) {}
func applicationDidBecomeActive(_: UIApplication) {}

func applicationWillTerminate(_ application: UIApplication) {}
func applicationWillTerminate(_: UIApplication) {}
}

extension KotlinThrowable: Swift.Error {}
44 changes: 22 additions & 22 deletions iosApp/iosApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ import shared
import SwiftUI

struct ContentView: View {
@State private var showContent = false
var body: some View {
VStack {
Button("Click me!") {
withAnimation {
showContent = !showContent
}
}
@State private var showContent = false
var body: some View {
VStack {
Button("Click me!") {
withAnimation {
showContent = !showContent
}
}

if showContent {
VStack(spacing: 16) {
Image(systemName: "swift")
.font(.system(size: 200))
.foregroundColor(.accentColor)
Text("SwiftUI: \(Greeting().greet())")
if showContent {
VStack(spacing: 16) {
Image(systemName: "swift")
.font(.system(size: 200))
.foregroundColor(.accentColor)
Text("SwiftUI: \(Greeting().greet())")
}
.transition(.move(edge: .top).combined(with: .opacity))
}
}
.transition(.move(edge: .top).combined(with: .opacity))
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.padding()
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.padding()
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
static var previews: some View {
ContentView()
}
}
38 changes: 19 additions & 19 deletions iosApp/iosApp/CounterViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ import shared
import UIKit

class CounterViewController: UIViewController {
private var delegate: CounterViewControllerDelegate?
private var delegate: CounterViewControllerDelegate?

override func viewDidLoad() {
super.viewDidLoad()
let container = UIStackView()
container.axis = .horizontal
container.alignment = .fill
container.distribution = .fillEqually
container.translatesAutoresizingMaskIntoConstraints = false
override func viewDidLoad() {
super.viewDidLoad()
let container = UIStackView()
container.axis = .horizontal
container.alignment = .fill
container.distribution = .fillEqually
container.translatesAutoresizingMaskIntoConstraints = false

view.addSubview(container)
container.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
container.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
container.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
container.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true
view.addSubview(container)
container.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
container.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
container.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true
container.heightAnchor.constraint(equalTo: view.heightAnchor).isActive = true

self.delegate = CounterViewControllerDelegate(root: container)
}
delegate = CounterViewControllerDelegate(root: container)
}

// MARK: - deinit
// MARK: - deinit

deinit {
delegate?.dispose()
}
deinit {
delegate?.dispose()
}
}
38 changes: 19 additions & 19 deletions iosApp/iosApp/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ import SwiftUI
import UIKit

class HomeViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
override func viewDidLoad() {
super.viewDidLoad()

// 1.
let vc = UIHostingController(rootView: ContentView())
// 1.
let vc = UIHostingController(rootView: ContentView())

let swiftuiView = vc.view!
swiftuiView.translatesAutoresizingMaskIntoConstraints = false
let swiftuiView = vc.view!
swiftuiView.translatesAutoresizingMaskIntoConstraints = false

// 2.Add the view controller to the destination view controller.
addChild(vc)
view.addSubview(swiftuiView)
// 2.Add the view controller to the destination view controller.
addChild(vc)
view.addSubview(swiftuiView)

// 3.Create and activate the constraints for the swiftui's view.
NSLayoutConstraint.activate([
swiftuiView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
swiftuiView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
swiftuiView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
swiftuiView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
])
// 3.Create and activate the constraints for the swiftui's view.
NSLayoutConstraint.activate([
swiftuiView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
swiftuiView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
swiftuiView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
swiftuiView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
])

// 4.Notify the child view controller that the move is complete.
vc.didMove(toParent: self)
}
// 4.Notify the child view controller that the move is complete.
vc.didMove(toParent: self)
}
}
Loading

0 comments on commit 86b5a2d

Please sign in to comment.