side_bar.dart 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import 'package:flutter/material.dart';
  2. class SideBar extends StatelessWidget {
  3. final String title;
  4. final String value;
  5. final String unit;
  6. final Function? onTap;
  7. final bool? hasDevice;
  8. const SideBar({
  9. super.key,
  10. required this.title,
  11. required this.value,
  12. required this.unit,
  13. this.onTap,
  14. this.hasDevice = false,
  15. });
  16. @override
  17. Widget build(BuildContext context) {
  18. return Container(
  19. margin: hasDevice!
  20. ? const EdgeInsets.only(top: 60)
  21. : const EdgeInsets.only(top: 10),
  22. child: InkWell(
  23. onTap: () => onTap?.call(),
  24. child: Container(
  25. margin: const EdgeInsets.only(top: 10),
  26. padding: const EdgeInsets.symmetric(vertical: 20),
  27. child: Row(
  28. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: [
  31. Container(
  32. padding: const EdgeInsets.symmetric(
  33. horizontal: 30,
  34. ),
  35. child: Text(
  36. title,
  37. style: const TextStyle(
  38. fontSize: 25,
  39. ),
  40. ),
  41. ),
  42. Container(
  43. alignment: Alignment.bottomRight,
  44. padding: const EdgeInsets.only(
  45. bottom: 20,
  46. right: 30,
  47. left: 40,
  48. ),
  49. child: FittedBox(
  50. child: Row(
  51. mainAxisAlignment: MainAxisAlignment.end,
  52. crossAxisAlignment: CrossAxisAlignment.end,
  53. children: [
  54. RichText(
  55. text: TextSpan(
  56. text: value,
  57. style: const TextStyle(
  58. fontSize: 60,
  59. color: Colors.black,
  60. ),
  61. children: [
  62. const TextSpan(text: ' '),
  63. TextSpan(
  64. text: unit,
  65. style: const TextStyle(fontSize: 25),
  66. )
  67. ],
  68. ),
  69. ),
  70. ],
  71. ),
  72. ),
  73. ),
  74. ],
  75. ),
  76. ),
  77. ),
  78. );
  79. }
  80. }