This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun UserInfo(username: String, email: String, modifier: Modifier = Modifier) { | |
Column( | |
modifier = modifier | |
.fillMaxWidth() | |
.padding(12.dp), | |
verticalArrangement = Arrangement.spacedBy(8.dp) | |
) { | |
Text(text = username, style = MaterialTheme.typography.titleLarge) | |
Text(text = email, style = MaterialTheme.typography.bodyMedium) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actual interface Parcelable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actual interface Parcelable : android.os.Parcelable | |
actual typealias Parcelize = kotlinx.parcelize.Parcelize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expect interface Parcelable | |
@OptIn(ExperimentalMultiplatform::class) | |
@OptionalExpectation | |
@Target(AnnotationTarget.CLASS) | |
@Retention(AnnotationRetention.BINARY) | |
expect annotation class Parcelize() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Parcelable | |
import kotlinx.parcelize.Parcelize | |
@Parcelize | |
data class Product( | |
val id: String, | |
val name: String, | |
val description: String, | |
val price: Double | |
) : Parcelable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ProductListView: View { | |
let viewModel: ProductListViewModel | |
@State var products: [Product] = [] | |
var body: View { | |
VStack { | |
... | |
} | |
.stateBinding($products, viewModel.products) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private struct StateBinding<State>: ViewModifier { | |
@Binding var state: State | |
let stateFlow: SkieSwiftStateFlow<State> | |
func body(content: Content) -> some View { | |
content.task { | |
for await state in stateFlow { | |
self.state = state | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductListViewModel : ViewModel() { | |
val products: StateFlow<List<Product>> | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UIHostingControllerWrapper<V: View, VM: ViewModel> : UIHostingController<V>, ViewModelStoreOwner { | |
let viewModelStore = ViewModelStore() | |
init(rootView: V, viewModel: VM) { | |
super.init(rootView: rootView) | |
let key = String(describing: VM.self) | |
viewModelStore.put(key: key, viewModel: viewModel) | |
} |
NewerOlder