LCOV - code coverage report
Current view: top level - src/widgets - device_item.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 28 0.0 %
Date: 2021-10-03 15:54:23 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : import 'package:widgetbook/src/models/device.dart';
       3             : import 'package:widgetbook/src/providers/device_provider.dart';
       4             : import '../utils/extensions.dart';
       5             : 
       6             : class DeviceItem extends StatelessWidget {
       7             :   final Device device;
       8           0 :   const DeviceItem({
       9             :     Key? key,
      10             :     required this.device,
      11           0 :   }) : super(key: key);
      12             : 
      13           0 :   @override
      14             :   Widget build(BuildContext context) {
      15           0 :     var deviceProvider = DeviceProvider.of(context)!;
      16           0 :     var state = deviceProvider.state;
      17           0 :     bool isCurrent = device == state.currentDevice;
      18           0 :     return GestureDetector(
      19           0 :       onTap: () {
      20           0 :         deviceProvider.selectDevice(
      21           0 :           device,
      22             :         );
      23             :       },
      24           0 :       child: buildTooltip(
      25             :         context: context,
      26             :         isCurrent: isCurrent,
      27             :       ),
      28             :     );
      29             :   }
      30             : 
      31           0 :   Widget buildTooltip(
      32             :       {required BuildContext context, required bool isCurrent}) {
      33           0 :     return Tooltip(
      34           0 :       child: buildIcon(
      35           0 :         device.type,
      36           0 :         isCurrent ? context.colorScheme.primary : context.theme.hintColor,
      37             :       ),
      38           0 :       message: device.name,
      39             :     );
      40             :   }
      41             : 
      42           0 :   Widget buildIcon(DeviceType type, Color color) {
      43             :     switch (type) {
      44           0 :       case DeviceType.watch:
      45           0 :         return Icon(
      46             :           Icons.watch,
      47             :           color: color,
      48             :         );
      49           0 :       case DeviceType.mobile:
      50           0 :         return Icon(
      51             :           Icons.smartphone,
      52             :           color: color,
      53             :         );
      54           0 :       case DeviceType.tablet:
      55           0 :         return Icon(
      56             :           Icons.tablet,
      57             :           color: color,
      58             :         );
      59           0 :       case DeviceType.desktop:
      60           0 :         return Icon(
      61             :           Icons.desktop_windows,
      62             :           color: color,
      63             :         );
      64           0 :       case DeviceType.unknown:
      65           0 :         return Icon(
      66             :           Icons.quiz,
      67             :           color: color,
      68             :         );
      69             :     }
      70             :   }
      71             : }

Generated by: LCOV version 1.15