This file contains hidden or 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
interface ListScreenContract { | |
val editButtonTitle: String | |
val isAddButtonVisible: Boolean | |
val isEditNameMode: Boolean | |
val isTableVisible: Boolean | |
fun print() = | |
"${javaClass.simpleName} [$editButtonTitle|$isAddButtonVisible|$isEditNameMode|$isTableVisible]" | |
} |
This file contains hidden or 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
@Preview | |
@Composable | |
fun TestStudyCardView() { | |
val data = arrayListOf( | |
StudyCard(0, "1$LOREM_IPSUM_FRONT", "1$LOREM_IPSUM_BACK"), | |
StudyCard(1, "2$LOREM_IPSUM_FRONT", "2$LOREM_IPSUM_BACK"), | |
StudyCard(2, "3$LOREM_IPSUM_FRONT", "3$LOREM_IPSUM_BACK"), | |
StudyCard(3, "4$LOREM_IPSUM_FRONT", "4$LOREM_IPSUM_BACK"), | |
StudyCard(4, "5$LOREM_IPSUM_FRONT", "5$LOREM_IPSUM_BACK"), | |
StudyCard(5, "6$LOREM_IPSUM_FRONT", "6$LOREM_IPSUM_BACK") |
This file contains hidden or 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
enum class CardFlipState { | |
FRONT_FACE, FLIP_BACK, BACK_FACE, FLIP_FRONT | |
} | |
enum class CardSwipeState { | |
INITIAL, SWIPED, DRAGGING | |
} | |
const val animationTime = 350 | |
private const val TOP_CARD_INDEX = 0 | |
private const val TOP_Z_INDEX = 100f |
This file contains hidden or 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
data class StudyCardDeckEvents( | |
val cardWidth: Float, | |
val cardHeight: Float, | |
val model: StudyCardDeckModel, | |
val peepHandler: () -> Unit, | |
val playHandler: (String, String) -> Unit, | |
val nextHandler: () -> Unit, | |
val actionCallback: (String) -> Unit = {} | |
) { | |
val cardSwipe: CardSwipeAnimation = CardSwipeAnimation( |
This file contains hidden or 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
data class StudyCardDeckModel( | |
var current: Int, | |
val dataSource: List<StudyCard>, | |
val visible: Int = 3, | |
val screenWidth: Int, | |
val screenHeight: Int | |
) { | |
private val colors = arrayOf(primaryColor, secondaryColor, tertiaryColor) | |
val count = dataSource.size | |
val visibleCards: Int = StrictMath.min(visible, dataSource.size - current) |
This file contains hidden or 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
data class CardsInDeckAnimation( | |
val paddingOffset: Float, | |
val count: Int = 3 | |
) { | |
private lateinit var scaleCards: List<MutableState<Float>> | |
private lateinit var offsetCards: List<MutableState<Float>> | |
private fun calculateScale(idx: Int): Float { | |
return 1f - idx * (1f / 10f) | |
} |
This file contains hidden or 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
data class CardSwipeAnimation( | |
val model: StudyCardDeckModel, | |
val cardWidth: Float, | |
val cardHeight: Float | |
) { | |
private lateinit var cardDragOffset: Animatable<Offset, AnimationVector2D> | |
@Composable | |
fun Init() { | |
cardDragOffset = remember { |
This file contains hidden or 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
data class FlipCardAnimation( | |
val peepHandler: () -> Unit | |
) { | |
private lateinit var flipState: MutableState<CardFlipState> | |
private lateinit var scaleXAnimation: State<Float> | |
private lateinit var scaleYAnimation: State<Float> | |
@Composable | |
fun Init() { | |
flipState = remember { mutableStateOf(CardFlipState.FRONT_FACE) } |
This file contains hidden or 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
val data = arrayListOf( | |
StudyCard(0, "1$LOREM_IPSUM_FRONT", "1$LOREM_IPSUM_BACK"), | |
StudyCard(1, "2$LOREM_IPSUM_FRONT", "2$LOREM_IPSUM_BACK"), | |
StudyCard(2, "3$LOREM_IPSUM_FRONT", "3$LOREM_IPSUM_BACK"), | |
StudyCard(3, "4$LOREM_IPSUM_FRONT", "4$LOREM_IPSUM_BACK"), | |
StudyCard(4, "5$LOREM_IPSUM_FRONT", "5$LOREM_IPSUM_BACK"), | |
StudyCard(5, "6$LOREM_IPSUM_FRONT", "6$LOREM_IPSUM_BACK") | |
) | |
@Preview |
This file contains hidden or 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
@Composable | |
fun StudyCardDeck( | |
current: Int, | |
visible: Int, | |
dataSource: List<StudyCard> | |
) { | |
val topCardIdx = 0 | |
val count = dataSource.size | |
val visibleCards: Int = StrictMath.min(visible, dataSource.size - current) |