Skip to content

Commit

Permalink
adding new icons, fix other, add gayacheckbox and gayaradiobutton
Browse files Browse the repository at this point in the history
  • Loading branch information
hayna-foursys committed Oct 1, 2024
1 parent 37f3b50 commit 246ae92
Show file tree
Hide file tree
Showing 47 changed files with 1,099 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.natura.android.checkbox

import android.content.Context
import android.content.res.ColorStateList
import android.util.AttributeSet
import androidx.appcompat.view.ContextThemeWrapper
import androidx.appcompat.widget.AppCompatCheckBox
import com.natura.android.R
import com.natura.android.resources.getColorTokenFromTheme

class GaYaCheckbox : AppCompatCheckBox {

constructor(context: Context) : super(context, null, R.attr.checkboxStyleSecondary) {
init()
}

constructor(context: Context, attrs: AttributeSet?) : super(
context,
attrs,
R.attr.checkboxStyleSecondary
) {
init()
}

constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
init()
}

constructor(context: Context, themeResId: Int) : super(
ContextThemeWrapper(context, themeResId),
null,
R.attr.checkboxStyleSecondary
) {
init()
}

private fun init() {
val colorChecked = getColorTokenFromTheme(context, R.attr.colorInputComponent)
val colorUnchecked = getColorTokenFromTheme(context, R.attr.colorInputComponent)
val colorIndeterminate = getColorTokenFromTheme(context, R.attr.colorInputComponent)
val colorDisabled = getColorTokenFromTheme(context, R.attr.colorContentDisabled)

val states = arrayOf(
intArrayOf(android.R.attr.state_checked, -android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_checked, -android.R.attr.state_enabled),
intArrayOf(android.R.attr.state_checked),
intArrayOf(-android.R.attr.state_checked),
intArrayOf(R.attr.state_indeterminate)
)

val colors = intArrayOf(
colorDisabled,
colorDisabled,
colorChecked,
colorUnchecked,
colorIndeterminate
)

buttonTintList = ColorStateList(states, colors)
updateDrawable()
}

var state = GaYaCheckboxState.UNCHECKED
set(value) {
field = value
refreshDrawableState()
updateDrawable()
}

private lateinit var indeterminateState: IntArray

private var onStateChangedListener: ((GaYaCheckboxState) -> Unit)? = null

fun setOnStateChangedListener(listener: (GaYaCheckboxState) -> Unit) {
onStateChangedListener = listener
}

private fun updateDrawable() {
val btnDrawable = when (state) {
GaYaCheckboxState.INDETERMINATE -> R.drawable.checkbox_status_indeterminate
GaYaCheckboxState.UNCHECKED -> R.drawable.checkbox_status_unchecked
GaYaCheckboxState.CHECKED -> R.drawable.checkbox_status_checked
}
setButtonDrawable(btnDrawable)
onStateChangedListener?.invoke(state)
}

override fun onCreateDrawableState(extraSpace: Int): IntArray {
indeterminateState = intArrayOf(R.attr.state_indeterminate)
val drawableState = super.onCreateDrawableState(extraSpace + 1)
mergeDrawableStates(drawableState, indeterminateState)
return drawableState
}

override fun setChecked(checked: Boolean) {
this.state = when (checked) {
true -> GaYaCheckboxState.CHECKED
else -> GaYaCheckboxState.UNCHECKED
}
super.setChecked(checked)
}
}

