Skip to content
Open
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 @@ -25,6 +25,7 @@ import androidx.appcompat.widget.SwitchCompat
import androidx.cardview.widget.CardView
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.ViewCompat
import androidx.databinding.BindingAdapter
import com.bumptech.glide.load.model.GlideUrl
Expand Down Expand Up @@ -583,6 +584,31 @@ fun setLayoutAppBackgroundTint(view: View, @ColorInt default: Int?) {
}
}

@BindingAdapter(value = ["appBackgroundDrawable", "appBackgroundColor"], requireAll = false)
fun setLayoutAppBackgroundAndTint(
view: View,
drawable: Drawable?,
@ColorInt default: Int?
) {
// pick color: app → system → default (if any)
val color = DynamicAppColor.getAppColors()?.barBackground?.let {
Color.rgb(it.red, it.green, it.blue)
} ?: DynamicAppColor.getSystemColors()?.barBackground ?: default

if (drawable != null) {
val d = DrawableCompat.wrap(drawable.mutate())
color?.let {
DrawableCompat.setTint(d, it)
DrawableCompat.setTintMode(d, PorterDuff.Mode.SRC_IN)
}
ViewCompat.setBackground(view, d)
} else {
// fallback: no drawable provided, just set a solid color if we have one
color?.let { view.setBackgroundColor(it) }
}
}


@BindingAdapter("isDisabled", "originalColor", requireAll = false)
fun setViewIsDisabled(view: View, disabled: Boolean, originalColor: Int?) {
val disabledColor = ContextCompat.getColor(view.context, R.color.light_grey_3)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/grey4" />
<stroke
android:width="1dp"
android:color="@color/grey4" />
<corners android:radius="24dp" />
</shape>
1 change: 1 addition & 0 deletions TripKitAndroidUI/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<color name="grey1">#E6EFF2</color>
<color name="grey2">#f5f6f7</color>
<color name="grey3">#F6F6F6</color>
<color name="grey4">#e6e6e6</color>
<color name="tripKitSuccess">#24883D</color>
<color name="tripKitWarning">#FCBA1E</color>
<color name="tripKitError">#E34040</color>
Expand Down
1 change: 1 addition & 0 deletions TripKitAndroidUI/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<dimen name="font_size_large">20sp</dimen>
<dimen name="font_size_huge">24sp</dimen>
<dimen name="font_size_xlarge">28sp</dimen>
<dimen name="font_size_22">22sp</dimen>
<dimen name="font_size_induction_subtitle">14sp</dimen>

<dimen name="bottom_sheet_peek_height">120dp</dimen>
Expand Down