Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#173 [UI] 메인 튜토리얼 #174

Merged
merged 13 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class AuthRepositoryImpl @Inject constructor(
localDataSource.bearType = bearType
}

override fun getTutorial(): Boolean = localDataSource.isHomeTutorial

override fun setTutorial(isTutorial: Boolean) {
localDataSource.isHomeTutorial = isTutorial
}

override fun getSignedUp(): Boolean = localDataSource.isUserSignUp
override fun getMember(): Boolean = localDataSource.isMemberDollExist

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ class LocalDataSource @Inject constructor(
set(value) = prefs.edit { putBoolean(IS_MEMBER, value) }
get() = prefs.getBoolean(IS_MEMBER, false)

var isHomeTutorial: Boolean
set(value) = prefs.edit { putBoolean(IS_HOME_TUTORIAL, value) }
get() = prefs.getBoolean(IS_HOME_TUTORIAL, true)

companion object {
private const val ACCESS_TOKEN = "access_token"
private const val REFRESH_TOKEN = "refresh_token"
private const val USER = "user"
private const val BEAR_TYPE = "bear_type"
private const val IS_MEMBER = "is_member"
private const val IS_HOME_TUTORIAL = "is_home_tutorial"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.sopetit.softie.domain.entity

import androidx.annotation.DrawableRes

data class Tutorial(
val tutorialId: Int,
@DrawableRes val content: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ interface AuthRepository {
suspend fun logOut(): Result<Unit>
fun getBearType(): String
fun setBearType(bearType: String)
fun getTutorial(): Boolean
fun setTutorial(isTutorial: Boolean)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sopetit.softie.domain.usecase.local

import com.sopetit.softie.domain.repository.AuthRepository
import javax.inject.Inject

class GetIsTutorialUseCase @Inject constructor(
private val authRepository: AuthRepository
) {
operator fun invoke() =
authRepository.getTutorial()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.sopetit.softie.domain.usecase.local
import com.sopetit.softie.domain.repository.AuthRepository
import javax.inject.Inject

class InitSIgnUpStateUseCase @Inject constructor(
class InitIsSignUpStateUseCase @Inject constructor(
private val authRepository: AuthRepository
) {
operator fun invoke(isSignUpState: Boolean) =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sopetit.softie.domain.usecase.local

import com.sopetit.softie.domain.repository.AuthRepository
import javax.inject.Inject

class SetIsTutorialUseCase @Inject constructor(
private val authRepository: AuthRepository
) {
operator fun invoke(isTutorial: Boolean) =
authRepository.setTutorial(isTutorial)
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ class DailyRoutineFragment :
title = getString(R.string.daily_routine_complete_question),
content = getString(R.string.daily_routine_complete_notice),
isContentVisible = true,
contentColor = R.color.gray400,
contentColor = R.color.gray500,
backBtnContent = getString(R.string.daily_routine_complete_yet),
doBtnContent = getString(R.string.daily_routine_complete_fix),
doBtnColor = R.drawable.shape_main1_fill_12_rect,
doBtnColor = R.drawable.shape_gray650_fill_12_rect,
backBtnAction = {},
doBtnAction = {
startDailyRoutineCompleteActivity()
Expand Down Expand Up @@ -232,10 +232,10 @@ class DailyRoutineFragment :
title = getString(R.string.daily_routine_edit_delete_question),
content = getString(R.string.daily_routine_edit_delete_notice),
isContentVisible = true,
contentColor = R.color.red,
contentColor = R.color.red200,
backBtnContent = getString(R.string.daily_routine_edit_delete_cancel),
doBtnContent = getString(R.string.daily_routine_edit_delete_fix),
doBtnColor = R.drawable.shape_red_fill_12_rect,
doBtnColor = R.drawable.shape_red200_fill_12_rect,
backBtnAction = {},
doBtnAction = {
val arraySize = viewModel.editRoutineIdArray.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DailyRoutineCompleteActivity : RoutineCompleteActivity(Cotton.DAILY) {
private val viewModel by viewModels<DailyRoutineCompleteViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStatusBarColorFromResource(R.color.white)
setStatusBarColorFromResource(R.color.gray0)

setDailyRoutineImage()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ class DailyRoutineAddActivity :
content = getCurrentSelectedRoutine()?.content
?: getString(R.string.daily_routine_basic_bottom_sheet_content),
isContentVisible = true,
contentColor = R.color.gray400,
contentColor = R.color.gray500,
backBtnContent = getString(R.string.daily_routine_add_no),
doBtnContent = getString(R.string.daily_routine_add_yes),
doBtnColor = R.drawable.shape_main1_fill_12_rect,
doBtnColor = R.drawable.shape_gray650_fill_12_rect,
backBtnAction = {},
doBtnAction = {
tossMsg()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class DailyRoutineAddThemeAdapter :
binding.tvDailyRoutineAddThemeName.setTextColor(
ContextCompat.getColor(
binding.root.context,
R.color.gray700
R.color.gray800
)
)
}
Expand All @@ -96,7 +96,7 @@ class DailyRoutineAddThemeAdapter :
binding.tvDailyRoutineAddThemeName.setTextColor(
ContextCompat.getColor(
binding.root.context,
R.color.gray400
R.color.gray500
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ class HappyMyRoutineFragment :
title = getString(R.string.happy_progress_bottom_sheet_title),
content = getString(R.string.happy_progress_bottom_sheet_content),
isContentVisible = true,
contentColor = R.color.gray400,
contentColor = R.color.gray500,
backBtnContent = getString(R.string.happy_progress_sheet_back_btn),
doBtnContent = getString(R.string.happy_progress_sheet_do_btn),
doBtnColor = R.drawable.shape_main1_fill_12_rect,
doBtnColor = R.drawable.shape_gray650_fill_12_rect,
backBtnAction = {},
doBtnAction = {
viewModel.happyProgressResponse.value?.let { viewModel.patchAchieveHappyRoutine(it.routineId) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class HappyRoutineCompleteActivity : RoutineCompleteActivity(Cotton.HAPPINESS) {
private val viewModel by viewModels<HappyRoutineCompleteViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStatusBarColorFromResource(R.color.white)
setStatusBarColorFromResource(R.color.gray0)

setHappyRoutineImage()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ class HappyDeleteFragment :
title = getString(R.string.happy_delete_bottom_sheet_title),
content = "",
isContentVisible = false,
contentColor = R.color.gray400,
contentColor = R.color.gray500,
backBtnContent = getString(R.string.happy_delete_bottom_sheet_back_btn),
doBtnContent = getString(R.string.happy_delete_bottom_sheet_do_btn),
doBtnColor = R.drawable.shape_red_fill_12_rect,
doBtnColor = R.drawable.shape_red200_fill_12_rect,
backBtnAction = {},
doBtnAction = {
viewModel.happyProgressResponse.observe(viewLifecycleOwner) { happyProgress ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ class HappyDetailActivity :
title = getString(R.string.happy_add_bottom_sheet_title),
content = "",
isContentVisible = true,
contentColor = R.color.main1,
contentColor = R.color.gray650,
backBtnContent = getString(R.string.happy_add_bottom_sheet_back_btn),
doBtnContent = getString(R.string.happy_add_bottom_sheet_do_btn),
doBtnColor = R.drawable.shape_main1_fill_12_rect,
doBtnColor = R.drawable.shape_gray650_fill_12_rect,
backBtnAction = {},
doBtnAction = {
viewModel.postAddRoutine(subRoutineId)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/sopetit/softie/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
private fun setBottomNavigationTint() {
binding.bnvMain.itemIconTintList = null

val selectedTextColor = ContextCompat.getColor(this, R.color.main1)
val unselectedTextColor = ContextCompat.getColor(this, R.color.gray200)
val selectedTextColor = ContextCompat.getColor(this, R.color.gray650)
val unselectedTextColor = ContextCompat.getColor(this, R.color.gray300)

binding.bnvMain.itemTextColor = ColorStateList(
arrayOf(
Expand Down
41 changes: 35 additions & 6 deletions app/src/main/java/com/sopetit/softie/ui/main/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.View
import androidx.fragment.app.setFragmentResultListener
import androidx.fragment.app.viewModels
import com.airbnb.lottie.LottieAnimationView
import com.sopetit.softie.R
Expand All @@ -30,17 +31,27 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home

companion object {
const val RUN_OUT = 0
val START = 0
val HELLO = 0
val DAILY = 1
val HAPPINESS = 2
const val REQUEST_KEY = "request_key"
const val RESULT_KEY = "result_key"
const val FINISH = "finish"
const val START = 0
const val HELLO = 0
const val DAILY = 1
const val HAPPINESS = 2
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setResultListener()
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.viewModel = viewModel
setStatusBarColor(R.color.home_background)

checkHomeTutorial()
setLottieVariable()
viewModel.getHome()
setUserLottieList()
Expand All @@ -49,7 +60,25 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
moveToPaymentView()
}

private fun setLottiesListener() {
private fun checkHomeTutorial() {
viewModel.isHomeTutorial.observe(viewLifecycleOwner) { isTutorial ->
if (isTutorial) {
val bottomSheet = HomeTutorialFragment()
bottomSheet.show(requireActivity().supportFragmentManager, this.tag)
}
}
}

private fun setResultListener() {
setFragmentResultListener(REQUEST_KEY) { _, bundle ->
val result = bundle.getString(RESULT_KEY)
if (result == FINISH) {
viewModel.updateHomeTutorial()
}
}
}

private fun setLottieListener() {
setLottieListener(helloLottie)
setLottieListener(dailyLottie)
setLottieListener(happinessLottie)
Expand Down Expand Up @@ -82,7 +111,7 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
}

private fun setClickListener() {
setLottiesListener()
setLottieListener()
setClickSetting()
setClickBear()
setClickDaily()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.sopetit.softie.ui.main.home

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.sopetit.softie.databinding.ItemHomeTutorialBinding
import com.sopetit.softie.domain.entity.Tutorial
import com.sopetit.softie.util.ItemDiffCallback

class HomeTutorialAdapter :
ListAdapter<Tutorial, HomeTutorialViewHolder>(
ItemDiffCallback<Tutorial>(
onItemsTheSame = { oldItem, newItem -> oldItem.tutorialId == newItem.tutorialId },
onContentsTheSame = { oldItem, newItem -> oldItem == newItem }
)
) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeTutorialViewHolder {
val binding = ItemHomeTutorialBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
return HomeTutorialViewHolder(binding)
}

override fun onBindViewHolder(holder: HomeTutorialViewHolder, position: Int) {
holder.onBind(getItem(position))
}
}

class HomeTutorialViewHolder(
private val binding: ItemHomeTutorialBinding
) : RecyclerView.ViewHolder(binding.root) {
fun onBind(data: Tutorial) {
binding.ivTutorialItem.setImageResource(data.content)
}
}
Loading
Loading