-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#176 [feat] 뷰페이저, recyclerview 구현 및 mock 데이터 적용
- Loading branch information
Showing
21 changed files
with
356 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
app/src/main/java/com/sopetit/softie/domain/repository/MockAddRoutineRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.sopetit.softie.domain.repository | ||
|
||
import com.sopetit.softie.domain.entity.MakerCard | ||
import com.sopetit.softie.domain.entity.RoutineTheme | ||
import javax.inject.Inject | ||
|
||
class MockAddRoutineRepository @Inject constructor() : AddRoutineRepository { | ||
override suspend fun getMakerCard(): Result<List<MakerCard>> { | ||
return Result.success( | ||
listOf( | ||
MakerCard( | ||
artistId = 1, | ||
artistImageUrl = "https://img.etoday.co.kr/pto_db/2024/04/600/20240426132100_2017673_647_863.jpeg", | ||
subTitle = "하이브의 주인은 누구?", | ||
title = "뉴진스가 돌아왔다", | ||
hashtag = listOf( | ||
MakerCard.Hashtag(hashtagId = 1, content = "민희진"), | ||
MakerCard.Hashtag(hashtagId = 2, content = "방시혁"), | ||
MakerCard.Hashtag(hashtagId = 2, content = "하이브") | ||
) | ||
), | ||
MakerCard( | ||
artistId = 2, | ||
artistImageUrl = "https://cdn.hankyung.com/photo/202211/BF.23427209.1.jpg", | ||
subTitle = "더이상 웹툰작가로는 못산다", | ||
title = "침착맨의 시크릿", | ||
hashtag = listOf( | ||
MakerCard.Hashtag(hashtagId = 3, content = "침착침착"), | ||
MakerCard.Hashtag(hashtagId = 4, content = "이말년") | ||
) | ||
), | ||
MakerCard( | ||
artistId = 3, | ||
artistImageUrl = "https://res.heraldm.com/content/image/2024/05/06/20240506050023_0.jpg", | ||
subTitle = "선재업고 얼마나 뛸 수 있어?", | ||
title = "변우석의 성공담", | ||
hashtag = listOf( | ||
MakerCard.Hashtag(hashtagId = 5, content = "류선재"), | ||
MakerCard.Hashtag(hashtagId = 6, content = "드라마") | ||
) | ||
) | ||
) | ||
) | ||
} | ||
|
||
override suspend fun getRoutineTheme(): Result<RoutineTheme> { | ||
return Result.success( | ||
RoutineTheme( | ||
themes = listOf( | ||
RoutineTheme.Themes( | ||
themeId = 1, | ||
modifier = "사람들과 어울리는", | ||
name = "관계 쌓기", | ||
description = "설명" | ||
), | ||
RoutineTheme.Themes( | ||
themeId = 2, | ||
modifier = "나를 돌보는", | ||
name = "마음 챙김", | ||
description = "설명2" | ||
), | ||
RoutineTheme.Themes( | ||
themeId = 3, | ||
modifier = "경제적으로 살아가는", | ||
name = "통통한 통장", | ||
description = "설명2" | ||
), | ||
RoutineTheme.Themes( | ||
themeId = 4, | ||
modifier = "하루를 상쾌하게", | ||
name = "산뜻한 일상", | ||
description = "설명2" | ||
), | ||
RoutineTheme.Themes( | ||
themeId = 5, | ||
modifier = "더 나은 나를 위해", | ||
name = "한 걸음 성장", | ||
description = "설명2" | ||
), | ||
RoutineTheme.Themes( | ||
themeId = 6, | ||
modifier = "튼튼하게 건강하게", | ||
name = "건강한 몸", | ||
description = "설명2" | ||
), | ||
RoutineTheme.Themes( | ||
themeId = 7, | ||
modifier = "튼튼하게 건강하게", | ||
name = "나와 친해지기", | ||
description = "설명2" | ||
) | ||
) | ||
) | ||
) | ||
} | ||
} |
7 changes: 5 additions & 2 deletions
7
app/src/main/java/com/sopetit/softie/domain/usecase/addroutine/GetMakerCardUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
package com.sopetit.softie.domain.usecase.addroutine | ||
|
||
import com.sopetit.softie.domain.entity.MakerCard | ||
import com.sopetit.softie.domain.repository.AddRoutineRepository | ||
import javax.inject.Inject | ||
|
||
class GetMakerCardUseCase @Inject constructor( | ||
private val addRoutineRepository: AddRoutineRepository | ||
) { | ||
suspend operator fun invoke() = | ||
addRoutineRepository.getMakerCard() | ||
suspend operator fun invoke(): Result<List<MakerCard>> { | ||
return addRoutineRepository.getMakerCard() | ||
} | ||
} | ||
|
11 changes: 9 additions & 2 deletions
11
app/src/main/java/com/sopetit/softie/domain/usecase/addroutine/GetRoutineThemeListUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
package com.sopetit.softie.domain.usecase.addroutine | ||
|
||
import com.sopetit.softie.domain.entity.RoutineTheme | ||
import com.sopetit.softie.domain.repository.AddRoutineRepository | ||
import javax.inject.Inject | ||
|
||
class GetRoutineThemeListUseCase @Inject constructor( | ||
private val addRoutineRepository: AddRoutineRepository | ||
) { | ||
suspend operator fun invoke() = | ||
addRoutineRepository.getRoutineTheme() | ||
suspend operator fun invoke(): Result<RoutineTheme> { | ||
return try { | ||
val result = addRoutineRepository.getRoutineTheme() | ||
result | ||
} catch (e: Exception) { | ||
Result.failure(e) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/src/main/java/com/sopetit/softie/ui/addroutine/list/RoutineThemeListAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.sopetit.softie.ui.addroutine.list | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import coil.load | ||
import com.sopetit.softie.R | ||
import com.sopetit.softie.databinding.ItemAddListBinding | ||
import com.sopetit.softie.domain.entity.RoutineTheme | ||
import com.sopetit.softie.util.ItemDiffCallback | ||
|
||
class RoutineThemeListAdapter : | ||
ListAdapter<RoutineTheme.Themes, RoutineThemeListAdapter.RoutineThemeListViewHolder>( | ||
ItemDiffCallback<RoutineTheme.Themes>( | ||
onItemsTheSame = { oldItem, newItem -> oldItem == newItem }, | ||
onContentsTheSame = { oldItem, newItem -> oldItem == newItem } | ||
) | ||
) { | ||
|
||
inner class RoutineThemeListViewHolder(private val binding: ItemAddListBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun onBind(data: RoutineTheme.Themes) { | ||
with(binding) { | ||
when (data.themeId) { | ||
1 -> ivAddListItemIcon.load(R.drawable.ic_theme1_pink) | ||
2 -> ivAddListItemIcon.load(R.drawable.ic_theme2_red) | ||
3 -> ivAddListItemIcon.load(R.drawable.ic_theme3_orange) | ||
4 -> ivAddListItemIcon.load(R.drawable.ic_theme4_yellow) | ||
5 -> ivAddListItemIcon.load(R.drawable.ic_theme5_green) | ||
6 -> ivAddListItemIcon.load(R.drawable.ic_theme6_sky) | ||
7 -> ivAddListItemIcon.load(R.drawable.ic_theme7_blue) | ||
else -> ivAddListItemIcon.load(R.drawable.ic_bear_base) | ||
} | ||
tvAddListItemContent.text = data.modifier | ||
tvAddListItemTitle.text = data.name | ||
} | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int | ||
): RoutineThemeListViewHolder { | ||
val binding = ItemAddListBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
) | ||
return RoutineThemeListViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: RoutineThemeListViewHolder, position: Int) { | ||
holder.onBind(currentList[position]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.