LCOV - code coverage report
Current view: top level - src/ui/editor/pages/helper_editor/font_editor - font_size_picker.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 25 27 92.6 %
Date: 2020-12-04 18:41:24 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : import 'package:flutter/services.dart';
       3             : import 'package:flutter/widgets.dart';
       4             : 
       5             : class FontSizePicker extends StatefulWidget {
       6             : 
       7             :   final TextStyle style;
       8             :   final Function(double) onFontSizeSelected;
       9             : 
      10           2 :   const FontSizePicker({
      11             :     Key key,
      12             :     this.style,
      13             :     this.onFontSizeSelected,
      14           2 :   }) : super(key: key);
      15             : 
      16           2 :   @override
      17           2 :   _FontSizePickerState createState() => _FontSizePickerState();
      18             : }
      19             : 
      20             : class _FontSizePickerState extends State<FontSizePicker> {
      21             : 
      22             :   double _currentSliderValue;
      23             :   bool _isHapticPlayed = false;
      24             : 
      25           2 :   @override
      26             :   void initState() {
      27           2 :     super.initState();
      28           8 :     _currentSliderValue = widget.style.fontSize ?? 20.0;
      29             :   }
      30             : 
      31           2 :   @override
      32             :   Widget build(BuildContext context) {
      33           2 :     return Column(
      34           2 :       children: [
      35           2 :         Text(
      36           8 :           '${_currentSliderValue.round().toString()}pt',
      37           2 :           key: ValueKey('pal_FontSizePicker_CurrentValue'),
      38             :         ),
      39           2 :         Slider(
      40           2 :           key: ValueKey('pal_FontSizePicker_Slider'),
      41           2 :           value: _currentSliderValue,
      42             :           min: 10,
      43             :           max: 80,
      44           6 :           label: _currentSliderValue.round().toString(),
      45           2 :           onChanged: (double value) {
      46           4 :             print("value : $value");
      47           4 :             num section = (value % 10).round();
      48           2 :             if (section == 0 && !_isHapticPlayed) {
      49           0 :               HapticFeedback.selectionClick();
      50           0 :               _isHapticPlayed = true;
      51             :             } else {
      52           2 :               _isHapticPlayed = false;
      53             :             }
      54           4 :             setState(() {
      55           2 :               _currentSliderValue = value;
      56             :             });
      57           6 :             widget.onFontSizeSelected(value);
      58             :           },
      59             :         ),
      60             :       ],
      61             :     );
      62             :   }
      63             : }

Generated by: LCOV version 1.14