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

πŸ”€ :: (#231) - add withdrawal function #234

Merged
merged 24 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4a04e30
:sparkles: :: Change PasswardChangeButton.kt -> SettingButton.kt
minStone-dev May 30, 2024
1d1f35b
:lipstick: :: Change setting screen design
minStone-dev May 31, 2024
59727e5
:lipstick: :: Add icon
minStone-dev May 31, 2024
44b4274
:lipstick: :: Add icon use SettingScreen.kt
minStone-dev May 31, 2024
ca20741
:lipstick: :: Add withdraw API
minStone-dev Jun 3, 2024
cc9d48f
:lipstick: :: Add withdraw DataSource
minStone-dev Jun 3, 2024
a30ab7b
:lipstick: :: Add withdraw Repository
minStone-dev Jun 3, 2024
6d2d8c8
:lipstick: :: Add WithdrawalUseCase
minStone-dev Jun 3, 2024
4717961
:lipstick: :: Add WithdrawalScreen.kt
minStone-dev Jun 3, 2024
ad385b9
:sparkles: :: Link withdrawalScreen
minStone-dev Jun 3, 2024
92baeff
:sparkles: :: Link withdrawalScreen
minStone-dev Jun 3, 2024
94c27d5
:sparkles: :: Change request type
minStone-dev Jun 4, 2024
2d86d07
:sparkles: :: Add WithdrawalUiState.kt
minStone-dev Jun 4, 2024
51cd8bb
:sparkles: :: Use withdrawalUseCase
minStone-dev Jun 4, 2024
1791863
:sparkles: :: Add withdrawal function
minStone-dev Jun 4, 2024
c4b6580
:sparkles: :: Add withdrawal dialog
minStone-dev Jun 5, 2024
0e38eb0
:sparkles: :: Add error text field
minStone-dev Jun 5, 2024
603b75e
:sparkles: :: Change button Text
minStone-dev Jun 5, 2024
4d6f5b7
:sparkles: :: Fix double toast error
minStone-dev Jun 5, 2024
c723566
Merge branch 'develop' into feature/231-add-withdrawal-function
minStone-dev Jun 6, 2024
88b7430
:sparkles: :: Fix conflict
minStone-dev Jun 6, 2024
cafccde
:sparkles: :: Fix conflict
minStone-dev Jun 8, 2024
0aa295b
:sparkles: :: Review reflection
minStone-dev Jun 8, 2024
8988016
:bookmark: :: Release 1.2.2
minStone-dev Jun 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ import com.goms.re_password.navigation.navigateToRePassword
import com.goms.re_password.navigation.passwordCheckScreen
import com.goms.re_password.navigation.rePasswordScreen
import com.goms.setting.navigation.navigateToSettingScreen
import com.goms.setting.navigation.navigateToWithdrawalScreen
import com.goms.setting.navigation.settingScreen
import com.goms.setting.navigation.withdrawalRoute
import com.goms.setting.navigation.withdrawalScreen
import com.goms.sign_up.navigation.navigateToNumber
import com.goms.sign_up.navigation.navigateToPassword
import com.goms.sign_up.navigation.navigateToSignUp
Expand Down Expand Up @@ -153,7 +156,6 @@ fun GomsNavHost(
onLateListClick = navController::navigateToLateList,
onSettingClick = navController::navigateToSettingScreen
)

qrcodeScanScreen(
onPermissionBlock = navController::popBackStack,
onSuccess = navController::popBackStack,
Expand All @@ -165,16 +167,20 @@ fun GomsNavHost(
onRemoteError = navController::popBackStack,
onErrorToast = onErrorToast
)

settingScreen(
onBackClick = navController::popBackStack,
onLogoutSuccess = onLogout,
onErrorToast = onErrorToast,
onPasswordCheck = navController::navigateToPasswordCheck,
onUpdateAlarm = onUpdateAlarm,
onThemeSelect = onThemeSelect
onThemeSelect = onThemeSelect,
onWithdrawalClick = navController::navigateToWithdrawalScreen
)
withdrawalScreen(
onBackClick = navController::popBackStack,
onWithdrawal = onLogout,
onErrorToast = onErrorToast
)

emailCheckScreen(
onBackClick = navController::popBackStack,
onNumberClick = navController::navigateToPasswordNumber,
Expand All @@ -190,8 +196,6 @@ fun GomsNavHost(
onSuccessClick = { appState.navigateToTopLevelDestination(TopLevelDestination.LOGIN) },
onErrorToast = onErrorToast
)


passwordCheckScreen(
onBackClick = navController::popBackStack,
onRePasswordClick = navController::navigateToRePassword
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ interface AccountRepository {
suspend fun findPassword(body: FindPasswordRequestModel): Flow<Unit>

suspend fun rePassword(body: RePasswordRequestModel): Flow<Unit>

suspend fun withdraw(password: String): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ class AccountRepositoryImpl @Inject constructor(
override suspend fun rePassword(body: RePasswordRequestModel): Flow<Unit> {
return remoteAccountDataSource.rePassword(body = body.toDto())
}

override suspend fun withdraw(password: String): Flow<Unit> {
return remoteAccountDataSource.withdraw(password = password)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,43 @@ fun VisibleIcon(
modifier = modifier,
colorFilter = if (tint != Color.Unspecified) ColorFilter.tint(tint) else null
)
}

@Composable
fun GomsLogoutIcon(
modifier: Modifier = Modifier,
tint: Color = Color.Unspecified
) {
Image(
painter = painterResource(id = R.drawable.ic_logout),
contentDescription = stringResource(id = R.string.logout_icon_description),
modifier = modifier,
colorFilter = if (tint != Color.Unspecified) ColorFilter.tint(tint) else null
)
}

@Composable
fun GomsPasswordChangeIcon(
modifier: Modifier = Modifier,
tint: Color = Color.Unspecified
) {
Image(
painter = painterResource(id = R.drawable.ic_password_change),
contentDescription = stringResource(id = R.string.password_change_icon_description),
modifier = modifier,
colorFilter = if (tint != Color.Unspecified) ColorFilter.tint(tint) else null
)
}

@Composable
fun GomsWithdrawalIcon(
modifier: Modifier = Modifier,
tint: Color = Color.Unspecified
) {
Image(
painter = painterResource(id = R.drawable.ic_withdrawal),
contentDescription = stringResource(id = R.string.withdrawal_icon_description),
modifier = modifier,
colorFilter = if (tint != Color.Unspecified) ColorFilter.tint(tint) else null
)
}
9 changes: 9 additions & 0 deletions core/design-system/src/main/res/drawable/ic_logout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M8.502,11.5C9.056,11.5 9.504,11.948 9.504,12.502C9.504,13.055 9.056,13.504 8.502,13.504C7.949,13.504 7.5,13.055 7.5,12.502C7.5,11.948 7.949,11.5 8.502,11.5ZM12,4.354V10.5L12,11.005L19.442,11.003L17.72,9.28C17.453,9.013 17.429,8.597 17.647,8.303L17.72,8.219C17.986,7.953 18.403,7.929 18.696,8.147L18.78,8.219L21.777,11.217C22.043,11.483 22.067,11.899 21.85,12.193L21.778,12.277L18.781,15.28C18.488,15.574 18.014,15.574 17.72,15.282C17.454,15.016 17.429,14.599 17.646,14.305L17.719,14.221L19.432,12.503L12,12.505L12,19.25C12,19.716 11.579,20.069 11.12,19.988L2.62,18.487C2.261,18.424 2,18.112 2,17.748V5.75C2,5.382 2.266,5.069 2.628,5.009L11.128,3.614C11.585,3.539 12,3.891 12,4.354ZM10.5,5.237L3.5,6.386V17.119L10.5,18.355V5.237ZM13,18.501L13.765,18.501L13.867,18.494C14.233,18.444 14.516,18.13 14.515,17.75L14.508,13.5H13V18.501ZM13.002,10L13,8.725V5L13.745,5C14.125,5 14.438,5.281 14.488,5.647L14.495,5.748L14.502,10H13.002Z"
android:fillColor="#ffffff"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M2,6.625C2,4.899 3.399,3.5 5.125,3.5H18.875C20.601,3.5 22,4.899 22,6.625V14.257C21.622,13.945 21.202,13.683 20.75,13.48V6.625C20.75,5.589 19.91,4.75 18.875,4.75H5.125C4.089,4.75 3.25,5.589 3.25,6.625V14.375C3.25,15.411 4.089,16.25 5.125,16.25H11.952L13.202,17.5H5.125C3.399,17.5 2,16.101 2,14.375V6.625ZM16.625,12.5C16.474,12.5 16.336,12.447 16.228,12.358C16.194,12.153 16.121,11.954 16.008,11.772C16.058,11.476 16.315,11.25 16.625,11.25H18.875C19.22,11.25 19.5,11.53 19.5,11.875C19.5,12.22 19.22,12.5 18.875,12.5H16.625ZM13.384,10.5L14.006,11.122C13.813,11.201 13.633,11.319 13.476,11.476L13.034,11.918L12.5,11.384L11.567,12.317C11.323,12.561 10.927,12.561 10.683,12.317C10.439,12.073 10.439,11.677 10.683,11.433L11.616,10.5L10.683,9.567C10.439,9.323 10.439,8.927 10.683,8.683C10.927,8.439 11.323,8.439 11.567,8.683L12.5,9.616L13.433,8.683C13.677,8.439 14.073,8.439 14.317,8.683C14.561,8.927 14.561,9.323 14.317,9.567L13.384,10.5ZM5.183,8.683C5.427,8.439 5.823,8.439 6.067,8.683L7,9.616L7.933,8.683C8.177,8.439 8.573,8.439 8.817,8.683C9.061,8.927 9.061,9.323 8.817,9.567L7.884,10.5L8.817,11.433C9.061,11.677 9.061,12.073 8.817,12.317C8.573,12.561 8.177,12.561 7.933,12.317L7,11.384L6.067,12.317C5.823,12.561 5.427,12.561 5.183,12.317C4.939,12.073 4.939,11.677 5.183,11.433L6.116,10.5L5.183,9.567C4.939,9.323 4.939,8.927 5.183,8.683ZM15.067,13.067C15.311,12.823 15.311,12.427 15.067,12.183C14.823,11.939 14.427,11.939 14.183,12.183L12.183,14.183C11.939,14.427 11.939,14.823 12.183,15.067L14.183,17.067C14.427,17.311 14.823,17.311 15.067,17.067C15.311,16.823 15.311,16.427 15.067,16.183L14.134,15.25H18.5C20.295,15.25 21.75,16.705 21.75,18.5C21.75,20.295 20.295,21.75 18.5,21.75C16.885,21.75 15.544,20.571 15.292,19.027C15.237,18.686 14.916,18.455 14.575,18.51C14.234,18.565 14.003,18.886 14.059,19.227C14.407,21.367 16.262,23 18.5,23C20.985,23 23,20.985 23,18.5C23,16.015 20.985,14 18.5,14H14.134L15.067,13.067Z"
android:fillColor="#ffffff"/>
</vector>
9 changes: 9 additions & 0 deletions core/design-system/src/main/res/drawable/ic_withdrawal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M11.314,15.499C11.486,14.966 11.726,14.462 12.022,13.999H5.253C4.011,13.999 3.004,15.006 3.004,16.248V16.826C3.004,17.719 3.322,18.582 3.902,19.261C5.468,21.095 7.854,22 11,22C11.6,22 12.173,21.967 12.717,21.901C12.326,21.477 11.991,21 11.723,20.482C11.488,20.494 11.248,20.5 11,20.5C8.262,20.5 6.296,19.755 5.043,18.287C4.695,17.879 4.504,17.361 4.504,16.826V16.248C4.504,15.835 4.839,15.499 5.253,15.499H11.314ZM11,2.004C13.762,2.004 16,4.242 16,7.004C16,9.765 13.762,12.004 11,12.004C8.239,12.004 6,9.765 6,7.004C6,4.242 8.239,2.004 11,2.004ZM11,3.504C9.067,3.504 7.5,5.071 7.5,7.004C7.5,8.937 9.067,10.504 11,10.504C12.933,10.504 14.5,8.937 14.5,7.004C14.5,5.071 12.933,3.504 11,3.504ZM23,17.5C23,20.538 20.538,23 17.5,23C14.462,23 12,20.538 12,17.5C12,14.462 14.462,12 17.5,12C20.538,12 23,14.462 23,17.5ZM14,17.5C14,17.776 14.224,18 14.5,18H20.5C20.776,18 21,17.776 21,17.5C21,17.224 20.776,17 20.5,17H14.5C14.224,17 14,17.224 14,17.5Z"
android:fillColor="#ffffff"/>
</vector>
3 changes: 3 additions & 0 deletions core/design-system/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@
<string name="menu_icon_description">메뉴 μ•„μ΄μ½˜</string>
<string name="invisible_icon_description">μ•ˆλ³΄μ΄λŠ” μ•„μ΄μ½˜</string>
<string name="visible_icon_description">λ³΄μ΄λŠ” μ•„μ΄μ½˜</string>
<string name="password_change_icon_description">λΉ„λ°€λ²ˆν˜Έ λ³€κ²½ μ•„μ΄μ½˜</string>
<string name="logout_icon_description">λ‘œκ·Έμ•„μ›ƒ μ•„μ΄μ½˜</string>
<string name="withdrawal_icon_description">νšŒμ›νƒˆν‡΄ μ•„μ΄μ½˜</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.goms.domain.account

import com.goms.data.repository.account.AccountRepository
import javax.inject.Inject

class WithdrawalUseCase@Inject constructor(
private val accountRepository: AccountRepository
) {
suspend operator fun invoke(password: String) = kotlin.runCatching {
accountRepository.withdraw(password = password)
}
}
6 changes: 6 additions & 0 deletions core/network/src/main/java/com/goms/network/api/AccountAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import retrofit2.http.Multipart
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path

interface AccountAPI {
@GET(RequestUrls.ACCOUNT.profile)
Expand Down Expand Up @@ -41,4 +42,9 @@ interface AccountAPI {
suspend fun rePassword(
@Body body: RePasswordRequest
)

@DELETE(RequestUrls.ACCOUNT.withdraw)
suspend fun withdraw(
@Path("password") password: String
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ interface AccountDataSource {
suspend fun findPassword(body: FindPasswordRequest): Flow<Unit>

suspend fun rePassword(body: RePasswordRequest): Flow<Unit>

suspend fun withdraw(password: String): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ class AccountDataSourceImpl @Inject constructor(
.sendRequest()
)
}.flowOn(Dispatchers.IO)

override suspend fun withdraw(password: String): Flow<Unit> = flow {
emit(
GomsApiHandler<Unit>()
.httpRequest { accountAPI.withdraw(password = password) }
.sendRequest()
)
}.flowOn(Dispatchers.IO)
}
2 changes: 2 additions & 0 deletions core/network/src/main/java/com/goms/network/di/RequestUrls.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ internal object RequestUrls {
const val accountIdx = "accountIdx"
const val deviceToken = "deviceToken"
const val outingUUID = "outingUUID"
const val password = "password"
}

object ACCOUNT {
Expand All @@ -15,6 +16,7 @@ internal object RequestUrls {
const val image = "$path/image"
const val newPassword = "$path/new-password"
const val changePassword = "$path/change-password"
const val withdraw = "$path/withdraw/{${PATH.password}}"
}

object AUTH {
Expand Down
64 changes: 44 additions & 20 deletions feature/setting/src/main/java/com/goms/setting/SettingScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.Divider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -36,8 +37,9 @@ import com.goms.design_system.theme.ThemeType
import com.goms.design_system.util.lockScreenOrientation
import com.goms.model.enum.Authority
import com.goms.model.enum.Switch
import com.goms.setting.component.PasswordChangeButton
import com.goms.setting.component.SettingButton
import com.goms.setting.component.SelectThemeDropDown
import com.goms.setting.component.SettingButtonType
import com.goms.setting.component.SettingProfileCard
import com.goms.setting.component.SettingSwitchComponent
import com.goms.setting.data.toData
Expand All @@ -56,7 +58,8 @@ internal fun SettingRoute(
onErrorToast: (throwable: Throwable?, message: Int?) -> Unit,
onThemeSelect: () -> Unit,
onUpdateAlarm: (String) -> Unit,
viewModel: SettingViewModel = hiltViewModel(),
onWithdrawalClick: () -> Unit,
viewModel: SettingViewModel = hiltViewModel()
) {
val context = LocalContext.current
val role by viewModel.role.collectAsStateWithLifecycle(initialValue = "")
Expand Down Expand Up @@ -144,16 +147,17 @@ internal fun SettingRoute(
onUpdateAlarm = { alarmData = it },
onUpdateTime = { timeData = it },
setDefaultProfileUiState = { viewModel.initProfileImage() },
onErrorToast = onErrorToast,
onPasswordCheck = onPasswordCheck,
onWithdrawalClick = onWithdrawalClick,
logoutUiState = logoutUiState,
setThemeUiState = setThemeUiState,
getProfileUiState = getProfileUiState,
themeState = themeState,
qrcodeState = qrcodeState,
alarmState = alarmState,
timeState = timeState,
profileImageUiState = profileImageUiState,
onErrorToast = onErrorToast,
onPasswordCheck = onPasswordCheck
profileImageUiState = profileImageUiState
)
}

Expand All @@ -172,19 +176,21 @@ private fun SettingScreen(
onUpdateAlarm: (String) -> Unit,
onUpdateTime: (String) -> Unit,
setDefaultProfileUiState: () -> Unit,
onErrorToast: (throwable: Throwable?, message: Int?) -> Unit,
onPasswordCheck: () -> Unit,
onWithdrawalClick: () -> Unit,
logoutUiState: LogoutUiState,
setThemeUiState: SetThemeUiState,
getProfileUiState: GetProfileUiState,
themeState: String,
qrcodeState: String,
alarmState: String,
timeState: String,
profileImageUiState: ProfileImageUiState,
onErrorToast: (throwable: Throwable?, message: Int?) -> Unit,
onPasswordCheck: () -> Unit
profileImageUiState: ProfileImageUiState
) {
var openDialog by remember { mutableStateOf(false) }
var openBottomSheet by remember { mutableStateOf(false) }
var isLogout by remember { mutableStateOf(true) }

LaunchedEffect("load data") {
getProfile()
Expand Down Expand Up @@ -253,9 +259,10 @@ private fun SettingScreen(
getProfileUiState = getProfileUiState
)
Spacer(modifier = Modifier.height(32.dp))
PasswordChangeButton(modifier = Modifier) {
onPasswordCheck()
}
Divider(
modifier = Modifier.fillMaxWidth(),
color = colors.WHITE.copy(0.15f)
)
Spacer(modifier = Modifier.height(24.dp))
SelectThemeDropDown(
modifier = Modifier,
Expand Down Expand Up @@ -328,28 +335,45 @@ private fun SettingScreen(
onFunctionOn = { onUpdateQrcode(Switch.ON.value) }
)
}
Spacer(modifier = Modifier.weight(1f))
GomsButton(
Spacer(modifier = Modifier.height(32.dp))
Divider(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.logout),
state = ButtonState.Logout
color = colors.WHITE.copy(0.15f)
)
Spacer(modifier = Modifier.height(24.dp))
SettingButton(
modifier = Modifier,
buttonType = SettingButtonType.PasswordChange.value
) {
onPasswordCheck()
}
SettingButton(
modifier = Modifier,
buttonType = SettingButtonType.Logout.value
) {
isLogout = true
openDialog = true
}
SettingButton(
modifier = Modifier,
buttonType = SettingButtonType.Withdrawal.value
) {
isLogout = false
openDialog = true
}
Spacer(modifier = Modifier.height(40.dp))
}
}
if (openDialog) {
GomsTwoButtonDialog(
openDialog = openDialog,
onStateChange = { openDialog = it },
title = stringResource(id = R.string.logout),
content = stringResource(id = R.string.want_logout),
title = stringResource(id = if(isLogout) R.string.logout else R.string.withdrawal),
content = stringResource(id = if(isLogout) R.string.want_logout else R.string.want_withdrawal),
dismissText = stringResource(id = R.string.cancel),
checkText = stringResource(id = R.string.logout),
checkText = stringResource(id = if(isLogout) R.string.logout else R.string.withdrawal),
onDismissClick = { openDialog = false }
) {
onLogoutClick()
if(isLogout) onLogoutClick() else onWithdrawalClick()
}
}
if (openBottomSheet) {
Expand Down
Loading