added changing appbar title for each tab
This commit is contained in:
@@ -32,6 +32,14 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
title: Text(
|
||||||
|
_currentTabTitle(),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
scrolledUnderElevation: 0,
|
scrolledUnderElevation: 0,
|
||||||
actions: [
|
actions: [
|
||||||
@@ -83,7 +91,7 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
|||||||
const SizedBox(width: 40),
|
const SizedBox(width: 40),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.group,
|
Icons.groups,
|
||||||
color: currentIndex == 2 ? Colors.white : Colors.black,
|
color: currentIndex == 2 ? Colors.white : Colors.black,
|
||||||
),
|
),
|
||||||
onPressed: () => onTabTapped(2),
|
onPressed: () => onTabTapped(2),
|
||||||
@@ -106,4 +114,18 @@ class _CustomNavigationBarState extends State<CustomNavigationBar>
|
|||||||
currentIndex = index;
|
currentIndex = index;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
String _currentTabTitle() {
|
||||||
|
switch (currentIndex) {
|
||||||
|
case 0:
|
||||||
|
return 'Home';
|
||||||
|
case 1:
|
||||||
|
return 'Game History';
|
||||||
|
case 2:
|
||||||
|
return 'Groups';
|
||||||
|
case 3:
|
||||||
|
return 'Statistics';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user