This commit is contained in:
Developer
2026-03-31 05:42:47 +08:00
parent 888363785b
commit d6ac0ed1e4
18 changed files with 751 additions and 170 deletions

View File

@@ -19,12 +19,14 @@ class MainNavigation extends StatefulWidget {
class _MainNavigationState extends State<MainNavigation> {
int _currentIndex = 0;
final GlobalKey<State<ProfilePage>> _profileKey =
GlobalKey<State<ProfilePage>>();
final List<Widget> _pages = [
late final List<Widget> _pages = [
const HomePage(),
const DiscoverPage(),
const FavoritesPage(),
const ProfilePage(),
ProfilePage(key: _profileKey),
];
final List<BottomNavigationBarItem> _bottomNavItems = [
@@ -73,6 +75,13 @@ class _MainNavigationState extends State<MainNavigation> {
setState(() {
_currentIndex = index;
});
// 切换到个人页面时刷新数据
if (index == 3) {
final profileState = _profileKey.currentState;
if (profileState != null && profileState.mounted) {
(profileState as dynamic).refreshData();
}
}
},
type: BottomNavigationBarType.fixed,
selectedItemColor: AppConstants.primaryColor,