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 YourViewModel: ViewModel() { | |
val uiScope = mutableStateOf<UIScope?>(null) | |
private val counter = mutableStateOf(0) | |
fun onButtonClick() { | |
if((++counter.value)%2==1){ | |
uiScope.scope { | |
it.toaster?.toast(it.toaster.stringResource(R.string.click_again)) | |
} | |
} | |
else{ |
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
val owner = LocalLifecycleOwner.current | |
val context = LocalContext.current | |
LaunchedEffect(key1 = vm.uiScope.value){ | |
vm.uiScope.forward( | |
ScopeManager( | |
navHostController = navController, | |
owner = owner, | |
toaster = Toaster(context) | |
) | |
) |
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
data class Toaster( | |
private val context: Context | |
){ | |
fun toast(message: String, duration: Int = Toast.LENGTH_SHORT){ | |
Toast.makeText(context, message,duration).show() | |
} | |
fun stringResource(@StringRes id: Int): String{ | |
return context.getString(id) | |
} |
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
package com.debduttapanda.marker | |
import com.squareup.kotlinpoet.FileSpec | |
import com.squareup.kotlinpoet.TypeSpec | |
import java.io.File | |
import javax.annotation.processing.AbstractProcessor | |
import javax.annotation.processing.RoundEnvironment | |
import javax.annotation.processing.SupportedSourceVersion | |
import javax.lang.model.SourceVersion | |
import javax.lang.model.element.Element |
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
package com.debduttapanda.marker | |
import javax.annotation.processing.AbstractProcessor | |
import javax.annotation.processing.RoundEnvironment | |
import javax.annotation.processing.SupportedSourceVersion | |
import javax.lang.model.SourceVersion | |
import javax.lang.model.element.Element | |
import javax.lang.model.element.TypeElement | |
@SupportedSourceVersion(SourceVersion.RELEASE_8) // 1 |
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
package com.debduttapanda.marker | |
@Target( | |
AnnotationTarget.FUNCTION, | |
AnnotationTarget.CLASS, | |
AnnotationTarget.FILE, | |
) | |
@Retention(AnnotationRetention.SOURCE) | |
annotation class Mark |
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
package com.debduttapanda.mymarker | |
import android.content.Context | |
import android.os.Bundle | |
import android.widget.Toast | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.Button |
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
package com.debduttapanda.powernavigation | |
import android.annotation.SuppressLint | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.annotation.DrawableRes | |
import androidx.compose.animation.ExperimentalAnimationApi | |
import androidx.compose.foundation.Image | |
import androidx.compose.foundation.background |
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
package com.debduttapanda.powernavigation | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.animation.ExperimentalAnimationApi | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.Divider |