ComposeUI - 서랍 (drawer)

림행크·2023년 4월 11일
0

ComposeUI

목록 보기
4/5
// 컨텐트 뷰 설정을 ComposeView 로
setContentView(
    ComposeView(this).apply {
    	// drawerState 기억.
		val drawerState = rememberDrawerState(initialValue = Closed)
        val drawerOpen by 
			viewModel.drawerShouldBeOpened.collectAsStateWithLifecycle()
		
        if (drawerOpen) {
		// Open drawer and reset state in VM.

			LaunchedEffect(Unit) {
				// wrap in try-finally to handle 					interruption whiles opening drawer
				try {
					drawerState.open()
				} finally {
                	viewModel.resetOpenDrawerAction()
				}
			}
		}
    }
)

0개의 댓글