-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from tukcomCD2024/feat/#26_UI-3
Feat : home UI 구현 #26
- Loading branch information
Showing
28 changed files
with
890 additions
and
83 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
48 changes: 48 additions & 0 deletions
48
.../ARchive/app/src/main/java/com/droidblossom/archive/presentation/snack/HomeSnackBarBig.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,48 @@ | ||
package com.droidblossom.archive.presentation.snack | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.widget.Toast | ||
import androidx.core.content.ContextCompat | ||
import androidx.databinding.DataBindingUtil | ||
import com.droidblossom.archive.R | ||
import com.droidblossom.archive.databinding.SnackbarHomeAlertWithImageBinding | ||
import com.google.android.material.snackbar.Snackbar | ||
|
||
class HomeSnackBarBig(private val view : View, private val message: String, private val imgUrl : String) { | ||
|
||
private val context = view.context | ||
private val snackBar = Snackbar.make(view, "", 5000) | ||
private val snackBarLayout = snackBar.view as Snackbar.SnackbarLayout | ||
private val inflater = LayoutInflater.from(context) | ||
private val snackBarBinding: SnackbarHomeAlertWithImageBinding = DataBindingUtil.inflate(inflater, R.layout.snackbar_home_alert_with_image, null, false) | ||
|
||
|
||
init { | ||
initView() | ||
initData() | ||
} | ||
|
||
private fun initView() { | ||
val location = view.findViewById<View>(R.id.place) | ||
|
||
with(snackBarLayout) { | ||
removeAllViews() | ||
setPadding(0, 0, 0, 70) | ||
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)) | ||
addView(snackBarBinding.root, 0) | ||
} | ||
snackBar.anchorView = location | ||
} | ||
|
||
private fun initData() { | ||
snackBarBinding.openBtn.setOnClickListener { | ||
Toast.makeText(context,"테스트2", Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
|
||
fun show() { | ||
snackBar.show() | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
...Rchive/app/src/main/java/com/droidblossom/archive/presentation/snack/HomeSnackBarSmall.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,50 @@ | ||
package com.droidblossom.archive.presentation.snack | ||
|
||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.widget.Toast | ||
import androidx.core.content.ContextCompat | ||
import androidx.databinding.DataBindingUtil | ||
import com.droidblossom.archive.R | ||
import com.droidblossom.archive.databinding.SnackbarHomeAlertBinding | ||
import com.google.android.material.snackbar.Snackbar | ||
|
||
|
||
class HomeSnackBarSmall(private val view :View) { | ||
|
||
private val context = view.context | ||
private val snackBar = Snackbar.make(view, "", 5000) | ||
private val snackBarLayout = snackBar.view as Snackbar.SnackbarLayout | ||
private val inflater = LayoutInflater.from(context) | ||
private val snackBarBinding: SnackbarHomeAlertBinding = DataBindingUtil.inflate(inflater, com.droidblossom.archive.R.layout.snackbar_home_alert, null, false) | ||
|
||
|
||
init { | ||
initView() | ||
initData() | ||
} | ||
|
||
private fun initView() { | ||
val location = view.findViewById<View>(R.id.place) | ||
|
||
with(snackBarLayout) { | ||
removeAllViews() | ||
setPadding(0, 0, 0, 70) | ||
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)) | ||
addView(snackBarBinding.root, 0) | ||
} | ||
snackBar.anchorView = location | ||
} | ||
|
||
private fun initData() { | ||
snackBarBinding.openBtn.setOnClickListener { | ||
Toast.makeText(context,"테스트1",Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
|
||
fun show() { | ||
snackBar.show() | ||
} | ||
|
||
} |
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
97 changes: 50 additions & 47 deletions
97
...d/ARchive/app/src/main/java/com/droidblossom/archive/presentation/ui/home/HomeFragment.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,60 +1,63 @@ | ||
package com.droidblossom.archive.presentation.ui.home | ||
|
||
import android.os.Bundle | ||
import androidx.fragment.app.Fragment | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.viewModels | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import com.droidblossom.archive.R | ||
import com.droidblossom.archive.databinding.FragmentHomeBinding | ||
import com.droidblossom.archive.presentation.base.BaseFragment | ||
import com.droidblossom.archive.presentation.snack.HomeSnackBarBig | ||
import com.droidblossom.archive.presentation.snack.HomeSnackBarSmall | ||
import com.droidblossom.archive.presentation.ui.home.createcapsule.CreateCapsuleActivity | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.flow.collect | ||
import kotlinx.coroutines.launch | ||
|
||
// TODO: Rename parameter arguments, choose names that match | ||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | ||
private const val ARG_PARAM1 = "param1" | ||
private const val ARG_PARAM2 = "param2" | ||
|
||
/** | ||
* A simple [Fragment] subclass. | ||
* Use the [HomeFragment.newInstance] factory method to | ||
* create an instance of this fragment. | ||
*/ | ||
class HomeFragment : Fragment() { | ||
// TODO: Rename and change types of parameters | ||
private var param1: String? = null | ||
private var param2: String? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
arguments?.let { | ||
param1 = it.getString(ARG_PARAM1) | ||
param2 = it.getString(ARG_PARAM2) | ||
@AndroidEntryPoint | ||
class HomeFragment : BaseFragment<HomeViewModelImpl, FragmentHomeBinding>(R.layout.fragment_home) { | ||
|
||
override val viewModel: HomeViewModelImpl by viewModels<HomeViewModelImpl>() | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
binding.vm = viewModel | ||
|
||
binding.makeGroupCapsuleBtn.setOnClickListener { | ||
//그룹 캡슐 생성 페이지로 이동 | ||
startActivity(CreateCapsuleActivity.newIntent(requireContext(),true)) | ||
} | ||
binding.makeOpenCapsuleBtn.setOnClickListener { | ||
//공개 캡슐 생성 페이지로 이동 | ||
startActivity(CreateCapsuleActivity.newIntent(requireContext(),false)) | ||
} | ||
binding.makeSecretCapsuleBtn.setOnClickListener { | ||
//그룹 캡슐 생성 페이지로 이동 | ||
startActivity(CreateCapsuleActivity.newIntent(requireContext(),false)) | ||
} | ||
|
||
binding.snackbarTestBtn.setOnClickListener { | ||
//스낵바 스몰 테스트용 | ||
HomeSnackBarSmall(requireView()).show() | ||
} | ||
|
||
binding.snackbarBigText.setOnClickListener { | ||
//스낵바 빅 테스트용 | ||
HomeSnackBarBig(requireView(), "", "").show() | ||
} | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
// Inflate the layout for this fragment | ||
return inflater.inflate(R.layout.fragment_home, container, false) | ||
} | ||
|
||
companion object { | ||
/** | ||
* Use this factory method to create a new instance of | ||
* this fragment using the provided parameters. | ||
* | ||
* @param param1 Parameter 1. | ||
* @param param2 Parameter 2. | ||
* @return A new instance of fragment HomeFragment. | ||
*/ | ||
// TODO: Rename and change types and number of parameters | ||
@JvmStatic | ||
fun newInstance(param1: String, param2: String) = | ||
HomeFragment().apply { | ||
arguments = Bundle().apply { | ||
putString(ARG_PARAM1, param1) | ||
putString(ARG_PARAM2, param2) | ||
} | ||
override fun observeData() { | ||
//FAB 상태 | ||
lifecycleScope.launch { | ||
repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
viewModel.filterCapsuleSelect.collect( | ||
|
||
) | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../ARchive/app/src/main/java/com/droidblossom/archive/presentation/ui/home/HomeViewModel.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,27 @@ | ||
package com.droidblossom.archive.presentation.ui.home | ||
|
||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
interface HomeViewModel { | ||
|
||
val filterCapsuleSelect : StateFlow<CapsuleFilter> | ||
val isClickedFAB : StateFlow<Boolean> | ||
val existsNotification : StateFlow<Boolean> | ||
val followLocation : StateFlow<Boolean> | ||
|
||
|
||
fun selectPublic() | ||
fun selectGroup() | ||
fun selectSecret() | ||
fun selectHotPlace() | ||
fun clickFollowBtn() | ||
fun clickNotificationBtn() | ||
fun clickFAB() | ||
enum class CapsuleFilter{ | ||
ALL, | ||
SECRET, | ||
PUBLIC, | ||
GROUP, | ||
HOT | ||
} | ||
} |
Oops, something went wrong.