Skip to content

Commit

Permalink
Merge pull request #104 from FOR-GRAD/21-졸업-요건-ui
Browse files Browse the repository at this point in the history
21 졸업 요건 UI
  • Loading branch information
dkyuuum authored Feb 20, 2024
2 parents 888b96f + de54d76 commit f598c89
Show file tree
Hide file tree
Showing 19 changed files with 1,052 additions and 686 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

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

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

data class CertificateUpdateInfo(
val certificateId: Long,
val updatedAt: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package umc.com.mobile.project.data.model

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

data class DeleteItem(
val certificateId: Long,
val name: String,
val date: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package umc.com.mobile.project.data.model.plan

data class TimeInfoResponse(
val type: String,
val name: String,
val credit:String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package umc.com.mobile.project.data.model.plan

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ package umc.com.mobile.project.data.network.api
import retrofit2.http.GET
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import umc.com.mobile.project.data.model.DeleteLicense
import umc.com.mobile.project.data.model.plan.AddTimeRequest
import umc.com.mobile.project.data.model.plan.AddTimeResponse
import umc.com.mobile.project.data.model.plan.BringlicenseResponse
import umc.com.mobile.project.data.model.plan.CertificateLicenseRequest
import umc.com.mobile.project.data.model.plan.CertificateResponse
import umc.com.mobile.project.data.model.plan.ListTimeResponse
import umc.com.mobile.project.data.model.plan.PlanFreeRequest
import umc.com.mobile.project.data.model.plan.PlanFreeResponse
Expand All @@ -17,6 +22,7 @@ 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
import umc.com.mobile.project.data.model.plan.EditMemoRequest
import umc.com.mobile.project.data.model.plan.UpTimeResponse


interface PlanApi {
Expand Down Expand Up @@ -48,9 +54,23 @@ interface PlanApi {
@POST("/plans/memo")
fun postFreeMemo(@Body request: PlanFreeRequest): Call<PlanFreeResponse>

@GET("/plans/timetable")
fun getUptime(@Query("grade") grade:Int, @Query("semester") semester : Int):Call<UpTimeResponse>

@PATCH("/plans/memo")
fun editMemo(@Body editMemoRequest: EditMemoRequest) : Call<PlanFreeResponse>

@PATCH("/plans/certifications")
fun certificateLicense(@Body request: List<CertificateLicenseRequest>) : Call<CertificateResponse>

@DELETE("/plans/certifications")
fun deleteLicense(@Query("certificateId") certificateId: Long): Call<DeleteLicense>









Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ class HomeFragment : Fragment() {
navigate(R.id.action_fragment_home_to_fragment_date)
}
binding.layoutNextPlan.setOnClickListener {
navigate(R.id.action_fragment_home_to_planSettingFragment)
navigate(R.id.action_fragment_home_to_planTimetableFragment)
}
binding.constraintLayout3.setOnClickListener {
navigate(R.id.action_fragment_home_to_planSettingFragment)
navigate(R.id.action_fragment_home_to_planTimetableFragment)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import android.text.Editable
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import umc.com.mobile.project.data.model.career.PointDtoList
import umc.com.mobile.project.data.model.career.Result
import umc.com.mobile.project.data.model.plan.TimeInfoResponse
import umc.com.mobile.project.data.model.plan.TimeResult
import umc.com.mobile.project.databinding.ItemCertificateBinding
import umc.com.mobile.project.databinding.ItemTimeSubjectBinding

class PlanRecyclerAdapter(
Expand All @@ -27,7 +25,7 @@ class PlanRecyclerAdapter(

override fun getItemCount(): Int = timeList.size

fun updateTimeList(newTimeList: List<TimeResult?>) {
fun updateTimeList(newTimeList: List<TimeResult>) {
this.timeList = newTimeList
notifyDataSetChanged() // 데이터가 변경되었음을 알리고 UI를 갱신
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
package umc.com.mobile.project.ui.plan

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.Observer
import androidx.navigation.fragment.findNavController
import androidx.viewpager.widget.ViewPager
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import umc.com.mobile.project.R
import umc.com.mobile.project.databinding.FragmentSettingBinding
import umc.com.mobile.project.databinding.PlanSubjectListBinding
import umc.com.mobile.project.databinding.PlanTimeTabMainBinding
import umc.com.mobile.project.databinding.SemesterChooseBinding
import umc.com.mobile.project.ui.gradInfo.adapter.GradInfoVPAdapter
import umc.com.mobile.project.ui.gradInfo.viewmodel.GradInfoViewModel

class PlanSettingFragment : Fragment() {
private var _binding: PlanTimeTabMainBinding? = null
Expand All @@ -39,24 +29,35 @@ class PlanSettingFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
// PlanTimeTabMainBinding을 인플레이트하여 루트 뷰를 가져옴
_binding = PlanTimeTabMainBinding.inflate(inflater, container, false)
val view = binding.root



// 탭 레이아웃 및 뷰페이저 초기화
initTabLayout()
initViewPager()

binding.planSettingBackButton.setOnClickListener {
findNavController().navigateUp()
}

return view


}


private fun initTabLayout() {

val tabTitle = arrayOf("시간표", "자격증", "자유")


viewPager = binding.viewPagerTimeTabMain
tabLayout = binding.tabLayoutPlanTime


val adapter = PlanVPAdapter(this)

adapter.addFragment(PlanTimeFragment())
Expand Down
31 changes: 17 additions & 14 deletions app/src/main/java/umc/com/mobile/project/ui/plan/PlanTimeAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package umc.com.mobile.project.ui.plan

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import umc.com.mobile.project.data.model.plan.TimeResult
import umc.com.mobile.project.data.model.plan.TimeInfoResponse
import umc.com.mobile.project.databinding.ItemPlanTimeBinding

class PlanTimeAdapter : ListAdapter<TimeResult, PlanTimeAdapter.ViewHolder>(TimeResultDiffCallback()) {
class PlanTimeAdapter(private var addnewtime: List<Any> = ArrayList()): ListAdapter<TimeInfoResponse, PlanTimeAdapter.ViewHolder>(UpTimeResultDiffCallback()) {

// ViewHolder 클래스는 그대로 유지합니다.
class ViewHolder(private val binding: ItemPlanTimeBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: TimeResult) {
binding.timeKindTitle.text = item.searchType
binding.timeClassTitle.text = item.searchName
binding.timeGradeTitle.text = item.searchCredit.toString() // toString() 추가, 학점을 문자열로 표시
fun bind(item: TimeInfoResponse) {
binding.timeKindTitle.text = item.type
binding.timeClassTitle.text = item.name
// 학점을 문자열로 변환하여 표시
binding.timeGradeTitle.text = item.credit.toString()
}
}

Expand All @@ -27,17 +29,18 @@ class PlanTimeAdapter : ListAdapter<TimeResult, PlanTimeAdapter.ViewHolder>(Time
holder.bind(item)
}

// 현재 데이터 리스트를 가져오는 편의 메서드를 추가합니다.
fun getCurrentData(): List<TimeResult> {
return currentList
fun updateTimeList(addnewtime: ArrayList<TimeInfoResponse>) {
submitList(addnewtime)
}

class TimeResultDiffCallback : DiffUtil.ItemCallback<TimeResult>() {
override fun areItemsTheSame(oldItem: TimeResult, newItem: TimeResult): Boolean {
return oldItem.searchName == newItem.searchName
class UpTimeResultDiffCallback : DiffUtil.ItemCallback<TimeInfoResponse>() {
override fun areItemsTheSame(oldItem: TimeInfoResponse, newItem: TimeInfoResponse): Boolean {
// subjectId를 비교하여 동일한 아이템인지 판별
return oldItem.name== newItem.name
}

override fun areContentsTheSame(oldItem: TimeResult, newItem: TimeResult): Boolean {
override fun areContentsTheSame(oldItem: TimeInfoResponse, newItem: TimeInfoResponse): Boolean {
// 내용이 동일한지 비교
return oldItem == newItem
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import umc.com.mobile.project.R
import umc.com.mobile.project.data.model.plan.TimeInfoResponse
import umc.com.mobile.project.databinding.PlanSubjectListBinding
import umc.com.mobile.project.ui.common.NavigationUtil.navigate

Expand Down Expand Up @@ -38,7 +39,7 @@ class PlanTimeFragment : Fragment() {
val adapter = PlanRecyclerAdapter(emptyList(), onAddButtonClicked = { timeResult ->

if (timeResult != null) {
viewModel.setSelectedTimeResult(timeResult)
viewModel.setSelectedTimeResult(timeResult = TimeInfoResponse(timeResult.searchType,timeResult.searchName,timeResult.searchCredit))
}


Expand Down Expand Up @@ -67,9 +68,7 @@ class PlanTimeFragment : Fragment() {
}

private fun setupNavigation() {
binding.planTimeMoveTimetable.setOnClickListener {
navigate(R.id.action_planSettingFragment_to_planTimetableFragment)
}


binding.planSubjectListSemester.setOnClickListener {
navigate(R.id.action_planSettingFragment_to_planSemesterFragment)
Expand Down
Loading

0 comments on commit f598c89

Please sign in to comment.