Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Fruitties ViewModel on iOS #34

Merged
merged 19 commits into from
Sep 26, 2024
Merged

Conversation

cartland
Copy link
Contributor

@cartland cartland commented Sep 10, 2024

  • Create IOSViewModelOwner in native source set
  • Instantiate IOSViewModelOwner in iOSApp.swift
  • Add helper function MainViewModel.newCreationExtras()
  • Instantiate MainViewModel in IOSViewModelOwner
  • collect() KMP StateFlow to State with SKIE preview API
  • Delete UIModel and use ViewModel directly
  • Cart calculates total items, not number of distinct items
  • Simplify Fruitties UI to match Android & iOS

* addToCart does not need async keyword
* await (home, cart) created an Xcode warning: Expression of type '((), ())' is unused
  * The async functions never return, so fixed by assigning result to _
Fruitties/iosApp/iosApp/CartView.swift Outdated Show resolved Hide resolved
Fruitties/iosApp/iosApp/ContentView.swift Outdated Show resolved Hide resolved
* "Cart has $total items"
* CartUiState -> CartUIState
Copy link

@dlam dlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me, thanks for updating the sample and helping out with the KMP efforts :)

* Edge-to-edge: Use contentWindowInsets to allow drawing to Bottom edge
* TopBar: Use CenterAlignedTopAppBar to simplify centering
Copy link

@alexvanyo alexvanyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me from the edge-to-edge perspective!

@cartland cartland merged commit 359b809 into android:main Sep 26, 2024
3 checks passed
@joreilly
Copy link

Smail thing but be good to update following in REAMDE to include ViewModel now

"Fruitties is a sample app using the Kotlin Multiplatform Room, DataStore and Ktor libraries to fetch, store and display data."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants