-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from team-haribo/feature/38-write-the-logic-ou…
…ting-current-situation 🔀 :: (#38) - write the logic outing current situation
- Loading branch information
Showing
24 changed files
with
458 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
core/data/src/main/java/com/goms/data/repository/council/CouncilRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.goms.data.repository.council | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import java.util.UUID | ||
|
||
interface CouncilRepository { | ||
suspend fun deleteOuting(accountIdx: UUID): Flow<Unit> | ||
} |
14 changes: 14 additions & 0 deletions
14
core/data/src/main/java/com/goms/data/repository/council/CouncilRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.goms.data.repository.council | ||
|
||
import com.goms.network.datasource.council.CouncilDataSource | ||
import kotlinx.coroutines.flow.Flow | ||
import java.util.UUID | ||
import javax.inject.Inject | ||
|
||
class CouncilRepositoryImpl @Inject constructor( | ||
private val remoteCouncilDataSource: CouncilDataSource | ||
) : CouncilRepository { | ||
override suspend fun deleteOuting(accountIdx: UUID): Flow<Unit> { | ||
return remoteCouncilDataSource.deleteOuting(accountIdx = accountIdx) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
core/design-system/src/main/java/com/goms/design_system/component/dialog/GomsDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.goms.design_system.component.dialog | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
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.text.font.FontWeight | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.window.Dialog | ||
import com.goms.design_system.theme.GomsTheme | ||
|
||
@Composable | ||
fun GomsDialog( | ||
openDialog: Boolean, | ||
onStateChange: (Boolean) -> Unit, | ||
title: String, | ||
content: String, | ||
dismissText: String, | ||
checkText: String, | ||
onDismissClick: () -> Unit, | ||
onCheckClick: () -> Unit | ||
) { | ||
var openDialog by remember { mutableStateOf(openDialog) } | ||
|
||
if (openDialog) { | ||
Dialog(onDismissRequest = { openDialog = false }) { | ||
GomsTheme { colors, typography -> | ||
Card( | ||
modifier = Modifier.width(280.dp), | ||
shape = RoundedCornerShape(12.dp), | ||
border = BorderStroke(width = 1.dp, color = colors.WHITE.copy(0.15f)) | ||
) { | ||
Column(modifier = Modifier.background(colors.G1)) { | ||
Column( | ||
modifier = Modifier | ||
.background(colors.G1) | ||
.padding(top = 16.dp, start = 16.dp, end = 16.dp) | ||
) { | ||
Text( | ||
text = title, | ||
modifier = Modifier.fillMaxWidth(), | ||
color = colors.WHITE, | ||
style = typography.titleSmall, | ||
fontWeight = FontWeight.SemiBold, | ||
) | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
Text( | ||
text = content, | ||
modifier = Modifier.fillMaxWidth(), | ||
color = colors.G7, | ||
style = typography.textMedium, | ||
fontWeight = FontWeight.Normal, | ||
) | ||
} | ||
Row( | ||
Modifier | ||
.fillMaxWidth() | ||
.height(64.dp) | ||
.padding(end = 8.dp) | ||
.background(colors.G1), | ||
horizontalArrangement = Arrangement.End, | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
TextButton( | ||
modifier = Modifier | ||
.weight(1f) | ||
.height(60.dp), | ||
onClick = { | ||
openDialog = false | ||
onDismissClick() | ||
} | ||
) { | ||
Text( | ||
text = dismissText, | ||
color = colors.I5, | ||
style = typography.textMedium, | ||
fontWeight = FontWeight.Medium, | ||
) | ||
} | ||
TextButton( | ||
modifier = Modifier | ||
.weight(1f) | ||
.height(60.dp), | ||
onClick = { | ||
openDialog = false | ||
onCheckClick() | ||
} | ||
) { | ||
Text( | ||
text = checkText, | ||
color = colors.N5, | ||
style = typography.textMedium, | ||
fontWeight = FontWeight.Medium, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
onStateChange(openDialog) | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun GomsDialogPreview() { | ||
GomsDialog( | ||
openDialog = true, | ||
onStateChange = {}, | ||
title = "외출 강제 복귀", | ||
content = "외출자를 강제로 복귀시키시겠습니까?", | ||
dismissText = "취소", | ||
checkText = "복귀", | ||
onDismissClick = {}, | ||
onCheckClick = {} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/goms/domain/council/DeleteOutingUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.goms.domain.council | ||
|
||
import com.goms.data.repository.council.CouncilRepository | ||
import java.util.UUID | ||
import javax.inject.Inject | ||
|
||
class DeleteOutingUseCase @Inject constructor( | ||
private val councilRepository: CouncilRepository | ||
) { | ||
suspend operator fun invoke(accountIdx: UUID) = kotlin.runCatching { | ||
councilRepository.deleteOuting(accountIdx = accountIdx) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/goms/domain/outing/OutingSearchUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.goms.domain.outing | ||
|
||
import com.goms.data.repository.outing.OutingRepository | ||
import com.goms.model.response.outing.OutingResponse | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class OutingSearchUseCase @Inject constructor( | ||
private val outingRepository: OutingRepository | ||
) { | ||
suspend operator fun invoke(name: String): Flow<List<OutingResponse>> = | ||
outingRepository.outingSearch(name = name) | ||
} |
12 changes: 12 additions & 0 deletions
12
core/network/src/main/java/com/goms/network/api/CouncilAPI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.goms.network.api | ||
|
||
import retrofit2.http.DELETE | ||
import retrofit2.http.Path | ||
import java.util.UUID | ||
|
||
interface CouncilAPI { | ||
@DELETE("/api/v2/student-council/outing/{accountIdx}") | ||
suspend fun deleteOuting( | ||
@Path("accountIdx") accountIdx: UUID | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
core/network/src/main/java/com/goms/network/datasource/council/CouncilDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.goms.network.datasource.council | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import java.util.UUID | ||
|
||
interface CouncilDataSource { | ||
suspend fun deleteOuting(accountIdx: UUID): Flow<Unit> | ||
} |
22 changes: 22 additions & 0 deletions
22
core/network/src/main/java/com/goms/network/datasource/council/CouncilDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.goms.network.datasource.council | ||
|
||
import com.goms.network.api.CouncilAPI | ||
import com.goms.network.util.GomsApiHandler | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import kotlinx.coroutines.flow.flowOn | ||
import java.util.UUID | ||
import javax.inject.Inject | ||
|
||
class CouncilDataSourceImpl @Inject constructor( | ||
private val councilAPI: CouncilAPI | ||
) : CouncilDataSource { | ||
override suspend fun deleteOuting(accountIdx: UUID): Flow<Unit> = flow { | ||
emit( | ||
GomsApiHandler<Unit>() | ||
.httpRequest { councilAPI.deleteOuting(accountIdx = accountIdx) } | ||
.sendRequest() | ||
) | ||
}.flowOn(Dispatchers.IO) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.