LCOV - code coverage report
Current view: top level - src/widgets - device_render.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/models/resolution.dart';
       4             : import 'package:widgetbook/src/models/organizers/organizers.dart';
       5             : import 'package:widgetbook/src/providers/device_provider.dart';
       6             : import 'package:widgetbook/src/providers/injected_theme_provider.dart';
       7             : import 'package:widgetbook/src/providers/injected_theme_state.dart';
       8             : 
       9             : class DeviceRender extends StatelessWidget {
      10             :   final Story story;
      11           0 :   const DeviceRender({
      12             :     Key? key,
      13             :     required this.story,
      14           0 :   }) : super(key: key);
      15             : 
      16           0 :   ThemeData getInjectedTheme(BuildContext context, InjectedThemeState state) {
      17           0 :     var brightness = Theme.of(context).brightness;
      18             : 
      19           0 :     if (brightness == Brightness.light && state.lightTheme != null) {
      20           0 :       return state.lightTheme!;
      21             :     }
      22           0 :     if (brightness == Brightness.dark && state.darkTheme != null) {
      23           0 :       return state.darkTheme!;
      24             :     }
      25             : 
      26             :     // TODO a warning would probably be good because otherwise the rendering is not representative
      27             :     // As an alternative at least one Theme has to be provided,
      28             :     //and theme switching is disabled if no theme for light AND dark is provided.
      29           0 :     return Theme.of(context);
      30             :   }
      31             : 
      32           0 :   @override
      33             :   Widget build(BuildContext context) {
      34           0 :     var deviceProvider = DeviceProvider.of(context)!;
      35           0 :     var state = deviceProvider.state;
      36             : 
      37           0 :     Device device = state.currentDevice;
      38           0 :     Resolution resolution = device.resolution;
      39             : 
      40           0 :     var themeState = InjectedThemeProvider.of(context)!.state;
      41             : 
      42           0 :     return Column(
      43             :       mainAxisAlignment: MainAxisAlignment.center,
      44           0 :       children: [
      45           0 :         Text(device.name),
      46             :         const SizedBox(
      47             :           height: 16,
      48             :         ),
      49           0 :         Container(
      50           0 :           decoration: BoxDecoration(
      51           0 :             border: Border.all(
      52           0 :               color: Theme.of(context).brightness == Brightness.dark
      53             :                   ? Colors.white
      54             :                   : Colors.black,
      55             :               width: 1,
      56             :             ),
      57             :           ),
      58           0 :           width: resolution.logicalSize.width,
      59           0 :           height: resolution.logicalSize.height,
      60           0 :           child: MaterialApp(
      61             :             debugShowCheckedModeBanner: false,
      62           0 :             theme: getInjectedTheme(context, themeState).copyWith(
      63             :               pageTransitionsTheme: const PageTransitionsTheme(
      64             :                 builders: {
      65             :                   TargetPlatform.iOS: FadeUpwardsPageTransitionsBuilder(),
      66             :                   TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
      67             :                 },
      68             :               ),
      69             :             ),
      70           0 :             home: Scaffold(
      71           0 :               body: story.builder(
      72             :                 context,
      73             :               ),
      74             :             ),
      75             :           ),
      76             :         ),
      77             :       ],
      78             :     );
      79             :   }
      80             : }

Generated by: LCOV version 1.15