function_button.dart 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import 'package:flutter/material.dart';
  2. import 'package:vitalapp/consts/styles.dart';
  3. /// 功能入口按钮
  4. class FunctionButton extends StatelessWidget {
  5. final String label;
  6. final Widget icon;
  7. final VoidCallback? onTap;
  8. const FunctionButton({
  9. super.key,
  10. required this.label,
  11. required this.icon,
  12. this.onTap,
  13. });
  14. @override
  15. Widget build(BuildContext context) {
  16. final borderRadius = GlobalStyles.borderRadius;
  17. return Container(
  18. decoration: BoxDecoration(
  19. color: Colors.white,
  20. border: Border.all(
  21. width: 1,
  22. color: Colors.grey.shade300,
  23. ),
  24. // boxShadow: [
  25. // BoxShadow(
  26. // color: Colors.grey.shade300, // 阴影颜色
  27. // spreadRadius: 2, // 阴影扩展半径
  28. // blurRadius: 2, // 阴影模糊半径
  29. // offset: const Offset(-1.6, 1.8), // 阴影偏移量,负值表示向左偏移
  30. // ),
  31. // ],
  32. borderRadius: borderRadius,
  33. ),
  34. child: Material(
  35. color: Colors.white,
  36. shape: RoundedRectangleBorder(borderRadius: borderRadius),
  37. child: InkWell(
  38. borderRadius: borderRadius,
  39. onTap: onTap,
  40. child: Container(
  41. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8)
  42. .copyWith(top: 16),
  43. child: Column(
  44. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  45. children: [
  46. Row(
  47. mainAxisAlignment: MainAxisAlignment.start,
  48. children: [
  49. const SizedBox(width: 32),
  50. icon,
  51. ],
  52. ),
  53. Row(
  54. mainAxisAlignment: MainAxisAlignment.end,
  55. children: [
  56. Text(
  57. label,
  58. style: TextStyle(
  59. color: Colors.grey.shade700,
  60. fontSize: 24,
  61. fontWeight: FontWeight.bold,
  62. ),
  63. ),
  64. const SizedBox(width: 12),
  65. ],
  66. ),
  67. ],
  68. ),
  69. ),
  70. ),
  71. ),
  72. );
  73. }
  74. }