From 0c9d869dbda23df8735a6548c697b8ed50f82b28 Mon Sep 17 00:00:00 2001 From: mangbaam Date: Sat, 16 Nov 2024 22:02:20 +0900 Subject: [PATCH] =?UTF-8?q?Boolti-337=20feat:=20=EA=B3=B5=EC=97=B0=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EB=B0=B1=EB=B2=84=ED=8A=BC=20=EC=A0=9C?= =?UTF-8?q?=EC=96=B4=20(=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/component/BtWebView.kt | 3 ++ .../ShowRegistrationScreen.kt | 37 ++++++++++++++++++- presentation/src/main/res/values/strings.xml | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/com/nexters/boolti/presentation/component/BtWebView.kt b/presentation/src/main/java/com/nexters/boolti/presentation/component/BtWebView.kt index c2e963ad..41326bfa 100644 --- a/presentation/src/main/java/com/nexters/boolti/presentation/component/BtWebView.kt +++ b/presentation/src/main/java/com/nexters/boolti/presentation/component/BtWebView.kt @@ -22,6 +22,9 @@ class BtWebView @JvmOverloads constructor( val progress = _progress.asStateFlow() init { + isFocusable = true + isFocusableInTouchMode = true + setupSettings() setupWebViewClient() } diff --git a/presentation/src/main/java/com/nexters/boolti/presentation/screen/showregistration/ShowRegistrationScreen.kt b/presentation/src/main/java/com/nexters/boolti/presentation/screen/showregistration/ShowRegistrationScreen.kt index cd7d9ead..751ab3b4 100644 --- a/presentation/src/main/java/com/nexters/boolti/presentation/screen/showregistration/ShowRegistrationScreen.kt +++ b/presentation/src/main/java/com/nexters/boolti/presentation/screen/showregistration/ShowRegistrationScreen.kt @@ -1,10 +1,13 @@ package com.nexters.boolti.presentation.screen.showregistration import android.annotation.SuppressLint +import android.app.ActionBar.LayoutParams import android.net.Uri import android.webkit.CookieManager import android.webkit.ValueCallback import android.webkit.WebStorage +import android.webkit.WebView +import androidx.activity.compose.BackHandler import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.animation.AnimatedVisibility @@ -12,7 +15,9 @@ import androidx.compose.animation.fadeOut import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.derivedStateOf @@ -29,6 +34,7 @@ import androidx.compose.ui.viewinterop.AndroidView import androidx.hilt.navigation.compose.hiltViewModel import com.nexters.boolti.presentation.BuildConfig import com.nexters.boolti.presentation.R +import com.nexters.boolti.presentation.component.BTDialog import com.nexters.boolti.presentation.component.BtBackAppBar import com.nexters.boolti.presentation.component.BtCircularProgressIndicator import com.nexters.boolti.presentation.component.BtWebView @@ -53,7 +59,10 @@ fun ShowRegistrationScreen( val domain = BuildConfig.DOMAIN val url = "https://${domain}/show/add" + var showExitDialog by mutableStateOf(false) + val scope = rememberCoroutineScope() + var webView: WebView? by remember { mutableStateOf(null) } var webviewProgress by remember { mutableIntStateOf(0) } val loading by remember { derivedStateOf { webviewProgress < 100 } } @@ -73,12 +82,16 @@ fun ShowRegistrationScreen( } } + BackHandler { + if (webView?.canGoBack() == true) webView?.goBack() else showExitDialog = true + } + Scaffold( modifier = modifier, topBar = { BtBackAppBar( title = stringResource(R.string.my_register_show), - onClickBack = onClickBack, + onClickBack = { showExitDialog = true }, ) }, ) { innerPadding -> @@ -90,6 +103,11 @@ fun ShowRegistrationScreen( AndroidView( factory = { context -> BtWebView(context).apply { + layoutParams = LayoutParams( + LayoutParams.MATCH_PARENT, + LayoutParams.MATCH_PARENT, + ) + setWebChromeClient( launchActivity = { launcher.launch(arrayOf("image/*")) }, setFilePathCallback = { callback -> filePathCallback = callback }, @@ -99,7 +117,7 @@ fun ShowRegistrationScreen( scope.launch { progress.collect { webviewProgress = it } } - } + }.also { webView = it } }, update = { webView -> webView.loadUrl(url) }, ) @@ -111,6 +129,21 @@ fun ShowRegistrationScreen( ) { BtCircularProgressIndicator() } + + if (showExitDialog) { + BTDialog( + positiveButtonLabel = stringResource(R.string.btn_exit), + onClickPositiveButton = onClickBack, + onClickNegativeButton = { showExitDialog = false }, + onDismiss = { showExitDialog = false }, + ) { + Text( + text = stringResource(R.string.exit_register_msg), + style = MaterialTheme.typography.titleLarge, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } } } } diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 75f44107..3dccb7ce 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -264,6 +264,7 @@ 입장 확인 정말 로그아웃 하시겠어요? 공연 등록 + 공연 등록을 종료하시겠어요? 프로필 보기 계정 설정 내 공연