import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../currentUser.dart'; import 'datatable.dart'; class RankingNavigation extends StatefulWidget { const RankingNavigation({Key? key}) : super(key: key); @override State createState() => _RankingNavigationState(); } class _RankingNavigationState extends State { int _selectedIndex = 0; static const List _widgetOptions = [ MyDataTable(name: 'daily_points'), MyDataTable(name: 'weekly_points'), MyDataTable(name: 'total_points'), ]; static const List _widgetOptions2 = [ CurrentUser(name: 'daily_points'), CurrentUser(name: 'weekly_points'), CurrentUser(name: 'total_points'), ]; void _onItemTapped(int index) { setState(() { _selectedIndex = index; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( toolbarHeight: 50, title: const Text('Ranking'), ), body: SafeArea( child: Column( children: [ SizedBox( height: 350, child:_widgetOptions.elementAt(_selectedIndex), ), Container( child:_widgetOptions2.elementAt(_selectedIndex), ) ], ) ), bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( icon: Icon(Icons.event), label: 'Daily', ), BottomNavigationBarItem( icon: Icon(Icons.event), label: 'Weekly', ), BottomNavigationBarItem( icon: Icon(Icons.event), label: 'Monthly', ), ], currentIndex: _selectedIndex, selectedItemColor: Colors.amber[800], onTap: _onItemTapped, ), ); } }