Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTAPPS-1346: Shared, iOS code blanks elif else statements #1176

Merged
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
29ab75c
Always enable delete button for Variable name
ivan-magda Sep 3, 2024
eb5fd98
Update iOS code blanks files structure
ivan-magda Sep 3, 2024
ce22769
Add StepQuizCodeBlanksIfStatementView
ivan-magda Sep 3, 2024
6be2ddf
Add if statement suggestion
ivan-magda Sep 4, 2024
584ba59
Display if statement code block
ivan-magda Sep 4, 2024
0b40dd4
Add indentLevel
ivan-magda Sep 4, 2024
5e3bc14
Add decrease indent level button
ivan-magda Sep 5, 2024
149e1a7
Handle decrease indent level button clicked
ivan-magda Sep 5, 2024
551a818
Update delete logic
ivan-magda Sep 5, 2024
1b1b223
Fix tests
ivan-magda Sep 5, 2024
4ac4cf0
Merge remote-tracking branch 'origin/develop' into feature/ALTAPPS-13…
ivan-magda Sep 5, 2024
f4eaa81
Fix isDeleteButtonEnabled for IfStatement
ivan-magda Sep 5, 2024
a6465ae
Add suggestions
ivan-magda Sep 6, 2024
68930b1
Render new elif and else statements
ivan-magda Sep 6, 2024
f818445
Handle new conditions logic
ivan-magda Sep 6, 2024
bb151d5
Handle indentation level when building reply
ivan-magda Sep 9, 2024
5652c74
Test DecreaseIndentLevelButtonClicked
ivan-magda Sep 9, 2024
1dd3f98
Merge branch 'feature/ALTAPPS-1340/Shared-iOS-Code-blanks-conditions'…
ivan-magda Sep 10, 2024
5895533
Merge branch 'develop' into feature/ALTAPPS-1340/Shared-iOS-Code-blan…
ivan-magda Sep 10, 2024
3e0dbdb
Merge branch 'feature/ALTAPPS-1340/Shared-iOS-Code-blanks-conditions'…
ivan-magda Sep 10, 2024
8bd9216
Add view state tests
ivan-magda Sep 10, 2024
1cc353e
Merge branch 'feature/ALTAPPS-1340/Shared-iOS-Code-blanks-conditions'…
ivan-magda Sep 11, 2024
627b5dd
Fix tests
ivan-magda Sep 11, 2024
32f36ad
Refactor tests
ivan-magda Sep 11, 2024
e485efe
Merge remote tracking branch origin/feature/ALTAPPS-1340/Shared-iOS-C…
ivan-magda Sep 11, 2024
4c2c708
Fix tests
ivan-magda Sep 11, 2024
ca7b82f
Add helpers for copy code block
ivan-magda Sep 11, 2024
e4952b0
Merge remote tracking branch origin/feature/ALTAPPS-1340/Shared-iOS-C…
ivan-magda Sep 11, 2024
f1802b9
Update StepQuizCodeBlanksReducerSuggestionClickedTest
ivan-magda Sep 11, 2024
3209444
Update StepQuizCodeBlanksReducerCodeBlockClickedTest
ivan-magda Sep 11, 2024
d938052
Update StepQuizCodeBlanksReducerCodeBlockChildClickedTest
ivan-magda Sep 11, 2024
282bf3e
Update StepQuizCodeBlanksReducerDeleteButtonClickedTest
ivan-magda Sep 11, 2024
f511bf4
Update StepQuizCodeBlanksReducerEnterButtonClickedTest
ivan-magda Sep 11, 2024
a087399
Update StepQuizCodeBlanksReducerSpaceButtonClickedTest
ivan-magda Sep 11, 2024
90a7bf1
Update StepQuizCodeBlanksReducerDecreaseIndentLevelButtonClickedTest
ivan-magda Sep 11, 2024
83e3c44
Merge remote tracking branch origin/develop
ivan-magda Sep 12, 2024
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
Prev Previous commit
Next Next commit
Update delete logic
  • Loading branch information
ivan-magda committed Sep 5, 2024
commit 551a81839a3c8621a9f969fa63528e2b9cd4f828
Original file line number Diff line number Diff line change
@@ -23,6 +23,12 @@ sealed class CodeBlock {
internal fun activeChildIndex(): Int? =
children.indexOfFirstOrNull { it.isActive }

internal fun areAllChildrenUnselected(): Boolean =
children.all { it is CodeBlockChild.SelectSuggestion && it.selectedSuggestion == null }

internal fun hasAnySelectedChild(): Boolean =
children.any { it is CodeBlockChild.SelectSuggestion && it.selectedSuggestion != null }

internal data class Blank(
override val isActive: Boolean,
override val indentLevel: Int,
Original file line number Diff line number Diff line change
@@ -413,7 +413,7 @@ class StepQuizCodeBlanksReducer(
)
)

activeChildIndex == 0 || activeCodeBlock.children.all { it.selectedSuggestion == null } ->
activeChildIndex == 0 || activeCodeBlock.areAllChildrenUnselected() ->
if (state.codeBlocks.size > 1) {
removeActiveCodeBlockAndSetNextActive()
} else {
@@ -425,6 +425,8 @@ class StepQuizCodeBlanksReducer(
val activeChildIndex = activeCodeBlock.activeChildIndex() ?: return@mutate
val activeChild = activeCodeBlock.children[activeChildIndex]

val nextCodeBlock = state.codeBlocks.getOrNull(activeCodeBlockIndex + 1)

when {
activeChild.selectedSuggestion != null ->
set(
@@ -452,6 +454,14 @@ class StepQuizCodeBlanksReducer(
}
)
)

(activeChildIndex == 0 || activeCodeBlock.areAllChildrenUnselected()) &&
(nextCodeBlock?.let { it.indentLevel == activeCodeBlock.indentLevel } ?: true) ->
if (state.codeBlocks.size > 1) {
removeActiveCodeBlockAndSetNextActive()
} else {
replaceActiveCodeWithBlank()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -40,22 +40,25 @@ object StepQuizCodeBlanksViewStateMapper {
val isDeleteButtonEnabled =
when (activeCodeBlock) {
is CodeBlock.Blank -> codeBlocks.size > 1
is CodeBlock.Print,
is CodeBlock.IfStatement -> true
is CodeBlock.Print -> true
is CodeBlock.Variable -> {
activeCodeBlock.activeChildIndex()?.let { activeChildIndex ->
when {
activeChildIndex == 0 || activeChildIndex > 1 ->
true

activeCodeBlock.children[activeChildIndex].selectedSuggestion == null &&
activeCodeBlock.children.any { it.selectedSuggestion != null } ->
activeCodeBlock.hasAnySelectedChild() ->
false

else -> true
}
} ?: false
}
is CodeBlock.IfStatement ->
codeBlocks.getOrNull(activeCodeBlockIndex + 1)?.let {
it.indentLevel == activeCodeBlock.indentLevel
} ?: true
null -> false
}