1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import 'package:calendar_view/utils/calendar_util.dart';
- import 'package:flutter/material.dart';
- class MyScheduleItem extends StatefulWidget {
- const MyScheduleItem({super.key, required this.type, required this.onClick});
- final ScheduleType type;
- final VoidCallback onClick;
- @override
- State<MyScheduleItem> createState() => _MyScheduleItemState();
- }
- class _MyScheduleItemState extends State<MyScheduleItem> {
- bool _isHover = false;
- get _type => widget.type;
- @override
- Widget build(BuildContext context) {
- return MouseRegion(
- cursor: SystemMouseCursors.click,
- onEnter: _handleMouseEnter,
- onExit: _handleMouseExit,
- child: GestureDetector(
- onTap: () {
- setState(() {
- _type.isSelected = !_type.isSelected;
- });
- widget.onClick.call();
- },
- child: Container(
- height: 40,
- padding: const EdgeInsets.symmetric(horizontal: 5),
- decoration: BoxDecoration(
- color:
- _isHover ? _type.color.withOpacity(0.08) : Colors.transparent,
- borderRadius: BorderRadius.circular(5),
- ),
- child: Row(
- children: [
- Center(
- child: Checkbox(
- splashRadius: 0,
- side: BorderSide(color: _type.color, width: 1), // 勾勾的颜色
- activeColor: _type.color, // 勾勾的背景色
- shape: const CircleBorder(),
- value: _type.isSelected,
- onChanged: (v) {
- setState(
- () {
- _type.isSelected = v!;
- },
- );
- widget.onClick.call();
- },
- ),
- ),
- const SizedBox(width: 5),
- Center(
- child: Text(_type.typeName),
- ),
- Expanded(
- child: Container(),
- ),
- if (_isHover)
- const Icon(
- Icons.more_horiz,
- size: 20,
- color: Colors.black26,
- ),
- const SizedBox(width: 10),
- ],
- ),
- ),
- ),
- );
- }
- void _handleMouseEnter(PointerEvent details) {
- setState(() {
- _isHover = true;
- });
- }
- void _handleMouseExit(PointerEvent details) {
- setState(() {
- _isHover = false;
- });
- }
- }
|