Skip to content

Commit

Permalink
[UI] #59 모아 약관 상세 웹뷰 화면 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ows3090 committed Mar 20, 2024
1 parent b1c4721 commit 974849e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 12 deletions.
2 changes: 2 additions & 0 deletions core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<string name="startup_onboarding_pager_skip">건너뛰기</string>
<string name="startup_onboarding_pager_next">다음</string>
<string name="startup_onboarding_start">시작하기</string>
<string name="startup_use_information_terms">모아 이용약관</string>
<string name="startup_privacy_information_terms">개인정보 처리방침</string>

<!-- My Page Setting -->
<string name="setting_bar_notification">알림</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fun BuddyConNavHost(

composable(route = StartUpDestination.Login.route) {
LoginScreen {
navHostController.navigate(GifticonDestination.Gifticon.route)
navHostController.navigate(StartUpDestination.SignUp.route)
}
}

Expand Down
1 change: 1 addition & 0 deletions feature/startup/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies {
implementation project(":domain")
implementation libs.accompanist.systemuicontroller
implementation libs.accompanist.pager
implementation libs.accompanist.webview
implementation libs.accompanist.pager.indicators
implementation libs.hilt.android
kapt libs.hilt.compiler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.yapp.buddycon.startup.signup

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
Expand All @@ -23,6 +24,8 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.web.WebView
import com.google.accompanist.web.rememberWebViewState
import com.yapp.buddycon.designsystem.R
import com.yapp.buddycon.designsystem.component.appbar.TopAppBarWithBack
import com.yapp.buddycon.designsystem.component.button.BuddyConButton
Expand All @@ -32,32 +35,71 @@ import com.yapp.buddycon.designsystem.theme.Grey40
import com.yapp.buddycon.designsystem.theme.Grey60
import com.yapp.buddycon.designsystem.theme.Paddings

private const val DEFAULT_TERMS_URL = ""
private const val SERVICE_TERMS_URL = "https://scarce-cartoon-27d.notion.site/e09da35361e142b7936c12e38396475e"
private const val PRIVACY_INFORMATION_TERMS_URL = "https://scarce-cartoon-27d.notion.site/c4e5ff54f9bd434e971a2631d122252c"

@Composable
fun SignUpScreen(
onNavigateToWelcome: () -> Unit = {},
onBack: () -> Unit
) {
var webUrl by remember { mutableStateOf(DEFAULT_TERMS_URL) }
val webViewState = rememberWebViewState(url = webUrl)
Scaffold(
topBar = {
TopAppBarWithBack(
title = stringResource(R.string.signup),
onBack = onBack
title = when (webUrl) {
SERVICE_TERMS_URL -> stringResource(R.string.startup_use_information_terms)
PRIVACY_INFORMATION_TERMS_URL -> stringResource(R.string.startup_privacy_information_terms)
else -> stringResource(R.string.signup)
},
onBack = {
if (webUrl == DEFAULT_TERMS_URL) {
onBack()
} else {
webUrl = DEFAULT_TERMS_URL
}
}
)
}
) { paddingValues ->
SignUpContent(
modifier = Modifier
.padding(paddingValues)
.fillMaxSize()
.background(BuddyConTheme.colors.background),
onNavigateToWelcome = onNavigateToWelcome
)
if (webUrl != DEFAULT_TERMS_URL) {
WebView(
state = webViewState,
modifier = Modifier.fillMaxSize(),
onCreated = {
it.settings.javaScriptEnabled = true
it.settings.domStorageEnabled = true
}
)
} else {
SignUpContent(
modifier = Modifier
.padding(paddingValues)
.fillMaxSize()
.background(BuddyConTheme.colors.background),
onLoadUseInformationTerms = { webUrl = SERVICE_TERMS_URL },
onLoadPrivacyInformationTerms = { webUrl = PRIVACY_INFORMATION_TERMS_URL },
onNavigateToWelcome = onNavigateToWelcome
)
}
}

BackHandler {
if (webUrl == DEFAULT_TERMS_URL) {
onBack()
} else {
webUrl = DEFAULT_TERMS_URL
}
}
}

@Composable
private fun SignUpContent(
modifier: Modifier = Modifier,
onLoadUseInformationTerms: () -> Unit = {},
onLoadPrivacyInformationTerms: () -> Unit = {},
onNavigateToWelcome: () -> Unit = {},
) {
var signUpTermsState by remember { mutableStateOf(SignUpTermsState()) }
Expand Down Expand Up @@ -92,7 +134,8 @@ private fun SignUpContent(
isChecked = signUpTermsState.termsOfUse,
text = stringResource(R.string.signup_terms_of_use_agree),
hasMore = true,
onCheck = { signUpTermsState = signUpTermsState.copy(termsOfUse = it) }
onCheck = { signUpTermsState = signUpTermsState.copy(termsOfUse = it) },
onClickHasMore = { onLoadUseInformationTerms() }
)
SignUpTermsContent(
modifier = Modifier
Expand All @@ -101,7 +144,8 @@ private fun SignUpContent(
isChecked = signUpTermsState.privacyPolicy,
text = stringResource(R.string.signup_privacy_policy_agree),
hasMore = true,
onCheck = { signUpTermsState = signUpTermsState.copy(privacyPolicy = it) }
onCheck = { signUpTermsState = signUpTermsState.copy(privacyPolicy = it) },
onClickHasMore = { onLoadPrivacyInformationTerms() }
)
Spacer(Modifier.weight(1f))
BuddyConButton(
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "tim
accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanist-compose" }
accompanist-pager = { group = "com.google.accompanist", name = "accompanist-pager", version.ref = "accompanist-compose" }
accompanist-pager-indicators = { group = "com.google.accompanist", name = "accompanist-pager-indicators", version.ref = "accompanist-compose" }
accompanist-webview = { group = "com.google.accompanist", name = "accompanist-webview", version.ref = "accompanist-compose" }

## 3rd library
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil-compose" }
Expand Down

0 comments on commit 974849e

Please sign in to comment.