@@ -102,7 +102,6 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
102102          children:  < Widget > [
103103            AddModelContainerMobile (
104104              name:  'Title' .tr (),
105-               autofocus:  true ,
106105              maxLines:  1 ,
107106              done:  (title) {
108107                setState (() {
@@ -150,6 +149,18 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
150149            AddModelContainerMobile (
151150              name:  'Pages read' .tr (),
152151              big:  true ,
152+               iconButton:  IconButton (
153+                 tooltip:  'Change way of input' .tr (),
154+                 onPressed:  () {
155+                   setState (() {
156+                     _bloc! .pagesReadSliderActive = 
157+                         ! _bloc! .pagesReadSliderActive;
158+                   });
159+                 },
160+                 icon:  _bloc! .pagesReadSliderActive
161+                     ?  const  Icon (Icons .edit)
162+                     :  const  Icon (Icons .edit_attributes_outlined),
163+               ),
153164              child:  _pagesReadChild,
154165            ),
155166            FittedBox (
@@ -260,7 +271,43 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
260271  /// Returns the Widget with which you 
261272  /// can make an input, of how many pages you read. 
262273Widget  get  _pagesReadChild {
263-     if  (_bloc! .entryBook ==  const  Book .none ()) {
274+     if  (_bloc! .pagesReadSliderActive &&  _bloc! .entryBook !=  const  Book .none ()) {
275+       return  Column (
276+         crossAxisAlignment:  CrossAxisAlignment .center,
277+         mainAxisAlignment:  MainAxisAlignment .end,
278+         mainAxisSize:  MainAxisSize .max,
279+         textBaseline:  TextBaseline .alphabetic,
280+         textDirection:  TextDirection .ltr,
281+         children:  [
282+           const  SizedBox (height:  25 ),
283+           RangeSlider (
284+             min:  0.0 ,
285+             max:  _bloc! .entryBook.pages.toDouble (),
286+             divisions:  _bloc! .entryBook.pages,
287+             onChanged:  (RangeValues  value) {
288+               setState (() {
289+                 _bloc! .entryStartPage =  value.start.toInt ();
290+                 _bloc! .entryEndPage =  value.end.toInt ();
291+                 _bloc! .checkForVars ();
292+               });
293+             },
294+             inactiveColor:  Coloring .mainColor.withOpacity (.4 ),
295+             activeColor:  Coloring .mainColor,
296+             semanticFormatterCallback:  (double  newValue) {
297+               return  '$newValue  pages read' ;
298+             },
299+             labels:  RangeLabels (
300+               _bloc! .entryStartPage.toString (),
301+               _bloc! .entryEndPage.toString (),
302+             ),
303+             values:  RangeValues (
304+               _bloc! .entryStartPage! .toDouble (),
305+               _bloc! .entryEndPage! .toDouble (),
306+             ),
307+           ),
308+         ],
309+       );
310+     } else  {
264311      return  Column (
265312        crossAxisAlignment:  CrossAxisAlignment .center,
266313        mainAxisAlignment:  MainAxisAlignment .spaceBetween,
@@ -269,11 +316,10 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
269316        textDirection:  TextDirection .ltr,
270317        verticalDirection:  VerticalDirection .down,
271318        children:  [
272-           TextField (
319+           TextFormField (
273320            autocorrect:  true ,
274321            autofocus:  false ,
275-             clipBehavior:  Clip .antiAliasWithSaveLayer,
276-             dragStartBehavior:  DragStartBehavior .down,
322+             initialValue:  _bloc! .entryStartPage? .toString (),
277323            enableIMEPersonalizedLearning:  true ,
278324            enableInteractiveSelection:  true ,
279325            enableSuggestions:  true ,
@@ -295,20 +341,45 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
295341              paste:  true ,
296342              selectAll:  true ,
297343            ),
298-             scribbleEnabled:  true ,
299344            selectionControls:  MaterialTextSelectionControls (),
300345            textDirection:  TextDirection .ltr,
301346            textInputAction:  TextInputAction .next,
302347            maxLines:  1 ,
303348            minLines:  1 ,
304-             selectionHeightStyle:  BoxHeightStyle .tight,
305-             selectionWidthStyle:  BoxWidthStyle .tight,
306349            showCursor:  true ,
307-             onSubmitted:  (str) {
308-               _bloc! .entryStartPage =  int .parse (str);
350+             onSaved:  (str) {
351+               if  (str !=  null ) {
352+                 setState (() {
353+                   try  {
354+                     _bloc! .entryStartPage =  int .parse (str);
355+                   } on  Exception  catch  (_) {
356+                     _bloc! .entryStartPage =  0 ;
357+                   }
358+                   _bloc! .checkForVars ();
359+                 });
360+               } else  {
361+                 return ;
362+               }
363+             },
364+             onFieldSubmitted:  (str) {
365+               setState (() {
366+                 try  {
367+                   _bloc! .entryStartPage =  int .parse (str);
368+                 } on  Exception  catch  (_) {
369+                   _bloc! .entryStartPage =  0 ;
370+                 }
371+                 _bloc! .checkForVars ();
372+               });
309373            },
310374            onChanged:  (str) {
311-               _bloc! .entryStartPage =  int .parse (str);
375+               setState (() {
376+                 try  {
377+                   _bloc! .entryStartPage =  int .parse (str);
378+                 } on  Exception  catch  (_) {
379+                   _bloc! .entryStartPage =  0 ;
380+                 }
381+                 _bloc! .checkForVars ();
382+               });
312383            },
313384            maxLengthEnforcement: 
314385                MaxLengthEnforcement .truncateAfterCompositionEnds,
@@ -317,11 +388,10 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
317388            ),
318389          ),
319390          const  SizedBox (height:  15 ),
320-           TextField (
391+           TextFormField (
321392            autocorrect:  true ,
322393            autofocus:  false ,
323-             clipBehavior:  Clip .antiAliasWithSaveLayer,
324-             dragStartBehavior:  DragStartBehavior .down,
394+             initialValue:  _bloc! .entryEndPage? .toString (),
325395            enableIMEPersonalizedLearning:  true ,
326396            enableInteractiveSelection:  true ,
327397            enableSuggestions:  true ,
@@ -343,20 +413,45 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
343413              paste:  true ,
344414              selectAll:  true ,
345415            ),
346-             scribbleEnabled:  true ,
347416            selectionControls:  MaterialTextSelectionControls (),
348417            textDirection:  TextDirection .ltr,
349418            textInputAction:  TextInputAction .next,
350419            maxLines:  1 ,
351420            minLines:  1 ,
352-             selectionHeightStyle:  BoxHeightStyle .tight,
353-             selectionWidthStyle:  BoxWidthStyle .tight,
354421            showCursor:  true ,
355-             onSubmitted:  (str) {
356-               _bloc! .entryEndPage =  int .parse (str);
422+             onSaved:  (str) {
423+               if  (str !=  null ) {
424+                 setState (() {
425+                   try  {
426+                     _bloc! .entryEndPage =  int .parse (str);
427+                   } on  Exception  catch  (_) {
428+                     _bloc! .entryEndPage =  0 ;
429+                   }
430+                   _bloc! .checkForVars ();
431+                 });
432+               } else  {
433+                 return ;
434+               }
435+             },
436+             onFieldSubmitted:  (str) {
437+               setState (() {
438+                 try  {
439+                   _bloc! .entryEndPage =  int .parse (str);
440+                 } on  Exception  catch  (_) {
441+                   _bloc! .entryEndPage =  0 ;
442+                 }
443+                 _bloc! .checkForVars ();
444+               });
357445            },
358446            onChanged:  (str) {
359-               _bloc! .entryEndPage =  int .parse (str);
447+               setState (() {
448+                 try  {
449+                   _bloc! .entryEndPage =  int .parse (str);
450+                 } on  Exception  catch  (_) {
451+                   _bloc! .entryEndPage =  0 ;
452+                 }
453+                 _bloc! .checkForVars ();
454+               });
360455            },
361456            maxLengthEnforcement: 
362457                MaxLengthEnforcement .truncateAfterCompositionEnds,
@@ -366,42 +461,6 @@ class _AddEntryScreenMobileState extends State<AddEntryScreenMobile> {
366461          ),
367462        ],
368463      );
369-     } else  {
370-       return  Column (
371-         crossAxisAlignment:  CrossAxisAlignment .center,
372-         mainAxisAlignment:  MainAxisAlignment .end,
373-         mainAxisSize:  MainAxisSize .max,
374-         textBaseline:  TextBaseline .alphabetic,
375-         textDirection:  TextDirection .ltr,
376-         children:  [
377-           const  SizedBox (height:  25 ),
378-           RangeSlider (
379-             min:  0.0 ,
380-             max:  _bloc! .entryBook.pages.toDouble (),
381-             divisions:  _bloc! .entryBook.pages,
382-             onChanged:  (RangeValues  value) {
383-               setState (() {
384-                 _bloc! .entryStartPage =  value.start.toInt ();
385-                 _bloc! .entryEndPage =  value.end.toInt ();
386-                 _bloc! .checkForVars ();
387-               });
388-             },
389-             inactiveColor:  Coloring .mainColor.withOpacity (.4 ),
390-             activeColor:  Coloring .mainColor,
391-             semanticFormatterCallback:  (double  newValue) {
392-               return  '$newValue  books read' ;
393-             },
394-             labels:  RangeLabels (
395-               _bloc! .entryStartPage.toString (),
396-               _bloc! .entryEndPage.toString (),
397-             ),
398-             values:  RangeValues (
399-               _bloc! .entryStartPage! .toDouble (),
400-               _bloc! .entryEndPage! .toDouble (),
401-             ),
402-           ),
403-         ],
404-       );
405464    }
406465  }
407466
0 commit comments