Skip to content

Instantly share code, notes, and snippets.

View igorescodro's full-sized avatar
♥️
Coding with love

Igor Escodro igorescodro

♥️
Coding with love
View GitHub Profile
@Composable
fun HomeList(taskViewModel: ListViewModel = viewModel()) {
val coroutineScope = rememberCoroutineScope()
val scaffoldState = rememberScaffoldState()
val onShowSnackbar: (Task) -> Unit = { task ->
coroutineScope.launch {
val snackbarResult = scaffoldState.snackbarHostState.showSnackbar(
message = "${task.title} completed",
actionLabel = "Undo"
@Composable
fun NavGraph(startDestination: String = "Home") {
val navController = rememberNavController()
val actions = remember(navController) { Actions(navController) }
NavHost(navController = navController, startDestination = startDestination) {
composable("Home") {
Home()
}
internal class DynamicActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyTheme {
DynamicScreen()
}
}
...
<application>
<activity
android:name=".presentation.DynamicActivity"
android:exported="true"
android:theme="@style/Theme.MyTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@Composable
fun NavGraph(startDestination: String = "Home") {
val navController = rememberNavController()
val context = LocalContext.current
val actions = remember(navController) { Actions(navController, context) }
NavHost(navController = navController, startDestination = startDestination) {
composable("Home") {
Home(onDynamicClick = actions.onDynamicClick)
android {
testOptions {
devices {
pixel2api29(com.android.build.api.dsl.ManagedVirtualDevice) {
device = "Pixel 2"
apiLevel = 29
systemImageSource = "google"
abi = "x86"
}
}
testOptions {
devices {
pixel2api29 (com.android.build.api.dsl.ManagedVirtualDevice) { ... }
nexus9api30 (com.android.build.api.dsl.ManagedVirtualDevice) { ... }
deviceGroups {
phoneAndTablet {
targetDevices.addAll(devices.pixel2api29, devices.nexus9api30)
}
}
}
<style name="Theme.MySplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/purple_500</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="postSplashScreenTheme">@style/Theme.MyApp</item>
</style>
<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Your theme attributes goes here -->
</style>
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
setContentView(R.layout.activity_main)
}
}
<application
...
android:theme="@style/Theme.MySplash">
...
</application>