nav_bar_page.dart 2.12 KB
import 'package:Parlando/account/page/account_page.dart';
import 'package:Parlando/home/home_page.dart';
import 'package:Parlando/poem/theme/tik_theme.dart';
import 'package:flutter/material.dart';

class NavBarPage extends StatefulWidget {
  const NavBarPage({Key? key, required this.initialPage}) : super(key: key);

  final String initialPage;

  @override
  NavBarPageState createState() => NavBarPageState();
}

/// This is the private State class that goes with NavBarPage.
class NavBarPageState extends State<NavBarPage> {
  String _currentPage = 'HomePage';

  @override
  void initState() {
    super.initState();
    _currentPage = widget.initialPage;
  }

  @override
  Widget build(BuildContext context) {
    final tabs = {
      'HomePage': const Home(),
      'UploadStatusPage': const AccountPage(),
      'UserProfile': const AccountPage(),
    };
    return Scaffold(
      body: tabs[_currentPage],
      bottomNavigationBar: BottomNavigationBar(
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Icon(
              Icons.home_filled,
              size: 24,
            ),
            label: 'Home',
            tooltip: '',
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.add_circle_outline_rounded,
              size: 50,
            ),
            activeIcon: Icon(
              Icons.add_circle_rounded,
              size: 50,
            ),
            label: '',
            tooltip: '',
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.person_rounded,
              size: 26,
            ),
            label: 'Profile',
            tooltip: '',
          )
        ],
        backgroundColor: TikTheme.tertiaryColor,
        currentIndex: tabs.keys.toList().indexOf(_currentPage),
        selectedItemColor: TikTheme.primaryColor,
        unselectedItemColor: const Color(0x53FFFFFF),
        onTap: (i) => setState(() => _currentPage = tabs.keys.toList()[i]),
        showSelectedLabels: true,
        showUnselectedLabels: true,
        type: BottomNavigationBarType.fixed,
      ),
    );
  }
}