diff --git a/app/src/main/java/com/ssjm/sw_hackathon/education/tab/EduBookmarkFragment.kt b/app/src/main/java/com/ssjm/sw_hackathon/education/tab/EduBookmarkFragment.kt index 74f2fc1..c5ba63e 100644 --- a/app/src/main/java/com/ssjm/sw_hackathon/education/tab/EduBookmarkFragment.kt +++ b/app/src/main/java/com/ssjm/sw_hackathon/education/tab/EduBookmarkFragment.kt @@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.ssjm.sw_hackathon.databinding.FragmentEduBookmarkBinding import com.ssjm.sw_hackathon.education.recycler.EducationAdapter +import com.ssjm.sw_hackathon.education.recycler.EducationItem import com.ssjm.sw_hackathon.education.recycler.EducationItemInterface // 교육 > 찜 @@ -40,6 +41,8 @@ class EduBookmarkFragment : Fragment() { // recyclerview 세팅 initRecycler() + + } // 교육 아이템 recyclerview 세팅 @@ -54,6 +57,11 @@ class EduBookmarkFragment : Fragment() { educationAdapter.items = bookmarkEducationItems!! } + private fun addEdu(edu: EducationItem) { + bookmarkEducationItems!!.add(edu) + educationAdapter.notifyDataSetChanged() + } + override fun onDestroy() { super.onDestroy() _binding = null diff --git a/app/src/main/java/com/ssjm/sw_hackathon/home/HomeFragment.kt b/app/src/main/java/com/ssjm/sw_hackathon/home/HomeFragment.kt index 0327857..dfaad23 100644 --- a/app/src/main/java/com/ssjm/sw_hackathon/home/HomeFragment.kt +++ b/app/src/main/java/com/ssjm/sw_hackathon/home/HomeFragment.kt @@ -5,7 +5,10 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.LinearLayoutManager import com.ssjm.sw_hackathon.databinding.FragmentHomeBinding +import com.ssjm.sw_hackathon.home.recycler.HomeTodoAdapter +import com.ssjm.sw_hackathon.home.recycler.HomeTodoItem // 메인 탭 class HomeFragment : Fragment() { @@ -13,6 +16,10 @@ class HomeFragment : Fragment() { private var _binding: FragmentHomeBinding? = null private val binding get() = _binding!! + // 실천 리스트 recyclerview adapter + private var homeTodoItems: MutableList? = null + private lateinit var homeTodoAdapter: HomeTodoAdapter + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -24,6 +31,30 @@ class HomeFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + + initRecycler() + + addTodo(HomeTodoItem("note1", "노트에 필사하기", "66일째 실천중", mutableListOf("월", "수"))) + addTodo(HomeTodoItem("barista2", "실기 학원", "32일째 실천중", mutableListOf("화", "목"))) + } + + // recyclerview 세팅 + private fun initRecycler() { + homeTodoItems = mutableListOf() + + // 링크 리스트 recyclerview 세팅 + homeTodoAdapter = HomeTodoAdapter( + requireContext() + ) + binding.recyclerviewHomeTodo.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) + binding.recyclerviewHomeTodo.adapter = homeTodoAdapter + binding.recyclerviewHomeTodo.isNestedScrollingEnabled = true + homeTodoAdapter.items = homeTodoItems!! + } + + private fun addTodo(todo: HomeTodoItem) { + homeTodoItems!!.add(todo) + homeTodoAdapter.notifyDataSetChanged() } override fun onDestroy() { diff --git a/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoAdapter.kt b/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoAdapter.kt new file mode 100644 index 0000000..f14f0a4 --- /dev/null +++ b/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoAdapter.kt @@ -0,0 +1,60 @@ +package com.ssjm.sw_hackathon.home.recycler + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.ssjm.sw_hackathon.R +import com.ssjm.sw_hackathon.databinding.ItemTodoOfHomeBinding + +class HomeTodoAdapter (private val context: Context, +) : RecyclerView.Adapter() { + + var items = mutableListOf() + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : + HomeTodoViewHolder { + + val view = LayoutInflater.from(context).inflate(R.layout.item_todo_of_home, parent, false) + + return HomeTodoViewHolder(ItemTodoOfHomeBinding.bind(view)) + } + + override fun getItemCount(): Int = items.size + + override fun onBindViewHolder(holder: HomeTodoViewHolder, position: Int) { + holder.bind(items[position]) + + // 링크 아이템 클릭 시 + /*holder.itemView.setOnClickListener { + onClickLinkItem(items[position].memoNum) + }*/ + } + + inner class HomeTodoViewHolder(private val binding: ItemTodoOfHomeBinding) : + RecyclerView.ViewHolder(binding.root) { + + fun bind(item: HomeTodoItem) { + + // 이미지 + val imgResourceName = "img_todo_" + item.coverImage + val iconResourceId = context.resources.getIdentifier(imgResourceName, "drawable", context.packageName) + binding.imgTodoCover.setImageResource(iconResourceId) + + // 내용 + binding.textTodoContent.text = item.content + + // 기간 + binding.textTodoPeriod.text = item.period + + // 요일 리스트 보여줄 recyclerview 세팅 + binding.recyclerviewHomeTodoDay.apply { + adapter = HomeTodoDayAdapter(context).build(item.day) + layoutManager = + LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) + } + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoDayAdapter.kt b/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoDayAdapter.kt new file mode 100644 index 0000000..6a00199 --- /dev/null +++ b/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoDayAdapter.kt @@ -0,0 +1,46 @@ +package com.ssjm.sw_hackathon.home.recycler + +import android.content.Context +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.ssjm.sw_hackathon.R +import com.ssjm.sw_hackathon.databinding.ItemTodoDayBinding +import com.ssjm.sw_hackathon.databinding.ItemTodoOfHomeBinding + +class HomeTodoDayAdapter (private val context: Context, +) : RecyclerView.Adapter() { + + var items = mutableListOf() + + fun build(days: MutableList?): HomeTodoDayAdapter { + if(days != null) + items = days + + return this + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : + HomeTodoDayViewHolder { + + val view = LayoutInflater.from(context).inflate(R.layout.item_todo_day, parent, false) + + return HomeTodoDayViewHolder(ItemTodoDayBinding.bind(view)) + } + + override fun getItemCount(): Int = items.size + + override fun onBindViewHolder(holder: HomeTodoDayViewHolder, position: Int) { + holder.bind(items[position]) + + } + + inner class HomeTodoDayViewHolder(private val binding: ItemTodoDayBinding) : + RecyclerView.ViewHolder(binding.root) { + + fun bind(item: String) { + binding.textTodoDay.text = item + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoItem.kt b/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoItem.kt new file mode 100644 index 0000000..e45e322 --- /dev/null +++ b/app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoItem.kt @@ -0,0 +1,10 @@ +package com.ssjm.sw_hackathon.home.recycler + +import android.graphics.drawable.Drawable + +data class HomeTodoItem( + val coverImage: String, + val content: String, + val period: String, + val day: MutableList +) diff --git a/app/src/main/res/layouts/home/drawable/img_todo_barista1.png b/app/src/main/res/layouts/home/drawable/img_todo_barista1.png new file mode 100644 index 0000000..f0f0b4a Binary files /dev/null and b/app/src/main/res/layouts/home/drawable/img_todo_barista1.png differ diff --git a/app/src/main/res/layouts/home/drawable/img_todo_barista2.png b/app/src/main/res/layouts/home/drawable/img_todo_barista2.png new file mode 100644 index 0000000..4418059 Binary files /dev/null and b/app/src/main/res/layouts/home/drawable/img_todo_barista2.png differ diff --git a/app/src/main/res/layouts/home/drawable/img_todo_note1.png b/app/src/main/res/layouts/home/drawable/img_todo_note1.png new file mode 100644 index 0000000..ba68f70 Binary files /dev/null and b/app/src/main/res/layouts/home/drawable/img_todo_note1.png differ diff --git a/app/src/main/res/layouts/home/drawable/shape_todo_cover_radius.xml b/app/src/main/res/layouts/home/drawable/shape_todo_cover_radius.xml new file mode 100644 index 0000000..9a89557 --- /dev/null +++ b/app/src/main/res/layouts/home/drawable/shape_todo_cover_radius.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layouts/home/drawable/shape_todo_day.xml b/app/src/main/res/layouts/home/drawable/shape_todo_day.xml new file mode 100644 index 0000000..7098c34 --- /dev/null +++ b/app/src/main/res/layouts/home/drawable/shape_todo_day.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layouts/home/drawable/shape_todo_title.xml b/app/src/main/res/layouts/home/drawable/shape_todo_title.xml new file mode 100644 index 0000000..832d3fe --- /dev/null +++ b/app/src/main/res/layouts/home/drawable/shape_todo_title.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layouts/home/layout/fragment_home.xml b/app/src/main/res/layouts/home/layout/fragment_home.xml index 65dd09e..0b8efb4 100644 --- a/app/src/main/res/layouts/home/layout/fragment_home.xml +++ b/app/src/main/res/layouts/home/layout/fragment_home.xml @@ -51,7 +51,7 @@ android:id="@+id/text_job" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="개발자" + android:text="바리스타" android:textSize="26sp" android:textStyle="bold" android:textColor="@color/black01" @@ -118,5 +118,18 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layouts/home/layout/item_todo_day.xml b/app/src/main/res/layouts/home/layout/item_todo_day.xml new file mode 100644 index 0000000..f9a99f6 --- /dev/null +++ b/app/src/main/res/layouts/home/layout/item_todo_day.xml @@ -0,0 +1,13 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layouts/home/layout/item_todo_of_home.xml b/app/src/main/res/layouts/home/layout/item_todo_of_home.xml new file mode 100644 index 0000000..a7e3406 --- /dev/null +++ b/app/src/main/res/layouts/home/layout/item_todo_of_home.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + \ No newline at end of file