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

Generated by: LCOV version 1.15