Skip to content

Commit

Permalink
Fixed Action button text color issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DhavalBaldhaa committed Jan 9, 2021
1 parent e8cdb37 commit 80131fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
val bottomSheetFilePicker = BottomSheetFilePicker(BuildConfig.APPLICATION_ID)
bottomSheetFilePicker.actionButtonBg = R.drawable.button_bg
bottomSheetFilePicker.cancelButtonBg = R.drawable.button_bg_filled
bottomSheetFilePicker.actionButtonTextColor = R.color.purple_500
bottomSheetFilePicker.actionButtonTextColor = R.color.green
bottomSheetFilePicker.cancelButtonTextColor = R.color.white
bottomSheetFilePicker.setMediaListenerCallback(BottomSheetFilePicker.IMAGE, object : MediaPickerCallback {
override fun onPickedSuccess(media: Media?) {
Expand All @@ -51,7 +51,6 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {
}
})
bottomSheetFilePicker.show(supportFragmentManager, "take_all")
bottomSheetFilePicker.setAction(BottomSheetFilePicker.TAKE_PHOTO)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFF</color>
<color name="green">#4CAF50</color>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ open class BottomSheetFilePicker(val applicationId: String) : BaseBottomSheet(),
@ColorRes
var cancelButtonTextColor: Int? = null

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = BottomSheetCameraDialogBinding.inflate(inflater, container, false)
return binding.root
}
Expand Down Expand Up @@ -128,19 +124,14 @@ open class BottomSheetFilePicker(val applicationId: String) : BaseBottomSheet(),

if (actionButtonTextColor != null) {
with(binding) {
btnTakePhoto.setTextColor(actionButtonTextColor!!)
btnChooseImage.setTextColor(actionButtonTextColor!!)
btnTakeVideo.setTextColor(actionButtonTextColor!!)
btnChooseVideo.setTextColor(actionButtonTextColor!!)
btnTakePhoto.setTextColor(ContextCompat.getColor(requireContext(), actionButtonTextColor!!))
btnChooseImage.setTextColor(ContextCompat.getColor(requireContext(), actionButtonTextColor!!))
btnTakeVideo.setTextColor(ContextCompat.getColor(requireContext(), actionButtonTextColor!!))
btnChooseVideo.setTextColor(ContextCompat.getColor(requireContext(), actionButtonTextColor!!))
}
}
if (cancelButtonBg != null) binding.btnCancel.setBackgroundResource(cancelButtonBg!!)
if (cancelButtonTextColor != null) binding.btnCancel.setTextColor(
ContextCompat.getColor(
requireContext(),
cancelButtonTextColor!!
)
)
if (cancelButtonTextColor != null) binding.btnCancel.setTextColor(ContextCompat.getColor(requireContext(), cancelButtonTextColor!!))
}

override fun onClick(view: View) {
Expand Down

0 comments on commit 80131fc

Please sign in to comment.