build method
- BuildContext context
override
Builds the main dashboard UI with navigation tabs and conditional tutorial overlays.
Implementation
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: SliderAppBar(
title: _getPageTitle(),
showBackButton: false,
showDarkModeToggle: true,
showStreak: true,
showFavoriteIcon: true,
subtitle: 'FitOffice@DHBW',
onToggleFavorite: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ExerciseFilter(
heading: AppLocalizations.of(context)!.tFavorites,
showOnlyFavorites: true,
),
),
).then((_) {
_loadUserFavorites();
_categoriesKey.currentState?.refreshData();
});
},
),
body: Stack(
children: [
/// Displays one of the four main screens based on [selectedIndex].
IndexedStack(
index: selectedIndex,
children: [
// 0: Progress Screen
ProgressScreen(),
// 1: Exercise Library TODO: Add Obx() support to update User Infos directly as Olison in ProfilScreen did.
LibraryScreen(),
// 2: Statistics Screen
StatisticScreen(),
// 3: Friends
ProfileScreen(),
],
),
/// Conditionally renders the full-screen tutorial overlay.
if (_isShowingTutorial)
Positioned(
top: 0,
left: 0,
child: Container(
key: _fullscreenDummyKey,
width: 0,
height: 0,
decoration: BoxDecoration(
color: Get.context?.theme.brightness == Brightness.dark
? const Color.fromARGB(204, 0, 0, 0)
: const Color(0xFF333333),
),
),
),
],
),
/// Bottom navigation bar for switching between tabs.
bottomNavigationBar: BottomNavigationBar(
currentIndex: selectedIndex,
onTap: (index) {
FocusScope.of(context).unfocus();
setState(() {
selectedIndex = index;
});
},
type: BottomNavigationBarType.fixed,
selectedItemColor: tBottomNavBarSelectedColor,
unselectedItemColor: tBottomNavBarUnselectedColor,
items: [
BottomNavigationBarItem(
icon: Container(key: _progressTabKey, child: Icon(Icons.route)),
label: AppLocalizations.of(context)!.tProgress,
),
BottomNavigationBarItem(
icon: Icon(Icons.book, key: _libraryTabKey),
label: AppLocalizations.of(context)!.tLibrary,
),
BottomNavigationBarItem(
icon: Icon(Icons.insert_chart, key: _statisticsTabKey),
label: AppLocalizations.of(context)!.tStatistics,
),
BottomNavigationBarItem(
icon: Icon(Icons.person, key: _profileTabKey),
label: AppLocalizations.of(context)!.tProfile,
),
],
),
);
}