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

Scroll to first checked custom location on open #7870

Merged

Conversation

kl
Copy link
Contributor

@kl kl commented Mar 24, 2025


This change is Reviewable

Copy link

linear bot commented Mar 24, 2025

@kl kl added the Android Issues related to Android label Mar 24, 2025
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt line 183 at r1 (raw file):

            }

            lazyListState.ScrollToFirstCheckedItem(state)

We hide away the Launched effect a bit here I feel like. It would be nice to have it one the top level if possible.

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @kl)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt line 247 at r1 (raw file):

        LaunchedEffect(Unit) {
            if (firstChecked != -1) {
                scrollToItem(firstChecked)

In select location we also have the animateScrollAndCentralizeItem function which we could use here also if we make it public and move it somewhere.

@kl kl force-pushed the custom-list-location-should-scroll-to-the-first-selected-droid-1609 branch from 254b02b to 2fe917f Compare March 24, 2025 13:33
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @kl and @Pururun)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt line 247 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

In select location we also have the animateScrollAndCentralizeItem function which we could use here also if we make it public and move it somewhere.

Does this one animate? Or just scroll to it? Not sure what we want though 🙃

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @kl and @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt line 247 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

Does this one animate? Or just scroll to it? Not sure what we want though 🙃

IIRC animateScrollAndCentralizeItem is so that the item is centered and not at the top. Why we need both is a bit of mystery to me as well,

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on @kl and @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt line 247 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

IIRC animateScrollAndCentralizeItem is so that the item is centered and not at the top. Why we need both is a bit of mystery to me as well,

Just checked and without scrollToItem you get this weird flickering and without animateScrollAndCentralizeItem it will just show the scrolled to item at the top of the list so I think both are required.

@kl kl force-pushed the custom-list-location-should-scroll-to-the-first-selected-droid-1609 branch from 2fe917f to abf5001 Compare March 25, 2025 10:46
Copy link
Contributor Author

@kl kl left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @Pururun and @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt line 183 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

We hide away the Launched effect a bit here I feel like. It would be nice to have it one the top level if possible.

Done.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/CustomListLocationsScreen.kt line 247 at r1 (raw file):

Previously, Pururun (Jonatan Rhodin) wrote…

Just checked and without scrollToItem you get this weird flickering and without animateScrollAndCentralizeItem it will just show the scrolled to item at the top of the list so I think both are required.

Done.

Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/extensions/LazyListExtensions.kt line 45 at r3 (raw file):

    }

suspend fun LazyListState.animateScrollAndCentralizeItem(index: Int) {

Nice

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kl)

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kl)

@Rawa Rawa force-pushed the custom-list-location-should-scroll-to-the-first-selected-droid-1609 branch from abf5001 to c35a459 Compare March 25, 2025 13:59
@Rawa Rawa merged commit 226d5f1 into main Mar 25, 2025
24 of 25 checks passed
@Rawa Rawa deleted the custom-list-location-should-scroll-to-the-first-selected-droid-1609 branch March 25, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants