Created
November 9, 2023 02:29
-
-
Save fergdev/f8b3c3f2e385b3ddedaa6ecef024e836 to your computer and use it in GitHub Desktop.
Compose Learning Template
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 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