Suspend function can be called from swift on Main thread. Examples:
// Sample.kt
suspend fun add(a: Int, b: Int): Int {
return a + b;
}
// Sample.swift
| class MainActivity : ComponentActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContent { | |
| PlaygroundTheme { | |
| Surface( | |
| modifier = Modifier.fillMaxSize(), | |
| color = MaterialTheme.colorScheme.background, | |
| ) { | |
| Box { |
| struct DependencyInjector { | |
| private static var dependencyList: [String:Any] = [:] | |
| static func resolve<T>() -> T { | |
| guard let t = dependencyList[String(describing: T.self)] as? T else { | |
| fatalError("No povider registered for type \(T.self)") | |
| } | |
| return t | |
| } | |
| import SwiftUI | |
| import UIKit | |
| import PhoneNumberKit | |
| struct PhoneNumberTextFieldView: UIViewRepresentable { | |
| @Binding var phoneNumber: String | |
| private let textField = PhoneNumberTextField() | |
| func makeUIView(context: Context) -> PhoneNumberTextField { | |
| textField.withExamplePlaceholder = true |
| // The SwiftUI Lab | |
| // Website: https://swiftui-lab.com | |
| // Article: https://swiftui-lab.com/alignment-guides | |
| import SwiftUI | |
| class Model: ObservableObject { | |
| @Published var minimumContainer = true | |
| @Published var extendedTouchBar = false | |
| @Published var twoPhases = true |
| package com.ed.lib.base.utils; | |
| import android.content.Context; | |
| import android.support.v7.widget.LinearLayoutManager; | |
| import android.support.v7.widget.RecyclerView; | |
| import android.util.AttributeSet; | |
| import android.view.ViewGroup; | |
| public class SpanningLinearLayoutManager extends LinearLayoutManager { |
| package au.id.alexn; | |
| import android.content.Context; | |
| import android.util.AttributeSet; | |
| import android.util.Log; | |
| import android.view.MotionEvent; | |
| import android.view.ScaleGestureDetector; | |
| import android.view.View; | |
| import android.widget.FrameLayout; |
| MIT License | |
| Copyright (c) 2020 Jan Heinrich Reimer | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |