Skip to content

Instantly share code, notes, and snippets.

@fergdev
Created November 9, 2023 02:29
Show Gist options
  • Save fergdev/f8b3c3f2e385b3ddedaa6ecef024e836 to your computer and use it in GitHub Desktop.
Save fergdev/f8b3c3f2e385b3ddedaa6ecef024e836 to your computer and use it in GitHub Desktop.
Compose Learning Template
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Theme {
Surface {
MainScreen(mainViewModel = MainViewModel())
}
}
}
}
}
class CountryRepository {
@Throws(IOException::class)
suspend fun getCountries(from: Int = 0, size: Int = 10): Flow<List<String>> {
delay(2000)
return MutableStateFlow(Countries.getCountriesSafe(from, size))
}
suspend fun getAllCountries(): Flow<List<String>> {
delay(2000)
return MutableStateFlow(Countries.getAllCountries())
}
}
class MainViewModel(
private val countryRepository: CountryRepository = CountryRepository(),
) : ViewModel() {
}
@Composable
private fun MainScreen(mainViewModel: MainViewModel) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment