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
66 changes: 66 additions & 0 deletions design/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,72 @@ package com.urlaunched.android.design.ui.pulltorefresh {

}

package com.urlaunched.android.design.ui.question.models {

public final class QuestionColors {
ctor public QuestionColors(optional long borderColor, optional long driverColor, optional long questionTextColor, optional long answerTextColor);
method public long component1-0d7_KjU();
method public long component2-0d7_KjU();
method public long component3-0d7_KjU();
method public long component4-0d7_KjU();
method public com.urlaunched.android.design.ui.question.models.QuestionColors copy-jRlVdoo(long borderColor, long driverColor, long questionTextColor, long answerTextColor);
method public long getAnswerTextColor();
method public long getBorderColor();
method public long getDriverColor();
method public long getQuestionTextColor();
property public final long answerTextColor;
property public final long borderColor;
property public final long driverColor;
property public final long questionTextColor;
}

public final class QuestionConstants {
ctor public QuestionConstants(optional float rotateAngleArrow, optional float defaultAngleArrow, optional String rotateStateArrowLabel);
method public float component1();
method public float component2();
method public String component3();
method public com.urlaunched.android.design.ui.question.models.QuestionConstants copy(float rotateAngleArrow, float defaultAngleArrow, String rotateStateArrowLabel);
method public float getDefaultAngleArrow();
method public float getRotateAngleArrow();
method public String getRotateStateArrowLabel();
property public final float defaultAngleArrow;
property public final float rotateAngleArrow;
property public final String rotateStateArrowLabel;
}

public final class QuestionDimens {
ctor public QuestionDimens(optional float borderWidth, optional float borderShape, optional float horizontalPadding, optional float minHeight, optional float answerTextVerticalPadding, optional float questionButtonSpacing);
method public float component1-D9Ej5fM();
method public float component2-D9Ej5fM();
method public float component3-D9Ej5fM();
method public float component4-D9Ej5fM();
method public float component5-D9Ej5fM();
method public float component6-D9Ej5fM();
method public com.urlaunched.android.design.ui.question.models.QuestionDimens copy-erZIsFM(float borderWidth, float borderShape, float horizontalPadding, float minHeight, float answerTextVerticalPadding, float questionButtonSpacing);
method public float getAnswerTextVerticalPadding();
method public float getBorderShape();
method public float getBorderWidth();
method public float getHorizontalPadding();
method public float getMinHeight();
method public float getQuestionButtonSpacing();
property public final float answerTextVerticalPadding;
property public final float borderShape;
property public final float borderWidth;
property public final float horizontalPadding;
property public final float minHeight;
property public final float questionButtonSpacing;
}

}

package com.urlaunched.android.design.ui.question.ui {

public final class QuestionItemKt {
method @androidx.compose.runtime.Composable public static void QuestionItem(optional androidx.compose.ui.Modifier modifier, String questionText, String answerText, androidx.compose.ui.text.TextStyle questionTextStyle, androidx.compose.ui.text.TextStyle answerTextStyle, optional com.urlaunched.android.design.ui.question.models.QuestionDimens questionDimens, optional com.urlaunched.android.design.ui.question.models.QuestionConstants questionConstants, optional com.urlaunched.android.design.ui.question.models.QuestionColors questionColors, kotlin.jvm.functions.Function1<? super java.lang.Float,kotlin.Unit> arrowButton);
}

}

package com.urlaunched.android.design.ui.scrollbar {

public final class ColumnScrollbarKt {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.urlaunched.android.design.ui.question.models

import androidx.compose.ui.graphics.Color

data class QuestionColors(
val borderColor: Color = Color.Black,
val driverColor: Color = Color.Black,
val questionTextColor: Color = Color.Black,
val answerTextColor: Color = Color.Black
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.urlaunched.android.design.ui.question.models

data class QuestionConstants(
val rotateAngleArrow: Float = 180f,
val defaultAngleArrow: Float = 0f,
val rotateStateArrowLabel: String = "rotate_state_arrow",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.urlaunched.android.design.ui.question.models

import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.urlaunched.android.design.resources.dimens.Dimens

data class QuestionDimens(
val borderWidth: Dp = 1.dp,
val borderShape: Dp = 14.dp,
val horizontalPadding: Dp = Dimens.spacingNormalSpecial,
val minHeight: Dp = 64.dp,
val answerTextVerticalPadding: Dp = Dimens.spacingNormalSpecial,
val questionButtonSpacing: Dp = Dimens.spacingNormalSpecial,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.urlaunched.android.design.ui.question.ui

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Divider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import com.urlaunched.android.design.ui.question.models.QuestionColors
import com.urlaunched.android.design.ui.question.models.QuestionConstants
import com.urlaunched.android.design.ui.question.models.QuestionDimens

@Composable
fun QuestionItem(
modifier: Modifier = Modifier,
questionText: String,
answerText: String,
questionTextStyle: TextStyle,
answerTextStyle: TextStyle,
questionDimens: QuestionDimens = QuestionDimens(),
questionConstants: QuestionConstants = QuestionConstants(),
questionColors: QuestionColors = QuestionColors(),
arrowButton: @Composable (rotation: Float) -> Unit
) {
var expanded by rememberSaveable { mutableStateOf(false) }

val rotateState by animateFloatAsState(
targetValue = if (expanded) questionConstants.rotateAngleArrow else questionConstants.defaultAngleArrow,
label = questionConstants.rotateStateArrowLabel
)

Column(
modifier
.border(
border = BorderStroke(width = questionDimens.borderWidth, color = questionColors.borderColor),
shape = RoundedCornerShape(questionDimens.borderShape)
)
.toggleable(
value = expanded,
onValueChange = { value ->
expanded = value
},
indication = null,
interactionSource = null
)
.padding(horizontal = questionDimens.horizontalPadding)
) {
Row(
modifier = Modifier.defaultMinSize(minHeight = questionDimens.minHeight),
verticalAlignment = Alignment.CenterVertically
) {
Text(
modifier = Modifier.weight(1f),
text = questionText,
style = questionTextStyle,
color = questionColors.questionTextColor
)

Spacer(modifier = Modifier.width(questionDimens.questionButtonSpacing))

arrowButton(rotateState)
}

Divider(color = questionColors.driverColor)

AnimatedVisibility(visible = expanded) {
Text(
modifier = Modifier.padding(vertical = questionDimens.answerTextVerticalPadding),
text = answerText,
style = answerTextStyle,
color = questionColors.answerTextColor
)
}
}
}