Skip to content

Commit

Permalink
[feat #70] 회원가입 퍼블리싱
Browse files Browse the repository at this point in the history
  • Loading branch information
parkuiery authored Oct 22, 2024
2 parents cb633bc + 1fab90d commit d8d4a1d
Show file tree
Hide file tree
Showing 63 changed files with 2,061 additions and 31 deletions.
1 change: 1 addition & 0 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ kotlin {

implementation(projects.feature.splash)
implementation(projects.feature.signin)
implementation(projects.feature.signup)
}
jvmMain.dependencies {
implementation(compose.desktop.currentOs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,70 @@ import androidx.compose.runtime.remember
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import team.aliens.dms.kmp.feature.signin.navigation.navigateToSignIn
import team.aliens.dms.kmp.feature.signup.model.SignUpData
import team.aliens.dms.kmp.feature.signup.navigation.navigateToEnterEmail
import team.aliens.dms.kmp.feature.signup.navigation.navigateToEnterEmailVerificationCode
import team.aliens.dms.kmp.feature.signup.navigation.navigateToEnterSchoolVerificationCode
import team.aliens.dms.kmp.feature.signup.navigation.navigateToEnterSchoolVerificationQuestion
import team.aliens.dms.kmp.feature.signup.navigation.navigateToSetId
import team.aliens.dms.kmp.feature.signup.navigation.navigateToSetPassword
import team.aliens.dms.kmp.feature.signup.navigation.navigateToSignUp
import team.aliens.dms.kmp.feature.signup.navigation.navigateToTerms

internal class DmsNavigator(
val navController: NavHostController,
) {

fun navigateToLogin() {
fun navigateToSignIn() {
navController.navigateToSignIn()
}

fun navigateToSignUp() {
navController.navigateToSignUp()
}

fun navigateToEnterSchoolVerificationCode() {
navController.navigateToEnterSchoolVerificationCode()
}

fun navigateToEnterSchoolVerificationQuestion(signUpData: SignUpData) {
navController.navigateToEnterSchoolVerificationQuestion(signUpData = signUpData)
}

fun navigateToEnterEmail(signUpData: SignUpData) {
navController.navigateToEnterEmail(signUpData = signUpData)
}

fun navigateToEnterEmailVerificationCode(signUpData: SignUpData) {
navController.navigateToEnterEmailVerificationCode(signUpData = signUpData)
}

fun navigateToSetId(signUpData: SignUpData) {
navController.navigateToSetId(signUpData = signUpData)
}

fun navigateToSetPassword(signUpData: SignUpData) {
navController.navigateToSetPassword(signUpData = signUpData)
}

fun navigateToTerms(signUpData: SignUpData) {
navController.navigateToTerms(signUpData = signUpData)
}

fun popBackStackIfNotHome() {
if (!isSameCurrentDestination()) {
popBackStack()
}
}

// TODO: private로 변경
fun popBackStack() {
navController.popBackStack()
}

private fun isSameCurrentDestination(): Boolean {
return navController.currentDestination?.route == ""
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package team.aliens.dms.kmp.di

import org.koin.dsl.module
import team.aliens.dms.kmp.feature.signin.di.signInModule
import team.aliens.dms.kmp.feature.signup.di.signUpModule
import team.aliens.dms.kmp.feature.splash.di.splashModule

internal val featureModule = module {
includes(
splashModule,
signInModule,
signUpModule,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package team.aliens.dms.kmp.navigation.authorized
import androidx.navigation.NavGraphBuilder
import androidx.navigation.navigation
import team.aliens.dms.kmp.DmsNavigator
import team.aliens.dms.kmp.core.network.PlatformConfig
import team.aliens.dms.kmp.feature.signin.navigation.signIn
import team.aliens.dms.kmp.feature.signup.navigation.signUp
import team.aliens.dms.kmp.feature.splash.navigation.NAVIGATION_SPLASH
import team.aliens.dms.kmp.feature.splash.navigation.splash

Expand All @@ -17,13 +19,24 @@ internal fun NavGraphBuilder.authNavigation(
startDestination = NAVIGATION_SPLASH,
) {
splash(
navigateToLogin = navigator::navigateToLogin,
navigateToLogin = navigator::navigateToSignIn,
)
signIn(
navigateToMain = { },
navigateToSignUp = { },
navigateToSignUp = navigator::navigateToSignUp,
navigateToFindId = { },
navigateToFindPassword = { },
)
signUp(
onBackPressed = navigator::popBackStack,
navigateToEnterSchoolVerificationQuestion = navigator::navigateToEnterSchoolVerificationQuestion,
navigateToEnterEmail = navigator::navigateToEnterEmail,
navigateToEnterEmailVerificationCode = navigator::navigateToEnterEmailVerificationCode,
navigateToSetId = navigator::navigateToSetId,
navigateToSetPassword = navigator::navigateToSetPassword,
navigateToTerms = navigator::navigateToTerms,
navigateToSignIn = navigator::navigateToSignIn,
termsUrl = PlatformConfig.termsUrl,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package team.aliens.dms.kmp.core.common.timer

import android.os.CountDownTimer

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
actual class CountDownTimer {
private var timer: CountDownTimer? = null

actual fun start(
durationMillis: Long,
intervalMillis: Long,
listener: CountDownTimerListener,
) {
timer = object : CountDownTimer(durationMillis, intervalMillis) {
override fun onTick(millisUntilFinished: Long) {
listener.onTick(millisUntilFinished)
}

override fun onFinish() {
listener.onFinish()
}
}.start()
}

actual fun stop() {
timer?.cancel()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package team.aliens.dms.kmp.core.common.timer

interface CountDownTimerListener {
fun onTick(timeLeft: Long)
fun onFinish()
}

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
expect class CountDownTimer() {
fun start(
durationMillis: Long,
intervalMillis: Long,
listener: CountDownTimerListener,
)

fun stop()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import androidx.compose.ui.unit.dp

object PaddingDefaults {
val Medium = 12.dp
val Large = 24.dp
val Large = 16.dp
val ExtraLarge = 24.dp
}

fun Modifier.horizontalPadding(
value: Dp = PaddingDefaults.Large,
value: Dp = PaddingDefaults.ExtraLarge,
): Modifier = padding(horizontal = value)

fun Modifier.topPadding(
value: Dp = PaddingDefaults.Medium,
): Modifier = padding(top = value)

fun Modifier.bottomPadding(
value: Dp = PaddingDefaults.Medium,
value: Dp = PaddingDefaults.Large,
): Modifier = padding(bottom = value)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.aliens.dms.kmp.core.common.utils

object Regex {
const val PASSWORD = "^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@\$!%*#?&])[A-Za-z\\d@\$!%*#?&]{8,20}\$"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.aliens.dms.kmp.core.common.utils

object ResourceKeys {
const val SIGN_UP = "signUp"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package team.aliens.dms.kmp.core.common.timer

import platform.Foundation.NSTimer
import kotlin.native.concurrent.freeze

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
actual class CountDownTimer {
private var timer: NSTimer? = null
private var timeLeft: Long = 0

actual fun start(
durationMillis: Long,
intervalMillis: Long,
listener: CountDownTimerListener,
) {
timeLeft = durationMillis
listener.freeze()
val intervalSeconds = intervalMillis / 1000.0

timer = NSTimer.scheduledTimerWithTimeInterval(intervalSeconds, true) {
timeLeft -= intervalMillis
if (timeLeft > 0) {
listener.onTick(timeLeft)
} else {
listener.onFinish()
stop()
}
}
}

actual fun stop() {
timer?.invalidate()
timer = null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package team.aliens.dms.kmp.core.common.timer

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
actual class CountDownTimer {
actual fun start(
durationMillis: Long,
intervalMillis: Long,
listener: CountDownTimerListener,
) {
}

actual fun stop() {
}
}
2 changes: 2 additions & 0 deletions core/design-system/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ kotlin {
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.kottie)

implementation(projects.core.common)
}
commonTest.dependencies {
implementation(libs.kotlin.test)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package team.aliens.dms.kmp.core.designsystem.webview

import android.graphics.Bitmap
import android.webkit.WebResourceError
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.viewinterop.AndroidView
import team.aliens.dms.kmp.core.designsystem.foundation.DmsTheme
import team.aliens.dms.kmp.core.designsystem.status.ErrorStatus
import team.aliens.dms.kmp.core.designsystem.webview.exception.WebViewErrorException

@Composable
actual fun DmsWebView(
modifier: Modifier,
url: String,
) {
val context = LocalContext.current
var isLoading by remember { mutableStateOf(true) }
var isError by remember { mutableStateOf(false) }

Box(
modifier = modifier,
contentAlignment = Alignment.Center,
) {
AndroidView(
factory = {
WebView(context).apply {
webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
isLoading = true
}

override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
isLoading = false
}

override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
error: WebResourceError?,
) {
super.onReceivedError(view, request, error)
isLoading = false
try {
throw WebViewErrorException("WebView error: ${error?.description}")
} catch (e: Exception) {
e.printStackTrace()
isError = true
}
}

override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?,
): Boolean {
return false
}
}
settings.javaScriptEnabled = true
}
},
update = { it.loadUrl(url) },
)

if (isLoading) {
CircularProgressIndicator()
}

if (isError) {
Box(
modifier = Modifier
.fillMaxSize()
.background(DmsTheme.colors.onBackground),
contentAlignment = Alignment.Center,
) {
ErrorStatus(title = "화면을 불러오지 못했어요.")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package team.aliens.dms.kmp.core.designsystem.webview.exception

class WebViewErrorException(message: String) : Exception(message)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<group>
<clip-path
android:pathData="M0,0h20v20h-20z"/>
<path
android:pathData="M10.542,10.455V7.539C10.542,7.391 10.49,7.264 10.387,7.159C10.285,7.053 10.157,7 10.005,7C9.852,7 9.723,7.051 9.617,7.154C9.511,7.256 9.459,7.383 9.459,7.535V10.658C9.459,10.746 9.477,10.83 9.513,10.91C9.549,10.989 9.602,11.063 9.671,11.132L11.851,13.313C11.967,13.428 12.094,13.483 12.234,13.479C12.374,13.475 12.505,13.412 12.625,13.292C12.746,13.171 12.806,13.042 12.806,12.905C12.806,12.767 12.746,12.638 12.625,12.518L10.542,10.455ZM10,17.583C9.087,17.583 8.231,17.411 7.432,17.065C6.634,16.72 5.938,16.25 5.344,15.656C4.75,15.062 4.28,14.366 3.935,13.568C3.59,12.769 3.417,11.913 3.417,11C3.417,10.087 3.59,9.231 3.935,8.432C4.28,7.634 4.75,6.938 5.344,6.344C5.938,5.75 6.634,5.28 7.432,4.935C8.231,4.589 9.087,4.417 10,4.417C10.914,4.417 11.77,4.589 12.568,4.935C13.366,5.28 14.062,5.75 14.656,6.344C15.25,6.938 15.72,7.634 16.065,8.432C16.411,9.231 16.583,10.087 16.583,11C16.583,11.913 16.411,12.769 16.065,13.568C15.72,14.366 15.25,15.062 14.656,15.656C14.062,16.25 13.366,16.72 12.568,17.065C11.77,17.411 10.914,17.583 10,17.583ZM2.242,6.442C2.121,6.322 2.061,6.193 2.061,6.055C2.061,5.918 2.121,5.789 2.242,5.668L4.689,3.221C4.805,3.106 4.932,3.047 5.072,3.044C5.212,3.041 5.343,3.1 5.463,3.221C5.584,3.342 5.644,3.471 5.644,3.608C5.644,3.746 5.584,3.875 5.463,3.995L2.995,6.463C2.88,6.579 2.756,6.634 2.623,6.63C2.49,6.626 2.363,6.563 2.242,6.442ZM17.779,6.442C17.658,6.563 17.529,6.623 17.392,6.623C17.255,6.623 17.126,6.563 17.005,6.442L14.558,3.995C14.443,3.88 14.384,3.752 14.381,3.612C14.378,3.472 14.437,3.342 14.558,3.221C14.679,3.1 14.808,3.04 14.945,3.04C15.082,3.04 15.211,3.1 15.332,3.221L17.779,5.689C17.894,5.805 17.953,5.929 17.956,6.062C17.959,6.195 17.9,6.322 17.779,6.442Z"
android:fillColor="#B3B7BB"/>
</group>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path
android:pathData="M0,0h24v24h-24z"/>
<path
android:pathData="M9.55,15.516L18.188,6.877C18.337,6.728 18.511,6.652 18.71,6.649C18.91,6.646 19.087,6.722 19.242,6.877C19.397,7.032 19.475,7.21 19.475,7.412C19.475,7.613 19.397,7.791 19.242,7.946L10.182,17.021C10.002,17.202 9.791,17.292 9.55,17.292C9.309,17.292 9.098,17.202 8.917,17.021L4.742,12.846C4.593,12.697 4.52,12.521 4.522,12.316C4.524,12.112 4.602,11.932 4.758,11.777C4.913,11.622 5.091,11.544 5.292,11.544C5.493,11.544 5.672,11.622 5.827,11.777L9.55,15.516Z"
android:fillColor="#919297"/>
</group>
</vector>
Loading

0 comments on commit d8d4a1d

Please sign in to comment.