|
|
|
@ -145,10 +145,7 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a |
|
|
|
|
|
|
|
|
|
override fun onAttachedToWindow() { |
|
|
|
|
super.onAttachedToWindow() |
|
|
|
|
if (attachToActivity) { |
|
|
|
|
attachToActivity() |
|
|
|
|
} |
|
|
|
|
wrapTheme() |
|
|
|
|
attachToActivity() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun setNavigationOnClickListener(clickListener: ((View) -> Unit)) { |
|
|
|
@ -179,7 +176,14 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a |
|
|
|
|
toolbar.setSubtitleTextAppearance(context, resId) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun wrapTheme() { |
|
|
|
|
private fun attachToActivity() { |
|
|
|
|
if(attachToActivity) { |
|
|
|
|
activity?.let { |
|
|
|
|
it.setSupportActionBar(toolbar) |
|
|
|
|
it.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUp) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val primaryTextColor = if (isInEditMode) Color.BLACK else context.primaryTextColor |
|
|
|
|
DrawableUtils.setTint(toolbar.overflowIcon, primaryTextColor) |
|
|
|
|
toolbar.setTitleTextColor(primaryTextColor) |
|
|
|
@ -191,13 +195,6 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun attachToActivity() { |
|
|
|
|
activity?.let { |
|
|
|
|
it.setSupportActionBar(toolbar) |
|
|
|
|
it.supportActionBar?.setDisplayHomeAsUpEnabled(displayHomeAsUp) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun wrapDrawableTint(drawable: Drawable?, tintList: ColorStateList?, tintMode: Int) { |
|
|
|
|
if (drawable == null || tintList == null) return |
|
|
|
|
val wrappedDrawable = DrawableCompat.wrap(drawable.mutate()) |
|
|
|
|