enum class GaYaCheckboxState {
UNCHECKED, CHECKED, INDETERMINATE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.natura.android.radiobutton

import android.content.Context
import android.content.res.ColorStateList
import android.util.AttributeSet
import androidx.appcompat.view.ContextThemeWrapper
import androidx.appcompat.widget.AppCompatRadioButton
import com.natura.android.R
import com.natura.android.resources.getColorTokenFromTheme

class GaYaRadiobutton : AppCompatRadioButton {

constructor(context: Context) : super(context, null, R.attr.radioButtonStyle) {
init()
}

constructor(context: Context, attrs: AttributeSet?) : super(
context,
attrs,
R.attr.radioButtonStyle
) {
init()
}

constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
) {
init()
}

constructor(context: Context, themeResId: Int) : super(
ContextThemeWrapper(context, themeResId),
null,
R.attr.radioButtonStyle
) {
init()
}

private val colorChecked by lazy { getColorTokenFromTheme(context, R.attr.colorInputComponent) }
private val colorUnchecked by lazy {
getColorTokenFromTheme(
context,
R.attr.colorInputComponent
)
}
private val colorDisabled by lazy {
getColorTokenFromTheme(
context,
R.attr.colorContentDisabled
)
}

private val colorStateList by lazy {
val states = arrayOf(
intArrayOf(android.R.attr.state_checked, -android.R.attr.state_enabled),
intArrayOf(-android.R.attr.state_checked, -android.R.attr.state_enabled),
intArrayOf(android.R.attr.state_checked),
intArrayOf(-android.R.attr.state_checked)
)

val colors = intArrayOf(
colorDisabled,
colorDisabled,
colorChecked,
colorUnchecked
)

ColorStateList(states, colors)
}

private fun init() {
buttonTintList = colorStateList
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<path
android:pathData="M7.554,2.363L7.809,1.726L7.811,1.727L7.817,1.73L7.837,1.738L7.912,1.768C7.977,1.795 8.07,1.834 8.19,1.886C8.428,1.988 8.768,2.138 9.181,2.331C10.005,2.716 11.123,3.276 12.298,3.97C13.47,4.663 14.717,5.5 15.786,6.446C16.846,7.384 17.787,8.476 18.273,9.69C19.145,11.87 19.573,14.242 19.785,16.048C19.829,16.42 19.864,16.77 19.892,17.09C20.035,15.193 20.467,12.413 21.499,9.833C23.333,5.333 31.666,1.833 31.999,1.833C32.333,1.667 32.666,1.667 32.833,1.833C33.166,2.167 33.166,2.333 33.166,2.667C33.166,2.833 32.333,10.167 31.499,14.333C30.833,17.833 28.333,20.975 27.499,21.975C27.517,21.987 27.528,21.999 27.532,22.011C27.923,22.35 28.31,22.699 28.697,23.048L28.837,23.174C29.644,23.903 30.453,24.633 31.316,25.326C32.594,26.352 33.225,28.015 33.325,29.716C33.425,31.428 32.998,33.295 32.019,34.856C31.032,36.429 29.477,37.701 27.35,38.157C25.321,38.593 22.864,38.267 20.003,36.903C17.141,38.267 14.684,38.593 12.655,38.157C10.529,37.701 8.973,36.429 7.987,34.856C7.008,33.295 6.58,31.428 6.68,29.716C6.78,28.015 7.412,26.352 8.69,25.326C9.608,24.588 10.45,23.829 11.277,23.083L11.384,22.987C11.708,22.695 12.03,22.405 12.353,22.121C12.305,22.063 12.295,22.014 12.333,21.975C12.223,21.844 12.085,21.536 11.925,21.338C11.622,20.971 11.257,20.503 10.877,19.954C9.906,18.552 8.797,16.569 8.349,14.33C8.225,13.713 8.102,13.026 7.982,12.302C7.322,8.475 6.739,3.424 6.672,2.603L6.671,2.592C6.639,2.301 6.762,2.014 6.995,1.837C7.228,1.659 7.537,1.617 7.809,1.726C7.809,1.726 7.809,1.726 7.554,2.363ZM14.277,20.34L14.297,20.363C15.349,19.615 16.412,19.04 17.544,18.698L17.541,18.647C17.509,18.116 17.45,17.363 17.342,16.486C17.122,14.71 16.709,12.511 15.952,10.619C15.673,9.923 15.056,9.139 14.129,8.319C13.221,7.515 12.12,6.768 11.026,6.122C10.502,5.813 9.988,5.531 9.51,5.282C9.56,5.682 9.615,6.11 9.673,6.555C9.985,8.948 10.396,11.816 10.8,13.84C11.153,15.603 12.112,17.359 13.055,18.732C13.517,19.405 13.956,19.958 14.277,20.34ZM25.671,20.293C24.744,19.591 23.732,19.049 22.585,18.716L22.514,18.622C22.516,18.554 22.52,18.48 22.523,18.402C22.548,17.898 22.597,17.182 22.696,16.34C22.896,14.641 23.29,12.511 24.047,10.619C24.325,9.923 24.942,9.139 25.869,8.319C26.778,7.515 27.879,6.768 28.972,6.122C29.496,5.813 30.01,5.531 30.489,5.282C30.438,5.682 30.384,6.11 30.326,6.555C30.014,8.948 29.603,11.816 29.198,13.84C28.844,15.611 27.938,17.271 27.066,18.53C26.637,19.15 26.232,19.65 25.938,19.993C25.833,20.114 25.743,20.215 25.671,20.293ZM25.019,30.006C25.94,30.006 26.686,29.26 26.686,28.34C26.686,27.419 25.94,26.673 25.019,26.673C24.099,26.673 23.353,27.419 23.353,28.34C23.353,29.26 24.099,30.006 25.019,30.006ZM16.666,28.34C16.666,29.26 15.92,30.006 14.999,30.006C14.079,30.006 13.333,29.26 13.333,28.34C13.333,27.419 14.079,26.673 14.999,26.673C15.92,26.673 16.666,27.419 16.666,28.34ZM16.702,32.254C16.808,31.903 17.132,31.662 17.499,31.662H22.499C22.867,31.662 23.191,31.903 23.297,32.254C23.403,32.606 23.267,32.985 22.962,33.189L20.462,34.856C20.182,35.042 19.817,35.042 19.537,34.856L17.037,33.189C16.732,32.985 16.595,32.606 16.702,32.254Z"
android:fillColor="#363636"
android:fillType="evenOdd"/>
</vector>
23 changes: 23 additions & 0 deletions designsystem/src/main/res/drawable/filled_content_exfoliator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<path
android:pathData="M27.501,1.667C27.736,1.667 27.961,1.766 28.119,1.941C28.18,2.008 28.243,2.079 28.309,2.153C28.87,2.783 29.617,3.661 30.363,4.654C31.11,5.649 31.855,6.757 32.412,7.846C32.971,8.939 33.334,9.999 33.334,10.903C33.334,14.559 30.417,16.667 27.501,16.667C24.585,16.667 21.667,14.559 21.667,10.903C21.667,9.999 22.031,8.939 22.589,7.846C23.146,6.757 23.891,5.649 24.638,4.654C25.385,3.661 26.132,2.783 26.692,2.153C26.758,2.079 26.822,2.008 26.882,1.941C27.04,1.766 27.265,1.667 27.501,1.667ZM26.667,13.333C27.588,13.333 28.334,12.587 28.334,11.667C28.334,10.746 27.588,10 26.667,10C25.747,10 25.001,10.746 25.001,11.667C25.001,12.587 25.747,13.333 26.667,13.333ZM28.334,7.5C28.334,7.96 27.961,8.333 27.501,8.333C27.04,8.333 26.667,7.96 26.667,7.5C26.667,7.04 27.04,6.667 27.501,6.667C27.961,6.667 28.334,7.04 28.334,7.5Z"
android:fillColor="#363636"
android:fillType="evenOdd"/>
<path
android:pathData="M16.244,15.275C16.086,15.1 15.861,15 15.626,15C15.39,15 15.165,15.1 15.007,15.275C14.91,15.383 14.807,15.497 14.701,15.616C13.797,16.632 12.592,18.047 11.39,19.647C10.186,21.25 8.995,23.024 8.108,24.758C7.214,26.508 6.667,28.143 6.667,29.489C6.667,35.093 11.124,38.333 15.626,38.333C20.128,38.333 24.584,35.093 24.584,29.489C24.584,28.143 24.038,26.508 23.143,24.758C22.256,23.024 21.065,21.25 19.861,19.647C18.659,18.047 17.455,16.632 16.55,15.616C16.444,15.497 16.342,15.383 16.244,15.275ZM15.001,31.667C15.001,32.587 14.255,33.333 13.334,33.333C12.413,33.333 11.667,32.587 11.667,31.667C11.667,30.746 12.413,30 13.334,30C14.255,30 15.001,30.746 15.001,31.667ZM15.834,25C16.294,25 16.667,24.627 16.667,24.167C16.667,23.706 16.294,23.333 15.834,23.333C15.374,23.333 15.001,23.706 15.001,24.167C15.001,24.627 15.374,25 15.834,25ZM20.001,28.333C20.001,29.254 19.254,30 18.334,30C17.413,30 16.667,29.254 16.667,28.333C16.667,27.413 17.413,26.667 18.334,26.667C19.254,26.667 20.001,27.413 20.001,28.333Z"
android:fillColor="#363636"
android:fillType="evenOdd"/>
<path
android:pathData="M5.834,17.5C5.834,17.96 6.207,18.333 6.667,18.333C7.127,18.333 7.501,17.96 7.501,17.5C7.501,16.58 8.247,15.833 9.167,15.833C9.627,15.833 10.001,15.46 10.001,15C10.001,14.54 9.627,14.167 9.167,14.167C8.247,14.167 7.501,13.42 7.501,12.5C7.501,12.04 7.127,11.667 6.667,11.667C6.207,11.667 5.834,12.04 5.834,12.5C5.834,13.42 5.087,14.167 4.167,14.167C3.707,14.167 3.334,14.54 3.334,15C3.334,15.46 3.707,15.833 4.167,15.833C5.087,15.833 5.834,16.58 5.834,17.5Z"
android:fillColor="#363636"/>
<path
android:pathData="M16.667,10C16.207,10 15.834,9.627 15.834,9.167C15.834,8.247 15.087,7.5 14.167,7.5C13.707,7.5 13.334,7.127 13.334,6.667C13.334,6.207 13.707,5.833 14.167,5.833C15.087,5.833 15.834,5.087 15.834,4.167C15.834,3.707 16.207,3.333 16.667,3.333C17.127,3.333 17.501,3.707 17.501,4.167C17.501,5.087 18.247,5.833 19.167,5.833C19.627,5.833 20.001,6.207 20.001,6.667C20.001,7.127 19.627,7.5 19.167,7.5C18.247,7.5 17.501,8.247 17.501,9.167C17.501,9.627 17.127,10 16.667,10Z"
android:fillColor="#363636"/>
<path
android:pathData="M32.501,29.167C32.501,29.627 32.874,30 33.334,30C33.794,30 34.167,29.627 34.167,29.167C34.167,28.247 34.914,27.5 35.834,27.5C36.294,27.5 36.667,27.127 36.667,26.667C36.667,26.207 36.294,25.833 35.834,25.833C34.914,25.833 34.167,25.087 34.167,24.167C34.167,23.707 33.794,23.333 33.334,23.333C32.874,23.333 32.501,23.707 32.501,24.167C32.501,25.087 31.754,25.833 30.834,25.833C30.374,25.833 30.001,26.207 30.001,26.667C30.001,27.127 30.374,27.5 30.834,27.5C31.754,27.5 32.501,28.247 32.501,29.167Z"
android:fillColor="#363636"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<path
android:pathData="M27.501,7.5C27.501,7.96 27.874,8.333 28.334,8.333C28.794,8.333 29.167,7.96 29.167,7.5C29.167,6.58 29.914,5.833 30.834,5.833C31.294,5.833 31.667,5.46 31.667,5C31.667,4.54 31.294,4.167 30.834,4.167C29.914,4.167 29.167,3.42 29.167,2.5C29.167,2.04 28.794,1.667 28.334,1.667C27.874,1.667 27.501,2.04 27.501,2.5C27.501,3.42 26.754,4.167 25.834,4.167C25.374,4.167 25.001,4.54 25.001,5C25.001,5.46 25.374,5.833 25.834,5.833C26.754,5.833 27.501,6.58 27.501,7.5Z"
android:fillColor="#363636"/>
<path
android:pathData="M23.213,10.68C23.262,10.723 23.298,10.779 23.317,10.843C23.337,10.906 23.339,10.975 23.324,11.04C23.309,11.105 23.277,11.164 23.231,11.211L21.864,12.608L22.186,14.581C22.195,14.633 22.192,14.686 22.179,14.736C22.166,14.786 22.143,14.833 22.111,14.873C22.079,14.913 22.039,14.945 21.993,14.967C21.948,14.989 21.899,15 21.85,15C21.794,15 21.74,14.986 21.691,14.958L20.001,14.027L18.31,14.955C18.253,14.986 18.19,15.001 18.126,14.996C18.063,14.991 18.001,14.967 17.95,14.928C17.899,14.889 17.859,14.836 17.835,14.774C17.811,14.713 17.803,14.646 17.813,14.581L18.138,12.607L16.771,11.21C16.725,11.163 16.692,11.104 16.677,11.039C16.662,10.974 16.664,10.906 16.684,10.842C16.704,10.778 16.74,10.722 16.789,10.679C16.838,10.636 16.897,10.608 16.961,10.598L18.849,10.312L19.694,8.52C19.726,8.463 19.77,8.416 19.824,8.383C19.878,8.351 19.94,8.333 20.002,8.333C20.064,8.333 20.126,8.351 20.18,8.383C20.234,8.416 20.278,8.463 20.31,8.52L21.155,10.312L23.044,10.598C23.106,10.608 23.165,10.637 23.213,10.68Z"
android:fillColor="#363636"/>
<path
android:pathData="M8.334,11.667C7.874,11.667 7.501,11.293 7.501,10.833C7.501,9.913 6.754,9.167 5.834,9.167C5.374,9.167 5.001,8.793 5.001,8.333C5.001,7.873 5.374,7.5 5.834,7.5C6.754,7.5 7.501,6.753 7.501,5.833C7.501,5.373 7.874,5 8.334,5C8.794,5 9.167,5.373 9.167,5.833C9.167,6.753 9.914,7.5 10.834,7.5C11.294,7.5 11.667,7.873 11.667,8.333C11.667,8.793 11.294,9.167 10.834,9.167C9.914,9.167 9.167,9.913 9.167,10.833C9.167,11.293 8.794,11.667 8.334,11.667Z"
android:fillColor="#363636"/>
<path
android:pathData="M16.667,3.333C16.667,4.254 15.921,5 15.001,5C14.08,5 13.334,4.254 13.334,3.333C13.334,2.413 14.08,1.667 15.001,1.667C15.921,1.667 16.667,2.413 16.667,3.333Z"
android:fillColor="#363636"/>
<path
android:pathData="M33.334,13.333C34.255,13.333 35.001,12.587 35.001,11.667C35.001,10.746 34.255,10 33.334,10C32.414,10 31.667,10.746 31.667,11.667C31.667,12.587 32.414,13.333 33.334,13.333Z"
android:fillColor="#363636"/>
<path
android:pathData="M30.255,15.922L24.966,14.6C25.26,14.124 25.488,13.603 25.636,13.05L33.536,15.025C33.79,15.088 33.987,15.261 34.089,15.481L36.579,20.461C36.672,20.646 36.692,20.857 36.638,21.055C36.63,21.083 36.62,21.111 36.61,21.138C36.523,21.358 36.348,21.531 36.127,21.614L22.793,26.614C22.376,26.77 21.91,26.571 21.735,26.162L20.001,22.116L18.267,26.162C18.245,26.213 18.218,26.261 18.188,26.305C17.975,26.615 17.573,26.75 17.208,26.614L3.875,21.614C3.654,21.531 3.478,21.358 3.392,21.138C3.305,20.918 3.316,20.672 3.422,20.461L5.922,15.461C5.961,15.382 6.012,15.312 6.071,15.251C6.175,15.144 6.31,15.064 6.465,15.025L14.366,13.05C14.514,13.603 14.742,14.124 15.036,14.6L9.746,15.922L20.001,19.127L30.255,15.922Z"
android:fillColor="#363636"/>
<path
android:pathData="M16.623,28.174C17.521,28.511 18.494,28.298 19.167,27.698V35.833C19.167,36.294 19.54,36.667 20.001,36.667C20.461,36.667 20.834,36.294 20.834,35.833V27.697C21.507,28.298 22.481,28.511 23.378,28.174L33.334,24.441V32.5C33.334,32.841 33.126,33.147 32.81,33.274L20.319,38.27C20.12,38.352 19.895,38.355 19.691,38.274L7.191,33.274C6.875,33.147 6.667,32.841 6.667,32.5V24.441L16.623,28.174Z"
android:fillColor="#363636"/>
</vector>
Loading

0 comments on commit 246ae92

Please sign in to comment.