Skip to content

Commit

Permalink
Merge pull request #180 from GSM-MSG/feature/#178_add_completion_of_l…
Browse files Browse the repository at this point in the history
…ecture

Feature/#178 add completion of lecture
  • Loading branch information
wjdcksdn authored May 21, 2024
2 parents d7c5ad4 + ee090b8 commit 9bcaee4
Show file tree
Hide file tree
Showing 34 changed files with 1,343 additions and 14 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
implementation(project(":feature:club"))
implementation(project(":feature:email"))
implementation(project(":feature:main"))
implementation(project(":feature:certification"))

implementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import com.example.my_page.navigation.myPageScreen
import com.example.my_page.navigation.navigateToMyPage
import com.example.my_page.navigation.navigateToPasswordChange
import com.msg.bitgoeul_android.ui.BitgoeulAppState
import com.msg.certification.navigation.addCertificationScreen
import com.msg.certification.navigation.certificationScreen
import com.msg.certification.navigation.navigateToAddCertificationPage
import com.msg.club.navigation.clubDetailScreen
import com.msg.club.navigation.clubScreen
import com.msg.club.navigation.navigateToClubDetailPage
Expand Down Expand Up @@ -152,5 +155,12 @@ fun BitgoeulNavHost(
mainPageScreen(
onLoginClicked = navController::navigateToLogin
)
certificationScreen(
onHumanClicked = navController::navigateToMyPage,
onEditClicked = navController::navigateToAddCertificationPage
)
addCertificationScreen(
onBackClicked = navController::popBackStack
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface CertificationRepository {
suspend fun getCertificationListForTeacher(studentId: UUID): Flow<List<CertificationListResponse>>
suspend fun getCertificationListForStudent(): Flow<List<CertificationListResponse>>
suspend fun writeCertification(body: WriteCertificationRequest): Flow<Unit>
suspend fun editCertification(studentId: UUID, id: UUID, body: WriteCertificationRequest): Flow<Unit>
suspend fun editCertification(id: UUID, body: WriteCertificationRequest): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ class CertificationRepositoryImpl @Inject constructor(
}

override suspend fun editCertification(
studentId: UUID,
id: UUID,
body: WriteCertificationRequest,
): Flow<Unit> {
return certificationDataSource.editCertification(
studentId = studentId,
id = id,
body = body
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,12 @@ fun BigAlertIcon() {
painter = painterResource(id = R.drawable.ic_big_alert),
contentDescription = "Big alert icon"
)
}

@Composable
fun HumanIcon() {
Image(
painter = painterResource(id = R.drawable.ic_human),
contentDescription = "Human upper body icon"
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.msg.design_system.component.topbar

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.msg.design_system.component.icon.CloseIcon
import com.msg.design_system.theme.BitgoeulAndroidTheme

@Composable
fun DetailSettingTopBar(
modifier: Modifier = Modifier,
text: String,
onBackClicked: () -> Unit
) {
BitgoeulAndroidTheme { colors, typography ->
Row(
modifier = modifier.fillMaxWidth()
) {
Text(
text = text,
style = typography.titleSmall,
color = colors.BLACK
)
Spacer(modifier = modifier.weight(1f))
IconButton(
modifier = modifier.size(24.dp),
content = { CloseIcon() },
onClick = onBackClicked
)
}
}
}
12 changes: 12 additions & 0 deletions core/design-system/src/main/res/drawable/ic_human.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<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="M4.888,14C7.077,12.145 7.936,12 12,12C16.064,12 16.923,12.145 19.112,14C20.825,15.451 21.589,16.889 21.982,18.881C22.099,19.471 21.621,20 21.01,20H2.99C2.379,20 1.901,19.471 2.018,18.881C2.411,16.889 3.175,15.451 4.888,14Z"
android:fillColor="#B8B8B8"/>
<path
android:pathData="M12,6m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0"
android:fillColor="#B8B8B8"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.inject.Inject
class EditCertificationUseCase @Inject constructor(
private val certificationRepository: CertificationRepository
) {
suspend operator fun invoke(studentId: UUID, id: UUID, body: WriteCertificationRequest) = runCatching {
certificationRepository.editCertification(studentId = studentId, id = id, body = body)
suspend operator fun invoke(id: UUID, body: WriteCertificationRequest) = runCatching {
certificationRepository.editCertification(id = id, body = body)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import java.time.LocalDate

data class WriteCertificationRequest(
val name: String,
val acquisitionData: LocalDate
val acquisitionDate: LocalDate
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.msg.model.remote.response.club

data class StudentBelongClubResponse(
val name: String,
val phoneNumber: Int,
val phoneNumber: String,
val email: String,
val credit: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ interface CertificationAPI {
@Body body: WriteCertificationRequest,
)

@PATCH("certification/{student_id}/{id}")
@PATCH("certification/{id}")
suspend fun editCertification(
@Path("student_id") studentId: UUID,
@Path("id") id: UUID,
@Body body: WriteCertificationRequest
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface CertificationDataSource {
suspend fun getCertificationListForTeacher(studentId: UUID): Flow<List<CertificationListResponse>>
suspend fun getCertificationListForStudent(): Flow<List<CertificationListResponse>>
suspend fun writeCertification(body: WriteCertificationRequest): Flow<Unit>
suspend fun editCertification(studentId: UUID, id: UUID, body: WriteCertificationRequest): Flow<Unit>
suspend fun editCertification(id: UUID, body: WriteCertificationRequest): Flow<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@ class CertificationDataSourceImpl @Inject constructor(
}.flowOn(Dispatchers.IO)

override suspend fun editCertification(
studentId: UUID,
id: UUID,
body: WriteCertificationRequest,
): Flow<Unit> = flow {
emit(
BitgoeulApiHandler<Unit>()
.httpRequest {
certificationAPI.editCertification(
studentId = studentId,
id = id,
body = body
)
Expand Down
1 change: 1 addition & 0 deletions feature/certification/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
8 changes: 8 additions & 0 deletions feature/certification/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
id("bitgoeul.android.feature")
id("bitgoeul.android.hilt")
}

android {
namespace = "com.msg.certification"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.msg.certification

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.msg.certification", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions feature/certification/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?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
@@ -0,0 +1,126 @@
package com.msg.certification

import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.msg.certification.component.AddAcquisitionDateSection
import com.msg.certification.component.AddCertificationSection
import com.msg.design_system.component.button.BitgoeulButton
import com.msg.design_system.component.topbar.DetailSettingTopBar
import com.msg.design_system.theme.BitgoeulAndroidTheme
import com.msg.design_system.theme.color.BitgoeulColor
import com.msg.ui.DevicePreviews
import com.msg.ui.util.toKoreanFormat
import java.time.LocalDate

@Composable
fun AddCertificationScreenRoute(
viewModel: CertificationViewModel = hiltViewModel(LocalContext.current as ComponentActivity),
onBackClicked: () -> Unit,
onAddClicked: () -> Unit
) {
AddCertificationScreen(
selectedName = viewModel.selectedTitle.value,
selectedDate = viewModel.selectedDate.value,
onBackClicked = {
onBackClicked()
},
onAddClicked = { name, acquisitionDate ->
viewModel.selectedCertificationId.value?.let {
viewModel.editCertification(name = name, acquisitionDate = acquisitionDate)
} ?: viewModel.writeCertification(name = name, acquisitionDate = acquisitionDate)
onAddClicked()
}
)
}

@Composable
fun AddCertificationScreen(
modifier: Modifier = Modifier,
selectedName: String,
selectedDate: LocalDate?,
onBackClicked: () -> Unit,
onAddClicked: (name: String, acquisitionDate: LocalDate) -> Unit
) {
val name = remember { mutableStateOf(selectedName) }
val date = remember { mutableStateOf(selectedDate) }

Box(
modifier = modifier
.fillMaxSize()
.background(color = BitgoeulColor.WHITE)
) {
val context = LocalContext.current
Column(
modifier = modifier
.fillMaxSize()
.padding(
top = 24.dp,
bottom = 14.dp,
start = 28.dp,
end = 28.dp
),
verticalArrangement = Arrangement.spacedBy(24.dp)
) {
DetailSettingTopBar(
text = "자격증 세부 설정",
onBackClicked = onBackClicked
)
AddCertificationSection(
onValueChange = {
name.value = it
},
onClickButton = {
name.value = ""
}
)
AddAcquisitionDateSection(
onDatePickerQuit = {
date.value = it
},
acquisitionDate = date.value?.toKoreanFormat() ?: ""
)
Spacer(modifier = modifier.weight(1f))
BitgoeulButton(
modifier = modifier.fillMaxWidth(),
text = "자격증 등록",
onClick = {
if (name.value.isBlank()) {
Toast.makeText(context, "자격증 이름을 입력해주세요", Toast.LENGTH_SHORT).show()
} else if (date.value == null) {
Toast.makeText(context, "취득일을 입력해주세요", Toast.LENGTH_SHORT).show()
} else {
onAddClicked(name.value, date.value!!)
}
}
)
}
}
}


@DevicePreviews
@Composable
fun AddCertificationScreenPre() {
AddCertificationScreen(
onBackClicked = {},
onAddClicked = {_,_->},
selectedName = "",
selectedDate = null
)
}
Loading

0 comments on commit 9bcaee4

Please sign in to comment.