Add different background for top unit in converter for visibility

This commit is contained in:
Ensar Sarajčić 2023-09-11 14:54:10 +02:00
parent bbf6ba12c6
commit 619b2660d3
2 changed files with 58 additions and 41 deletions

View File

@ -14,9 +14,7 @@ import com.simplemobiletools.calculator.helpers.DOT
import com.simplemobiletools.calculator.helpers.NumberFormatHelper
import com.simplemobiletools.calculator.helpers.converters.Converter
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.applyColorFilter
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
import com.simplemobiletools.commons.extensions.getProperTextColor
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.models.RadioItem
import me.grantland.widget.AutofitHelper
import kotlin.reflect.KMutableProperty0
@ -46,8 +44,8 @@ class ConverterView @JvmOverloads constructor(
binding.swapButton.setOnClickListener { switch() }
binding.topUnitName.setClickListenerForUnitSelector(::topUnit, ::bottomUnit)
binding.bottomUnitName.setClickListenerForUnitSelector(::bottomUnit, ::topUnit)
binding.topUnitHolder.setClickListenerForUnitSelector(::topUnit, ::bottomUnit)
binding.bottomUnitHolder.setClickListenerForUnitSelector(::bottomUnit, ::topUnit)
updateColors()
}
@ -75,6 +73,7 @@ class ConverterView @JvmOverloads constructor(
binding.bottomUnitName,
ColorStateList.valueOf(context.getProperPrimaryColor())
)
binding.topUnitHolder.setBackgroundColor(context.getProperBackgroundColor().lightenColor())
binding.swapButton.applyColorFilter(context.getProperPrimaryColor())
}

View File

@ -5,25 +5,34 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/top_unit_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="@dimen/small_margin"
android:layout_marginBottom="@dimen/small_margin"
android:layout_marginStart="@dimen/activity_margin"
android:layout_weight="1"
android:textSize="@dimen/big_text_size"
app:drawableEndCompat="@drawable/ic_arrow_drop_down_vector" />
<TextView
android:id="@+id/top_unit_text"
<LinearLayout
android:id="@+id/top_unit_holder"
android:layout_width="match_parent"
android:layout_height="0dp"
android:singleLine="true"
android:textAlignment="viewEnd"
android:layout_weight="2"
android:textSize="@dimen/display_text_size" />
android:layout_height="wrap_content"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:orientation="vertical"
android:layout_weight="3">
<TextView
android:id="@+id/top_unit_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="@dimen/small_margin"
android:layout_marginBottom="@dimen/small_margin"
android:layout_marginStart="@dimen/activity_margin"
android:layout_weight="1"
android:textSize="@dimen/big_text_size"
app:drawableEndCompat="@drawable/ic_arrow_drop_down_vector" />
<TextView
android:id="@+id/top_unit_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:singleLine="true"
android:textAlignment="viewEnd"
android:layout_weight="2"
android:textSize="@dimen/display_text_size" />
</LinearLayout>
<ImageView
android:id="@+id/swap_button"
@ -35,24 +44,33 @@
android:layout_weight="0.5"
android:src="@drawable/ic_swap_vertical_vector" />
<TextView
android:id="@+id/bottom_unit_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="@dimen/activity_margin"
android:layout_marginBottom="@dimen/small_margin"
android:layout_weight="1"
android:textSize="@dimen/big_text_size"
app:drawableEndCompat="@drawable/ic_arrow_drop_down_vector" />
<TextView
android:id="@+id/bottom_unit_text"
<LinearLayout
android:id="@+id/bottom_unit_holder"
android:layout_width="match_parent"
android:layout_height="0dp"
android:singleLine="true"
android:textAlignment="viewEnd"
android:layout_weight="2"
android:textSize="@dimen/display_text_size" />
android:layout_height="wrap_content"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:orientation="vertical"
android:layout_weight="3">
<TextView
android:id="@+id/bottom_unit_name"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="@dimen/activity_margin"
android:layout_marginBottom="@dimen/small_margin"
android:layout_weight="1"
android:textSize="@dimen/big_text_size"
app:drawableEndCompat="@drawable/ic_arrow_drop_down_vector" />
<TextView
android:id="@+id/bottom_unit_text"
android:layout_width="match_parent"
android:layout_height="0dp"
android:singleLine="true"
android:textAlignment="viewEnd"
android:layout_weight="2"
android:textSize="@dimen/display_text_size" />
</LinearLayout>
</com.simplemobiletools.calculator.views.ConverterView>