-
-
Notifications
You must be signed in to change notification settings - Fork 278
feat: support for xiaomi smart pen #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9131bdb
bec4440
a5eedfd
f4317ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import 'package:flutter/foundation.dart' show kDebugMode; | |
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter/services.dart'; | ||
| import 'package:flutter_quill/flutter_quill.dart' as flutter_quill; | ||
| import 'package:focus_detector/focus_detector.dart'; | ||
| import 'package:keybinder/keybinder.dart'; | ||
| import 'package:logging/logging.dart'; | ||
| import 'package:printing/printing.dart'; | ||
|
|
@@ -1555,96 +1556,106 @@ class EditorState extends State<Editor> { | |
| child: child!, | ||
| ); | ||
| }, | ||
| child: Scaffold( | ||
| appBar: DynamicMaterialApp.isFullscreen | ||
| ? null | ||
| : AppBar( | ||
| toolbarHeight: kToolbarHeight, | ||
| title: widget.customTitle != null | ||
| ? Text(widget.customTitle!) | ||
| : Form( | ||
| key: _filenameFormKey, | ||
| autovalidateMode: AutovalidateMode.onUserInteraction, | ||
| child: TextFormField( | ||
| decoration: const InputDecoration( | ||
| border: InputBorder.none, | ||
| child: FocusDetector( | ||
| onFocusGained: () { | ||
| // Key bindings won't work until keyboard is shown at least once for some reason. | ||
| // This is a workaround to fix that. It should be unnoticable to the user. | ||
| if (Platform.isAndroid) { | ||
| SystemChannels.textInput.invokeMethod('TextInput.show'); | ||
| SystemChannels.textInput.invokeMethod('TextInput.hide'); | ||
| } | ||
| }, | ||
|
Comment on lines
+1560
to
+1567
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This solution seems a bit hacky. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And Redmi (if it makes a difference), please. |
||
| child: Scaffold( | ||
| appBar: DynamicMaterialApp.isFullscreen | ||
| ? null | ||
| : AppBar( | ||
| toolbarHeight: kToolbarHeight, | ||
| title: widget.customTitle != null | ||
| ? Text(widget.customTitle!) | ||
| : Form( | ||
| key: _filenameFormKey, | ||
| autovalidateMode: AutovalidateMode.onUserInteraction, | ||
| child: TextFormField( | ||
| decoration: const InputDecoration( | ||
| border: InputBorder.none, | ||
| ), | ||
| controller: filenameTextEditingController, | ||
| onChanged: renameFile, | ||
| autofocus: needsNaming, | ||
| validator: _validateFilenameTextField, | ||
| ), | ||
| controller: filenameTextEditingController, | ||
| onChanged: renameFile, | ||
| autofocus: needsNaming, | ||
| validator: _validateFilenameTextField, | ||
| ), | ||
| ), | ||
| leading: SaveIndicator( | ||
| savingState: savingState, | ||
| triggerSave: saveToFile, | ||
| ), | ||
| actions: [ | ||
| IconButton( | ||
| icon: const AdaptiveIcon( | ||
| icon: Icons.insert_page_break, | ||
| cupertinoIcon: CupertinoIcons.add, | ||
| ), | ||
| tooltip: t.editor.menu.insertPage, | ||
| onPressed: () => setState(() { | ||
| final currentPageIndex = this.currentPageIndex; | ||
| insertPageAfter(currentPageIndex); | ||
| CanvasGestureDetector.scrollToPage( | ||
| pageIndex: currentPageIndex + 1, | ||
| pages: coreInfo.pages, | ||
| screenWidth: MediaQuery.sizeOf(context).width, | ||
| transformationController: _transformationController, | ||
| ); | ||
| }), | ||
| leading: SaveIndicator( | ||
| savingState: savingState, | ||
| triggerSave: saveToFile, | ||
| ), | ||
| IconButton( | ||
| icon: const AdaptiveIcon( | ||
| icon: Icons.grid_view, | ||
| cupertinoIcon: CupertinoIcons.rectangle_grid_2x2, | ||
| actions: [ | ||
| IconButton( | ||
| icon: const AdaptiveIcon( | ||
| icon: Icons.insert_page_break, | ||
| cupertinoIcon: CupertinoIcons.add, | ||
| ), | ||
| tooltip: t.editor.menu.insertPage, | ||
| onPressed: () => setState(() { | ||
| final currentPageIndex = this.currentPageIndex; | ||
| insertPageAfter(currentPageIndex); | ||
| CanvasGestureDetector.scrollToPage( | ||
| pageIndex: currentPageIndex + 1, | ||
| pages: coreInfo.pages, | ||
| screenWidth: MediaQuery.sizeOf(context).width, | ||
| transformationController: _transformationController, | ||
| ); | ||
| }), | ||
| ), | ||
| tooltip: t.editor.pages, | ||
| onPressed: () { | ||
| showDialog( | ||
| context: context, | ||
| builder: (context) => AdaptiveAlertDialog( | ||
| title: Text(t.editor.pages), | ||
| content: pageManager(context), | ||
| actions: const [], | ||
| ), | ||
| ); | ||
| }, | ||
| ), | ||
| IconButton( | ||
| icon: const AdaptiveIcon( | ||
| icon: Icons.more_vert, | ||
| cupertinoIcon: CupertinoIcons.ellipsis_vertical, | ||
| IconButton( | ||
| icon: const AdaptiveIcon( | ||
| icon: Icons.grid_view, | ||
| cupertinoIcon: CupertinoIcons.rectangle_grid_2x2, | ||
| ), | ||
| tooltip: t.editor.pages, | ||
| onPressed: () { | ||
| showDialog( | ||
| context: context, | ||
| builder: (context) => AdaptiveAlertDialog( | ||
| title: Text(t.editor.pages), | ||
| content: pageManager(context), | ||
| actions: const [], | ||
| ), | ||
| ); | ||
| }, | ||
| ), | ||
| onPressed: () { | ||
| showModalBottomSheet( | ||
| context: context, | ||
| builder: (context) => bottomSheet(context), | ||
| isScrollControlled: true, | ||
| showDragHandle: true, | ||
| backgroundColor: colorScheme.surface, | ||
| constraints: const BoxConstraints( | ||
| maxWidth: 500, | ||
| ), | ||
| ); | ||
| }, | ||
| ) | ||
| ], | ||
| ), | ||
| body: body, | ||
| floatingActionButton: (DynamicMaterialApp.isFullscreen && | ||
| !Prefs.editorToolbarShowInFullscreen.value) | ||
| ? FloatingActionButton( | ||
| shape: cupertino ? const CircleBorder() : null, | ||
| onPressed: () { | ||
| DynamicMaterialApp.setFullscreen(false, updateSystem: true); | ||
| }, | ||
| child: const Icon(Icons.fullscreen_exit), | ||
| ) | ||
| : null, | ||
| IconButton( | ||
| icon: const AdaptiveIcon( | ||
| icon: Icons.more_vert, | ||
| cupertinoIcon: CupertinoIcons.ellipsis_vertical, | ||
| ), | ||
| onPressed: () { | ||
| showModalBottomSheet( | ||
| context: context, | ||
| builder: (context) => bottomSheet(context), | ||
| isScrollControlled: true, | ||
| showDragHandle: true, | ||
| backgroundColor: colorScheme.surface, | ||
| constraints: const BoxConstraints( | ||
| maxWidth: 500, | ||
| ), | ||
| ); | ||
| }, | ||
| ) | ||
| ], | ||
| ), | ||
| body: body, | ||
| floatingActionButton: (DynamicMaterialApp.isFullscreen && | ||
| !Prefs.editorToolbarShowInFullscreen.value) | ||
| ? FloatingActionButton( | ||
| shape: cupertino ? const CircleBorder() : null, | ||
| onPressed: () { | ||
| DynamicMaterialApp.setFullscreen(false, updateSystem: true); | ||
| }, | ||
| child: const Icon(Icons.fullscreen_exit), | ||
| ) | ||
| : null, | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary/secondary color switching is out-of-scope for this PR. Additional stylus button functionalities are something we'd need to properly design in the future.
For now, please just make either button switch to the eraser like with other styluses.