LCOV - code coverage report
Current view: | top level - src/widgets/tiles - tile.dart (source / functions) |  |  | Hit | Total | Coverage
Test: | lcov.info |  | Lines: | 0 | 28 | 0.0 %
Date: | 2021-10-11 06:57:03 |  | Functions: | 0 | 0 | -

              Line data    Source code
           1             : import 'package:flutter/material.dart';
           2             : import 'package:widgetbook/src/constants/radii.dart';
           3             : import 'package:widgetbook/src/models/organizers/organizer.dart';
           4             : import 'package:widgetbook/src/providers/canvas_provider.dart';
           5             : import 'package:widgetbook/src/utils/styles.dart';
           6             : import 'package:widgetbook/src/utils/utils.dart';
           7             :
           8             : class Tile extends StatefulWidget {
           9           0 :   const Tile({
          10             :     Key? key,
          11             :     required this.iconData,
          12             :     required this.iconColor,
          13             :     required this.organizer,
          14             :     this.onClicked,
          15           0 :   }) : super(key: key);
          16             :
          17             :   final IconData iconData;
          18             :   final Color iconColor;
          19             :   final Organizer organizer;
          20             :   final VoidCallback? onClicked;
          21             :
          22             :   static const double spacing = 8;
          23             :
          24           0 :   @override
          25           0 :   _TileState createState() => _TileState();
          26             : }
          27             :
          28             : class _TileState extends State<Tile> {
          29             :   bool hovered = false;
          30             :
          31           0 :   Widget _buildTile(BuildContext context) {
          32           0 :     return Padding(
          33             :       padding: const EdgeInsets.symmetric(
          34             :         vertical: 4,
          35             :         horizontal: 8,
          36             :       ),
          37           0 :       child: Row(
          38           0 :         children: [
          39           0 :           Icon(
          40           0 :             widget.iconData,
          41           0 :             color: hovered ? context.colorScheme.onPrimary : widget.iconColor,
          42             :             size: 16,
          43             :           ),
          44             :           const SizedBox(
          45             :             width: Tile.spacing,
          46             :           ),
          47           0 :           Text(widget.organizer.name),
          48             :         ],
          49             :       ),
          50             :     );
          51             :   }
          52             :
          53           0 :   @override
          54             :   Widget build(BuildContext context) {
          55           0 :     final state = CanvasProvider.of(context)!.state;
          56           0 :     final isSelected = state.selectedStory == widget.organizer;
          57             :
          58           0 :     return GestureDetector(
          59           0 :       onTap: () {
          60           0 :         widget.onClicked?.call();
          61             :       },
          62           0 :       child: MouseRegion(
          63           0 :         onEnter: (e) {
          64           0 :           setState(() => hovered = true);
          65             :         },
          66           0 :         onExit: (e) {
          67           0 :           setState(() => hovered = false);
          68             :         },
          69             :         cursor: SystemMouseCursors.click,
          70           0 :         child: AnimatedContainer(
          71           0 :           decoration: BoxDecoration(
          72           0 :             color: hovered || isSelected
          73           0 :                 ? Styles.getHighlightColor(context)
          74             :                 : null,
          75             :             borderRadius: Radii.defaultRadius,
          76             :           ),
          77             :           duration: const Duration(milliseconds: 100),
          78           0 :           child: _buildTile(context),
          79             :         ),
          80             :       ),
          81             :     );
          82             :   }
          83             : }

Generated by: LCOV version 1.15