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

View File

@ -5,6 +5,14 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:id="@+id/top_unit_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:orientation="vertical"
android:layout_weight="3">
<TextView <TextView
android:id="@+id/top_unit_name" android:id="@+id/top_unit_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -24,6 +32,7 @@
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:layout_weight="2" android:layout_weight="2"
android:textSize="@dimen/display_text_size" /> android:textSize="@dimen/display_text_size" />
</LinearLayout>
<ImageView <ImageView
android:id="@+id/swap_button" android:id="@+id/swap_button"
@ -35,6 +44,14 @@
android:layout_weight="0.5" android:layout_weight="0.5"
android:src="@drawable/ic_swap_vertical_vector" /> android:src="@drawable/ic_swap_vertical_vector" />
<LinearLayout
android:id="@+id/bottom_unit_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin"
android:orientation="vertical"
android:layout_weight="3">
<TextView <TextView
android:id="@+id/bottom_unit_name" android:id="@+id/bottom_unit_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -54,5 +71,6 @@
android:textAlignment="viewEnd" android:textAlignment="viewEnd"
android:layout_weight="2" android:layout_weight="2"
android:textSize="@dimen/display_text_size" /> android:textSize="@dimen/display_text_size" />
</LinearLayout>
</com.simplemobiletools.calculator.views.ConverterView> </com.simplemobiletools.calculator.views.ConverterView>