Skip to content

Commit

Permalink
FIX: LabelTextElement background
Browse files Browse the repository at this point in the history
  • Loading branch information
balakz committed May 31, 2021
1 parent 3436904 commit 2a1e566
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion formbuilderlibrary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def gitVersionCode = { ->

def VERSION_MAJOR = 2
def VERSION_MINOR = 1
def VERSION_PATCH = 0
def VERSION_PATCH = 1

String VERSION_NAME = "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import cz.qase.android.formbuilderlibrary.R
import cz.qase.android.formbuilderlibrary.common.setBackgroundColorResourceId
import cz.qase.android.formbuilderlibrary.common.setTextColorResourceId
import cz.qase.android.formbuilderlibrary.element.generic.FormElementNoValue
import kotlinx.android.synthetic.main.form_header_item.view.*

open class LabelTextElement(private val label: String,
private val text: String,
private val groupComponent: Int = R.layout.form_group_item_inline,
private val headerComponent: Int = R.layout.form_inline_label,
private val textComponent: Int = R.layout.form_inline_text,
protected val formStyleBundle: FormStyleBundle? = null) : FormElementNoValue() {
open class LabelTextElement(
private val label: String,
private val text: String,
private val groupComponent: Int = R.layout.form_group_item_inline,
private val headerComponent: Int = R.layout.form_inline_label,
private val textComponent: Int = R.layout.form_inline_text,
protected val formStyleBundle: FormStyleBundle? = null
) : FormElementNoValue() {

private var textView: TextView? = null
private var labelView: TextView? = null
Expand All @@ -33,8 +36,10 @@ open class LabelTextElement(private val label: String,
override fun createView(context: Context, formStyleBundle: FormStyleBundle): View {
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val view = inflater.inflate(groupComponent, null) as ViewGroup
val headerView = prepareLabel(inflater, context, this.formStyleBundle
?: formStyleBundle, view)
val headerView = prepareLabel(
inflater, context, this.formStyleBundle
?: formStyleBundle, view
)
val textView = prepareText(inflater, context, this.formStyleBundle ?: formStyleBundle, view)
view.setBackgroundColorResourceId(context, formStyleBundle.secondaryBackgroundColor)
view.addView(headerView)
Expand All @@ -49,7 +54,12 @@ open class LabelTextElement(private val label: String,
override fun disableElement(context: Context, formStyleBundle: FormStyleBundle) {
}

private fun prepareText(inflater: LayoutInflater, context: Context, formStyleBundle: FormStyleBundle, root: ViewGroup): TextView {
private fun prepareText(
inflater: LayoutInflater,
context: Context,
formStyleBundle: FormStyleBundle,
root: ViewGroup
): TextView {
val textView = inflater.inflate(textComponent, root, false) as TextView
textView.setTextColorResourceId(context, formStyleBundle.secondaryTextColor)
textView.text = text
Expand All @@ -65,9 +75,18 @@ open class LabelTextElement(private val label: String,
textView?.text = text
}

private fun prepareLabel(inflater: LayoutInflater, context: Context, formStyleBundle: FormStyleBundle, root: ViewGroup): TextView {
private fun prepareLabel(
inflater: LayoutInflater,
context: Context,
formStyleBundle: FormStyleBundle,
root: ViewGroup
): TextView {
val headerView = inflater.inflate(headerComponent, root, false) as TextView
headerView.setTextColorResourceId(context, formStyleBundle.primaryTextColor)
headerView.setBackgroundColorResourceId(
context,
formStyleBundle.secondaryBackgroundColor
)
headerView.text = label
labelView = headerView
return headerView
Expand Down

0 comments on commit 2a1e566

Please sign in to comment.