diff --git a/CHANGELOG.md b/CHANGELOG.md index 01ffaf7..ae941e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [3.4.0] - 2023.01.05 + +- Remove `DefaultMongolTextEditingShortcuts` from `MongolEditableTextState` (#35) (@Satsrag) +- To switch the behavior of left/right and up/down keys in `MongolEditableText`, developers now need to add `MongolTextEditingShortcuts` at the top of the widget tree. See [#33](https://github.com/suragch/mongol/issues/33) for discussion. + ## [3.3.1] - 2022.12.31 - Fix: crash when MongolTextField contain a line end with ' \n' (#34) (@Satsrag) diff --git a/README.md b/README.md index 8d9cf7b..563e3e1 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,13 @@ Since it's likely that some of your users' devices won't have a Mongolian font i ### 1. Get a font -You can find a font from the following companies: +You can find a font from the following sources: -- [Menksoft](http://www.menksoft.com/site/alias__menkcms/2805/Default.aspx) -- [Delehi](http://www.delehi.com/cn/2693.html) -- [One BolorSoft font](https://www.mngl.net/downloads/fonts/MongolianScript.ttf) +- [Menksoft](https://www.mklai.cn/download-font?productId=a0ec7735b5714334934ff3c094ca0a5e) +- [MongolFont](http://www.mongolfont.com/en/font/index.html) +- [BolorSoft](https://www.mngl.net/#download) +- [Z Mongol Code](https://install.zcodetech.com/) +- [CMs font](https://phabricator.wikimedia.org/T130502) ### 2. Add the font to your project @@ -109,9 +111,8 @@ In your `main.dart` file, set the `fontFamily` for the app theme. ```dart MaterialApp( - title: 'My App', theme: ThemeData(fontFamily: 'MenksoftQagan'), - home: MyHomePage(), + // ... ); ``` @@ -142,6 +143,15 @@ MongolTextField( ), ``` +In order to correctly handle right/left and up/down keys on the web and desktop (or for physical keyboards connected to a mobile app), you need to return the `MongolTextEditingShortcuts` widget from the `builder` method of your `MaterialApp` (or `CupertinoApp` or `WidgetsApp`) at the top of your widget tree: + +```dart +MaterialApp( + builder: (context, child) => MongolTextEditingShortcuts(child: child), + // ... +) +``` + ## Horizontal lists You can display horizontally scrolling lists with the standard `ListView` widget. All you need to do is set the scroll direction to horizontal. @@ -227,6 +237,6 @@ This alert dialog works mostly the same as the Flutter `AlertDialog`. - Improve keyboard (this may be better as a separate package) - Various other text based widgets - Support `WidgetSpan`. -- Add missing tests (currently commented out) +- Add more tests - For `MongolTextAlign.bottom` don't count final space in line height - Add `MongolSelectableText` widget \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 16a4855..f71cec1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -27,15 +27,13 @@ class DemoApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - builder: (context, child) { - return MongolTextEditingShortcuts(child: child); - }, + builder: (context, child) => MongolTextEditingShortcuts(child: child), title: 'mongol', theme: ThemeData( fontFamily: 'MenksoftQagan', ), home: Scaffold( - appBar: AppBar(title: const Text('Flutter mongol package 3.3.1')), + appBar: AppBar(title: const Text('Flutter mongol package 3.4.0')), body: const HomeScreen(), ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index fbaa68d..dc0fd8c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -94,7 +94,7 @@ packages: path: ".." relative: true source: path - version: "3.3.1" + version: "3.4.0" path: dependency: transitive description: diff --git a/lib/src/editing/mongol_text_editing_shortcuts.dart b/lib/src/editing/mongol_text_editing_shortcuts.dart index 969bdc1..c8d45d9 100644 --- a/lib/src/editing/mongol_text_editing_shortcuts.dart +++ b/lib/src/editing/mongol_text_editing_shortcuts.dart @@ -11,14 +11,23 @@ import 'package:flutter/widgets.dart'; import 'mongol_text_editing_intents.dart'; /// Switch up/down arrow keys and left/right arrow keys +/// +/// Insert this widget just below the MaterialApp (or WidgetsApp or +/// CupertinoApp) in order to cause the arrow keys to behave as expected +/// in a `MongolTextField`. +/// +/// ``` +/// MaterialApp( +/// builder: (context, child) => MongolTextEditingShortcuts(child: child), +/// ``` class MongolTextEditingShortcuts extends StatelessWidget { const MongolTextEditingShortcuts({Key? key, required this.child}) : super(key: key); final Widget? child; - // These are shortcuts are shared between most platforms except macOS for it - // uses different modifier keys as the line/word modifier. + // These shortcuts are shared between most platforms except macOS, which + // uses different modifier keys for the line/word modifier. static final Map _commonShortcuts = { // Arrow: Move Selection. diff --git a/pubspec.yaml b/pubspec.yaml index 1214a14..bea20cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: mongol description: Flutter widget package for displaying and editing vertical Mongolian text. # When updating version, also update CHANGELOG.md and example/lib/main.dart -version: 3.3.1 +version: 3.4.0 homepage: https://github.com/suragch/mongol environment: