Index_page.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import 'package:common_project/public_view/test_page.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:common_project/common_project.dart';
  5. import 'package:module_chat/view/enter_room_page.dart';
  6. import 'package:module_home/view/home_index_page.dart';
  7. import 'package:module_home/view/home_main_page.dart';
  8. import 'package:module_im/view/message_dynamic/message_dynamic_list.dart';
  9. import 'package:module_im/view/message_list_view/conversation_page.dart';
  10. import 'package:module_im/view/message_list_view/message_conversation_page.dart';
  11. import 'package:module_im/view/message_notification_page.dart';
  12. import 'package:module_login/view/login_index_page.dart';
  13. import 'package:module_me/view/me_index_page.dart';
  14. import 'package:module_home/view/center_open_chat_page.dart';
  15. import 'package:module_chat/text_page/chat_init_page.dart';
  16. import 'package:module_chat/view/chat_room_index_page.dart';
  17. import 'package:module_im/view/textRecorder.dart';
  18. import 'package:module_me/view/me_main_page.dart';
  19. import 'package:module_me/view/me_voice_room_page.dart';
  20. import 'package:module_im/view/message_dynamic/message_dynamic_index.dart';
  21. class IndexPage extends StatefulWidget {
  22. @override
  23. _IndexPageState createState() => _IndexPageState();
  24. }
  25. class _IndexPageState extends State<IndexPage> {
  26. //tab页面数组
  27. List <Widget> tabPages=[
  28. // HomeIndexPage(),
  29. HomeMainPage(),
  30. // TestPage(),
  31. // ConversationPage({"coversationType":1,"targetId":"418663664451584"}),
  32. // MessageConversationPage(1,'418663664451584'),
  33. // MessageDynamicListPage(),
  34. MessageDynamicIndex(),
  35. CenterOpenChatPage(),
  36. MessageNotificationPage(),
  37. // ChatRoomIndexPage("13213"),
  38. // EnterRoomPage(),
  39. MeIndexPage(),
  40. //MeVoiceRoomPage(),
  41. // MeMainPage(null),
  42. // LoginIndexPage()
  43. // TextRecorder(),
  44. ];
  45. List bottomNavigationTitleList=['首页','我的',"房间","录音测试",];
  46. List bottomNavigationIconList=[Icon(Icons.home),Icon(Icons.add),Icon(Icons.ac_unit_rounded),Icon(Icons.animation)];
  47. //tab图标数组
  48. List <BottomNavigationBarItem> bottomNavigationList=[
  49. // BottomNavigationBarItem(icon: Icon(Icons.home),title: Text('首页')),
  50. // BottomNavigationBarItem(icon: Icon(Icons.add),title: Text('我的'))
  51. ];
  52. // int currentIndex = 0;
  53. @override
  54. void initState() {
  55. // TODO: implement initState
  56. // if(SpUtil.getString(SPKeys.loginInfo) != ""){
  57. //
  58. // Application.navigateTo(context: GlobalConstKey.getContext(), route: RouterPath().loginIndex);
  59. //
  60. // }
  61. super.initState();
  62. //
  63. for(int i=0;i<bottomNavigationTitleList.length;i++){
  64. bottomNavigationList.add( BottomNavigationBarItem(icon: bottomNavigationIconList[i],label: bottomNavigationTitleList[i]),);
  65. }
  66. }
  67. @override
  68. Widget build(BuildContext context) {
  69. return Builder(builder: (context){
  70. int currentIndex = context.select((TabIndexCubit value) => value.state.currentIndex! as int);
  71. TabIndexCubit cubit = BlocProvider.of<TabIndexCubit>(context);
  72. context.select((TabIndexCubit value) => cubit.state.timeStr);
  73. return Scaffold(
  74. backgroundColor: Theme.of(context).primaryColor,
  75. body: IndexedStack(
  76. index: currentIndex,
  77. children: tabPages,
  78. ),
  79. bottomNavigationBar: BottomNavigationBar(
  80. backgroundColor: Colors.white,
  81. type: BottomNavigationBarType.fixed,
  82. fixedColor: HexColor.fromHex("#6A00FE"),
  83. items: cubit.state.items as List<BottomNavigationBarItem>,
  84. currentIndex: currentIndex,
  85. onTap: (index){
  86. if(index!=currentIndex) { //过滤重复点击 导航栏
  87. if(index==2){
  88. DialogAddWidget(
  89. context: context,
  90. gravity: Gravity.bottom,
  91. decoration: BoxDecoration(
  92. color: Colors.transparent
  93. ),
  94. borderRadius: 0.0,
  95. barrierColor: Color(0xCC000000),
  96. backgroundColor: Color(0x80000000),
  97. widget: BeganGoPage(),
  98. );
  99. }else{
  100. context.read<TabIndexCubit>().changPage(index);
  101. }
  102. }
  103. },
  104. ),
  105. );
  106. });
  107. }
  108. }