search_bar_widget.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:go_router/go_router.dart';
  4. import '../../widget/my_txt.dart';
  5. /// @author: bo.zeng
  6. /// @email: cnhbwds@gmail.com
  7. /// @date: 2025 2025/4/25 13:15
  8. /// @description:
  9. class SearchBarWidget extends StatelessWidget {
  10. final int tabIndex;
  11. const SearchBarWidget({super.key, required this.tabIndex});
  12. @override
  13. Widget build(BuildContext context) {
  14. if (tabIndex == 3 ) {
  15. return const SizedBox.shrink();
  16. } else {
  17. return GestureDetector(
  18. onTap: () {
  19. if (tabIndex == 0) {
  20. context.push("/search");
  21. } else if (tabIndex == 2){
  22. context.push("/video/search");
  23. } else if (tabIndex == 1) {
  24. context.push("/activity/search");
  25. }
  26. },
  27. child: Container(
  28. height: 32.h,
  29. decoration: BoxDecoration(
  30. shape: BoxShape.rectangle,
  31. borderRadius: BorderRadius.circular(30.0.r),
  32. color: Colors.white,
  33. ),
  34. child: Row(
  35. crossAxisAlignment: CrossAxisAlignment.center,
  36. children: [
  37. SizedBox(width: 5.w),
  38. Icon(Icons.search_outlined, color: Colors.grey, size: 30.w),
  39. myTxt(text: "输入您想搜索的内容", fontSize: 16.sp, color: Colors.grey),
  40. ],
  41. ),
  42. ),
  43. );
  44. }
  45. }
  46. }