Skip to content

Commit

Permalink
웹뷰 사용하는 페이지에서 코루틴 위치 수정 (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
eastshine2741 authored Oct 8, 2023
1 parent 87fa190 commit a3a4709
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ import com.wafflestudio.snutt2.R
import com.wafflestudio.snutt2.components.compose.SimpleTopBar
import com.wafflestudio.snutt2.ui.ThemeMode
import com.wafflestudio.snutt2.views.LocalNavController
import kotlinx.coroutines.launch

@Composable
fun PersonalInformationPolicyPage() {
val navController = LocalNavController.current
val context = LocalContext.current
val scope = rememberCoroutineScope()
val userViewModel = hiltViewModel<UserViewModel>()
val webViewClient = WebViewClient()
val themeMode by userViewModel.themeMode.collectAsState()

var accessToken: String
val url = stringResource(R.string.api_server) + stringResource(R.string.privacy)
val headers = HashMap<String, String>()
headers["x-access-apikey"] = stringResource(R.string.api_key)
Expand All @@ -42,25 +39,16 @@ fun PersonalInformationPolicyPage() {
}
}

var webViewUrlReady by remember { mutableStateOf(false) }

Column(modifier = Modifier.fillMaxSize()) {
SimpleTopBar(
title = stringResource(R.string.settings_personal_information_policy),
onClickNavigateBack = { navController.popBackStack() },
)
if (webViewUrlReady) {
AndroidView(factory = {
WebView(context).apply {
this.webViewClient = webViewClient
this.loadUrl(url, headers)
}
},)
}
scope.launch {
accessToken = userViewModel.getAccessToken()
headers["x-access-token"] = accessToken
webViewUrlReady = true
}
AndroidView(factory = {
WebView(context).apply {
this.webViewClient = WebViewClient()
loadUrl(url, headers)
}
},)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ import com.wafflestudio.snutt2.R
import com.wafflestudio.snutt2.components.compose.SimpleTopBar
import com.wafflestudio.snutt2.ui.ThemeMode
import com.wafflestudio.snutt2.views.LocalNavController
import kotlinx.coroutines.launch

@Composable
fun ServiceInfoPage() {
val navController = LocalNavController.current
val context = LocalContext.current
val scope = rememberCoroutineScope()
val userViewModel = hiltViewModel<UserViewModel>()
val webViewClient = WebViewClient()
val themeMode by userViewModel.themeMode.collectAsState()

var accessToken: String
val url = stringResource(R.string.api_server) + stringResource(R.string.terms)
val headers = HashMap<String, String>()
headers["x-access-apikey"] = stringResource(R.string.api_key)
Expand All @@ -43,26 +40,17 @@ fun ServiceInfoPage() {
}
}

var webViewUrlReady by remember { mutableStateOf(false) }

Column(modifier = Modifier.fillMaxSize()) {
SimpleTopBar(
title = stringResource(R.string.settings_service_info),
onClickNavigateBack = { navController.popBackStack() },
)
if (webViewUrlReady) {
AndroidView(factory = {
WebView(context).apply {
this.webViewClient = webViewClient
this.loadUrl(url, headers)
}
},)
}
scope.launch {
accessToken = userViewModel.getAccessToken()
headers["x-access-token"] = accessToken
webViewUrlReady = true
}
AndroidView(factory = {
WebView(context).apply {
this.webViewClient = webViewClient
loadUrl(url, headers)
}
},)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@ import com.wafflestudio.snutt2.R
import com.wafflestudio.snutt2.components.compose.SimpleTopBar
import com.wafflestudio.snutt2.ui.ThemeMode
import com.wafflestudio.snutt2.views.LocalNavController
import kotlinx.coroutines.launch

@Composable
fun TeamInfoPage() {
val navController = LocalNavController.current
val context = LocalContext.current
val scope = rememberCoroutineScope()
val userViewModel = hiltViewModel<UserViewModel>()
val webViewClient = WebViewClient()
val themeMode by userViewModel.themeMode.collectAsState()

var accessToken: String
val url = stringResource(R.string.api_server) + stringResource(R.string.member)
val headers = HashMap<String, String>()
headers["x-access-apikey"] = stringResource(R.string.api_key)
Expand All @@ -43,26 +40,17 @@ fun TeamInfoPage() {
}
}

var webViewUrlReady by remember { mutableStateOf(false) }

Column(modifier = Modifier.fillMaxSize()) {
SimpleTopBar(
title = stringResource(R.string.settings_team_info),
onClickNavigateBack = { navController.popBackStack() },
)
if (webViewUrlReady) {
AndroidView(factory = {
WebView(context).apply {
this.webViewClient = webViewClient
this.loadUrl(url, headers)
}
},)
}
scope.launch {
accessToken = userViewModel.getAccessToken()
headers["x-access-token"] = accessToken
webViewUrlReady = true
}
AndroidView(factory = {
WebView(context).apply {
this.webViewClient = webViewClient
loadUrl(url, headers)
}
},)
}
}

Expand Down

0 comments on commit a3a4709

Please sign in to comment.