-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tạo các màn hình cho: learn, flip, test, match flashcard
- Loading branch information
Showing
22 changed files
with
471 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.../com/pwhs/quickmem/presentation/app/study_set/study/flip_flashcard/FlipFlashCardScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.flip_flashcard | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import com.ramcosta.composedestinations.annotation.Destination | ||
import com.ramcosta.composedestinations.annotation.RootGraph | ||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator | ||
import com.ramcosta.composedestinations.result.ResultBackNavigator | ||
|
||
@Destination<RootGraph> | ||
@Composable | ||
fun FlipFlashCardScreen( | ||
modifier: Modifier = Modifier, | ||
navigator: DestinationsNavigator, | ||
resultNavigator: ResultBackNavigator<Boolean>, | ||
viewModel: FlipFlashCardViewModel = hiltViewModel() | ||
) { | ||
val uiState by viewModel.uiState.collectAsState() | ||
LaunchedEffect(key1 = true) { | ||
viewModel.uiEvent.collect { event -> | ||
when (event) { | ||
else -> {} | ||
} | ||
|
||
} | ||
} | ||
FlipFlashCard(modifier = modifier) | ||
} | ||
|
||
@Composable | ||
fun FlipFlashCard(modifier: Modifier = Modifier) { | ||
Scaffold { innerPadding -> | ||
Column( | ||
modifier = modifier.padding(innerPadding) | ||
) { | ||
Text( | ||
text = "FlipFlashCardScreen", | ||
style = MaterialTheme.typography.bodyLarge | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun FlipFlashCardScreenPreview() { | ||
MaterialTheme { | ||
FlipFlashCard() | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...om/pwhs/quickmem/presentation/app/study_set/study/flip_flashcard/FlipFlashCardUiAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.flip_flashcard | ||
|
||
sealed class FlipFlashCardUiAction { | ||
} |
4 changes: 4 additions & 0 deletions
4
...com/pwhs/quickmem/presentation/app/study_set/study/flip_flashcard/FlipFlashCardUiEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.flip_flashcard | ||
|
||
sealed class FlipFlashCardUiEvent { | ||
} |
5 changes: 5 additions & 0 deletions
5
...com/pwhs/quickmem/presentation/app/study_set/study/flip_flashcard/FlipFlashCardUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.flip_flashcard | ||
|
||
data class FlipFlashCardUiState( | ||
val isLoading: Boolean = false, | ||
) |
22 changes: 22 additions & 0 deletions
22
...m/pwhs/quickmem/presentation/app/study_set/study/flip_flashcard/FlipFlashCardViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.flip_flashcard | ||
|
||
import androidx.lifecycle.ViewModel | ||
import kotlinx.coroutines.channels.Channel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.receiveAsFlow | ||
import javax.inject.Inject | ||
|
||
class FlipFlashCardViewModel @Inject constructor() : ViewModel() { | ||
private val _uiState = MutableStateFlow(FlipFlashCardUiState()) | ||
val uiState = _uiState.asStateFlow() | ||
|
||
private val _uiEvent = Channel<FlipFlashCardUiEvent>() | ||
val uiEvent = _uiEvent.receiveAsFlow() | ||
|
||
fun onEvent(event: FlipFlashCardUiEvent) { | ||
when (event) { | ||
else -> {} | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...ain/java/com/pwhs/quickmem/presentation/app/study_set/study/learn/LearnFlashCardScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.learn | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import com.ramcosta.composedestinations.annotation.Destination | ||
import com.ramcosta.composedestinations.annotation.RootGraph | ||
import com.ramcosta.composedestinations.navigation.DestinationsNavigator | ||
import com.ramcosta.composedestinations.result.ResultBackNavigator | ||
|
||
@Destination<RootGraph> | ||
@Composable | ||
fun LearnFlashCardScreen( | ||
modifier: Modifier = Modifier, | ||
resultNavigator: ResultBackNavigator<Boolean>, | ||
navigator: DestinationsNavigator, | ||
viewModel: LearnFlashCardViewModel = hiltViewModel() | ||
) { | ||
val uiState by viewModel.uiState.collectAsState() | ||
LaunchedEffect(key1 = true) { | ||
viewModel.uiEvent.collect { event -> | ||
when (event) { | ||
else -> {} | ||
} | ||
|
||
} | ||
} | ||
LearnFlashCard(modifier = modifier) | ||
} | ||
|
||
@Composable | ||
fun LearnFlashCard(modifier: Modifier = Modifier) { | ||
Scaffold { innerPadding -> | ||
Column( | ||
modifier = modifier.padding(innerPadding) | ||
) { | ||
Text( | ||
text = "LearnFlashCardScreen", | ||
style = MaterialTheme.typography.bodyLarge | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun LearnFlashCardScreenPreview() { | ||
MaterialTheme { | ||
LearnFlashCard() | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...n/java/com/pwhs/quickmem/presentation/app/study_set/study/learn/LearnFlashCardUiAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.learn | ||
|
||
sealed class LearnFlashCardUiAction { | ||
} |
4 changes: 4 additions & 0 deletions
4
...in/java/com/pwhs/quickmem/presentation/app/study_set/study/learn/LearnFlashCardUiEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.learn | ||
|
||
sealed class LearnFlashCardUiEvent { | ||
} |
5 changes: 5 additions & 0 deletions
5
...in/java/com/pwhs/quickmem/presentation/app/study_set/study/learn/LearnFlashCardUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.learn | ||
|
||
data class LearnFlashCardUiState( | ||
val isLoading: Boolean = false, | ||
) |
22 changes: 22 additions & 0 deletions
22
.../java/com/pwhs/quickmem/presentation/app/study_set/study/learn/LearnFlashCardViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.pwhs.quickmem.presentation.app.study_set.study.learn | ||
|
||
import androidx.lifecycle.ViewModel | ||
import kotlinx.coroutines.channels.Channel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.receiveAsFlow | ||
import javax.inject.Inject | ||
|
||
class LearnFlashCardViewModel @Inject constructor() : ViewModel() { | ||
private val _uiState = MutableStateFlow(LearnFlashCardUiState()) | ||
val uiState = _uiState.asStateFlow() | ||
|
||
private val _uiEvent = Channel<LearnFlashCardUiEvent>() | ||
val uiEvent = _uiEvent.receiveAsFlow() | ||
|
||
fun onEvent(event: LearnFlashCardUiEvent) { | ||
when (event) { | ||
else -> {} | ||
} | ||
} | ||
} |
Oops, something went wrong.