Skip to content

Commit

Permalink
feat(study set): sửa các lỗi giao diện
Browse files Browse the repository at this point in the history
  • Loading branch information
nqmgaming committed Dec 3, 2024
1 parent 7d651fa commit 2967d85
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 73 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ dependencies {
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.analytics)
implementation(libs.firebase.messaging.ktx)
implementation(libs.onesignal)
// implementation(libs.onesignal)
implementation(libs.androidx.paging.runtime.ktx)
implementation(libs.androidx.paging.compose)
implementation(libs.bundles.roomdb)
Expand Down
9 changes: 2 additions & 7 deletions app/src/main/java/com/pwhs/quickmem/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package com.pwhs.quickmem

import android.app.Application
import com.google.firebase.messaging.FirebaseMessaging
import com.onesignal.OneSignal
import com.onesignal.debug.LogLevel as OneSignalLogLevel
import com.pwhs.quickmem.core.datastore.AppManager
import com.pwhs.quickmem.core.datastore.TokenManager
import com.pwhs.quickmem.data.dto.notification.DeviceTokenRequestDto
import com.pwhs.quickmem.data.remote.ApiService
import com.revenuecat.purchases.LogLevel as RevenueCatLogLevel
import com.revenuecat.purchases.LogLevel
import com.revenuecat.purchases.Purchases
import com.revenuecat.purchases.PurchasesConfiguration
import dagger.hilt.android.HiltAndroidApp
Expand Down Expand Up @@ -38,16 +36,13 @@ class App : Application() {
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree())
}
Purchases.logLevel = RevenueCatLogLevel.DEBUG
OneSignal.Debug.logLevel = OneSignalLogLevel.VERBOSE
OneSignal.initWithContext(this, BuildConfig.ONESIGNAL_APP_ID)
Purchases.logLevel = LogLevel.DEBUG
Purchases.configure(
PurchasesConfiguration.Builder(
context = this,
apiKey = BuildConfig.REVENUECAT_API_KEY,
).build()
)
Purchases.sharedInstance.setOnesignalID(OneSignal.User.onesignalId)
// Get FCM token
getFCMToken()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.pwhs.quickmem.presentation.app.study_set.detail.material
import android.speech.tts.TextToSpeech
import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -19,28 +18,25 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.pwhs.quickmem.R
import com.pwhs.quickmem.presentation.component.ViewImageDialog
import com.pwhs.quickmem.presentation.component.ShowImageDialog
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.Locale
Expand Down Expand Up @@ -78,7 +74,6 @@ fun CardDetail(
startTTS = false
}


