diff --git a/app/src/main/java/com/example/remind/data/model/response/GetDailyMoodResponse.kt b/app/src/main/java/com/example/remind/data/model/response/GetDailyMoodResponse.kt index b66c257..d3ae491 100644 --- a/app/src/main/java/com/example/remind/data/model/response/GetDailyMoodResponse.kt +++ b/app/src/main/java/com/example/remind/data/model/response/GetDailyMoodResponse.kt @@ -2,10 +2,10 @@ package com.example.remind.data.model.response data class GetDailyMoodResponse( val code: Int, - val `data`: Data, + val `data`: DailyActivity, val message: String ) -data class Data( +data class DailyActivity( val activities: List = emptyList(), val feelingType: String = "", val moodDetail: String = "" diff --git a/app/src/main/java/com/example/remind/data/model/response/ListData.kt b/app/src/main/java/com/example/remind/data/model/response/ListData.kt index 621da0c..14fbe8c 100644 --- a/app/src/main/java/com/example/remind/data/model/response/ListData.kt +++ b/app/src/main/java/com/example/remind/data/model/response/ListData.kt @@ -1,5 +1,5 @@ package com.example.remind.data.model.response -data class ListData( - val name: String="" -) +//data class ListData( +// val name: String="" +//) diff --git a/app/src/main/java/com/example/remind/data/model/response/MemberInfoResponse.kt b/app/src/main/java/com/example/remind/data/model/response/MemberInfoResponse.kt new file mode 100644 index 0000000..cfefd6d --- /dev/null +++ b/app/src/main/java/com/example/remind/data/model/response/MemberInfoResponse.kt @@ -0,0 +1,13 @@ +package com.example.remind.data.model.response + +data class MemberInfoResponse( + val code: Int, + val `data`: Info, + val message: String +) +data class Info( + val age: Int=0, + val gender: String="", + val imageUrl: String="", + val name: String="" +) \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/data/network/service/AuthService.kt b/app/src/main/java/com/example/remind/data/network/service/AuthService.kt index 9d0cbf1..2bce768 100644 --- a/app/src/main/java/com/example/remind/data/network/service/AuthService.kt +++ b/app/src/main/java/com/example/remind/data/network/service/AuthService.kt @@ -3,12 +3,15 @@ package com.example.remind.data.network.service import com.example.remind.data.model.request.KakaoLoginRequest import com.example.remind.data.model.request.OnBoardingRequest import com.example.remind.data.model.request.TokenRequest +import com.example.remind.data.model.response.MemberInfoResponse import com.example.remind.data.model.response.OnBoardingResponse import com.example.remind.data.model.response.SocialLoginResponse import com.example.remind.data.model.response.TokenResponse import com.example.remind.data.network.adapter.ApiResult import retrofit2.http.Body +import retrofit2.http.GET import retrofit2.http.POST +import retrofit2.http.Query interface AuthService { @POST("/member/refresh") @@ -25,4 +28,9 @@ interface AuthService { suspend fun OnBoarding( @Body body: OnBoardingRequest ): ApiResult + + @GET("/member/info") + suspend fun MemberInfo( + @Query("memberId") memberId:Int + ): ApiResult } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/data/network/service/DoctorService.kt b/app/src/main/java/com/example/remind/data/network/service/DoctorService.kt index 7f5741e..47973d5 100644 --- a/app/src/main/java/com/example/remind/data/network/service/DoctorService.kt +++ b/app/src/main/java/com/example/remind/data/network/service/DoctorService.kt @@ -3,6 +3,7 @@ package com.example.remind.data.network.service import com.example.remind.data.model.request.SetAcceptrequest import com.example.remind.data.model.response.GetAcceptResponse import com.example.remind.data.model.response.GetPatientResponse +import com.example.remind.data.model.response.MoodChartResponse import com.example.remind.data.network.adapter.ApiResult import retrofit2.http.Body import retrofit2.http.GET @@ -19,4 +20,13 @@ interface DoctorService { suspend fun setRequest( @Body body: SetAcceptrequest ): ApiResult + + @GET("/mood/chart/connection") + suspend fun getPatienceMoodChart( + @Query("year") year: Int, + @Query("month") month: Int, + @Query("day") day: Int, + @Query("size") size: Int, + @Query("memberId") memberId: Int, + ): ApiResult } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/data/repository/auth/AuthRepository.kt b/app/src/main/java/com/example/remind/data/repository/auth/AuthRepository.kt index 17666b4..7ea7cff 100644 --- a/app/src/main/java/com/example/remind/data/repository/auth/AuthRepository.kt +++ b/app/src/main/java/com/example/remind/data/repository/auth/AuthRepository.kt @@ -2,14 +2,13 @@ package com.example.remind.data.repository.auth import com.example.remind.data.model.request.KakaoLoginRequest import com.example.remind.data.model.request.OnBoardingRequest -import com.example.remind.data.model.request.TokenRequest +import com.example.remind.data.model.response.MemberInfoResponse import com.example.remind.data.model.response.OnBoardingResponse import com.example.remind.data.model.response.SocialLoginResponse -import com.example.remind.data.model.response.TokenResponse import com.example.remind.data.network.adapter.ApiResult -import retrofit2.http.Body interface AuthRepository { suspend fun getTokenFromKakao(body: KakaoLoginRequest): ApiResult suspend fun postOnBoardingInfo(body: OnBoardingRequest): ApiResult + suspend fun getMemberInfo(memberId: Int): ApiResult } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/data/repository/auth/AuthRepositoryImpl.kt b/app/src/main/java/com/example/remind/data/repository/auth/AuthRepositoryImpl.kt index 0d77597..9174668 100644 --- a/app/src/main/java/com/example/remind/data/repository/auth/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/example/remind/data/repository/auth/AuthRepositoryImpl.kt @@ -2,10 +2,9 @@ package com.example.remind.data.repository.auth import com.example.remind.data.model.request.KakaoLoginRequest import com.example.remind.data.model.request.OnBoardingRequest -import com.example.remind.data.model.request.TokenRequest +import com.example.remind.data.model.response.MemberInfoResponse import com.example.remind.data.model.response.OnBoardingResponse import com.example.remind.data.model.response.SocialLoginResponse -import com.example.remind.data.model.response.TokenResponse import com.example.remind.data.network.adapter.ApiResult import com.example.remind.data.network.service.AuthService import javax.inject.Inject @@ -22,4 +21,8 @@ class AuthRepositoryImpl @Inject constructor( return service.OnBoarding(body) } + override suspend fun getMemberInfo(memberId: Int): ApiResult { + return service.MemberInfo(memberId) + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepository.kt b/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepository.kt index 950c992..0a32e8c 100644 --- a/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepository.kt +++ b/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepository.kt @@ -3,9 +3,11 @@ package com.example.remind.data.repository.doctor import com.example.remind.data.model.request.SetAcceptrequest import com.example.remind.data.model.response.GetAcceptResponse import com.example.remind.data.model.response.GetPatientResponse +import com.example.remind.data.model.response.MoodChartResponse import com.example.remind.data.network.adapter.ApiResult interface DoctorRepository { suspend fun getPatientList(status: String): ApiResult suspend fun getRequest(body: SetAcceptrequest): ApiResult + suspend fun getMoodChart(year: Int, month: Int, day: Int, size: Int, memberId: Int): ApiResult } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepositoryImpl.kt b/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepositoryImpl.kt index f8897cd..2114f5f 100644 --- a/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepositoryImpl.kt +++ b/app/src/main/java/com/example/remind/data/repository/doctor/DoctorRepositoryImpl.kt @@ -3,6 +3,7 @@ package com.example.remind.data.repository.doctor import com.example.remind.data.model.request.SetAcceptrequest import com.example.remind.data.model.response.GetAcceptResponse import com.example.remind.data.model.response.GetPatientResponse +import com.example.remind.data.model.response.MoodChartResponse import com.example.remind.data.network.adapter.ApiResult import com.example.remind.data.network.service.DoctorService import javax.inject.Inject @@ -18,4 +19,14 @@ class DoctorRepositoryImpl @Inject constructor( return service.setRequest(body) } + override suspend fun getMoodChart( + year: Int, + month: Int, + day: Int, + size: Int, + memberId: Int + ): ApiResult { + return service.getPatienceMoodChart(year, month, day, size, memberId) + } + } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/domain/usecase/doctor_usecase/GetDoctorMoodChartUseCase.kt b/app/src/main/java/com/example/remind/domain/usecase/doctor_usecase/GetDoctorMoodChartUseCase.kt new file mode 100644 index 0000000..ba4f194 --- /dev/null +++ b/app/src/main/java/com/example/remind/domain/usecase/doctor_usecase/GetDoctorMoodChartUseCase.kt @@ -0,0 +1,20 @@ +package com.example.remind.domain.usecase.doctor_usecase + +import com.example.remind.data.model.response.MoodChartResponse +import com.example.remind.data.network.adapter.ApiResult +import com.example.remind.data.repository.doctor.DoctorRepository +import javax.inject.Inject + +class GetDoctorMoodChartUseCase @Inject constructor( + private val doctorRepository: DoctorRepository +) { + suspend operator fun invoke( + year: Int, + month: Int, + day: Int, + size: Int, + memberId: Int + ): ApiResult { + return doctorRepository.getMoodChart(year, month, day, size, memberId) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/domain/usecase/onboarding_usecase/MemberInfoUseCase.kt b/app/src/main/java/com/example/remind/domain/usecase/onboarding_usecase/MemberInfoUseCase.kt new file mode 100644 index 0000000..4a15807 --- /dev/null +++ b/app/src/main/java/com/example/remind/domain/usecase/onboarding_usecase/MemberInfoUseCase.kt @@ -0,0 +1,14 @@ +package com.example.remind.domain.usecase.onboarding_usecase + +import com.example.remind.data.model.response.MemberInfoResponse +import com.example.remind.data.network.adapter.ApiResult +import com.example.remind.data.repository.auth.AuthRepository +import javax.inject.Inject + +class MemberInfoUseCase @Inject constructor( + private val authRepository: AuthRepository +) { + suspend operator fun invoke(memberId: Int): ApiResult { + return authRepository.getMemberInfo(memberId) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorContract.kt b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorContract.kt index fa0065a..2f78bd0 100644 --- a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorContract.kt +++ b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorContract.kt @@ -8,6 +8,7 @@ import com.example.remind.core.base.UiEvent import com.example.remind.core.base.UiState import com.example.remind.data.model.response.DoctorData import com.example.remind.data.model.response.GetMonthlyMedicineResponse +import com.example.remind.data.model.response.Info import com.example.remind.data.model.response.Mood import com.example.remind.data.model.response.PercentList import com.example.remind.data.model.response.Prescription @@ -26,6 +27,8 @@ class DoctorContract { val prescription: Prescription = Prescription(), val getMonthlyMedicineResponse: GetMonthlyMedicineResponse = GetMonthlyMedicineResponse(), val feelingTotalPerCent: List = emptyList(), + val memberInfo: Info = Info(), + val patientInfo: Info = Info() ): UiState sealed class Event: UiEvent { diff --git a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMainScreen.kt b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMainScreen.kt index ea86d7b..f07b714 100644 --- a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMainScreen.kt +++ b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMainScreen.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -21,6 +22,7 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -28,12 +30,15 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController +import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi +import com.bumptech.glide.integration.compose.GlideImage import com.example.remind.R import com.example.remind.core.common.component.BasicButton import com.example.remind.core.common.component.BasicListItem import com.example.remind.core.common.component.MainAppBar import com.example.remind.core.common.component.RemindSearchTextField import com.example.remind.core.designsystem.theme.RemindTheme +import com.example.remind.data.model.response.Info import kotlinx.coroutines.flow.collectLatest @OptIn(ExperimentalFoundationApi::class) @@ -49,6 +54,7 @@ fun DoctorMain( LaunchedEffect(Unit) { viewModel.getPatients() viewModel.getRequestPatients() + viewModel.getMemberInfo() } LaunchedEffect(true) { @@ -75,7 +81,10 @@ fun DoctorMain( modifier = Modifier.padding(start = 26.dp, end = 28.dp), ) { item { - Profile(modifier = Modifier) + Profile( + modifier = Modifier, + myInfo = uiState.memberInfo + ) } stickyHeader { StickyHeaderComponent( @@ -115,22 +124,26 @@ fun DoctorMain( } +@OptIn(ExperimentalGlideComposeApi::class) @Composable -fun Profile(modifier: Modifier) { +fun Profile( + modifier: Modifier, + myInfo: Info +) { Row( modifier = modifier .fillMaxWidth() .padding(start = 20.dp, end = 24.dp), verticalAlignment = Alignment.CenterVertically ) { - //예비 - Icon( - painter = painterResource(id = R.drawable.ic_logo), - contentDescription = null, - modifier = modifier - .size(width = 71.dp, height = 95.dp) - .padding(start = 20.dp), - tint = RemindTheme.colors.main_1 + GlideImage( + modifier = Modifier + .size(width = 80.dp, height = 80.dp) + .clip(RoundedCornerShape(10.dp)) + .padding(end = 8.dp), + contentScale = ContentScale.Crop, + model = myInfo.imageUrl, + contentDescription = null ) Column( modifier = modifier @@ -138,7 +151,7 @@ fun Profile(modifier: Modifier) { ) { Text( modifier = modifier.padding(end = 24.dp, bottom = 4.dp), - text = "김말랑 님", + text = "${myInfo.name}님", style = RemindTheme.typography.b1Bold ) Text( @@ -165,10 +178,10 @@ fun StickyHeaderComponent( modifier = modifier .background(color = RemindTheme.colors.white) .padding( - start = 44.dp, - top = 14.dp, - bottom = 9.dp - ), + start = 44.dp, + top = 14.dp, + bottom = 9.dp + ), text = stringResource(R.string.관리_중인_환자), style = RemindTheme.typography.b3Bold.copy(color = RemindTheme.colors.main_6) ) @@ -210,6 +223,7 @@ fun StickyHeaderComponent( RemindSearchTextField( modifier = Modifier .weight(1f) + .fillMaxHeight() .padding(start = 14.dp), hintText = stringResource(R.string.검색), onValueChange = {}, diff --git a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMedicineManage.kt b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMedicineManage.kt index 0df3079..f23e432 100644 --- a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMedicineManage.kt +++ b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMedicineManage.kt @@ -44,6 +44,7 @@ fun DoctorMedicineManage( val uiState by viewModel.uiState.collectAsStateWithLifecycle() val effectFlow = viewModel.effect val scrollState = rememberScrollState() + LaunchedEffect(true) { effectFlow.collectLatest { effect -> when(effect) { @@ -53,7 +54,7 @@ fun DoctorMedicineManage( } } } - val patientInfo = uiState.acceptList.patientDtos.find { it.memberId == uiState.memberId } + //val patientInfo = uiState.acceptList.patientDtos.find { it.memberId == uiState.memberId } RemindTheme { Column( modifier = Modifier @@ -63,7 +64,7 @@ fun DoctorMedicineManage( .verticalScroll(scrollState) ) { BasicBackAppBar ( - modifier = Modifier, + modifier = Modifier.padding(top = 20.dp), onClick = {navController.navigateUp()}, title = "환자 관리" ) @@ -72,7 +73,7 @@ fun DoctorMedicineManage( verticalAlignment = Alignment.CenterVertically ) { Text( - text = "${patientInfo?.name}님의 약 처방", + text = "${uiState.patientInfo.name}님의 약 처방", style = RemindTheme.typography.b2Bold.copy(color = RemindTheme.colors.text) ) Spacer(modifier = Modifier.weight(1f)) @@ -92,7 +93,8 @@ fun DoctorMedicineManage( ) BasicButton( modifier = Modifier - .fillMaxWidth(), + .fillMaxWidth() + .padding(top = 7.dp), text = "약 처방 업데이트", RoundedCorner = 12.dp, backgroundColor = RemindTheme.colors.main_6, @@ -186,6 +188,7 @@ fun PatientMedicineContainer( Text( modifier = modifier .fillMaxWidth() + .padding(bottom = 11.dp) .background( color = RemindTheme.colors.main_2, shape = RoundedCornerShape(20.dp) diff --git a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMoodChartScreen.kt b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMoodChartScreen.kt index 4df0409..0da11e2 100644 --- a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMoodChartScreen.kt +++ b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorMoodChartScreen.kt @@ -3,13 +3,17 @@ package com.example.remind.feature.screens.doctor import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight 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.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll @@ -30,6 +34,10 @@ import com.example.remind.R import com.example.remind.core.common.component.BasicBackAppBar import com.example.remind.core.common.component.BasicButton import com.example.remind.core.designsystem.theme.RemindTheme +import com.example.remind.data.model.graphScoreModel +import com.example.remind.feature.screens.patience.moodchart.GraphComponent +import com.example.remind.feature.screens.patience.moodchart.ScoreList +import com.example.remind.feature.screens.patience.moodchart.ShowWeek import com.example.remind.feature.screens.patience.moodchart.component.FeelingPercentGraph import kotlinx.coroutines.flow.collectLatest import java.time.LocalDate @@ -54,6 +62,13 @@ fun DoctorMoodChaartScreen( val year = LocalDate.now().year val month = LocalDate.now().monthValue val date = LocalDate.now().dayOfMonth + val graphYaxisList = listOf( + graphScoreModel(100, R.drawable.ic_verygood), + graphScoreModel(75, R.drawable.ic_good), + graphScoreModel(50, R.drawable.ic_normal), + graphScoreModel(25, R.drawable.ic_bad), + graphScoreModel(0, R.drawable.ic_terrible), + ) RemindTheme { Column( modifier = Modifier @@ -63,7 +78,7 @@ fun DoctorMoodChaartScreen( .verticalScroll(scrollState) ) { BasicBackAppBar ( - modifier = Modifier, + modifier = Modifier.padding(top = 20.dp), onClick = {navController.navigateUp()}, title = "무드 차트 상세" ) @@ -72,7 +87,9 @@ fun DoctorMoodChaartScreen( style = RemindTheme.typography.b2Bold.copy(color = RemindTheme.colors.text) ) BasicButton( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp), text = "${year}.${month}.${date} 기록 확인", RoundedCorner = 12.dp, backgroundColor = RemindTheme.colors.main_6, @@ -83,6 +100,73 @@ fun DoctorMoodChaartScreen( }, textStyle = RemindTheme.typography.b3Bold ) + if(uiState.xAxisData.isNotEmpty() && uiState.yAxisData.isNotEmpty()) { + Box( + modifier = Modifier + .fillMaxWidth() + .padding(top = 8.dp) + .height(300.dp) + .border( + width = 1.dp, + shape = RoundedCornerShape(12.dp), + color = RemindTheme.colors.grayscale_2 + ) + ) { + Row( + modifier = Modifier + .align(Alignment.TopCenter) + .padding(top = 10.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Image( + modifier = Modifier.padding(end = 7.dp), + painter = painterResource(id = R.drawable.ic_arrow_graph_left), + contentDescription = null + ) + Text( + modifier = Modifier.padding(end = 7.dp), + text = ShowWeek(), + style = RemindTheme.typography.b3Medium.copy(color = RemindTheme.colors.text) + ) + Image( + painter = painterResource(id = R.drawable.ic_arrow_graph_right), + contentDescription = null + ) + } + Row( + modifier = Modifier + .fillMaxWidth() + .padding(start = 7.dp, end = 10.dp) + ) { + Column( + modifier = Modifier + .fillMaxHeight() + .padding(top = 20.dp), + verticalArrangement = Arrangement.SpaceEvenly + ) { + graphYaxisList.forEach { data -> + ScoreList( + data = data, + modifier = Modifier.weight(1f) + ) + } + } + Spacer(modifier = Modifier.width(25.dp)) + if(uiState.xAxisData.isNotEmpty() && uiState.yAxisData.isNotEmpty()) { + GraphComponent( + modifier = Modifier.weight(4f), + dateListX = uiState.xAxisData, + dateListY = uiState.yAxisData, + pointClick = {} + ) + } else { + CircularProgressIndicator() + } + } + } + } else { + CircularProgressIndicator() + } Text( modifier = Modifier.padding(top = 20.dp), text = stringResource(id = R.string.기분별_활동_차트), @@ -93,37 +177,15 @@ fun DoctorMoodChaartScreen( text = stringResource(id = R.string.무엇을_할_때_기분이_좋은지_확인), style = RemindTheme.typography.b2Medium.copy(color = RemindTheme.colors.grayscale_3) ) - Box( + //사진넣기 사진넣기 + Image( modifier = Modifier - .padding(top = 8.dp) - .border( - width = 1.dp, - color = RemindTheme.colors.grayscale_2, - shape = RoundedCornerShape(12.dp) - ) - ) { - if(uiState.feelingTotalPerCent.isNotEmpty()) { - FeelingPercentGraph( - modifier = Modifier.padding(top = 12.dp, bottom = 21.dp, start = 8.dp, end = 8.dp), - percentList = uiState.feelingTotalPerCent, - onClick = {} - ) - } else { - CircularProgressIndicator() - } - Text( - modifier = Modifier.padding(top = 20.dp), - text = stringResource(id = R.string.무드_차트_월별_비교) - ) - Image( - modifier = Modifier - .fillMaxWidth() - .padding(top = 8.dp, bottom = 105.dp), - painter = painterResource(id = R.drawable.moodcontainer_example), - contentScale = ContentScale.FillWidth, - contentDescription = null - ) - } + .fillMaxWidth() + .padding(top = 8.dp, bottom = 105.dp), + painter = painterResource(id = R.drawable.moodcontainer_example), + contentScale = ContentScale.FillWidth, + contentDescription = null + ) } } } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorRegisterScreen.kt b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorRegisterScreen.kt index dd7f352..655df55 100644 --- a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorRegisterScreen.kt +++ b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorRegisterScreen.kt @@ -57,7 +57,7 @@ fun DoctorRegisterScreen( .background(color = RemindTheme.colors.white) ) { BasicBackAppBar ( - modifier = Modifier, + modifier = Modifier.padding(top = 20.dp), onClick = {navController.navigateUp()}, title = stringResource(id = R.string.환자_추가하기) ) diff --git a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorViewModel.kt b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorViewModel.kt index 0cca5f1..e0ad6d9 100644 --- a/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorViewModel.kt +++ b/app/src/main/java/com/example/remind/feature/screens/doctor/DoctorViewModel.kt @@ -8,8 +8,10 @@ import com.example.remind.core.base.BaseViewModel import com.example.remind.data.model.request.SetAcceptrequest import com.example.remind.data.network.adapter.ApiResult import com.example.remind.data.network.interceptor.TokenManager +import com.example.remind.domain.usecase.doctor_usecase.GetDoctorMoodChartUseCase import com.example.remind.domain.usecase.doctor_usecase.GetPatientUseCase import com.example.remind.domain.usecase.doctor_usecase.GetRequestUseCase +import com.example.remind.domain.usecase.onboarding_usecase.MemberInfoUseCase import com.example.remind.domain.usecase.patience_usecase.GetFeelingPercentUseCase import com.example.remind.domain.usecase.patience_usecase.GetMedicineRateUseCase import com.example.remind.domain.usecase.patience_usecase.GetMonthlyMedicineUseCase @@ -25,10 +27,12 @@ class DoctorViewModel @Inject constructor( private val getPatientUseCase: GetPatientUseCase, private val getRequestUseCase: GetRequestUseCase, private val getMedicineRateUseCase: GetMedicineRateUseCase, - private val getMoodChartUseCase: GetMoodChartUseCase, + //private val getMoodChartUseCase: GetMoodChartUseCase, private val prescriptionUseCase: PrescriptionUseCase, private val getMonthlyMedicineUseCase: GetMonthlyMedicineUseCase, - private val getFeelingPercentUseCase: GetFeelingPercentUseCase + private val getFeelingPercentUseCase: GetFeelingPercentUseCase, + private val memberInfoUseCase: MemberInfoUseCase, + private val getDoctorMoodChartUseCase: GetDoctorMoodChartUseCase ): BaseViewModel( initialState = DoctorContract.State() ) { @@ -39,16 +43,18 @@ class DoctorViewModel @Inject constructor( viewModelScope.launch { getPatients() getRequestPatients() - getMedicineRate() - getMoodChartData(year, month, date-6) - getPrescription() - getMonthMedicine() + //getMedicineRate() + //getMoodChartData(year, month, date-6) + //getPrescription() + //getMonthMedicine() getFeelingPerCent() + getMemberInfo() } } override fun reduceState(event: DoctorContract.Event) { when(event) { is DoctorContract.Event.RegisterButtonClicked -> { + getRequestPatients() navigateToRoute( destination = Screens.Doctor.DoctorPatienceRegister.route, current = Screens.Doctor.DoctorMain.route, @@ -65,6 +71,8 @@ class DoctorViewModel @Inject constructor( updateState(currentState.copy( memberId = event.memberId )) + getPatientInfo(event.memberId) + getMoodChartData(year, month, date, event.memberId) navigateToRoute( destination = Screens.Doctor.PatienceManage.route, current = Screens.Doctor.DoctorMain.route, @@ -79,6 +87,9 @@ class DoctorViewModel @Inject constructor( ) } is DoctorContract.Event.ClickToMedicine -> { + getPrescription() + getMedicineRate() + getMonthMedicine() navigateToRoute( destination = Screens.Doctor.ManageMedicine.route, current = Screens.Doctor.PatienceManage.route, @@ -167,9 +178,9 @@ class DoctorViewModel @Inject constructor( } } } - private fun getMoodChartData(year: Int, month: Int, day: Int) { + private fun getMoodChartData(year: Int, month: Int, day: Int, memberId: Int) { viewModelScope.launch { - val result = getMoodChartUseCase.invoke(year, month, day, 7) + val result = getDoctorMoodChartUseCase.invoke(year, month, day, 7, memberId) when(result) { is ApiResult.Success -> { updateState(currentState.copy( @@ -223,5 +234,31 @@ class DoctorViewModel @Inject constructor( } } } + fun getMemberInfo() { + viewModelScope.launch { + val result = memberInfoUseCase.invoke(0) + when(result) { + is ApiResult.Success -> { + updateState(currentState.copy( + memberInfo = result.data.data + )) + } + else ->{} + } + } + } + fun getPatientInfo(memberId: Int) { + viewModelScope.launch { + val result = memberInfoUseCase.invoke(memberId) + when(result) { + is ApiResult.Success -> { + updateState(currentState.copy( + patientInfo = result.data.data + )) + } + else ->{} + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/remind/feature/screens/doctor/PatientManageScreen.kt b/app/src/main/java/com/example/remind/feature/screens/doctor/PatientManageScreen.kt index 41c394b..9af493c 100644 --- a/app/src/main/java/com/example/remind/feature/screens/doctor/PatientManageScreen.kt +++ b/app/src/main/java/com/example/remind/feature/screens/doctor/PatientManageScreen.kt @@ -27,18 +27,24 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Brush +import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController +import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi +import com.bumptech.glide.integration.compose.GlideImage import com.example.remind.R import com.example.remind.core.common.component.BasicBackAppBar import com.example.remind.core.common.component.BasicButton import com.example.remind.core.designsystem.theme.RemindTheme import com.example.remind.data.model.graphScoreModel import com.example.remind.data.model.response.DoctorData +import com.example.remind.data.model.response.Info import com.example.remind.data.model.response.Rate import com.example.remind.feature.screens.patience.moodchart.GraphComponent import com.example.remind.feature.screens.patience.moodchart.MoodChartContract @@ -86,21 +92,22 @@ fun PatientManageScreen( .verticalScroll(scrollState) ) { BasicBackAppBar ( - modifier = Modifier, + modifier = Modifier.padding(top = 20.dp), onClick = {navController.navigateUp()}, title = "환자 관리" ) PatientProfile( - modifier = Modifier.fillMaxWidth(), - memberData = uiState.doctorData, - memberId = uiState.memberId ?: 0 + modifier = Modifier + .padding(top = 25.dp) + .fillMaxWidth(), + memberData = uiState.patientInfo ) Row( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically ) { Text( - modifier = Modifier.padding(top = 30.dp), + modifier = Modifier.padding(top = 30.dp, bottom= 7.dp), text = stringResource(id = R.string.약_복용률), style = RemindTheme.typography.b2Bold.copy(color = RemindTheme.colors.text) ) @@ -228,41 +235,37 @@ fun PatientManageScreen( } } +@OptIn(ExperimentalGlideComposeApi::class) @Composable fun PatientProfile( modifier: Modifier = Modifier, - memberData: DoctorData, - memberId: Int + memberData: Info, ) { Row( modifier = modifier - .fillMaxWidth() - .padding(start = 20.dp, end = 24.dp), + .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically ) { - val patient = memberData.patientDtos.find { it.memberId == memberId } - - Icon( - painter = painterResource(id = R.drawable.ic_logo), - contentDescription = null, - modifier = modifier - .size(width = 71.dp, height = 95.dp) - .padding(start = 20.dp), - tint = RemindTheme.colors.main_1 + GlideImage( + modifier = Modifier + .size(width = 80.dp, height = 80.dp) + .clip(RoundedCornerShape(10.dp)), + contentScale = ContentScale.Crop, + model = memberData.imageUrl, + contentDescription = null ) Column( modifier = modifier - .fillMaxWidth() + .padding(start = 8.dp), + horizontalAlignment = Alignment.Start ) { Text( - modifier = modifier.padding(end = 24.dp, bottom = 4.dp), - text = patient?.name ?: "김말랑", + text = memberData.name, style = RemindTheme.typography.b1Bold ) Text( - modifier = modifier.padding(end = 24.dp), - text = "만${patient?.age} ${patient?.gender}", - style = RemindTheme.typography.h2Medium + text = "만${memberData.age} ${memberData.gender}", + style = RemindTheme.typography.h2Medium.copy(fontSize = 14.sp) ) } } @@ -273,6 +276,10 @@ fun DoctorMedicineRateContainer( modifier: Modifier = Modifier, rate: Rate ) { + val total = String.format("%.1f", rate.totalRate) + val breakfast = String.format("%.1f", rate.breakfastRate) + val lunch = String.format("%.1f", rate.lunchRate) + val dinner = String.format("%.1f", rate.dinnerRate) Box( modifier = modifier .fillMaxWidth() @@ -288,7 +295,7 @@ fun DoctorMedicineRateContainer( ) { Row { Text( - text = String.format("%.1f", rate.totalRate), + text = "${total}%", style = RemindTheme.typography.h1Bold.copy(color= RemindTheme.colors.main_6) ) Text( @@ -306,8 +313,8 @@ fun DoctorMedicineRateContainer( style = RemindTheme.typography.c2Medium.copy(color= RemindTheme.colors.text) ) Text( - modifier = modifier.padding(start = 4.dp), - text = String.format("%.1f", rate.breakfastRate), + modifier = modifier.padding(start = 4.dp ,end = 12.dp), + text = "$breakfast%", style = RemindTheme.typography.c2Medium.copy(color= RemindTheme.colors.main_6) ) Text( @@ -315,8 +322,8 @@ fun DoctorMedicineRateContainer( style = RemindTheme.typography.c2Medium.copy(color= RemindTheme.colors.text) ) Text( - modifier = modifier.padding(start = 4.dp), - text = String.format("%.1f", rate.lunchRate), + modifier = modifier.padding(start = 4.dp,end = 12.dp), + text = "$lunch%", style = RemindTheme.typography.c2Medium.copy(color= RemindTheme.colors.main_6) ) Text( @@ -325,7 +332,7 @@ fun DoctorMedicineRateContainer( ) Text( modifier = modifier.padding(start = 4.dp), - text = String.format("%.1f", rate.dinnerRate), + text = "$dinner%", style = RemindTheme.typography.c2Medium.copy(color= RemindTheme.colors.main_6) ) } diff --git a/app/src/main/java/com/example/remind/feature/screens/patience/home/HomeContract.kt b/app/src/main/java/com/example/remind/feature/screens/patience/home/HomeContract.kt index c86df04..c2d6d82 100644 --- a/app/src/main/java/com/example/remind/feature/screens/patience/home/HomeContract.kt +++ b/app/src/main/java/com/example/remind/feature/screens/patience/home/HomeContract.kt @@ -6,8 +6,8 @@ import androidx.navigation.NavOptionsBuilder import com.example.remind.core.base.UiEffect import com.example.remind.core.base.UiEvent import com.example.remind.core.base.UiState +import com.example.remind.data.model.response.DailyActivity import com.example.remind.data.model.response.DailyTakingMedicineList -import com.example.remind.data.model.response.Data class HomeContract { data class State( @@ -16,7 +16,7 @@ class HomeContract { val medicineDailyData: List = emptyList(), val notTakingReason: String? = null, val clickTime: String = "", - val dailyMood: Data = Data(), + val dailyMood: DailyActivity = DailyActivity(), ): UiState sealed class Event: UiEvent { diff --git a/app/src/main/java/com/example/remind/feature/screens/patience/moodchart/MoodChartContract.kt b/app/src/main/java/com/example/remind/feature/screens/patience/moodchart/MoodChartContract.kt index 61fb666..953a4e3 100644 --- a/app/src/main/java/com/example/remind/feature/screens/patience/moodchart/MoodChartContract.kt +++ b/app/src/main/java/com/example/remind/feature/screens/patience/moodchart/MoodChartContract.kt @@ -5,8 +5,8 @@ import androidx.navigation.NavOptionsBuilder import com.example.remind.core.base.UiEffect import com.example.remind.core.base.UiEvent import com.example.remind.core.base.UiState +import com.example.remind.data.model.response.DailyActivity import com.example.remind.data.model.response.DailyTakingMedicineList -import com.example.remind.data.model.response.Data import com.example.remind.data.model.response.Mood import com.example.remind.data.model.response.PercentList import java.time.LocalDate @@ -17,7 +17,7 @@ class MoodChartContract { val xAxisData: List = emptyList(), val yAxisData: List = emptyList(), val date: String = LocalDate.now().dayOfMonth.toString(), - val dailyMood: Data = Data(), + val dailyMood: DailyActivity = DailyActivity(), val feelingTotalPerCent: List = emptyList(), val dailyMedicine: List = emptyList(), val currentSeriesDay: Int = 0