Skip to content

Commit

Permalink
Fix: 향후계획/시간표 성적 선택 탭 이동 수정 #50
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyuuum committed Feb 19, 2024
1 parent b90d4ef commit 1623cec
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 134 deletions.
Original file line number Diff line number Diff line change
@@ -1,74 +1,50 @@
package umc.com.mobile.project.ui.plan

import android.content.res.ColorStateList
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.gridlayout.widget.GridLayout
import umc.com.mobile.project.R
import umc.com.mobile.project.databinding.FragmentPlanlicenseBinding
import android.widget.EditText
import androidx.core.view.setMargins
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager

import umc.com.mobile.project.data.model.plan.SavelicenseRequest
import umc.com.mobile.project.data.model.plan.semesterResult
import umc.com.mobile.project.databinding.SemesterChooseBinding
import java.time.LocalDate

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

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





return binding.root
}



override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)


val adapter = PlanSemesterAdapter(listOf()) // 초기 데이터로 빈 리스트 사용

// RecyclerView에 어댑터와 레이아웃 매니저 설정
binding.recyclerViewPlanSemester.adapter = adapter
binding.recyclerViewPlanSemester.layoutManager = LinearLayoutManager(context)


viewModel.planSemesterInfo.observe(viewLifecycleOwner) { semesterInfo ->
// 데이터가 업데이트되면 어댑터의 리스트 업데이트
adapter.semesterList = semesterInfo?.result ?: emptyList()
adapter.notifyDataSetChanged()

}

viewModel.getSemesterInfo() // 데이터 로드
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
private var _binding: SemesterChooseBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = SemesterChooseBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val adapter = PlanSemesterAdapter(emptyList()) // 초기 데이터로 빈 리스트 사용

// RecyclerView에 어댑터와 레이아웃 매니저 설정
binding.recyclerViewPlanSemester.adapter = adapter
binding.recyclerViewPlanSemester.layoutManager = LinearLayoutManager(context)

viewModel.planSemesterInfo.observe(viewLifecycleOwner) { semesterInfo ->
// 데이터가 업데이트되면 어댑터의 리스트 업데이트
adapter.semesterList = semesterInfo?.result ?: emptyList()
adapter.notifyDataSetChanged()
}

viewModel.getSemesterInfo() // 데이터 로드
}

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


Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,76 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
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
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!
private var _binding: PlanTimeTabMainBinding? = null
private val viewModel: PlanViewModel by viewModels()
private val binding get() = _binding!!

private lateinit var viewPager : ViewPager2
private lateinit var tabLayout : TabLayout
private lateinit var viewPager: ViewPager2
private lateinit var tabLayout: TabLayout

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = PlanTimeTabMainBinding.inflate(inflater, container, false)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
// PlanTimeTabMainBinding을 인플레이트하여 루트 뷰를 가져옴
_binding = PlanTimeTabMainBinding.inflate(inflater, container, false)
val view = binding.root

initTabLayout()
initViewPager()


return binding.root
}
// 탭 레이아웃 및 뷰페이저 초기화
initTabLayout()
initViewPager()

private fun initTabLayout() {
return view
}

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

private fun initTabLayout() {

viewPager = binding.viewPagerTimeTabMain
tabLayout = binding.tabLayoutPlanTime
val tabTitle = arrayOf("시간표", "자격증", "자유")


val adapter = PlanVPAdapter(this)
viewPager = binding.viewPagerTimeTabMain
tabLayout = binding.tabLayoutPlanTime

adapter.addFragment(PlanTimeFragment())
adapter.addFragment(PlanlicenseFragment())
adapter.addFragment(PlanFreeFragment())

viewPager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
viewPager.adapter = adapter
val adapter = PlanVPAdapter(this)

TabLayoutMediator(tabLayout, viewPager
) { tab, position -> tab.text = tabTitle[position] }.attach()
}
adapter.addFragment(PlanTimeFragment())
adapter.addFragment(PlanlicenseFragment())
adapter.addFragment(PlanFreeFragment())

private fun initViewPager() {
viewPager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
viewPager.adapter = adapter

binding.viewPagerTimeTabMain.isUserInputEnabled = false
}
TabLayoutMediator(tabLayout, viewPager
) { tab, position -> tab.text = tabTitle[position] }.attach()
}

private fun initViewPager() {

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
binding.viewPagerTimeTabMain.isUserInputEnabled = false
}


override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,64 +17,68 @@ import umc.com.mobile.project.ui.common.NavigationUtil.navigate
import umc.com.mobile.project.ui.plan.PlanViewModel

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

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



viewModel.getListTimeInfo()
val adapter = viewModel.listTimeInfo.value?.let { PlanRecyclerAdapter(it.result) }
viewModel.getListTimeInfo()
val adapter = viewModel.listTimeInfo.value?.let { PlanRecyclerAdapter(it.result) }

binding.recyclerView.adapter = adapter
binding.recyclerView.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
binding.recyclerView.adapter = adapter
binding.recyclerView.layoutManager =
LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)



viewModel.listTimeInfo.observe(viewLifecycleOwner) { timenewList ->
if (timenewList != null) {
if (adapter != null) {
adapter.timeList=timenewList.result
adapter.notifyDataSetChanged()
}
}
viewModel.listTimeInfo.observe(viewLifecycleOwner) { timenewList ->
if (timenewList != null) {
if (adapter != null) {
adapter.timeList=timenewList.result
adapter.notifyDataSetChanged()
}
}




}
}

_binding!!.planSubjectListSemester.setOnClickListener {
//api 연결
// viewModel.addCareer()
navigate(R.id.action_planSettingFragment_to_planSemesterFragment)
}


return binding.root

}
return binding.root

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binding.planSubjectListSemester.setOnClickListener {
}

findNavController().navigate(R.id.action_planTimeFragment_to_planSemesterFragment)
}
}







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


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

}
8 changes: 0 additions & 8 deletions app/src/main/res/navigation/mobile_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,5 @@
android:id="@+id/planSemesterFragment"
android:name="umc.com.mobile.project.ui.plan.PlanSemesterFragment"
android:label="PlanSemesterFragment" />
<fragment
android:id="@+id/planTimeFragment"
android:name="umc.com.mobile.project.ui.plan.PlanTimeFragment"
android:label="PlanTimeFragment" >
<action
android:id="@+id/action_planTimeFragment_to_planSemesterFragment"
app:destination="@id/planSemesterFragment" />
</fragment>

</navigation>

0 comments on commit 1623cec

Please sign in to comment.