Skip to content

Commit

Permalink
DEP-362 feat: 첫 회원가입 시 회원가입완료화면으로 유도 (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimhyeing authored Jan 8, 2023
1 parent 84eebbf commit d6b2392
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 26 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
<activity android:name=".signup.SignupActivity"
android:exported="true"/>

<activity android:name=".signup.complete.SignupCompleteActivity"
android:exported="false"/>

<activity
android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
android:exported="true">
Expand Down
44 changes: 44 additions & 0 deletions core-design-system/src/main/res/drawable/ic_signup_complete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="160dp"
android:height="160dp"
android:viewportWidth="160"
android:viewportHeight="160">
<path
android:pathData="M105.59,88.36C105.71,88.19 105.97,88.2 106.08,88.38L109.04,93.57L113.93,91.21C114.16,91.1 114.41,91.32 114.33,91.56L113.18,94.87L118.31,94.68C118.59,94.67 118.72,95.01 118.5,95.19L113.78,99.04L117.06,102.79C117.23,102.98 117.09,103.27 116.84,103.26L112.71,103.11L113.39,108.17C113.43,108.43 113.12,108.6 112.92,108.43L106.88,103.34L101.16,106.69C100.98,106.8 100.75,106.68 100.73,106.48L100.27,102.21L92.84,103.87C92.56,103.93 92.37,103.58 92.58,103.38L97.92,98.42L93.12,94.99C92.88,94.82 93.01,94.45 93.3,94.47L98.68,94.76L94.9,87.22C94.76,86.95 95.09,86.68 95.33,86.87L102.6,92.63L105.59,88.36Z"
android:fillColor="#34C185"/>
<path
android:pathData="M123.5,24.62C123.56,24.27 123.96,24.1 124.25,24.3L132.52,29.91L138.14,22.78C138.4,22.44 138.94,22.59 138.99,23.02L139.7,28.84L147.28,24.79C147.68,24.57 148.14,24.99 147.94,25.41L143.67,34.68L151.35,37.9C151.74,38.06 151.75,38.61 151.36,38.78L145.04,41.59L149.79,48.7C150.03,49.06 149.69,49.54 149.27,49.43L136.43,46.21L130.3,55.45C130.11,55.75 129.68,55.74 129.49,55.44L125.67,49.36L115.71,57.31C115.33,57.62 114.79,57.22 114.96,56.77L119.35,45.38L109.61,43.75C109.13,43.67 109.06,43.02 109.5,42.83L117.81,39.32L106.58,30.76C106.17,30.45 106.47,29.8 106.98,29.91L122.14,33.24L123.5,24.62Z"
android:fillColor="#34C185"/>
<path
android:pathData="M89.61,55.77m-5.55,0a5.55,5.55 0,1 1,11.1 0a5.55,5.55 0,1 1,-11.1 0"
android:fillColor="#3F80FF"/>
<path
android:pathData="M18.55,30.55m-5.55,0a5.55,5.55 0,1 1,11.1 0a5.55,5.55 0,1 1,-11.1 0"
android:fillColor="#3F80FF"/>
<path
android:pathData="M48.9,36L37.85,40.4L46.79,53L57.85,48.6L48.9,36Z"
android:fillColor="#FED130"/>
<path
android:pathData="M76.02,24L67.85,15.79L80.67,8L88.85,16.21L76.02,24Z"
android:fillColor="#FE88E4"/>
<path
android:pathData="M67.42,99.06L56.12,96.52L62.77,83.06L74.07,85.61L67.42,99.06Z"
android:fillColor="#FE88E4"/>
<path
android:pathData="M153.61,86L141.85,85.53L138.08,70.53L149.85,71L153.61,86Z"
android:fillColor="#FF4D4D"/>
<path
android:pathData="M111.67,152L119.85,143.79L107.02,136L98.85,144.21L111.67,152Z"
android:fillColor="#FED130"/>
<path
android:pathData="M41.77,72.4L7,152.43L88.69,119.32L41.77,72.4Z"
android:fillColor="#E1EBFF"/>
<path
android:pathData="M82.45,121.85L32.75,93.16L26.55,107.44L64.27,129.22L82.45,121.85Z"
android:fillColor="#3F80FF"
android:fillType="evenOdd"/>
<path
android:pathData="M49.85,135.06L21.63,118.77L15.42,133.05L31.67,142.43L49.85,135.06Z"
android:fillColor="#3F80FF"
android:fillType="evenOdd"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package com.depromeet.threedays.data.datasource.auth

import com.depromeet.threedays.data.entity.auth.PostSignupRequest
import com.depromeet.threedays.data.entity.auth.SignupMemberEntity
import com.depromeet.threedays.data.entity.base.ApiResponse

interface AuthRemoteDataSource {
suspend fun postSignup(request: PostSignupRequest): SignupMemberEntity
suspend fun postSignup(request: PostSignupRequest): ApiResponse<SignupMemberEntity>
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package com.depromeet.threedays.data.datasource.auth
import com.depromeet.threedays.data.api.AuthService
import com.depromeet.threedays.data.entity.auth.PostSignupRequest
import com.depromeet.threedays.data.entity.auth.SignupMemberEntity
import com.depromeet.threedays.data.entity.base.ApiResponse
import javax.inject.Inject

class AuthRemoteDataSourceImpl@Inject constructor(
private val authService: AuthService
) : AuthRemoteDataSource {
override suspend fun postSignup(request: PostSignupRequest): SignupMemberEntity {
return authService.postSignup(request = request).data ?: throw IllegalStateException()
override suspend fun postSignup(request: PostSignupRequest): ApiResponse<SignupMemberEntity> {
return authService.postSignup(request = request)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.depromeet.threedays.data.mapper

import com.depromeet.threedays.data.entity.auth.SignupMemberEntity
import com.depromeet.threedays.data.entity.base.ApiResponse
import com.depromeet.threedays.data.entity.member.MemberEntity
import com.depromeet.threedays.domain.entity.auth.SignupMember
import com.depromeet.threedays.domain.entity.member.AuthenticationProvider
import com.depromeet.threedays.domain.entity.member.Member
import com.depromeet.threedays.domain.key.RESOURCE_CREATE

fun MemberEntity.toMember() = Member(
memberId = this.id,
Expand All @@ -14,11 +16,16 @@ fun MemberEntity.toMember() = Member(
resource = this.resource,
)

fun SignupMemberEntity.toSignupMember() = SignupMember(
id = this.id,
name = this.name,
certificationSubject = AuthenticationProvider.from(this.certificationSubject),
token = this.token,
resource = this.resource,
notificationConsent = this.notificationConsent
)
fun ApiResponse<SignupMemberEntity>.toSignupMember(): SignupMember {
val data = this.data ?: throw IllegalStateException()
val code = this.code
return SignupMember(
id = data.id,
name = data.name,
certificationSubject = AuthenticationProvider.from(data.certificationSubject),
token = data.token,
resource = data.resource,
notificationConsent = data.notificationConsent,
isSignedUp = (code != RESOURCE_CREATE)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ data class SignupMember(
val name: String,
val notificationConsent: Boolean,
val resource: String,
val token: Token
val token: Token,
val isSignedUp: Boolean
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.depromeet.threedays.domain.key

const val RESOURCE_CREATE = "resource.created"
1 change: 0 additions & 1 deletion presentation/signup/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package com.depromeet.threedays.signup

import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import com.depromeet.threedays.core.BaseActivity
import com.depromeet.threedays.core.analytics.*
import com.depromeet.threedays.core.util.setOnSingleClickListener
import com.depromeet.threedays.navigator.HomeNavigator
import com.depromeet.threedays.signup.SignupViewModel.Action
import com.depromeet.threedays.signup.complete.SignupCompleteActivity
import com.depromeet.threedays.signup.databinding.ActivitySignupBinding
import com.depromeet.threedays.signup.extension.loginWithKakaoOrThrow
import com.kakao.sdk.common.model.ClientError
import com.kakao.sdk.common.model.ClientErrorCause
import com.kakao.sdk.user.UserApiClient
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
Expand Down Expand Up @@ -72,12 +77,17 @@ class SignupActivity: BaseActivity<ActivitySignupBinding>(R.layout.activity_sign
}

private fun observe() {
viewModel.isSuccess.observe(this) { isSuccess ->
if (isSuccess) {
val intent = homeNavigator.intent(this)
startActivity(intent)
finish()
viewModel.action.onEach { action ->
val intent = when(action) {
Action.AlreadySignedUp -> {
homeNavigator.intent(this)
}
Action.FirstSignup -> {
Intent(this@SignupActivity, SignupCompleteActivity::class.java)
}
}
}
startActivity(intent)
finish()
}.launchIn(lifecycleScope)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.distinctUntilChanged
import androidx.lifecycle.viewModelScope
import com.depromeet.threedays.core.BaseViewModel
import com.depromeet.threedays.domain.entity.auth.SignupMember
import com.depromeet.threedays.domain.entity.member.AuthenticationProvider
import com.depromeet.threedays.domain.repository.NotificationTokenRepository
import com.depromeet.threedays.domain.usecase.auth.CreateMemberUserCase
import com.depromeet.threedays.domain.usecase.notification.token.UpdateNotificationTokenUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
Expand All @@ -21,19 +25,26 @@ class SignupViewModel @Inject constructor(
private val updateNotificationTokenUseCase: UpdateNotificationTokenUseCase,
) : BaseViewModel() {

private val _action = MutableSharedFlow<Action>()
val action: SharedFlow<Action>
get() = _action.asSharedFlow()

private val _isSuccess = MutableLiveData(false)
val isSuccess: LiveData<Boolean> = _isSuccess.distinctUntilChanged()

fun createMember(certificationSubject: AuthenticationProvider = AuthenticationProvider.KAKAO, socialToken: String) {
viewModelScope.launch {
kotlin.runCatching {
createMemberUserCase.invoke(
certificationSubject = certificationSubject,
socialToken = socialToken
createMemberUserCase.invoke(
certificationSubject = certificationSubject,
socialToken = socialToken
).runCatching {
this.getOrThrow()
}.onSuccess { value: SignupMember ->
_action.emit(
if(value.isSignedUp) Action.AlreadySignedUp
else Action.FirstSignup
)
}.onSuccess {
Timber.i("--- SignupViewModel - token: ${it.getOrNull()?.token}")
_isSuccess.value = true
Timber.i("--- SignupViewModel - token : ${value.token}")
}.onFailure { throwable ->
Timber.e("--- SignupViewModel - Signup error: ${throwable.message}")
}
Expand All @@ -50,4 +61,9 @@ class SignupViewModel @Inject constructor(
}
}
}

sealed class Action{
object FirstSignup: Action()
object AlreadySignedUp: Action()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.depromeet.threedays.signup.complete

import android.os.Bundle
import com.depromeet.threedays.core.BaseActivity
import com.depromeet.threedays.core.util.setOnSingleClickListener
import com.depromeet.threedays.navigator.HomeNavigator
import com.depromeet.threedays.signup.R
import com.depromeet.threedays.signup.databinding.ActivitySignupCompleteBinding
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class SignupCompleteActivity : BaseActivity<ActivitySignupCompleteBinding>(R.layout.activity_signup_complete) {

@Inject
lateinit var homeNavigator: HomeNavigator

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
initView()
}

private fun initView() {
binding.tvCheck.setOnSingleClickListener {
val intent = homeNavigator.intent(this)
startActivity(intent)
finish()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".complete.SignupCompleteActivity"
tools:ignore="ContentDescription">

<ImageView
android:id="@+id/iv_signup_complete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="170dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_signup_complete" />

<TextView
android:id="@+id/tv_signup_complete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/signup_complete"
android:textAppearance="@style/Typography.Heading"
app:layout_constraintEnd_toEndOf="@+id/iv_signup_complete"
app:layout_constraintStart_toStartOf="@+id/iv_signup_complete"
app:layout_constraintTop_toBottomOf="@+id/iv_signup_complete" />

<TextView
android:id="@+id/tv_check"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="30dp"
android:background="@drawable/bg_rect_gray800_r15"
android:gravity="center"
android:paddingVertical="18dp"
android:text="@string/check"
android:textAppearance="@style/Typography.Button1"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
2 changes: 2 additions & 0 deletions presentation/signup/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
<resources>
<string name="signup_title">작심삼일이라면,\n짝심삼일과 함께</string>
<string name="signup_with_kakao">카카오로 계속하기</string>
<string name="signup_complete">회원가입 완료!</string>
<string name="check">확인</string>
</resources>

0 comments on commit d6b2392

Please sign in to comment.