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

WIP dual backstack #5

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from
Open

WIP dual backstack #5

wants to merge 2 commits into from

Conversation

LachlanMcKee
Copy link
Owner

Description

...

Check list

  • I have updated CHANGELOG.md if required.
  • I have updated documentation if required.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 19 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 12 potential problems in the proposed changes. Check the Files changed tab for more details.


override fun isApplicable(elements: DualBackStackElements<T>): Boolean = true

override fun invoke(

Check warning

Code scanning / detekt

Prefer splitting up complex methods into smaller, easier to understand methods.

The function invoke appears to be too complex (17). Defined complexity threshold for methods is set to '15'
Comment on lines +39 to +40
if (previousElement != null && previousElement.eitherState(Active1) &&
(element.eitherState(StashedInBackStack2) || element.eitherState(Active2))

Check warning

Code scanning / detekt

Complex conditions should be simplified and extracted into well-named methods if necessary.

This condition is too complex (4). Defined complexity threshold for conditions is set to '4'
Comment on lines +62 to +64
if (twoPanelsEnabled &&
(element.eitherState(StashedInBackStack2) || element.eitherState(Active2)) &&
previousElement != null && previousElement.eitherState(StashedInBackStack1)

Check warning

Code scanning / detekt

Complex conditions should be simplified and extracted into well-named methods if necessary.

This condition is too complex (5). Defined complexity threshold for conditions is set to '4'
Comment on lines +60 to +87
while (listIterator.hasNext()) {
val index = listIterator.nextIndex()
val element = listIterator.next()

if (element.targetState == Active1) {
listIterator.remove()

check(index != 0) { "Cannot pop the last active left panel" }

val stashedPanel1 = listIterator.previous()
listIterator.set(
stashedPanel1.transitionTo(
newTargetState = Active1,
operation = this
)
)
break

} else if (element.targetState == StashedInBackStack2 || element.targetState == Active2) {
// In this case there was no active panel 1, so we are not in 'two panel' mode.
check(index > 1) { "Cannot pop the last active left panel" }

listIterator.previous()
listIterator.previous()
listIterator.remove()
break
}
}

Check warning

Code scanning / detekt

The loop contains more than one break or continue statement. The code should be refactored to increase readability.

The loop contains more than one break or continue statement. The code should be refactored to increase readability.
Comment on lines +33 to +78
while (listIterator.hasNext()) {
val index = listIterator.nextIndex()
val element = listIterator.next()
val isLast = index == newElementsList.lastIndex

if (!twoPanelsEnabled) {
if (previousElement != null && previousElement.eitherState(Active1) &&
(element.eitherState(StashedInBackStack2) || element.eitherState(Active2))
) {
// We must call previous twice to actually go back to the previous element.
listIterator.previous()
val stashedBackStackElement = listIterator.previous()
listIterator.set(
stashedBackStackElement.transitionTo(
newTargetState = StashedInBackStack1,
operation = this
)
)
break
} else if (isLast && element.eitherState(StashedInBackStack1)) {
listIterator.set(
element.transitionTo(
newTargetState = Active1,
operation = this
)
)
break
}
}
if (twoPanelsEnabled &&
(element.eitherState(StashedInBackStack2) || element.eitherState(Active2)) &&
previousElement != null && previousElement.eitherState(StashedInBackStack1)
) {
// We must call previous twice to actually go back to the previous element.
listIterator.previous()
val stashedBackStackElement = listIterator.previous()
listIterator.set(
stashedBackStackElement.transitionTo(
newTargetState = Active1,
operation = this
)
)
break
}
previousElement = element
}

Check warning

Code scanning / detekt

The loop contains more than one break or continue statement. The code should be refactored to increase readability.

The loop contains more than one break or continue statement. The code should be refactored to increase readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant