w_day.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import 'package:flutter/material.dart';
  2. import 'package:jiffy/jiffy.dart';
  3. class WDay extends StatelessWidget {
  4. const WDay(
  5. {super.key, required this.date, this.highlight = false, this.onTap});
  6. final Jiffy date;
  7. final bool highlight;
  8. final Function()? onTap;
  9. @override
  10. Widget build(BuildContext context) {
  11. return Container(
  12. margin: const EdgeInsets.only(top: 10, bottom: 10),
  13. height: 50,
  14. child: Align(
  15. alignment: Alignment.center,
  16. child: InkWell(
  17. onTap: onTap,
  18. child: Container(
  19. width: 150,
  20. decoration: highlight
  21. ? colorsdays("today")
  22. : ([1, 7].contains(date.dayOfWeek)
  23. ? colorsdays("weekend")
  24. : colorsdays("anyday")),
  25. child: Padding(
  26. padding: const EdgeInsets.all(8.0),
  27. child: Text(
  28. date.format(pattern: "EEE dd MMM y"),
  29. style: const TextStyle(fontWeight: FontWeight.w700),
  30. textAlign: TextAlign.center,
  31. ),
  32. ),
  33. ),
  34. ),
  35. ),
  36. );
  37. }
  38. }
  39. BoxDecoration colorsdays(String day) {
  40. switch (day) {
  41. case "weekend":
  42. return BoxDecoration(
  43. gradient: const LinearGradient(
  44. colors: [Color.fromRGBO(44, 45, 116, 1), Color.fromRGBO(0, 2, 67, 1)],
  45. begin: Alignment.centerLeft,
  46. end: Alignment.centerRight,
  47. ),
  48. border: Border.all(
  49. color: Colors.yellow,
  50. ),
  51. borderRadius: const BorderRadius.all(Radius.circular(20.0)),
  52. );
  53. case "today":
  54. return BoxDecoration(
  55. gradient: const LinearGradient(
  56. colors: [
  57. Color.fromRGBO(225, 57, 57, 1),
  58. Color.fromRGBO(84, 1, 1, 1),
  59. ],
  60. begin: Alignment.centerLeft,
  61. end: Alignment.centerRight,
  62. ),
  63. border: Border.all(
  64. color: Colors.transparent,
  65. ),
  66. borderRadius: const BorderRadius.all(Radius.circular(20.0)),
  67. );
  68. default:
  69. return BoxDecoration(
  70. gradient: const LinearGradient(
  71. colors: [Color.fromRGBO(44, 45, 116, 1), Color.fromRGBO(0, 2, 67, 1)],
  72. begin: Alignment.centerLeft,
  73. end: Alignment.centerRight,
  74. ),
  75. border: Border.all(
  76. color: Colors.transparent,
  77. ),
  78. borderRadius: const BorderRadius.all(Radius.circular(20.0)),
  79. );
  80. }
  81. }