Skip to content

Commit

Permalink
Merge pull request #85 from FOR-GRAD/21-졸업-요건-ui
Browse files Browse the repository at this point in the history
21 졸업 요건 UI
  • Loading branch information
dkyuuum authored Feb 13, 2024
2 parents 0d94bb3 + 1d49ff6 commit 00059be
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,46 +1,32 @@
import com.google.gson.annotations.SerializedName

data class CompletionResponse(
@SerializedName("isSuccess")
val isSuccess: Boolean,
@SerializedName("code")
val code: String,
@SerializedName("message")
val message: String,
@SerializedName("result")
val result: Result
)

data class Result(
@SerializedName("titleList")
val titleList: TitleList,
val titleList: List<String>,
@SerializedName("completionDtoMap")
val completionDtoMap: List<Map<String, List<String>>>,
@SerializedName("majorRequirements")
val majorRequirements: MajorRequirements
val completionDtoMap: List<Map<String, List<String>>>
)

data class TitleList(
@SerializedName("titleList")
val titles: List<String>
)

data class CompletionDto(
data class CompletionDtoMap(
@SerializedName("필수교양(기초)")
val requiredBasic: List<String>,
val requiredBasicCourses: List<String>,
@SerializedName("필수교양(소양)")
val requiredCultural: List<String>,
val requiredGeneralCourses: List<String>,
@SerializedName("선택필수교양")
val optionalRequired: List<String>,
val electiveRequiredCourses: List<String>,
@SerializedName("소 계")
val optionalRequiredSubtotal: List<String>
)

data class MajorRequirements(
val subtotal: List<String>,
@SerializedName("제1트랙")
val track1: List<String>,
@SerializedName("제2트랙")
val track2: List<String>,
@SerializedName("부전공 부전공 - micro college")
val minorMicroCollege: List<String>
val minor: List<String>
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package umc.com.mobile.project.ui.gradInfo

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -24,50 +25,55 @@ class CompletionStateFragment : Fragment() {
viewModel.getCompletionInfo() // 사용자 개인별 이수 현황 조회 api

viewModel.completionInfo.observe(viewLifecycleOwner, Observer {
// general
// binding.tvTotalScore.text = it?.result?.completionDtoMap?.generalMap?.subtotal?.get("소 계") ?: "누적 / (총계)"
val completionDtoMap: List<Map<String, List<String>>>? = it?.result?.completionDtoMap

// major
// binding.tvTotalScore2.text = it?.result?.majorCompletionDto?.majorMap?.total?.get(0).toString()
binding.tvTrack11Content.text = it?.result?.majorRequirements?.track1?.get(0).toString()
binding.tvTrack12Content.text = it?.result?.majorRequirements?.track1?.get(1).toString()
binding.tvTrack13Content.text = it?.result?.majorRequirements?.track1?.get(2).toString()
binding.tvTrack21Content.text = it?.result?.majorRequirements?.track2?.get(0).toString()
binding.tvTrack22Content.text = it?.result?.majorRequirements?.track2?.get(1).toString()
binding.tvTrack23Content.text = it?.result?.majorRequirements?.track2?.get(2).toString()
/**
* 필수 교양 (기초)
*/
completionDtoMap?.firstOrNull { it.containsKey("필수교양(기초)") }?.get("필수교양(기초)")?.let { requiredBasicCourses1 ->
binding.tvBasic1.text = requiredBasicCourses1[0]
binding.tvBasic1Content.text = requiredBasicCourses1[1]
binding.tvBasic2.text = requiredBasicCourses1[2]
binding.tvBasic2Content.text = requiredBasicCourses1[3]
binding.tvBasic3.text = requiredBasicCourses1[4]
binding.tvBasic3Content.text = requiredBasicCourses1[5]

})
// binding.tvBasic4.text = requiredBasicCourses1[6]
// binding.tvBasic4Content.text = requiredBasicCourses1[7]
// binding.tvBasic5.text = requiredBasicCourses1[8]
// binding.tvBasic5Content.text = requiredBasicCourses1[9]
// binding.tvBasic6.text = requiredBasicCourses1[10]
// binding.tvBasic6Content.text = requiredBasicCourses1[11]
}

viewModel.foundationElectiveCourses.observe(viewLifecycleOwner, Observer { courses ->
courses?.let {
if (it.isNotEmpty()) {
val coursesList = it.map { entry -> entry.key to entry.value }
if (coursesList.size > 1) {
binding.tvSoyang1.text = coursesList[0].first
binding.tvSoyang1Content.text = coursesList[0].second
binding.tvSoyang2.text = coursesList[1].first
binding.tvSoyang2Content.text = coursesList[1].second
}
}
/**
* 필수 교양 (소양)
*/
completionDtoMap?.firstOrNull { it.containsKey("필수교양(소양)") }?.get("필수교양(소양)")?.let { requiredBasicCourses2 ->
binding.tvSoyang1.text = requiredBasicCourses2[0]
binding.tvSoyang1Content.text = requiredBasicCourses2[1]
binding.tvSoyang2.text = requiredBasicCourses2[2]
binding.tvSoyang2Content.text = requiredBasicCourses2[3]
binding.tvTotalScore.text = requiredBasicCourses2[5]
}
})

viewModel.requiredBasicCourses.observe(viewLifecycleOwner, Observer { courses ->
courses?.let {
if (it.isNotEmpty()) {
val coursesList = it.map { entry -> entry.key to entry.value }
if (coursesList.size > 2) {
binding.tvBasic1.text = coursesList[0].first
binding.tvBasic1Content.text = coursesList[0].second
binding.tvBasic2.text = coursesList[1].first
binding.tvBasic2Content.text = coursesList[1].second
binding.tvBasic3.text = coursesList[2].first
binding.tvBasic3Content.text = coursesList[2].second
}
}
/**
* 트랙 1, 트랙 2
*/
completionDtoMap?.firstOrNull { it.containsKey("제1트랙") }?.get("제1트랙")?.let { track1Values ->
binding.tvTrack11Content.text = track1Values[0]
binding.tvTrack12Content.text = track1Values[1]
binding.tvTrack13Content.text = track1Values[2]
binding.tvTotalScore2.text = track1Values[3]
}
})

completionDtoMap?.firstOrNull { it.containsKey("제2트랙") }?.get("제2트랙")?.let { track1Values ->
binding.tvTrack21Content.text = track1Values[0]
binding.tvTrack22Content.text = track1Values[1]
binding.tvTrack23Content.text = track1Values[2]
}

})

return binding.root
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,4 @@ class GradeFragment : Fragment() {
binding.recyclerView2.adapter = adapter2
binding.recyclerView2.layoutManager = GridLayoutManager(context, 2)
}

private fun observeGrades() {
viewModel.grades.observe(viewLifecycleOwner, Observer { gradesMap ->
(binding.recyclerView2.adapter as? AverageRVAdapter)?.setData(gradesMap.values.toList())

val selectedGradeInfo = gradesMap["1 학기 성적"]
binding.tvAcquiredCredit.text = selectedGradeInfo?.acquiredCredits
binding.tvAppliedCredit.text = selectedGradeInfo?.appliedCredits
binding.tvAverageGrade.text = selectedGradeInfo?.averageGrade
binding.tvAverageTotal.text = selectedGradeInfo?.totalGrade
binding.tvPercent.text = selectedGradeInfo?.percentile
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,36 @@ class CompletionStateViewModel : ViewModel() {
val completionInfo: MutableLiveData<CompletionResponse?>
get() = _completionInfo

// 필수교양기초
private val _requiredBasicCourses: MutableLiveData<Map<String, String>> = MutableLiveData()
val requiredBasicCourses: LiveData<Map<String, String>>
get() = _requiredBasicCourses

private val _foundationElectiveCourses: MutableLiveData<Map<String, String>> = MutableLiveData()
val foundationElectiveCourses: MutableLiveData<Map<String, String>>
val foundationElectiveCourses: LiveData<Map<String, String>>
get() = _foundationElectiveCourses

// private fun processRequiredBasicCourses(completionResponse: CompletionResponse) {
// val requiredBasicCoursesMap = mutableMapOf<String, String>()
// val foundationElectiveCoursesMap = mutableMapOf<String, String>()
//
// val liberalArts = completionResponse.result.completionDtoMap.find { it.keys.equals("필수교양(기초)")}?.values
// val requiredBasicCourses = liberalArts?.requiredBasic
// val foundationElectiveCourses = liberalArts?.fundamental
//
// requiredBasicCourses?.let {
// for ((index, courseName) in requiredBasicCourses.withIndex()) {
// requiredBasicCoursesMap["Course ${index + 1}"] = courseName
// Log.d("Completion: requiredBasicCoursesMap ", "Course ${index + 1} : $courseName")
// }
// }
//
// foundationElectiveCourses?.let {
// for ((index, courseName) in requiredBasicCourses.withIndex()) {
// foundationElectiveCoursesMap["Course ${index + 1}"] = courseName
// Log.d("Completion: foundationElectiveCoursesMap ", "Course ${index + 1} : $courseName")
// }
// }
//
// _requiredBasicCourses.postValue(requiredBasicCoursesMap)
// _foundationElectiveCourses.postValue(foundationElectiveCoursesMap)
// }
// 전공 트랙
private val _majorTrack1Courses: MutableLiveData<Map<String, String>> = MutableLiveData()
val majorTrack1Courses: MutableLiveData<Map<String, String>>
get() = _majorTrack1Courses

private fun processRequiredBasicCourses(completionResponse: CompletionResponse) {
val requiredBasicCoursesMap = mutableMapOf<String, String>()
// val majorTrack1CoursesList = completionResponse.result.completionDtoMaptrack1
// val majorTrack2CoursesList = completionResponse.result.majorRequirements.track1

/*
_majorTrack1Courses?.let {
for ((index, courseName) in requiredBasicCourses.withIndex()) {
majorTrack1CoursesMap["Course ${index + 1}"] = courseName
Log.d("Completion: foundationElectiveCoursesMap ", "Course ${index + 1} : $courseName")
}
}*/

_requiredBasicCourses.postValue(requiredBasicCoursesMap)
// _majorTrack1Courses.postValue(majorTrack1CoursesMap)
}


fun getCompletionInfo() {
Expand Down
124 changes: 124 additions & 0 deletions app/src/main/res/layout/fragment_completion_state.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="사고와 표현"
Expand All @@ -77,7 +79,9 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="영어커뮤니케이션\n독해 / 작문"
Expand All @@ -92,7 +96,9 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="문제해결을 위한\n코딩 첫 걸음"
Expand Down Expand Up @@ -156,7 +162,125 @@
app:layout_constraintTop_toTopOf="parent" />

</androidx.appcompat.widget.LinearLayoutCompat>
<!--
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/linearLayoutCompat3"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/tv_grade"
app:layout_constraintStart_toStartOf="@+id/tv_grade"
app:layout_constraintTop_toBottomOf="@+id/layout_basic_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_basic_4"
style="@style/MediumFont.12"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="사고와 표현"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_basic_5"
style="@style/MediumFont.12"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="영어커뮤니케이션\n독해 / 작문"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_basic_6"
style="@style/MediumFont.12"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="문제해결을 위한\n코딩 첫 걸음"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/layout_basic_content2"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="@+id/tv_grade"
app:layout_constraintStart_toStartOf="@+id/tv_grade"
app:layout_constraintTop_toBottomOf="@+id/linearLayoutCompat3">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_basic_4_content"
style="@style/MediumFont.12"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray_left_bottom_radius_15"
android:gravity="center"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="0 / (0)"
android:textColor="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_basic_5_content"
style="@style/MediumFont.12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray"
android:gravity="center"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="0 / (0)"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_basic_6_content"
style="@style/MediumFont.12"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/bg_stroke_gray_right_bottom_radius_15"
android:gravity="center"
android:paddingTop="9dp"
android:paddingBottom="9dp"
android:text="0 / (0)"
android:textColor="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.appcompat.widget.LinearLayoutCompat>
-->
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_soyang"
style="@style/MediumFont.13"
Expand Down

0 comments on commit 00059be

Please sign in to comment.