Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 릴리즈 v1.0.0 1차 QA #97

Merged
merged 5 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/java/com/moya/funch/di/MemberModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.moya.funch.repository.MemberRepository
import com.moya.funch.repository.MemberRepositoryImpl
import com.moya.funch.usecase.CreateUserProfileUseCase
import com.moya.funch.usecase.CreateUserProfileUseCaseImpl
import com.moya.funch.usecase.DeleteUserProfileUseCase
import com.moya.funch.usecase.DeleteUserProfileUseCaseImpl
import com.moya.funch.usecase.LoadUserProfileUseCase
import com.moya.funch.usecase.LoadUserProfileUseCaseImpl
import com.moya.funch.usecase.LoadViewCountUseCase
Expand Down Expand Up @@ -32,6 +34,10 @@ object MemberModule {
@Binds
@Singleton
fun bindCreateUserProfileUseCase(useCase: CreateUserProfileUseCaseImpl): CreateUserProfileUseCase

@Binds
@Singleton
fun bindDeleteUserProfileUseCase(useCase: DeleteUserProfileUseCaseImpl): DeleteUserProfileUseCase
}

@Module
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/moya/funch/navigation/FunchNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ fun FunchNavHost(hasProfile: Boolean, navController: NavHostController = remembe
with(navController) {
profileGraph(
onNavigateToHome = ::onNavigateToHome,
onCloseMyProfile = ::onCloseMyProfile
onCloseMyProfile = ::onCloseMyProfile,
onNavigateCreateProfile = ::navigateToCreateProfileFromMyProfile
)
homeScreen(
onNavigateToMatching = ::onNavigateToMatching,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import com.moya.funch.model.ProfileModel

interface RemoteUserDataSource : UserDataSource {
suspend fun createUserProfile(userModel: ProfileModel): Result<ProfileModel>

suspend fun deleteUserProfile(): Result<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ class RemoteUserDataSourceImpl @Inject constructor(
memberService.createMember(request).data
}.mapCatching { it.toModel() }
}

override suspend fun deleteUserProfile(): Result<String> {
return runCatching {
memberService.deleteMember(userDataStore.userId).message
}.onSuccess {
userDataStore.clear()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ class MemberRepositoryImpl @Inject constructor(
it.toDomain()
}
}

override suspend fun deleteUserProfile(): Result<String> {
return remoteUserDataSource.deleteUserProfile()
}
}
79 changes: 79 additions & 0 deletions core/designsystem/src/main/java/com/moya/funch/ui/FunchDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.moya.funch.ui

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.moya.funch.theme.FunchTheme
import com.moya.funch.theme.LocalBackgroundTheme

@Composable
fun FunchDialog(
title: String,
text: String,
dismissText: String,
confirmText: String,
onDismiss: () -> Unit,
onConfirm: () -> Unit
) {
AlertDialog(
title = {
Text(text = title)
},
titleContentColor = Color(0xFFE6E0E9),
text = {
Text(text = text)
},
textContentColor = Color(0xFFCAC4D0),
containerColor = Color(0xFF2B2930),
confirmButton = {
Box(
modifier = Modifier
.clickable(onClick = onConfirm)
.padding(vertical = 10.dp, horizontal = 12.dp)
) {
Text(
text = confirmText,
color = Color(0xFFD0BCFF)
)
}
},
onDismissRequest = { onDismiss() },
dismissButton = {
Box(
modifier = Modifier
.clickable(onClick = onDismiss)
.padding(vertical = 10.dp, horizontal = 12.dp)
) {
Text(
text = dismissText,
color = Color(0xFFD0BCFF)
)
}
}
)
}

@Preview
@Composable
private fun Preview1() {
FunchTheme {
Surface(color = LocalBackgroundTheme.current.color) {
FunchDialog(
title = "프로필 삭제하기",
text = "기존 프로필이 삭제되고 복구가 불가능해요.\n정말 삭제하실 건가요?",
dismissText = "취소하기",
confirmText = "삭제하기",
onDismiss = {},
onConfirm = {}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ interface MemberRepository {
suspend fun fetchUserViewCount(): Result<Int>

suspend fun fetchMemberProfile(id: String): Result<Profile>

suspend fun deleteUserProfile(): Result<String>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.moya.funch.usecase

import com.moya.funch.repository.MemberRepository
import javax.inject.Inject

class DeleteUserProfileUseCaseImpl @Inject constructor(
private val memberRepository: MemberRepository
) : DeleteUserProfileUseCase {
override suspend operator fun invoke(): Result<String> {
return memberRepository.deleteUserProfile()
}
}

fun interface DeleteUserProfileUseCase {
suspend operator fun invoke(): Result<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.moya.funch.network.dto.request.MemberRequest
import com.moya.funch.network.dto.response.BaseResponse
import com.moya.funch.network.dto.response.member.MemberResponse
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
Expand All @@ -19,4 +20,7 @@ interface MemberService {

@GET("api/v1/members")
suspend fun findMemberByDeviceNumber(@Query("deviceNumber") deviceNumber: String): BaseResponse<MemberResponse>

@DELETE("api/v1/members/{id}")
suspend fun deleteMember(@Path("id") id: String): BaseResponse<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ import androidx.compose.ui.layout.boundsInWindow
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -540,7 +543,8 @@ private fun SubwayRow(
is SubwayTextFieldState.Success -> {
HorizontalSubwayStations(
subwayStations = subwayStations,
onSubwayStationChange = onSubwayStationChange
onSubwayStationChange = onSubwayStationChange,
text = subwayStation
)
}

Expand All @@ -558,7 +562,8 @@ private fun SubwayRow(
is SubwayTextFieldState.Typing -> {
HorizontalSubwayStations(
subwayStations = subwayStations,
onSubwayStationChange = onSubwayStationChange
onSubwayStationChange = onSubwayStationChange,
text = subwayStation
)
}
}
Expand All @@ -567,7 +572,11 @@ private fun SubwayRow(
}

@Composable
private fun HorizontalSubwayStations(subwayStations: List<SubwayStation>, onSubwayStationChange: (String) -> Unit) {
private fun HorizontalSubwayStations(
subwayStations: List<SubwayStation>,
onSubwayStationChange: (String) -> Unit,
text: String
) {
val focusManager = LocalFocusManager.current

Spacer(modifier = Modifier.height(4.dp))
Expand All @@ -578,6 +587,30 @@ private fun HorizontalSubwayStations(subwayStations: List<SubwayStation>, onSubw
horizontalArrangement = Arrangement.spacedBy(4.dp)
) {
subwayStations.forEach { station ->
val annotatedText = buildAnnotatedString {
val startIndex = station.name.indexOf(text)
if (startIndex >= 0) {
val endIndex = startIndex + text.length
if (startIndex > 0) {
withStyle(style = SpanStyle(color = Gray500)) {
append(station.name.substring(0, startIndex))
}
}
withStyle(style = SpanStyle(color = White)) {
append(station.name.substring(startIndex, endIndex))
}
if (endIndex < station.name.length) {
withStyle(style = SpanStyle(color = Gray500)) {
append(station.name.substring(endIndex))
}
}
} else {
withStyle(style = SpanStyle(color = Gray500)) {
append(station.name)
}
}
}

Box(
modifier = Modifier
.background(
Expand All @@ -596,8 +629,7 @@ private fun HorizontalSubwayStations(subwayStations: List<SubwayStation>, onSubw
.padding(8.dp)
) {
Text(
text = station.name,
color = White,
text = annotatedText,
style = FunchTheme.typography.b
)
}
Expand Down Expand Up @@ -663,7 +695,7 @@ private fun Preview1() {
@Composable
private fun Preview2() {
FunchTheme {
var text by remember { mutableStateOf("") }
var text by remember { mutableStateOf("삼성") }

Surface(
modifier = Modifier
Expand All @@ -676,8 +708,8 @@ private fun Preview2() {
isKeyboardVisible = {},
textFieldState = SubwayTextFieldState.Typing,
subwayStations = listOf(
SubwayStation("삼성역"),
SubwayStation("삼성중앙역")
SubwayStation("삼성"),
SubwayStation("삼성중앙")
),
scrollState = rememberScrollState()
)
Expand Down
Loading
Loading