main_video_page.dart 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:news_app/ui/video/video_rank_list_page.dart';
  5. import 'package:news_app/ui/video/video_recommend_list_page.dart';
  6. import '../../constant/color_res.dart';
  7. import '../../gen/assets.gen.dart';
  8. import '../search/search_bar_widget.dart';
  9. /// @author: bo.zeng
  10. /// @email: cnhbwds@gmail.com
  11. /// @date: 2025 2025/4/9 16:00
  12. /// @description:
  13. class MainVideoPage extends StatefulWidget {
  14. const MainVideoPage({super.key});
  15. @override
  16. State<MainVideoPage> createState() => _MainVideoPageState();
  17. }
  18. class _MainVideoPageState extends State<MainVideoPage>
  19. with AutomaticKeepAliveClientMixin {
  20. @override
  21. Widget build(BuildContext context) {
  22. super.build(context);
  23. return DefaultTabController(
  24. length: 2,
  25. child: Scaffold(
  26. appBar: AppBar(
  27. elevation: 0,
  28. // 移除阴影
  29. scrolledUnderElevation: 0,
  30. // 禁用滚动时的阴影变化
  31. backgroundColor: color5F59F7,
  32. centerTitle: true,
  33. title: Row(
  34. spacing: 10.w,
  35. children: [
  36. Image.asset(Assets.images.logo.path,width: 70.w,),
  37. Expanded(
  38. child: SearchBarWidget(tabIndex: 2,),
  39. )
  40. ],
  41. ),
  42. systemOverlayStyle: SystemUiOverlayStyle(
  43. statusBarColor: color5F59F7,
  44. statusBarIconBrightness: Brightness.light, // 状态栏图标颜色
  45. ),
  46. bottom: TabBar(
  47. tabAlignment: TabAlignment.center,
  48. isScrollable: false,
  49. indicatorColor: Colors.white,
  50. dividerHeight: 0,
  51. labelColor: Colors.white,
  52. // 选中标签颜色
  53. unselectedLabelColor: Colors.white,
  54. // 未选中标签颜色
  55. labelStyle: TextStyle(
  56. fontWeight: FontWeight.bold, // 选中标签加粗
  57. fontSize: 15.0.sp,
  58. ),
  59. unselectedLabelStyle: TextStyle(
  60. fontWeight: FontWeight.normal, // 未选中标签不加粗
  61. fontSize: 12.0.sp,
  62. ),
  63. tabs: [Tab(text: "推荐"), Tab(text: "视频榜")],
  64. ),
  65. ),
  66. body: Stack(
  67. children: [
  68. Positioned(
  69. child: Container(
  70. height: 100.h,
  71. decoration: BoxDecoration(
  72. gradient: LinearGradient(
  73. colors: [color5F59F7, color6592FD, Colors.white],
  74. begin: Alignment.topCenter,
  75. end: Alignment.bottomCenter,
  76. ),
  77. ),
  78. ),
  79. ),
  80. TabBarView(
  81. children: [VideoRecommendListPage(), VideoRankListPage()],
  82. ),
  83. ],
  84. ),
  85. ),
  86. );
  87. }
  88. @override
  89. bool get wantKeepAlive => true;
  90. }