-
Notifications
You must be signed in to change notification settings - Fork 3
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 #63 from woowacourse-teams/feature/hackathon-woof
해커톤 bottomSheet 구현
- Loading branch information
Showing
41 changed files
with
1,217 additions
and
12 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
22 changes: 22 additions & 0 deletions
22
...app/src/main/java/com/woowacourse/friendogly/presentation/ui/chatlist/ChatListFragment.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,22 @@ | ||
package com.woowacourse.friendogly.presentation.ui.chatlist | ||
|
||
import com.woowacourse.friendogly.R | ||
import com.woowacourse.friendogly.databinding.FragmentChatListBinding | ||
import com.woowacourse.friendogly.presentation.base.BaseFragment | ||
|
||
class ChatListFragment : BaseFragment<FragmentChatListBinding>(R.layout.fragment_chat_list) { | ||
override fun initViewCreated() { | ||
|
||
binding.test.setOnClickListener { | ||
val bottomSheet = WoofBottomSheet() | ||
val bundle = WoofBottomSheet.getBundle(WoofDogUiModel("https://t1.daumcdn.net/thumb/R720x0.fjpg/?fname=http://t1.daumcdn.net/brunch/service/user/cnoC/image/PTcGsuuqjlyY1d9MxFkG7RAndmo.jpg", | ||
"땡이","소형견",2,"땡이 닉네임이랑 땡이 강아지 이름 똑가틈")) | ||
bottomSheet.arguments = bundle | ||
bottomSheet.show(parentFragmentManager, "") | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
80 changes: 80 additions & 0 deletions
80
.../app/src/main/java/com/woowacourse/friendogly/presentation/ui/chatlist/WoofBottomSheet.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,80 @@ | ||
package com.woowacourse.friendogly.presentation.ui.chatlist | ||
|
||
import android.app.Dialog | ||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.FrameLayout | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.load.resource.bitmap.CenterCrop | ||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners | ||
import com.google.android.material.bottomsheet.BottomSheetBehavior | ||
import com.google.android.material.bottomsheet.BottomSheetDialog | ||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment | ||
import com.woowacourse.friendogly.R | ||
import com.woowacourse.friendogly.presentation.utils.bindGlide1000 | ||
import com.woowacourse.friendogly.presentation.utils.bundleParcelable | ||
|
||
class WoofBottomSheet : BottomSheetDialogFragment() { | ||
|
||
private lateinit var dlg: BottomSheetDialog | ||
|
||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
dlg = super.onCreateDialog(savedInstanceState) as BottomSheetDialog | ||
dlg.setOnShowListener { | ||
val bottomSheet = | ||
dlg.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout | ||
|
||
val behavior = BottomSheetBehavior.from(bottomSheet) | ||
behavior.isDraggable = false | ||
behavior.state = BottomSheetBehavior.STATE_EXPANDED | ||
} | ||
return dlg | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
return inflater.inflate(R.layout.bottom_sheet_woof, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
//setBackgroundTransparent() | ||
|
||
val info = this.arguments?.bundleParcelable(EXTRA_DOG_INFO_ID, WoofDogUiModel::class.java) | ||
?: error("dog info가 잘못 들어옴") | ||
|
||
dlg.findViewById<TextView>(R.id.tv_woof_dog_name)?.text = info.name | ||
dlg.findViewById<TextView>(R.id.tv_woof_dog_age)?.text = "${info.age} 살" | ||
dlg.findViewById<TextView>(R.id.tv_woof_dog_gender)?.text = info.name | ||
dlg.findViewById<TextView>(R.id.tv_woof_dog_size)?.text = info.size | ||
dlg.findViewById<TextView>(R.id.tv_woof_dog_desc)?.text = info.description | ||
|
||
Glide.with(requireContext()) | ||
.load(info.imageUrl) | ||
.into(dlg.findViewById<ImageView>(R.id.iv_woof_dog)!!) | ||
|
||
} | ||
|
||
private fun setBackgroundTransparent() { | ||
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | ||
} | ||
|
||
companion object { | ||
private const val EXTRA_DOG_INFO_ID = "dogInfo" | ||
|
||
fun getBundle(dog: WoofDogUiModel): Bundle { | ||
return Bundle().apply { this.putParcelable(EXTRA_DOG_INFO_ID, dog) } | ||
} | ||
} | ||
|
||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...d/app/src/main/java/com/woowacourse/friendogly/presentation/ui/chatlist/WoofDogUiModel.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,14 @@ | ||
package com.woowacourse.friendogly.presentation.ui.chatlist | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
|
||
@Parcelize | ||
data class WoofDogUiModel( | ||
val imageUrl: String, | ||
val name: String, | ||
val size: String, | ||
val age: Int, | ||
val description: String, | ||
): Parcelable |
39 changes: 39 additions & 0 deletions
39
...com/woowacourse/friendogly/presentation/ui/profilesetting/ProfieSettingBindingAdapters.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,39 @@ | ||
package com.woowacourse.friendogly.presentation.ui.profilesetting | ||
|
||
import android.annotation.SuppressLint | ||
import android.widget.TextView | ||
import androidx.core.content.ContextCompat | ||
import androidx.databinding.BindingAdapter | ||
import com.woowacourse.friendogly.R | ||
|
||
@SuppressLint("SetTextI18n") | ||
@BindingAdapter("editTextLength") | ||
fun TextView.bindEditTextLength(contents: String?) { | ||
val length = contents?.length ?: 0 | ||
|
||
val color = | ||
if (length != 0) { | ||
ContextCompat.getColor(context, R.color.black) | ||
} else { | ||
ContextCompat.getColor(context, R.color.gray05) | ||
} | ||
|
||
this.apply { | ||
text = "$length/15" | ||
setTextColor(color) | ||
} | ||
} | ||
|
||
@SuppressLint("UseCompatLoadingForDrawables") | ||
@BindingAdapter("editBtnBackgroundTextColor") | ||
fun TextView.bindEditBtnBackground(contents: String?) { | ||
val length = contents?.length ?: 0 | ||
|
||
if (length > 0) { | ||
this.background = context.getDrawable(R.drawable.rect_blue_fill_16) | ||
this.setTextColor(context.getColor(R.color.black)) | ||
} else { | ||
this.background = context.getDrawable(R.drawable.rect_gray03_fill_16) | ||
this.setTextColor(context.getColor(R.color.gray08)) | ||
} | ||
} |
Oops, something went wrong.