function_button.dart 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.center,
  48. children: [
  49. icon,
  50. ],
  51. ),
  52. Row(
  53. mainAxisAlignment: MainAxisAlignment.center,
  54. children: [
  55. Text(
  56. label,
  57. style: TextStyle(
  58. color: Colors.grey.shade700,
  59. fontSize: 24,
  60. fontWeight: FontWeight.bold,
  61. ),
  62. ),
  63. ],
  64. ),
  65. ],
  66. ),
  67. ),
  68. ),
  69. ),
  70. );
  71. }
  72. }