LCOV - code coverage report
Current view: top level - src/widgets - device_render.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 30 31 96.8 %
Date: 2021-10-28 11:30:47 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : import 'package:widgetbook/src/models/organizers/organizers.dart';
       3             : import 'package:widgetbook/src/providers/device_provider.dart';
       4             : import 'package:widgetbook/src/providers/injected_theme_provider.dart';
       5             : import 'package:widgetbook/src/providers/injected_theme_state.dart';
       6             : import 'package:widgetbook/src/providers/theme_provider.dart';
       7             : 
       8             : class DeviceRender extends StatelessWidget {
       9           1 :   const DeviceRender({
      10             :     Key? key,
      11             :     required this.story,
      12           1 :   }) : super(key: key);
      13             : 
      14             :   final Story story;
      15             : 
      16           1 :   ThemeData getInjectedTheme(BuildContext context, InjectedThemeState state) {
      17           2 :     final brightness = ThemeProvider.of(context)!.state;
      18             : 
      19           2 :     if (brightness == ThemeMode.light && state.lightTheme != null) {
      20           1 :       return state.lightTheme!;
      21             :     }
      22           2 :     if (brightness == ThemeMode.dark && state.darkTheme != null) {
      23           1 :       return state.darkTheme!;
      24             :     }
      25           0 :     return state.lightTheme ?? state.darkTheme!;
      26             :   }
      27             : 
      28           1 :   @override
      29             :   Widget build(BuildContext context) {
      30           1 :     final deviceProvider = DeviceProvider.of(context)!;
      31           1 :     final state = deviceProvider.state;
      32             : 
      33           1 :     final device = state.currentDevice;
      34           1 :     final resolution = device.resolution;
      35             : 
      36           2 :     final themeState = InjectedThemeProvider.of(context)!.state;
      37             : 
      38           1 :     return Column(
      39             :       mainAxisAlignment: MainAxisAlignment.center,
      40           1 :       children: [
      41           2 :         Text(device.name),
      42             :         const SizedBox(
      43             :           height: 16,
      44             :         ),
      45           1 :         Container(
      46           1 :           decoration: BoxDecoration(
      47           1 :             border: Border.all(
      48           3 :               color: Theme.of(context).brightness == Brightness.dark
      49             :                   ? Colors.white
      50             :                   : Colors.black,
      51             :             ),
      52             :           ),
      53           2 :           width: resolution.logicalSize.width,
      54           2 :           height: resolution.logicalSize.height,
      55           1 :           child: MaterialApp(
      56             :             debugShowCheckedModeBanner: false,
      57           3 :             themeMode: Theme.of(context).brightness == Brightness.light
      58             :                 ? ThemeMode.light
      59             :                 : ThemeMode.dark,
      60           1 :             home: AnimatedTheme(
      61             :               duration: Duration.zero,
      62           2 :               data: getInjectedTheme(context, themeState).copyWith(
      63           2 :                 brightness: Theme.of(context).brightness,
      64             :                 pageTransitionsTheme: const PageTransitionsTheme(
      65             :                   builders: {
      66             :                     TargetPlatform.iOS: FadeUpwardsPageTransitionsBuilder(),
      67             :                     TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
      68             :                   },
      69             :                 ),
      70             :               ),
      71           1 :               child: Scaffold(
      72           2 :                 body: story.builder(
      73             :                   context,
      74             :                 ),
      75             :               ),
      76             :             ),
      77             :           ),
      78             :         ),
      79             :       ],
      80             :     );
      81             :   }
      82             : }

Generated by: LCOV version 1.15