| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import 'package:flutter/material.dart';
- import 'package:jiffy/jiffy.dart';
- class WDay extends StatelessWidget {
- const WDay(
- {super.key, required this.date, this.highlight = false, this.onTap});
- final Jiffy date;
- final bool highlight;
- final Function()? onTap;
- @override
- Widget build(BuildContext context) {
- return Container(
- margin: const EdgeInsets.only(top: 10, bottom: 10),
- height: 50,
- child: Align(
- alignment: Alignment.center,
- child: InkWell(
- onTap: onTap,
- child: Container(
- width: 150,
- decoration: highlight
- ? colorsdays("today")
- : ([1, 7].contains(date.dayOfWeek)
- ? colorsdays("weekend")
- : colorsdays("anyday")),
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: Text(
- date.format(pattern: "EEE dd MMM y"),
- style: const TextStyle(fontWeight: FontWeight.w700),
- textAlign: TextAlign.center,
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
- BoxDecoration colorsdays(String day) {
- switch (day) {
- case "weekend":
- return BoxDecoration(
- gradient: const LinearGradient(
- colors: [Color.fromRGBO(44, 45, 116, 1), Color.fromRGBO(0, 2, 67, 1)],
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- ),
- border: Border.all(
- color: Colors.yellow,
- ),
- borderRadius: const BorderRadius.all(Radius.circular(20.0)),
- );
- case "today":
- return BoxDecoration(
- gradient: const LinearGradient(
- colors: [
- Color.fromRGBO(225, 57, 57, 1),
- Color.fromRGBO(84, 1, 1, 1),
- ],
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- ),
- border: Border.all(
- color: Colors.transparent,
- ),
- borderRadius: const BorderRadius.all(Radius.circular(20.0)),
- );
- default:
- return BoxDecoration(
- gradient: const LinearGradient(
- colors: [Color.fromRGBO(44, 45, 116, 1), Color.fromRGBO(0, 2, 67, 1)],
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- ),
- border: Border.all(
- color: Colors.transparent,
- ),
- borderRadius: const BorderRadius.all(Radius.circular(20.0)),
- );
- }
- }
|