recommend_page.dart 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import 'package:douyin_demo/providers/recommend_provider.dart';
  2. import 'package:douyin_demo/views/bottom_safebar.dart';
  3. import 'package:douyin_demo/views/main_tab_view.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:provider/provider.dart';
  6. /// Description: 推荐界面
  7. /// Time : 04/02/2022 星期六
  8. /// Author : liuyuqi.gov@msn.cn
  9. class RecommendPage extends StatelessWidget {
  10. final int selIndex;
  11. const RecommendPage({Key? key, required this.selIndex}) : super(key: key);
  12. @override
  13. Widget build(BuildContext context) {
  14. double rpx = MediaQuery.of(context).size.width / 750;
  15. return MultiProvider(
  16. providers: [
  17. ChangeNotifierProvider(
  18. create: (BuildContext context) {
  19. return RecommendProvider();
  20. },
  21. )
  22. ],
  23. child: Scaffold(
  24. resizeToAvoidBottomInset: false,
  25. body: Stack(children: [
  26. // 关注、推荐tab
  27. MainTabView(),
  28. Positioned(
  29. top: 20 * rpx,
  30. // height: 120,
  31. width: 750 * rpx,
  32. child: SafeArea(
  33. child: Container(
  34. // decoration: BoxDecoration(color: Colors.pinkAccent),
  35. child: TopTab(),
  36. )),
  37. ),
  38. ]),
  39. bottomNavigationBar: BottomSafeBar(
  40. selIndex: selIndex,
  41. ),
  42. ));
  43. }
  44. }
  45. class TopTab extends StatefulWidget {
  46. TopTab({Key? key}) : super(key: key);
  47. _TopTabState createState() => _TopTabState();
  48. }
  49. class _TopTabState extends State<TopTab> with SingleTickerProviderStateMixin {
  50. @override
  51. void initState() {
  52. super.initState();
  53. }
  54. @override
  55. Widget build(BuildContext context) {
  56. RecommendProvider provider = Provider.of<RecommendProvider>(context);
  57. double rpx = MediaQuery.of(context).size.width / 750;
  58. return Row(
  59. crossAxisAlignment: CrossAxisAlignment.center,
  60. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  61. children: [
  62. // BottomNavigationBar(items: [BottomNavigationBarItem(icon: null,)],)
  63. SizedBox(
  64. width: 17 * rpx,
  65. ),
  66. Icon(
  67. Icons.search,
  68. size: 50 * rpx,
  69. color: Colors.white,
  70. ),
  71. Container(
  72. child: Container(
  73. padding: EdgeInsets.symmetric(horizontal: 90 * rpx),
  74. width: 500 * rpx,
  75. child: TabBar(
  76. indicatorColor: Colors.white,
  77. labelStyle: TextStyle(color: Colors.white, fontSize: 20),
  78. indicatorPadding: EdgeInsets.symmetric(horizontal: 30),
  79. unselectedLabelStyle:
  80. TextStyle(color: Colors.grey[700], fontSize: 18),
  81. controller: provider.controller,
  82. tabs: <Widget>[Text("关注"), Text("推荐")],
  83. ))),
  84. Icon(
  85. Icons.live_tv,
  86. size: 30,
  87. color: Colors.white,
  88. ),
  89. SizedBox(
  90. width: 10,
  91. ),
  92. ],
  93. );
  94. }
  95. }