Skip to content

Use the material3 pull-to-refresh instead of accompanist (3 commits: swap LoadingContent to PullToRefreshBox; drop the accompanist dependency and declare androidx.appcompat explicitly since it was only coming in transitively; remove the leftover ScrollChildSwipeRefreshLayout styleable) - #1078

Open
rootkiller6788 wants to merge 3 commits into
android:mainfrom
rootkiller6788:use-m3-pull-to-refresh

Conversation

@rootkiller6788

Copy link
Copy Markdown

The tasks, statistics and task detail screens pull to refresh through Accompanist's SwipeRefresh, via LoadingContent in util/ComposeUtils.kt. The add/edit screen got moved to the material3 PullToRefreshBox back in the M3 pass, so this is the last Accompanist usage left in the app.

I swapped LoadingContent over to PullToRefreshBox. The signature is unchanged, so the three callers don't need touching, and the refresh semantics are the same: the indicator follows the loading flag and onRefresh is passed straight through. Only the indicator itself looks different now, since PullToRefreshBox overlays it instead of laying it out.

Then dropped the accompanist dependency (and the catalog entries for it, including three aliases that were already unused).

One thing worth flagging there: accompanist-appcompat-theme was the only thing putting androidx.appcompat on the classpath, and the app theme in values/styles.xml extends Theme.AppCompat.Light.NoActionBar. So removing it on its own would break resource linking. I declared androidx.appcompat directly instead - the version catalog already had the alias at 1.7.0, it just wasn't referenced anywhere. Better to have it explicit than borrowed from a library we don't use.

Also deleted values/attrs.xml. It only declares a refreshing attr for ScrollChildSwipeRefreshLayout, a custom view from the old Views version of the app - neither the class nor any layout exists any more, and nothing references the styleable.

I left the empty state alone, so it still doesn't offer a pull to refresh. That's #916 and it has its own PR, didn't want to bundle it in here.

How I checked it: I don't have an Android SDK on this machine, so I verified offline rather than by running the tests. Pulled compose-bom 2024.12.01's pom to confirm it resolves material3 1.3.1, then javap'd the real PullToRefreshBox signature out of the material3-android aar to make sure the parameter names/order I used line up. Grepped for any remaining accompanist reference (only build files and ComposeUtils had them) and for ScrollChildSwipeRefreshLayout (only attrs.xml). The appcompat transitive dependency I confirmed from the actual accompanist-appcompat-theme-0.36.0.pom.

A CI run of the tasks / statistics / task detail screen tests would be the real confirmation - I couldn't do that here.

The add/edit screen was moved to PullToRefreshBox during the M3 pass but
ComposeUtils was left on Accompanist's SwipeRefresh, so the tasks,
statistics and task detail screens were still using the deprecated one.
Same behaviour: the indicator follows the loading flag and onRefresh is
passed straight through.
Nothing imports com.google.accompanist any more now that LoadingContent
uses PullToRefreshBox, so the last two entries go too. The three remaining
catalog aliases (flowlayout, systemuicontroller, testharness) were already
unused.

One catch: accompanist-appcompat-theme was the only thing pulling
androidx.appcompat onto the classpath, and the app theme in styles.xml is
Theme.AppCompat.Light.NoActionBar. So appcompat gets declared directly
instead of being borrowed from a library we no longer use. The catalog
already had the alias pointing at 1.7.0.
It declares a refreshing attr for a custom SwipeRefreshLayout subclass
from the old Views version of the app. That class and the layouts are
long gone, and nothing references the styleable, so the whole file goes.
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