Skip to content

Commit

Permalink
feat(flip):cải thiện giao diện học
Browse files Browse the repository at this point in the history
  • Loading branch information
nqmgaming committed Dec 1, 2024
1 parent cbaf681 commit 88c63aa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Scaffold
Expand Down Expand Up @@ -77,10 +76,11 @@ fun AddStudySetToFolderItem(
modifier = Modifier
.padding(8.dp)
.background(Color.Transparent)
.weight(1f)
) {
Text(
studySet.title,
style = MaterialTheme.typography.titleMedium.copy(
style = typography.titleMedium.copy(
fontWeight = FontWeight.Bold
),
maxLines = 2,
Expand All @@ -93,14 +93,14 @@ fun AddStudySetToFolderItem(
Text(
buildAnnotatedString {
withStyle(
style = MaterialTheme.typography.bodySmall.toSpanStyle()
style = typography.bodySmall.toSpanStyle()
.copy(
fontWeight = FontWeight.Bold
)
) {
append("${studySet.flashcardCount}")
withStyle(
style = MaterialTheme.typography.bodySmall.toSpanStyle()
style = typography.bodySmall.toSpanStyle()
.copy(
fontWeight = FontWeight.Normal
)
Expand All @@ -115,7 +115,7 @@ fun AddStudySetToFolderItem(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
text = studySet?.subject?.name ?: SubjectModel.defaultSubjects[0].name,
text = studySet.subject?.name ?: SubjectModel.defaultSubjects[0].name,
style = typography.bodySmall.copy(
color = colorScheme.onSurface.copy(alpha = 0.6f)
)
Expand Down Expand Up @@ -154,7 +154,7 @@ fun AddStudySetToFolderItem(
)
Text(
studySet.owner.username,
style = MaterialTheme.typography.bodySmall
style = typography.bodySmall
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ fun FlipFlashCard(
CardStack(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
.zIndex(2f),
stackState = stackState,
cardElevation = 10.dp,
Expand Down Expand Up @@ -302,7 +301,8 @@ fun FlipFlashCard(
}
StudyFlipFlashCard(
flashCard = flashcard,
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize(),
isSwipingLeft = isSwipingLeft,
isSwipingRight = isSwipingRight,
stillLearningColor = stillLearningColor,
Expand All @@ -324,7 +324,9 @@ fun FlipFlashCard(

true -> {
FlipFlashCardFinish(
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 16.dp),
isEndOfList = true,
countStillLearning = countStillLearning,
countKnown = countKnown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
Expand Down Expand Up @@ -120,7 +121,6 @@ fun StudyFlipFlashCard(
scaleY = effectScale,
alpha = effectAlpha
)
.padding(vertical = 16.dp)
) {
when {
isShowingEffect -> when {
Expand Down Expand Up @@ -181,6 +181,7 @@ fun StudyFlipFlashCard(
verticalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
.animateContentSize()
.align(Alignment.Center)
.graphicsLayer(
Expand All @@ -189,7 +190,6 @@ fun StudyFlipFlashCard(
scaleY = effectScale,
alpha = effectAlpha
)
.padding(vertical = 16.dp)
) {
when {
isShowingEffect -> when {
Expand Down Expand Up @@ -278,14 +278,14 @@ fun StudyFlipFlashCard(
verticalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
.animateContentSize()
.align(Alignment.Center)
.graphicsLayer(
scaleX = effectScale,
scaleY = effectScale,
alpha = effectAlpha
)
.padding(vertical = 16.dp)
) {
when {
isShowingEffect -> when {
Expand Down Expand Up @@ -346,6 +346,7 @@ fun StudyFlipFlashCard(
verticalArrangement = Arrangement.Center,
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
.animateContentSize()
.align(Alignment.Center)
.graphicsLayer(
Expand All @@ -354,7 +355,6 @@ fun StudyFlipFlashCard(
scaleY = effectScale,
alpha = effectAlpha
)
.padding(vertical = 16.dp)
) {
when {
isShowingEffect -> when {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import com.msusman.compose.cardstack.internal.visible
* Created by Muhammad Usman : [email protected] on 7/19/2023.
*/
@Composable
fun CardContainer(stackState: StackState, index: Int, content: @Composable () -> Unit) {
fun CardContainer(
stackState: StackState,
index: Int,
content: @Composable () -> Unit
) {
val cardState: CardSate = stackState.cardQueue[index]
Box(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ fun <T> CardStack(
) {
items.forEachIndexed { index, item ->
CardContainer(stackState = stackState, index = index) {
content(item)
Box(
modifier = Modifier.padding(16.dp)
) {
content(item)
}
}
}
}
Expand Down

0 comments on commit 88c63aa

Please sign in to comment.