// Function to start/stop TTS
fun toggleSpeech() {
if (isSpeaking) {
Expand Down Expand Up @@ -198,7 +193,7 @@ fun CardDetail(

// Image Viewer Dialog
if (isImageViewerOpen) {
ViewImageDialog(
ShowImageDialog(
definitionImageUri = definitionImageUri,
onDismissRequest = {
isImageViewerOpen = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight.Companion.Bold
import androidx.compose.ui.text.style.TextAlign
Expand Down Expand Up @@ -85,6 +86,7 @@ fun MaterialTabScreen(
var explanation by remember { mutableStateOf("") }
var showGetAllDialog by remember { mutableStateOf(false) }
var learningMode by remember { mutableStateOf(LearnMode.NONE) }
val context = LocalContext.current

Scaffold { innerPadding ->
Box(
Expand Down Expand Up @@ -162,15 +164,15 @@ fun MaterialTabScreen(
)
) {
Text(
text = "Make a copy",
text = stringResource(R.string.txt_make_a_copy),
style = typography.titleMedium.copy(
color = colorScheme.background
)
)
}

Text(
text = "You can now edit this study set,just create a copy of it.",
text = stringResource(R.string.txt_you_can_not_edit_this_study_set_just_create_a_copy_of_it),
style = typography.bodyMedium.copy(
color = colorScheme.onSurface
),
Expand Down Expand Up @@ -289,9 +291,14 @@ fun MaterialTabScreen(
onToggleStarClick(flashCards.id, isStarred)
},
onMenuClick = {
hint = flashCards.hint ?: "There is no hint for this flashcard."
explanation = flashCards.explanation
?: "There is no explanation for this flashcard."
(flashCards.hint
?: context.getString(R.string.txt_there_is_no_hint_for_this_flashcard)).also {
hint = it
}
(flashCards.explanation
?: context.getString(R.string.txt_there_is_no_explanation_for_this_flashcard)).also {
explanation = it
}
showMenu = true
studySetId = flashCards.id
onFlashCardClick(flashCards.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ fun UnfinishedLearningBottomSheet(
TextButton(
onClick = onEndSessionClick,
colors = ButtonDefaults.outlinedButtonColors(
contentColor = colorScheme.primary,
containerColor = Color.Transparent
contentColor = colorScheme.error,
containerColor = Color.Transparent,
),
modifier = Modifier
.padding(top = 4.dp)
.fillMaxWidth(),
.padding(top = 4.dp),
shape = shapes.medium
) {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,21 @@ fun FlipFlashCardFinish(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.padding(top = 20.dp)
.padding(16.dp)
) {
item {
Text(
text = stringResource(R.string.txt_you_re_doing_great_keep_it_up),
style = MaterialTheme.typography.titleLarge.copy(
fontWeight = FontWeight.Bold
)
),
modifier = Modifier.padding(16.dp)
)
}
item {
StudySetDonutChart(
modifier = Modifier
.size(200.dp)
.padding(16.dp),
.size(200.dp),
studySetsStillLearn = countStillLearning.coerceAtLeast(0),
studySetsMastered = countKnown.coerceAtLeast(0),
color = studySetColor
Expand Down Expand Up @@ -222,7 +221,8 @@ fun FlipFlashCardFinish(
},
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
.padding(top = 16.dp)
.padding(horizontal = 16.dp),
shape = MaterialTheme.shapes.small,
colors = ButtonDefaults.buttonColors(
containerColor = studySetColor,
Expand Down Expand Up @@ -252,13 +252,14 @@ fun FlipFlashCardFinish(
}
}
item {
if (isGetAll) {
if ( isEndOfList) {
Button(
onClick = {
onRestartClicked()
},
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp)
.padding(horizontal = 16.dp),
shape = MaterialTheme.shapes.small,
colors = ButtonDefaults.buttonColors(
Expand All @@ -283,7 +284,8 @@ fun FlipFlashCardFinish(
fontSize = 18.sp,
),
textAlign = TextAlign.Center,
modifier = Modifier.padding(16.dp)
modifier = Modifier
.padding(16.dp)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ class LearnByQuizViewModel @Inject constructor(

init {
val studySetId = savedStateHandle.get<String>("studySetId") ?: ""
val isGetAll = savedStateHandle.get<Boolean>("isGetAll") ?: false
val studySetTitle = savedStateHandle.get<String>("studySetTitle") ?: ""
val studySetDescription = savedStateHandle.get<String>("studySetDescription") ?: ""
val studySetColorId = savedStateHandle.get<Int>("studySetColorId") ?: 0
val studySetSubjectId = savedStateHandle.get<Int>("studySetSubjectId") ?: 0
_uiState.update {
it.copy(
studySetId = studySetId,
isGetAll = isGetAll,
studySetTitle = studySetTitle,
studySetDescription = studySetDescription,
studySetColor = ColorModel.defaultColors[studySetColorId],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.pwhs.quickmem.core.data.states.RandomAnswer
import com.pwhs.quickmem.presentation.component.ViewImageDialog
import com.pwhs.quickmem.presentation.component.ShowImageDialog

@Composable
fun LearnQuizCardAnswer(
Expand Down Expand Up @@ -107,7 +107,7 @@ fun LearnQuizCardAnswer(

// Image Viewer Dialog
if (isImageViewerOpen) {
ViewImageDialog(
ShowImageDialog(
definitionImageUri = definitionImageUri,
onDismissRequest = {
isImageViewerOpen = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import com.airbnb.lottie.compose.rememberLottieComposition
import com.pwhs.quickmem.R
import com.pwhs.quickmem.core.data.states.WrongAnswer
import com.pwhs.quickmem.presentation.app.study_set.detail.progress.StudySetDonutChart
import com.pwhs.quickmem.presentation.component.ViewImageDialog
import com.pwhs.quickmem.presentation.component.ShowImageDialog
import com.pwhs.quickmem.ui.theme.correctColor
import com.pwhs.quickmem.ui.theme.incorrectColor
import com.pwhs.quickmem.util.toStringTime
Expand Down Expand Up @@ -100,19 +100,18 @@ fun QuizFlashCardFinish(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.padding(top = 20.dp)
.padding(16.dp)
) {
Text(
text = encouragementMessage,
style = MaterialTheme.typography.titleLarge.copy(
fontWeight = FontWeight.Bold
)
),
modifier = Modifier.padding(16.dp)
)
StudySetDonutChart(
modifier = Modifier
.size(200.dp)
.padding(16.dp),
.size(200.dp),
studySetsStillLearn = wrongAnswerCount.coerceAtLeast(0),
studySetsMastered = correctAnswerCount.coerceAtLeast(0),
color = studySetColor
Expand Down Expand Up @@ -232,7 +231,8 @@ fun QuizFlashCardFinish(
},
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
.padding(top = 16.dp)
.padding(horizontal = 16.dp),
shape = MaterialTheme.shapes.small,
colors = ButtonDefaults.buttonColors(
containerColor = studySetColor,
Expand Down Expand Up @@ -271,6 +271,7 @@ fun QuizFlashCardFinish(
},
modifier = Modifier
.fillMaxWidth()
.padding(top = 16.dp)
.padding(horizontal = 16.dp),
shape = MaterialTheme.shapes.small,
colors = ButtonDefaults.buttonColors(
Expand All @@ -295,7 +296,8 @@ fun QuizFlashCardFinish(
fontSize = 18.sp,
),
textAlign = TextAlign.Center,
modifier = Modifier.padding(16.dp)
modifier = Modifier
.padding(16.dp)
)
}
}
Expand Down Expand Up @@ -375,7 +377,7 @@ fun QuizFlashCardFinish(

// Image Viewer Dialog
if (isImageViewerOpen) {
ViewImageDialog(
ShowImageDialog(
definitionImageUri = definitionImageUri,
onDismissRequest = {
isImageViewerOpen = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import com.pwhs.quickmem.presentation.app.study_set.studies.component.Unfinished
import com.pwhs.quickmem.presentation.app.study_set.studies.true_false.component.TrueFalseButton
import com.pwhs.quickmem.presentation.app.study_set.studies.true_false.component.TrueFalseFlashcardFinish
import com.pwhs.quickmem.presentation.component.LoadingOverlay
import com.pwhs.quickmem.presentation.component.ViewImageDialog
import com.pwhs.quickmem.presentation.component.ShowImageDialog
import com.pwhs.quickmem.ui.theme.QuickMemTheme
import com.pwhs.quickmem.util.toColor
import com.ramcosta.composedestinations.annotation.Destination
Expand Down Expand Up @@ -366,7 +366,7 @@ fun LearnByTrueFalse(
LoadingOverlay(isLoading = isLoading)
// Image Viewer Dialog
if (isImageViewerOpen) {
ViewImageDialog(
ShowImageDialog(
definitionImageUri = definitionImageUri,
onDismissRequest = {
isImageViewerOpen = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ class LearnByTrueFalseViewModel @Inject constructor(

init {
val studySetId = savedStateHandle.get<String>("studySetId") ?: ""
val isGetAll = savedStateHandle.get<Boolean>("isGetAll") ?: false
val studySetTitle = savedStateHandle.get<String>("studySetTitle") ?: ""
val studySetDescription = savedStateHandle.get<String>("studySetDescription") ?: ""
val studySetColorId = savedStateHandle.get<Int>("studySetColorId") ?: 0
val studySetSubjectId = savedStateHandle.get<Int>("studySetSubjectId") ?: 0
_uiState.update {
it.copy(
studySetId = studySetId,
isGetAll = isGetAll,
studySetTitle = studySetTitle,
studySetDescription = studySetDescription,
studySetColor = ColorModel.defaultColors[studySetColorId],
Expand Down
Loading

0 comments on commit 2967d85

Please sign in to comment.