diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index df5071e..015dc35 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -12,6 +12,8 @@ @color/black + @color/black + diff --git a/build.gradle b/build.gradle index d4a77ef..0b85693 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { kakao_version = '2.12.1' dataStorePreferences_version = '1.0.0' retrofit2Version = '2.9.0' - + recyclerViewVersion = '1.2.1' } dependencies { diff --git a/common-ui/build.gradle b/common-ui/build.gradle index bd1fcd6..85af470 100644 --- a/common-ui/build.gradle +++ b/common-ui/build.gradle @@ -38,6 +38,10 @@ android { dependencies { + api project(path: ':common') + + + api "androidx.recyclerview:recyclerview:$rootProject.recyclerViewVersion" // Fragment api "androidx.fragment:fragment:$rootProject.fragment_version" diff --git a/common-ui/src/main/res/layout/item_story.xml b/common-ui/src/main/res/layout/item_story.xml index b9fb288..4e41fb7 100644 --- a/common-ui/src/main/res/layout/item_story.xml +++ b/common-ui/src/main/res/layout/item_story.xml @@ -18,9 +18,7 @@ - + - diff --git a/common/src/main/java/com/example/common/data/dto/StoryListResponse.kt b/common/src/main/java/com/example/common/data/dto/StoryListResponse.kt new file mode 100644 index 0000000..37bed55 --- /dev/null +++ b/common/src/main/java/com/example/common/data/dto/StoryListResponse.kt @@ -0,0 +1,8 @@ +package com.example.common.data.dto + +import com.example.common.data.entity.StoryWithDate + +data class StoryListResponse( + val success: Boolean, + val data: List +) \ No newline at end of file diff --git a/common/src/main/java/com/example/common/data/entity/HomeData.kt b/common/src/main/java/com/example/common/data/entity/HomeData.kt index 49b7b56..8554b18 100644 --- a/common/src/main/java/com/example/common/data/entity/HomeData.kt +++ b/common/src/main/java/com/example/common/data/entity/HomeData.kt @@ -1,21 +1,23 @@ package com.example.common.data.entity +import com.kakao.sdk.user.model.User + data class HomeData( val couple: Couple, - val newStory: NewStory, + val newStory: Story, val widgets: List ) data class Couple( - val me: Me, - val mine: Mine, + val me: UserInfo, + val mine: UserInfo, val name: String, val startDate: String ) -data class NewStory( +data class Story( val date: String, val postId: Int, val region: String, @@ -23,17 +25,7 @@ data class NewStory( ) -data class Mine( - val birthday: String, - val description: String, - val gender: String, - val instaId: String, - val nickname: String, - val profileImage: String -) - - -data class Me( +data class UserInfo( val birthday: String, val description: String, val gender: String, diff --git a/common/src/main/java/com/example/common/data/entity/StoryWithDate.kt b/common/src/main/java/com/example/common/data/entity/StoryWithDate.kt new file mode 100644 index 0000000..2afbfc2 --- /dev/null +++ b/common/src/main/java/com/example/common/data/entity/StoryWithDate.kt @@ -0,0 +1,7 @@ +package com.example.common.data.entity + +data class StoryWithDate( + val year : String, + val month : String, + val posts : List +) \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt new file mode 100644 index 0000000..87fbbdc --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.kt @@ -0,0 +1,58 @@ +package com.najudoryeong.mineme.story + +import android.util.Log +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import com.example.common.data.entity.Story +import com.najudoryeong.mineme.common_ui.databinding.ItemStoryBinding +import com.najudoryeong.mineme.story.databinding.TestStoryBinding + + +class StoryAdapter : ListAdapter(StoryDiffCallback()) { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + return StoryViewHolder( + TestStoryBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) + ) + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + if (holder is StoryViewHolder){ + val story = getItem(position) + holder.bind(story) + } + } + + class StoryViewHolder(private val binding: TestStoryBinding) : + RecyclerView.ViewHolder(binding.root) { + fun bind(storyModel: StoryModel) { + with(binding) { + story = storyModel + executePendingBindings() + itemView.setOnClickListener { + // story 상세보기 + Log.d("testStory","상세보기 클릭") + } + } + } + } + + +} + + +private class StoryDiffCallback : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { + return oldItem === newItem + } + + override fun areContentsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { + return oldItem == newItem + } +} \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt index fd6d19c..5960063 100644 --- a/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryFragment.kt @@ -2,11 +2,29 @@ package com.najudoryeong.mineme.story import com.najudoryeong.mineme.common_ui.BaseFragment import com.najudoryeong.mineme.story.databinding.FragmentStoryBinding +import com.example.common.data.entity.Story class StoryFragment : BaseFragment(Story) { + + private val myListAdapter: StoryAdapter by lazy { + StoryAdapter() + } + + private val dataSet = arrayListOf().apply { + add(StoryModel("2022-01-03",1, "마산","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) + add(StoryModel("2022-01-04",1, "마산1","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) + add(StoryModel("2022-01-05",1, "마산2","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) + add(StoryModel("2022-01-06",1, "마산3","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) + add(StoryModel("2022-01-07",1, "마산4","https://images.unsplash.com/photo-1511739001486-6bfe10ce785f?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80")) + + } + override fun initView() { binding.apply { - + //todo callback + recyclerView.adapter = myListAdapter } + myListAdapter.submitList(dataSet) + } } \ No newline at end of file diff --git a/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt b/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt new file mode 100644 index 0000000..63c4688 --- /dev/null +++ b/story/src/main/java/com/najudoryeong/mineme/story/StoryModel.kt @@ -0,0 +1,8 @@ +package com.najudoryeong.mineme.story + +data class StoryModel( + val date: String, + val postId: Int, + val region: String, + val thumbnailImage: String +) diff --git a/story/src/main/res/layout/fragment_story.xml b/story/src/main/res/layout/fragment_story.xml index 82d4fa7..095d4da 100644 --- a/story/src/main/res/layout/fragment_story.xml +++ b/story/src/main/res/layout/fragment_story.xml @@ -1,18 +1,36 @@ - + android:layout_height="match_parent"> - - - + android:layout_height="match_parent"> + + + + + + + + + + + diff --git a/story/src/main/res/layout/test_story.xml b/story/src/main/res/layout/test_story.xml new file mode 100644 index 0000000..37e6ef5 --- /dev/null +++ b/story/src/main/res/layout/test_story.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +