add rich editor

merge-requests/673/head
Elham Rababah 5 years ago
parent ced2e533f0
commit 8cac9b6fe9

@ -58,6 +58,8 @@ PODS:
- Flutter (1.0.0)
- flutter_flexible_toast (0.0.1):
- Flutter
- flutter_inappwebview (0.0.1):
- Flutter
- flutter_plugin_android_lifecycle (0.0.1):
- Flutter
- GoogleDataTransport (7.5.1):
@ -151,6 +153,7 @@ DEPENDENCIES:
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`)
- flutter_flexible_toast (from `.symlinks/plugins/flutter_flexible_toast/ios`)
- flutter_inappwebview (from `.symlinks/plugins/flutter_inappwebview/ios`)
- flutter_plugin_android_lifecycle (from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`)
- hexcolor (from `.symlinks/plugins/hexcolor/ios`)
- imei_plugin (from `.symlinks/plugins/imei_plugin/ios`)
@ -218,6 +221,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_flexible_toast:
:path: ".symlinks/plugins/flutter_flexible_toast/ios"
flutter_inappwebview:
:path: ".symlinks/plugins/flutter_inappwebview/ios"
flutter_plugin_android_lifecycle:
:path: ".symlinks/plugins/flutter_plugin_android_lifecycle/ios"
hexcolor:
@ -285,6 +290,7 @@ SPEC CHECKSUMS:
FirebaseMessaging: 5eca4ef173de76253352511aafef774caa1cba2a
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_flexible_toast: 0547e740cae0c33bb7c51bcd931233f4584e1143
flutter_inappwebview: 69dfbac46157b336ffbec19ca6dfd4638c7bf189
flutter_plugin_android_lifecycle: dc0b544e129eebb77a6bfb1239d4d1c673a60a35
GoogleDataTransport: f56af7caa4ed338dc8e138a5d7c5973e66440833
GoogleUtilities: 7f2f5a07f888cdb145101d6042bc4422f57e70b3
@ -322,4 +328,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 649616dc336b3659ac6b2b25159d8e488e042b69
COCOAPODS: 1.10.1
COCOAPODS: 1.10.0.rc.1

