Fix bug translation FR

This commit is contained in:
Thomas Fransolet 2024-01-17 17:00:24 +01:00
parent 57c7d56306
commit 0f325605e5
3 changed files with 65 additions and 5 deletions

28
analysis_options.yaml Normal file
View File

@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -13,13 +13,25 @@ class _TranslationInputAndResourceContainerState extends State<TranslationInputA
TabController? _tabController; TabController? _tabController;
QuillEditorController controllerQuill = QuillEditorController(); QuillEditorController controllerQuill = QuillEditorController();
ValueNotifier<String?>? currentLanguage; ValueNotifier<String?>? currentLanguage;
bool isInit = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_tabController = new TabController(length: widget.newValues.length, vsync: this); _tabController = new TabController(length: widget.newValues.length, vsync: this);
currentLanguage = ValueNotifier<String>(widget.newValues.first.language!); currentLanguage = ValueNotifier<String>(widget.newValues.first.language!);
controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
controllerQuill.onEditorLoaded(() {
print("onEditorLoaded");
isInit = true;
});
Future.delayed(Duration(milliseconds: 500), () {
print("Future.delayed");
controllerQuill.clear();
controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
isInit = true;
});
controllerQuill.onTextChanged((p0) async { controllerQuill.onTextChanged((p0) async {
var plainText = await controllerQuill.getPlainText(); var plainText = await controllerQuill.getPlainText();
@ -41,6 +53,8 @@ class _TranslationInputAndResourceContainerState extends State<TranslationInputA
setState(() { setState(() {
currentLanguage!.value = widget.newValues[_tabController!.index].language; currentLanguage!.value = widget.newValues[_tabController!.index].language;
if(!widget.isAudio) { if(!widget.isAudio) {
print("insert try without ress");
print(widget.newValues[_tabController!.index].value!);
controllerQuill.clear(); controllerQuill.clear();
controllerQuill.insertText(widget.newValues[_tabController!.index].value!); controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
} }
@ -145,7 +159,9 @@ class _TranslationInputAndResourceContainerState extends State<TranslationInputA
//onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'), //onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'),
//onTextChanged: (text) => debugPrint('widget text change $text'), //onTextChanged: (text) => debugPrint('widget text change $text'),
onTextChanged: (value) { onTextChanged: (value) {
newValues.where((element) => element.language! == currentLanguage.value).first.value = value; if(isInit) {
newValues.where((element) => element.language! == currentLanguage.value).first.value = value;
}
}, },
onEditorCreated: () => debugPrint('Editor has been loaded'), onEditorCreated: () => debugPrint('Editor has been loaded'),
onEditorResized: (height) => onEditorResized: (height) =>

View File

@ -12,13 +12,25 @@ class _TranslationInputContainerState extends State<TranslationInputContainer> w
TabController? _tabController; TabController? _tabController;
QuillEditorController controllerQuill = QuillEditorController(); QuillEditorController controllerQuill = QuillEditorController();
ValueNotifier<String?>? currentLanguage; ValueNotifier<String?>? currentLanguage;
bool isInit = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_tabController = new TabController(length: widget.newValues.length, vsync: this); _tabController = new TabController(length: widget.newValues.length, vsync: this);
currentLanguage = ValueNotifier<String>(widget.newValues.first.language!); currentLanguage = ValueNotifier<String>(widget.newValues.first.language!);
controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
controllerQuill.onEditorLoaded(() {
print("onEditorLoaded");
isInit = true;
});
Future.delayed(Duration(milliseconds: 500), () {
print("Future.delayed");
controllerQuill.clear();
controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
isInit = true;
});
controllerQuill.onTextChanged((p0) async { controllerQuill.onTextChanged((p0) async {
var plainText = await controllerQuill.getPlainText(); var plainText = await controllerQuill.getPlainText();
@ -40,6 +52,8 @@ class _TranslationInputContainerState extends State<TranslationInputContainer> w
setState(() { setState(() {
currentLanguage!.value = widget.newValues[_tabController!.index].language; currentLanguage!.value = widget.newValues[_tabController!.index].language;
if(!widget.isAudio) { if(!widget.isAudio) {
print("insert try without ress");
print(widget.newValues[_tabController!.index].value!);
controllerQuill.clear(); controllerQuill.clear();
controllerQuill.insertText(widget.newValues[_tabController!.index].value!); controllerQuill.insertText(widget.newValues[_tabController!.index].value!);
} }
@ -82,7 +96,7 @@ class _TranslationInputContainerState extends State<TranslationInputContainer> w
child: Container( child: Container(
height: widget.isTitle ? MediaQuery.of(context).size.height *0.13 : MediaQuery.of(context).size.height *0.35, height: widget.isTitle ? MediaQuery.of(context).size.height *0.13 : MediaQuery.of(context).size.height *0.35,
child: QuillHtmlEditor( child: QuillHtmlEditor(
text: newValues.where((element) => element.language! == currentLanguage.value).first.value!, //text: newValues.where((element) => element.language! == currentLanguage.value).first.value!,
hintText: '', hintText: '',
controller: controllerQuill, controller: controllerQuill,
minHeight: widget.isTitle ? 80 : 240, minHeight: widget.isTitle ? 80 : 240,
@ -97,7 +111,9 @@ class _TranslationInputContainerState extends State<TranslationInputContainer> w
//onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'), //onFocusChanged: (hasFocus) => debugPrint('has focus $hasFocus'),
//onTextChanged: (text) => debugPrint('widget text change $text'), //onTextChanged: (text) => debugPrint('widget text change $text'),
onTextChanged: (value) { onTextChanged: (value) {
newValues.where((element) => element.language! == currentLanguage.value).first.value = value; if(isInit) {
newValues.where((element) => element.language! == currentLanguage.value).first.value = value;
}
}, },
onEditorCreated: () => debugPrint('Editor has been loaded'), onEditorCreated: () => debugPrint('Editor has been loaded'),
onEditorResized: (height) => onEditorResized: (height) =>