function_button.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. borderRadius: borderRadius,
  25. ),
  26. child: Material(
  27. color: Colors.white,
  28. shape: RoundedRectangleBorder(borderRadius: borderRadius),
  29. child: InkWell(
  30. borderRadius: borderRadius,
  31. onTap: onTap,
  32. child: Container(
  33. padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
  34. child: Column(
  35. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  36. children: [
  37. Row(
  38. mainAxisAlignment: MainAxisAlignment.center,
  39. children: [
  40. icon,
  41. ],
  42. ),
  43. Row(
  44. mainAxisAlignment: MainAxisAlignment.center,
  45. children: [
  46. Text(
  47. label,
  48. style: TextStyle(
  49. color: Colors.grey.shade700,
  50. fontSize: 20,
  51. fontWeight: FontWeight.bold,
  52. ),
  53. ),
  54. ],
  55. ),
  56. ],
  57. ),
  58. ),
  59. ),
  60. ),
  61. );
  62. }
  63. }