Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
fix(profile_page): tab and pages not being synced
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Nov 20, 2021
1 parent 6ad4b51 commit 485942f
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions lib/ui/components/trackers/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,6 @@ class _ProfilePageState extends State<ProfilePage>
void initState() {
super.initState();

tabController.addListener(() async {
if (tabController.index != pageController.page &&
pageController.hasClients) {
await pageController.animateToPage(
tabController.index,
duration: Defaults.animationsSlower,
curve: Curves.easeInOut,
);
}
});

pageController.addListener(() {
if (tabController.index != pageController.page) {
tabController.animateTo(pageController.page!.toInt());
}
});

onReady(() async {
final dynamic _user = await widget.getUserInfo();

Expand Down Expand Up @@ -150,6 +133,13 @@ class _ProfilePageState extends State<ProfilePage>
tabs: tabs,
labelColor: Theme.of(context).textTheme.bodyText1?.color,
indicatorColor: Theme.of(context).primaryColor,
onTap: (final int index) async {
await pageController.animateToPage(
index,
duration: Defaults.animationsSlower,
curve: Curves.easeInOut,
);
},
);

return Scaffold(
Expand Down Expand Up @@ -197,6 +187,9 @@ class _ProfilePageState extends State<ProfilePage>
itemCount: tabs.length,
itemBuilder: (final BuildContext context, final int index) =>
widget.getMediaList(widget.tabs[index]),
onPageChanged: (final int page) {
tabController.animateTo(page);
},
),
),
)
Expand Down

0 comments on commit 485942f

Please sign in to comment.