show_more_icon.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import 'package:flutter/material.dart';
  2. import 'package:flyinsono/lab/color/lab_colors.dart';
  3. class ShowMoreIcon extends StatefulWidget {
  4. const ShowMoreIcon({
  5. super.key,
  6. required this.isLeft,
  7. required this.onTap,
  8. });
  9. final bool isLeft;
  10. final VoidCallback onTap;
  11. @override
  12. State<ShowMoreIcon> createState() => _ShowMoreIconState();
  13. }
  14. class _ShowMoreIconState extends State<ShowMoreIcon> {
  15. bool _isHover = false;
  16. @override
  17. Widget build(BuildContext context) {
  18. Color backgroundColor = _isHover ? LabColors.base700 : LabColors.base600;
  19. return MouseRegion(
  20. cursor: SystemMouseCursors.click,
  21. onEnter: (_) {
  22. setState(() {
  23. _isHover = true;
  24. });
  25. },
  26. onExit: (_) {
  27. setState(() {
  28. _isHover = false;
  29. });
  30. },
  31. child: GestureDetector(
  32. onTap: widget.onTap,
  33. child: Container(
  34. width: 20,
  35. margin: EdgeInsets.symmetric(vertical: 5),
  36. decoration: BoxDecoration(
  37. color: backgroundColor,
  38. borderRadius: BorderRadius.circular(3),
  39. ),
  40. child: Center(
  41. child: Icon(
  42. widget.isLeft
  43. ? Icons.keyboard_double_arrow_left
  44. : Icons.keyboard_double_arrow_right,
  45. color: LabColors.base300,
  46. size: 20,
  47. ),
  48. ),
  49. )),
  50. );
  51. }
  52. // 备用样式
  53. final style1 = BoxDecoration(
  54. // 左右渐变
  55. gradient: LinearGradient(
  56. begin: Alignment.centerRight,
  57. end: Alignment.centerLeft,
  58. colors: [
  59. LabColors.base900,
  60. LabColors.base800.withOpacity(0.1),
  61. ],
  62. ),
  63. );
  64. }