Skip to content

Commit

Permalink
웹뷰 헤더 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-xyz committed Aug 6, 2024
1 parent 33a9a48 commit c04717a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/mashup/ui/webview/WebViewScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ fun WebViewScreen(
webViewUrl = webViewUiState.webViewUrl,
isScrollTop = isScrollTop,
onBackPressed = onBackPressed,
mashupBridge = mashupBridge
mashupBridge = mashupBridge,
additionalHttpHeaders = webViewUiState.additionalHttpHeaders
)
}
}
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/com/mashup/ui/webview/WebViewViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import javax.inject.Inject

Expand All @@ -26,16 +25,17 @@ class WebViewViewModel @Inject constructor(
savedStateHandle.getStateFlow(EXTRA_TITLE_KEY, ""),
savedStateHandle.getStateFlow(EXTRA_URL_KEY, ""),
showDividerFlow,
userPreferenceRepository.getUserPreference().map { it.platform }
) { title, webViewUrl, showDivider, platform ->
userPreferenceRepository.getUserPreference()
) { title, webViewUrl, showDivider, prefs ->
var convertWebViewUrl = webViewUrl
if (title == "mashong") {
convertWebViewUrl += platform
convertWebViewUrl += prefs.platform
}
WebViewUiState.Success(
title = title,
webViewUrl = convertWebViewUrl,
showToolbarDivider = showDivider
showToolbarDivider = showDivider,
additionalHttpHeaders = mapOf(Pair("authorization", prefs.token))
)
}.stateIn(
viewModelScope,
Expand All @@ -57,6 +57,7 @@ sealed interface WebViewUiState {
data class Success(
val title: String,
val webViewUrl: String,
val showToolbarDivider: Boolean
val showToolbarDivider: Boolean,
val additionalHttpHeaders: Map<String, String>
) : WebViewUiState
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class MashupBridge(
Toast.makeText(context, toast, Toast.LENGTH_SHORT).show()
}

@JavascriptInterface
override fun step(type: String) {
when (Type.values().find { it.name == type.uppercase() }) {
Type.BACK -> onBackPressed()
Expand Down

0 comments on commit c04717a

Please sign in to comment.