Skip to content

Commit 760f430

Browse files
committed
FEAT: 웹뷰 토큰 리프레시 브릿지만 연결
1 parent cd3a6f4 commit 760f430

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

feature/webview/src/main/java/com/plottwist/feature/webview/WebViewContract.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ data class WebViewState(
99
sealed class WebViewAction {
1010
data object ClickBack : WebViewAction()
1111
data class OnPageFinished(val webView: WebView) : WebViewAction()
12+
data class OnRequestTokenRefresh(val webView: WebView) : WebViewAction()
1213
}
1314

1415
sealed class WebViewSideEffect {

feature/webview/src/main/java/com/plottwist/feature/webview/WebViewScreen.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ fun WebViewScreen(
4747
onPageFinished = {
4848
viewModel.handleAction(WebViewAction.OnPageFinished(it))
4949
},
50+
onRequestTokenRefresh = {
51+
webView?.reload()
52+
},
5053
url = state.url
5154
)
5255
}
@@ -57,6 +60,7 @@ private fun WebViewScreen(
5760
url: String,
5861
onWebViewCreated : (WebView) -> Unit,
5962
onPageFinished: (webView: WebView) -> Unit,
63+
onRequestTokenRefresh: () -> Unit,
6064
modifier: Modifier = Modifier,
6165
) {
6266
TukWebView(
@@ -67,7 +71,8 @@ private fun WebViewScreen(
6771
addBridge = {
6872
it.addJavascriptInterface(
6973
DefaultBridge(
70-
onNavigateHome = onBackClick
74+
onNavigateHome = onBackClick,
75+
onRequestTokenRefresh = onRequestTokenRefresh
7176
),
7277
BRIDGE_NAME
7378
)
@@ -89,11 +94,19 @@ fun WebViewAppBar(
8994

9095
internal const val BRIDGE_NAME = "AndroidBridge"
9196

92-
private class DefaultBridge(val onNavigateHome: () -> Unit) {
97+
private class DefaultBridge(
98+
val onNavigateHome: () -> Unit,
99+
val onRequestTokenRefresh: () -> Unit
100+
) {
93101
@JavascriptInterface
94102
fun navigateHome() {
95103
onNavigateHome()
96104
}
105+
106+
@JavascriptInterface
107+
fun requestTokenRefresh() {
108+
onRequestTokenRefresh()
109+
}
97110
}
98111

99112
@Preview
@@ -103,6 +116,7 @@ private fun WebViewScreenPreview() {
103116
onBackClick = {},
104117
url = "https://www.google.com",
105118
onWebViewCreated = {},
106-
onPageFinished = {}
119+
onPageFinished = {},
120+
onRequestTokenRefresh = {}
107121
)
108122
}

feature/webview/src/main/java/com/plottwist/feature/webview/WebViewViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class WebViewViewModel @Inject constructor(
3131
is WebViewAction.OnPageFinished -> {
3232
handlePageFinished(action.webView)
3333
}
34+
35+
is WebViewAction.OnRequestTokenRefresh -> {
36+
// TODO 토큰 재발급 후 액세스 토큰 웹뷰에 보내기 로직
37+
}
3438
}
3539
}
3640

0 commit comments

Comments
 (0)