@ -0,0 +1,174 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/provider/robot_provider.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:flutter/material.dart';
import 'package:html_editor_enhanced/html_editor.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_to_text.dart' as stt;
import '../speech-text-popup.dart';
class HtmlRichEditor extends StatefulWidget {
HtmlRichEditor({
key,
this.hint = "Your text here...",
this.initialText,
this.height = 400,
this.decoration,
this.darkMode = false,
this.showBottomToolbar = false,
this.toolbar,
}) : super(key: key);
final String hint;
final String initialText;
final double height;
final BoxDecoration decoration;
final bool darkMode;
final bool showBottomToolbar;
final List<Toolbar> toolbar;
@override
_HtmlRichEditorState createState() => _HtmlRichEditorState();
}
class _HtmlRichEditorState extends State<HtmlRichEditor> {
ProjectViewModel projectViewModel;
stt.SpeechToText speech = stt.SpeechToText();
var recognizedWord;
var event = RobotProvider();
@override
void initState() {
requestPermissions();
event.controller.stream.listen((p) {
if (p['startPopUp'] == 'true') {
if (this.mounted) {
initSpeechState().then((value) => {onVoiceText()});
}
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
return Stack(
children: [
HtmlEditor(
hint: widget.hint,
height: widget.height,
initialText: widget.initialText,
showBottomToolbar: widget.showBottomToolbar,
darkMode: widget.darkMode,
decoration: widget.decoration ??
BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
border: Border.all(color: Colors.grey[200], width: 0.5),
),
toolbar: widget.toolbar ??
const [
// Style(),
Font(buttons: [
FontButtons.bold,
FontButtons.underline,
FontButtons.clear
]),
// ColorBar(buttons: [ColorButtons.color]),
Paragraph(buttons: [
ParagraphButtons.ul,
ParagraphButtons.ol,
ParagraphButtons.paragraph
]),
// Insert(buttons: [InsertButtons.link, InsertButtons.picture, InsertButtons.video, InsertButtons.table]),
// Misc(buttons: [MiscButtons.fullscreen, MiscButtons.codeview, MiscButtons.help])
],
),
Positioned(
top:
50, //MediaQuery.of(context).size.height * 0,
right: projectViewModel.isArabic
? MediaQuery.of(context).size.width * 0.75
: 15,
child: Column(
children: [
IconButton(
icon: Icon(DoctorApp.speechtotext,
color: Colors.black, size: 35),
onPressed: () {
initSpeechState()
.then((value) => {onVoiceText()});
},
),
],
))
],
);
}
onVoiceText() async {
new SpeechToText(context: context).showAlertDialog(context);
var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode;
bool available = await speech.initialize(
onStatus: statusListener, onError: errorListener);
if (available) {
speech.listen(
onResult: resultListener,
listenMode: stt.ListenMode.confirmation,
localeId: lang == 'en' ? 'en-US' : 'ar-SA',
);
} else {
print("The user has denied the use of speech recognition.");
}
}
void errorListener(SpeechRecognitionError error) {
event.setValue({"searchText": 'null'});
//SpeechToText.closeAlertDialog(context);
print(error);
}
void statusListener(String status) {
recognizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....';
}
void requestPermissions() async {
Map<Permission, PermissionStatus> statuses = await [
Permission.microphone,
].request();
}
void resultListener(result)async {
recognizedWord = result.recognizedWords;
event.setValue({"searchText": recognizedWord});
String txt = await HtmlEditor.getText();
if (result.finalResult == true) {
setState(() {
SpeechToText.closeAlertDialog(context);
speech.stop();
HtmlEditor.setText(txt+recognizedWord);
});
} else {
print(result.finalResult);
}
}
Future<void> initSpeechState() async {
bool hasSpeech = await speech.initialize(
onError: errorListener, onStatus: statusListener);
print(hasSpeech);
if (!mounted) return;
}
}

@ -426,6 +426,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
flutter_inappwebview:
dependency: transitive
description:
name: flutter_inappwebview
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0+4"
flutter_localizations:
dependency: "direct main"
description: flutter
@ -518,6 +525,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+4"
html_editor_enhanced:
dependency: "direct main"
description:
name: html_editor_enhanced
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
http:
dependency: "direct main"
description:
@ -1013,6 +1027,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+3"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.2"
vector_math:
dependency: transitive
description:

@ -90,6 +90,11 @@ dependencies:
speech_to_text:
path: speech_to_text
#Html Editor Enhanced
html_editor_enhanced: ^1.3.0
dev_dependencies:
flutter_test:
sdk: flutter

@ -1,69 +1,48 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "1.15.0-nullsafety.3"
cupertino_icons:
dependency: "direct main"
description:
@ -71,6 +50,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
@ -81,13 +67,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
json_annotation:
dependency: transitive
description:
@ -101,14 +80,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety.3"
nested:
dependency: transitive
description:
@ -122,7 +101,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.8.0-nullsafety.1"
permission_handler:
dependency: "direct main"
description:
@ -137,13 +116,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
plugin_platform_interface:
dependency: transitive
description:
@ -158,13 +130,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.1"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
sky_engine:
dependency: transitive
description: flutter
@ -176,7 +141,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.2"
speech_to_text:
dependency: "direct dev"
description:
@ -190,56 +155,49 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.7.0 <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.16.0 <2.0.0"

@ -15,13 +15,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.39.13"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
@ -35,14 +28,14 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
build:
dependency: transitive
description:
@ -99,13 +92,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "7.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.2.0-nullsafety.1"
checked_yaml:
dependency: transitive
description:
@ -119,7 +119,7 @@ packages:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0-nullsafety.1"
code_builder:
dependency: transitive
description:
@ -133,7 +133,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
version: "1.15.0-nullsafety.3"
convert:
dependency: transitive
description:
@ -168,7 +168,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
fixnum:
dependency: transitive
description:
@ -221,13 +221,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
io:
dependency: transitive
description:
@ -269,14 +262,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety.3"
mime:
dependency: transitive
description:
@ -311,7 +304,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.8.0-nullsafety.1"
pedantic:
dependency: transitive
description:
@ -319,13 +312,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
pool:
dependency: transitive
description:
@ -386,21 +372,21 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
stream_transform:
dependency: transitive
description:
@ -414,21 +400,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.2.19-nullsafety.2"
timing:
dependency: transitive
description:
@ -442,14 +428,14 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety.3"
watcher:
dependency: transitive
description:
@ -464,13 +450,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
yaml:
dependency: transitive
description:
@ -479,5 +458,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.7.0 <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.10.0"

Loading…
Cancel
Save