@@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart' show kDebugMode;
99import  'package:flutter/material.dart' ;
1010import  'package:flutter/services.dart' ;
1111import  'package:flutter_quill/flutter_quill.dart'  as  flutter_quill;
12+ import  'package:focus_detector/focus_detector.dart' ;
1213import  'package:keybinder/keybinder.dart' ;
1314import  'package:logging/logging.dart' ;
1415import  'package:printing/printing.dart' ;
@@ -1555,96 +1556,106 @@ class EditorState extends State<Editor> {
15551556          child:  child! ,
15561557        );
15571558      },
1558-       child:  Scaffold (
1559-         appBar:  DynamicMaterialApp .isFullscreen
1560-             ?  null 
1561-             :  AppBar (
1562-                 toolbarHeight:  kToolbarHeight,
1563-                 title:  widget.customTitle !=  null 
1564-                     ?  Text (widget.customTitle! )
1565-                     :  Form (
1566-                         key:  _filenameFormKey,
1567-                         autovalidateMode:  AutovalidateMode .onUserInteraction,
1568-                         child:  TextFormField (
1569-                           decoration:  const  InputDecoration (
1570-                             border:  InputBorder .none,
1559+       child:  FocusDetector (
1560+         onFocusGained:  () {
1561+           // Key bindings won't work until keyboard is shown at least once for some reason. 
1562+           // This is a workaround to fix that. It should be unnoticable to the user. 
1563+           if  (Platform .isAndroid) {
1564+             SystemChannels .textInput.invokeMethod ('TextInput.show' );
1565+             SystemChannels .textInput.invokeMethod ('TextInput.hide' );
1566+           }
1567+         },
1568+         child:  Scaffold (
1569+           appBar:  DynamicMaterialApp .isFullscreen
1570+               ?  null 
1571+               :  AppBar (
1572+                   toolbarHeight:  kToolbarHeight,
1573+                   title:  widget.customTitle !=  null 
1574+                       ?  Text (widget.customTitle! )
1575+                       :  Form (
1576+                           key:  _filenameFormKey,
1577+                           autovalidateMode:  AutovalidateMode .onUserInteraction,
1578+                           child:  TextFormField (
1579+                             decoration:  const  InputDecoration (
1580+                               border:  InputBorder .none,
1581+                             ),
1582+                             controller:  filenameTextEditingController,
1583+                             onChanged:  renameFile,
1584+                             autofocus:  needsNaming,
1585+                             validator:  _validateFilenameTextField,
15711586                          ),
1572-                           controller:  filenameTextEditingController,
1573-                           onChanged:  renameFile,
1574-                           autofocus:  needsNaming,
1575-                           validator:  _validateFilenameTextField,
15761587                        ),
1577-                       ),
1578-                 leading:  SaveIndicator (
1579-                   savingState:  savingState,
1580-                   triggerSave:  saveToFile,
1581-                 ),
1582-                 actions:  [
1583-                   IconButton (
1584-                     icon:  const  AdaptiveIcon (
1585-                       icon:  Icons .insert_page_break,
1586-                       cupertinoIcon:  CupertinoIcons .add,
1587-                     ),
1588-                     tooltip:  t.editor.menu.insertPage,
1589-                     onPressed:  () =>  setState (() {
1590-                       final  currentPageIndex =  this .currentPageIndex;
1591-                       insertPageAfter (currentPageIndex);
1592-                       CanvasGestureDetector .scrollToPage (
1593-                         pageIndex:  currentPageIndex +  1 ,
1594-                         pages:  coreInfo.pages,
1595-                         screenWidth:  MediaQuery .sizeOf (context).width,
1596-                         transformationController:  _transformationController,
1597-                       );
1598-                     }),
1588+                   leading:  SaveIndicator (
1589+                     savingState:  savingState,
1590+                     triggerSave:  saveToFile,
15991591                  ),
1600-                   IconButton (
1601-                     icon:  const  AdaptiveIcon (
1602-                       icon:  Icons .grid_view,
1603-                       cupertinoIcon:  CupertinoIcons .rectangle_grid_2x2,
1592+                   actions:  [
1593+                     IconButton (
1594+                       icon:  const  AdaptiveIcon (
1595+                         icon:  Icons .insert_page_break,
1596+                         cupertinoIcon:  CupertinoIcons .add,
1597+                       ),
1598+                       tooltip:  t.editor.menu.insertPage,
1599+                       onPressed:  () =>  setState (() {
1600+                         final  currentPageIndex =  this .currentPageIndex;
1601+                         insertPageAfter (currentPageIndex);
1602+                         CanvasGestureDetector .scrollToPage (
1603+                           pageIndex:  currentPageIndex +  1 ,
1604+                           pages:  coreInfo.pages,
1605+                           screenWidth:  MediaQuery .sizeOf (context).width,
1606+                           transformationController:  _transformationController,
1607+                         );
1608+                       }),
16041609                    ),
1605-                     tooltip :  t.editor.pages, 
1606-                     onPressed :  () { 
1607-                       showDialog ( 
1608-                         context :  context ,
1609-                         builder :  (context)  =>   AdaptiveAlertDialog ( 
1610-                           title :   Text ( t.editor.pages) ,
1611-                           content :   pageManager (context), 
1612-                           actions :   const  [], 
1613-                         ) ,
1614-                       ); 
1615-                     } ,
1616-                   ),
1617-                   IconButton ( 
1618-                     icon :   const   AdaptiveIcon ( 
1619-                       icon :   Icons .more_vert, 
1620-                       cupertinoIcon :   CupertinoIcons .ellipsis_vertical ,
1610+                     IconButton ( 
1611+                       icon :   const   AdaptiveIcon ( 
1612+                         icon :   Icons .grid_view, 
1613+                         cupertinoIcon :   CupertinoIcons .rectangle_grid_2x2 ,
1614+                       ), 
1615+                       tooltip :   t.editor.pages,
1616+                       onPressed :  () { 
1617+                         showDialog ( 
1618+                           context :  context ,
1619+                           builder :  (context)  =>   AdaptiveAlertDialog ( 
1620+                             title :   Text (t.editor.pages) ,
1621+                             content :   pageManager (context ),
1622+                             actions :   const  [], 
1623+                           ), 
1624+                         ); 
1625+                       } ,
16211626                    ),
1622-                     onPressed:  () {
1623-                       showModalBottomSheet (
1624-                         context:  context,
1625-                         builder:  (context) =>  bottomSheet (context),
1626-                         isScrollControlled:  true ,
1627-                         showDragHandle:  true ,
1628-                         backgroundColor:  colorScheme.surface,
1629-                         constraints:  const  BoxConstraints (
1630-                           maxWidth:  500 ,
1631-                         ),
1632-                       );
1633-                     },
1634-                   )
1635-                 ],
1636-               ),
1637-         body:  body,
1638-         floatingActionButton:  (DynamicMaterialApp .isFullscreen && 
1639-                 ! Prefs .editorToolbarShowInFullscreen.value)
1640-             ?  FloatingActionButton (
1641-                 shape:  cupertino ?  const  CircleBorder () :  null ,
1642-                 onPressed:  () {
1643-                   DynamicMaterialApp .setFullscreen (false , updateSystem:  true );
1644-                 },
1645-                 child:  const  Icon (Icons .fullscreen_exit),
1646-               )
1647-             :  null ,
1627+                     IconButton (
1628+                       icon:  const  AdaptiveIcon (
1629+                         icon:  Icons .more_vert,
1630+                         cupertinoIcon:  CupertinoIcons .ellipsis_vertical,
1631+                       ),
1632+                       onPressed:  () {
1633+                         showModalBottomSheet (
1634+                           context:  context,
1635+                           builder:  (context) =>  bottomSheet (context),
1636+                           isScrollControlled:  true ,
1637+                           showDragHandle:  true ,
1638+                           backgroundColor:  colorScheme.surface,
1639+                           constraints:  const  BoxConstraints (
1640+                             maxWidth:  500 ,
1641+                           ),
1642+                         );
1643+                       },
1644+                     )
1645+                   ],
1646+                 ),
1647+           body:  body,
1648+           floatingActionButton:  (DynamicMaterialApp .isFullscreen && 
1649+                   ! Prefs .editorToolbarShowInFullscreen.value)
1650+               ?  FloatingActionButton (
1651+                   shape:  cupertino ?  const  CircleBorder () :  null ,
1652+                   onPressed:  () {
1653+                     DynamicMaterialApp .setFullscreen (false , updateSystem:  true );
1654+                   },
1655+                   child:  const  Icon (Icons .fullscreen_exit),
1656+                 )
1657+               :  null ,
1658+         ),
16481659      ),
16491660    );
16501661  }
0 commit comments