rankingNavigation.dart 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import '../currentUser.dart';
  4. import 'datatable.dart';
  5. class RankingNavigation extends StatefulWidget {
  6. const RankingNavigation({Key? key}) : super(key: key);
  7. @override
  8. State<RankingNavigation> createState() => _RankingNavigationState();
  9. }
  10. class _RankingNavigationState extends State<RankingNavigation> {
  11. int _selectedIndex = 0;
  12. static const List<Widget> _widgetOptions = <Widget>[
  13. MyDataTable(name: 'daily_points'),
  14. MyDataTable(name: 'weekly_points'),
  15. MyDataTable(name: 'total_points'),
  16. ];
  17. static const List<Widget> _widgetOptions2 = <Widget>[
  18. CurrentUser(name: 'daily_points'),
  19. CurrentUser(name: 'weekly_points'),
  20. CurrentUser(name: 'total_points'),
  21. ];
  22. void _onItemTapped(int index) {
  23. setState(() {
  24. _selectedIndex = index;
  25. });
  26. }
  27. @override
  28. Widget build(BuildContext context) {
  29. return Scaffold(
  30. appBar: AppBar(
  31. toolbarHeight: 50,
  32. title: const Text('Ranking'),
  33. ),
  34. body: SafeArea(
  35. child: Column(
  36. children: [
  37. SizedBox(
  38. height: 350,
  39. child:_widgetOptions.elementAt(_selectedIndex),
  40. ),
  41. Container(
  42. child:_widgetOptions2.elementAt(_selectedIndex),
  43. )
  44. ],
  45. )
  46. ),
  47. bottomNavigationBar: BottomNavigationBar(
  48. items: const <BottomNavigationBarItem>[
  49. BottomNavigationBarItem(
  50. icon: Icon(Icons.event),
  51. label: 'Daily',
  52. ),
  53. BottomNavigationBarItem(
  54. icon: Icon(Icons.event),
  55. label: 'Weekly',
  56. ),
  57. BottomNavigationBarItem(
  58. icon: Icon(Icons.event),
  59. label: 'Monthly',
  60. ),
  61. ],
  62. currentIndex: _selectedIndex,
  63. selectedItemColor: Colors.amber[800],
  64. onTap: _onItemTapped,
  65. ),
  66. );
  67. }
  68. }