This file contains 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
@Composable | |
fun FirstScreen( | |
navigate: () -> Unit, | |
firstContainer: FirstContainer = rememberFirstContainer(), | |
firstViewModel: FirstViewModel = viewModel(factory = firstContainer.viewModelFactory) | |
) { // content here.. } | |
@Composable | |
fun rememberFirstContainer(): FirstContainer { | |
return remember { |
This file contains 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
@Composable | |
fun FirstScreen( | |
navigate: () -> Unit, | |
firstContainer: FirstContainer = FirstContainer().also { | |
DaggerFirstComponent.builder().build().inject(it) | |
}, | |
firstViewModel: FirstViewModel = viewModel(factory = firstContainer.viewModelFactory) | |
) { } |
This file contains 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
@Component( | |
modules = [FirstModule::class, VmModule::class] // dagger modules here if needed | |
) | |
interface FirstComponent { | |
fun inject(firstContainer: FirstContainer) // inject the container instead of the activity/fragment | |
@Component.Builder | |
interface Builder { | |
fun build(): FirstComponent |
This file contains 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
@Stable | |
class FirstContainer { | |
@Inject lateinit var firstScreenTracker: FirstScreenTracker | |
@Inject lateinit var viewModelFactory: ViewModelFactory | |
} |
This file contains 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 : AppCompatActivity() { | |
@Inject lateinit var firstScreenTracker: FirstScreenTracker | |
@Inject lateinit var viewModelFactory: ViewModelFactory | |
override fun onCreate(savedInstanceState: Bundle?) { | |
DaggerFirstComponent.builder().build().inject(this) // build dagger component and inject | |
super.onCreate(savedInstanceState) | |
setContent { |
This file contains 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
@Composable | |
fun FirstScreen( | |
navigate: () -> Unit, | |
firstScreenTracker: FirstScreenTracker, | |
viewModelFactory: ViewModelFactory, | |
firstViewModel: FirstViewModel = viewModel(factory = viewModelFactory) | |
) { | |
// content... | |
} |
This file contains 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
@Composable | |
fun FirstScreen( | |
navigate: () -> Unit, | |
firstContainer: FirstContainer = rememberFirstContainer(), | |
firstViewModel: FirstViewModel = viewModel(factory = firstContainer.viewModelFactory) | |
) { | |
// content... | |
} |
This file contains 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
@Composable | |
private fun MainContent( | |
changeSystemBarStyle: (SystemBarStyle) -> Unit | |
) { | |
Scaffold( | |
modifier = Modifier.fillMaxSize(), | |
containerColor = Color.Black | |
) { paddingValues -> | |
LaunchedEffect(Unit) { |
This file contains 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
@Composable | |
fun BoxWithConstraintsScope.draggableBox() { | |
Box( | |
modifier = Modifier | |
.fillMaxWidth() | |
.height(boxHeight) | |
.background(Color.White) | |
.align(Alignment.BottomCenter) | |
.pointerInput(Unit) { | |
detectVerticalDragGestures { change, dragAmount -> |
This file contains 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
@Composable | |
fun MainContent() { | |
Scaffold { paddingValues -> | |
// .... | |
val layoutDirection = LocalLayoutDirection.current | |
Box( | |
modifier = Modifier | |
.fillMaxSize() | |
.padding( | |
start = paddingValues.calculateStartPadding(layoutDirection), |
NewerOlder