Skip to content

Commit

Permalink
Merge pull request #88 from FOR-GRAD/21-졸업-요건-ui
Browse files Browse the repository at this point in the history
21 졸업 요건 UI
  • Loading branch information
dkyuuum authored Feb 14, 2024
2 parents e4b3987 + 044d6ab commit fd9da40
Show file tree
Hide file tree
Showing 63 changed files with 2,429 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package umc.com.mobile.project.data.model.plan

data class AddTimeResponse(
val semesterDto: SemesterDto,
val subjectDtoList: List<SubjectDtoList>,
)

data class SemesterDto(
val grade: Long,
val semester: Long,
)

data class SubjectDtoList(
val type: String,
val name: String,
val credit: Long,
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package umc.com.mobile.project.data.model.plan

import java.time.LocalDateTime

data class BringlicenseResponse(
val isSuccess: Boolean,
val code: String,
val message: String,
val result: List<BringResult>,
)

data class BringResult(
val certificateId: Long,
val createdAt: String,
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package umc.com.mobile.project.data.model.plan



data class ListTimeResponse(
val isSuccess: Boolean,
val code: String,
val message: String,
val result: List<TimeResult>,
)

data class TimeResult(
val searchGrade: String,
val searchType: String,
val searchName: String,
val searchCredit: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package umc.com.mobile.project.data.model.plan

data class PlanTrackResponse(
val isSuccess: Boolean,
val code: String,
val message: String,
val result: List<TrackResult>,
)

data class TrackResult(
val trackCode: String,
val trackName: String,
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package umc.com.mobile.project.data.model.plan

import java.time.LocalDate


data class SaveInfo(
val name: String,
val date: String
)

data class SavelicenseRequest(
val info: List<SaveInfo>
)



Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package umc.com.mobile.project.data.model.plan

data class SemesterTimeResponse(
val isSuccess: Boolean,
val code: String,
val message: String,
val result: List<semesterResult>,
) {


}

data class semesterResult(
val hakkiNum: String,
val hakkiText: String,
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package umc.com.mobile.project.data.model.plan

data class UPlicenseResponse(
val isSuccess: Boolean,
val code: String,
val message: String,
val result: List<Result>,
)

data class Result(
val certificateId: Long,
val name: String,
val date: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package umc.com.mobile.project.data.network.api

import retrofit2.http.GET
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST
import retrofit2.http.Query
import umc.com.mobile.project.data.model.plan.BringlicenseResponse
import umc.com.mobile.project.data.model.plan.ListTimeResponse
import umc.com.mobile.project.data.model.plan.PlanTrackResponse
import umc.com.mobile.project.data.model.plan.SaveInfo
import umc.com.mobile.project.data.model.plan.SemesterTimeResponse
import umc.com.mobile.project.data.model.plan.UPlicenseResponse


interface PlanApi {
@GET("plans/certifications")
fun getUPlicense(): Call<UPlicenseResponse>


@POST("plans/certifications")
fun saveLicense(@Body request: List<SaveInfo>): Call<BringlicenseResponse>




@GET("/plans/timetable/searchSubject")
fun getListTime(@Query("hakki") hakki:String, @Query("track") track : String) : Call<ListTimeResponse>

@GET("/plans/timetable/searchTrack")
fun getTrackInfo(@Query("hakki") hakki: String) : Call<PlanTrackResponse>

@GET("/plans/timetable/searchHakki")
fun getSemesterInfo():Call<SemesterTimeResponse>



}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class GradeFragment : Fragment() {
binding.tvSemester.text = selectedSemester
})

viewModel.totalAverage.observe(viewLifecycleOwner, Observer { totalAverageGrade ->
binding.tvAverageTotal.text = totalAverageGrade.toString()
})

viewModel.selectedSemesterGradeAndGrades.observe(viewLifecycleOwner) { pair ->
val selectedGrade = pair.first
val gradesMap = pair.second
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package umc.com.mobile.project.ui.gradInfo.adapter

import android.app.AlertDialog
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup
Expand All @@ -10,6 +11,7 @@ import umc.com.mobile.project.ui.gradInfo.viewmodel.GradeViewModel
class AverageRVAdapter(private val viewModel: GradeViewModel) :
RecyclerView.Adapter<AverageRVAdapter.MyViewHolder>() {
private var dataList = mutableListOf<GradesTotalDto>()
var totalAverageGrade = 0.0

inner class MyViewHolder(private val binding: ItemAverageGradeBinding) :
RecyclerView.ViewHolder(binding.root) {
Expand All @@ -21,20 +23,32 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) :
val semesterGrade = "${position + 1} 학기 성적"
viewModel.onSemesterItemClick(semester)
viewModel.onSemesterGradeItemClick(semesterGrade)

val gradesTotalDto = dataList[position]
if (gradesTotalDto.averageGrade == "0.0") {
val alertDialogBuilder = AlertDialog.Builder(binding.root.context)
alertDialogBuilder.setTitle("알림")
alertDialogBuilder.setMessage("${position + 1} 학기의 성적이 아직 입력되지 않았습니다.")
alertDialogBuilder.setPositiveButton("확인") { dialog, _ ->
dialog.dismiss()
}
}
}
}
}

fun bind(gradesTotalDto: GradesTotalDto, position: Int) {
val count = if (position % 2 == 0) {
val semester = if (position % 2 == 0) {
1
} else {
2
}
val semester = if (position % 2 == 0) position / 2 + 1 else (position + 1) / 2
val grade = if (position % 2 == 0) position / 2 + 1 else (position + 1) / 2
// totalAverageGrade += Integer.parseInt(gradesTotalDto.averageGrade)

binding.tvSemesterContent1.text = "$semester - $count"
binding.tvSemesterContent1.text = "$grade - $semester"
binding.tvAverageGradeContent1.text = gradesTotalDto.averageGrade
// viewModel.onSetTotalAverageGrade(totalAverageGrade, position+1)
}
}

Expand Down Expand Up @@ -69,6 +83,7 @@ class AverageRVAdapter(private val viewModel: GradeViewModel) :
)
)
}

notifyDataSetChanged()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,6 @@ 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: LiveData<Map<String, String>>
get() = _foundationElectiveCourses

// 전공 트랙
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() {
gradInfoApiService.getCompletion().enqueue(object : Callback<CompletionResponse> {
override fun onResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,6 @@ class GradeViewModel : ViewModel() {
val error: LiveData<String>
get() = _error

private val _userSemester: MutableLiveData<String> = MutableLiveData()
val userSemester: LiveData<String>
get() = _userSemester

private val _userClassification: MutableLiveData<String> = MutableLiveData()
val userClassification: LiveData<String>
get() = _userClassification

private val _userSubjectName: MutableLiveData<String> = MutableLiveData()
val userSubjectName: LiveData<String>
get() = _userSubjectName

private val _userCredits: MutableLiveData<String> = MutableLiveData()
val userCredits: LiveData<String>
get() = _userCredits

private val _userGrade: MutableLiveData<String> = MutableLiveData()
val userGrade: LiveData<String>
get() = _userGrade

private val _userTrack: MutableLiveData<String> = MutableLiveData()
val userTrack: LiveData<String>
get() = _userTrack

private val _userAppliedCredit: MutableLiveData<String> = MutableLiveData()
val userAppliedCredit: LiveData<String>
get() = _userAppliedCredit

private val _userAcquiredCredit: MutableLiveData<String> = MutableLiveData()
val userAcquiredCredit: LiveData<String>
get() = _userAcquiredCredit

private val _userAverageTotal: MutableLiveData<String> = MutableLiveData()
val userAverageTotal: LiveData<String>
get() = _userAverageTotal

private val _userAverageGrade: MutableLiveData<String> = MutableLiveData()
val userAverageGrade: LiveData<String>
get() = _userAverageGrade

private val _userPercentile: MutableLiveData<String> = MutableLiveData()
val userPercentile: LiveData<String>
get() = _userPercentile

private val _gradesInfo: MutableLiveData<GradesResponse?> = MutableLiveData()
val gradesInfo: MutableLiveData<GradesResponse?>
get() = _gradesInfo
Expand All @@ -85,6 +41,10 @@ class GradeViewModel : ViewModel() {
private val selectedSemesterGrade: LiveData<String>
get() = _selectedSemesterGrade

private val _totalAverage: MutableLiveData<Double> = MutableLiveData()
val totalAverage: LiveData<Double>
get() = _totalAverage

val selectedSemesterGradeAndGrades: MediatorLiveData<Pair<String?, Map<String, GradesTotalDto>?>> = MediatorLiveData()

init {
Expand Down Expand Up @@ -174,4 +134,8 @@ class GradeViewModel : ViewModel() {
fun onSemesterGradeItemClick(grade: String) {
_selectedSemesterGrade.postValue(grade)
}
}

fun onSetTotalAverageGrade(totalAverageGrade: Double, totalNumber: Int) {
_totalAverage.postValue((totalAverageGrade/totalNumber))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class HomeFragment : Fragment() {
binding.btnCheeringWordMove.setOnClickListener {
navigate(R.id.action_fragment_home_to_fragment_date)
}
binding.layoutNextPlan.setOnClickListener {
navigate(R.id.action_fragment_home_to_planSettingFragment)
}
}

private fun saveCheeringMemo() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package umc.com.mobile.project.ui.plan

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import umc.com.mobile.project.databinding.FragmentPlanFreeBinding
import umc.com.mobile.project.ui.plan.PlanViewModel

class PlanFreeFragment : Fragment() {
private var _binding: FragmentPlanFreeBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
_binding = FragmentPlanFreeBinding.inflate(inflater, container, false)

viewModel.text.observe(viewLifecycleOwner) { text ->
// Update your UI here with the LiveData update
// Make sure 'textViewExample' matches the ID of the TextView in your layout
// binding.textViewExample.text = text
}
return binding.root
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Loading

0 comments on commit fd9da40

Please sign in to comment.