upgrade packages
This commit is contained in:
@@ -9,7 +9,7 @@ import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:zefyrka/zefyrka.dart';
|
||||
// import 'package:zefyrka/zefyrka.dart';
|
||||
// import 'package:zefyr/zefyr.dart';
|
||||
|
||||
typedef void ProfileCallback();
|
||||
@@ -23,8 +23,8 @@ class TermEdit extends StatefulWidget {
|
||||
|
||||
class _TermEditState extends State<TermEdit> {
|
||||
/// Allows to control the editor and the document.
|
||||
late ZefyrController _controllerEng;
|
||||
late ZefyrController _controllerMm;
|
||||
// late ZefyrController _controllerEng;
|
||||
// late ZefyrController _controllerMm;
|
||||
|
||||
/// Zefyr editor like any other input field requires a focus node.
|
||||
late FocusNode _focusNodeEng;
|
||||
@@ -37,23 +37,23 @@ class _TermEditState extends State<TermEdit> {
|
||||
_isLoading = false;
|
||||
|
||||
// Here we must load the document and pass it to Zefyr controller.
|
||||
_controllerEng = ZefyrController(_loadDocument(widget.term!.termEng ?? ""));
|
||||
_controllerMm = ZefyrController(_loadDocument(widget.term!.termMm ?? ""));
|
||||
// _controllerEng = ZefyrController(_loadDocument(widget.term!.termEng ?? ""));
|
||||
// _controllerMm = ZefyrController(_loadDocument(widget.term!.termMm ?? ""));
|
||||
_focusNodeEng = FocusNode();
|
||||
_focusNodeMm = FocusNode();
|
||||
}
|
||||
|
||||
/// Loads the document to be edited in Zefyr.
|
||||
NotusDocument _loadDocument(String data) {
|
||||
late NotusDocument doc;
|
||||
try {
|
||||
doc = NotusDocument.fromJson(jsonDecode(data));
|
||||
} catch (e) {}
|
||||
if (doc == null) {
|
||||
doc = NotusDocument();
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
// NotusDocument _loadDocument(String data) {
|
||||
// late NotusDocument doc;
|
||||
// try {
|
||||
// doc = NotusDocument.fromJson(jsonDecode(data));
|
||||
// } catch (e) {}
|
||||
// if (doc == null) {
|
||||
// doc = NotusDocument();
|
||||
// }
|
||||
// return doc;
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -122,8 +122,8 @@ class _TermEditState extends State<TermEdit> {
|
||||
height: MediaQuery.of(context).size.height - 200,
|
||||
child: TabBarView(
|
||||
children: [
|
||||
textEditor(_controllerEng, _focusNodeEng),
|
||||
textEditor(_controllerMm, _focusNodeMm),
|
||||
// textEditor(_controllerEng, _focusNodeEng),
|
||||
// textEditor(_controllerMm, _focusNodeMm),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -135,24 +135,24 @@ class _TermEditState extends State<TermEdit> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget textEditor(ZefyrController controller, FocusNode focusNode) {
|
||||
return ListView(
|
||||
children: [
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height - 200,
|
||||
child: ZefyrEditor(
|
||||
autofocus: false,
|
||||
padding: EdgeInsets.all(16),
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
// Widget textEditor(ZefyrController controller, FocusNode focusNode) {
|
||||
// return ListView(
|
||||
// children: [
|
||||
// Container(
|
||||
// height: MediaQuery.of(context).size.height - 200,
|
||||
// child: ZefyrEditor(
|
||||
// autofocus: false,
|
||||
// padding: EdgeInsets.all(16),
|
||||
// controller: controller,
|
||||
// focusNode: focusNode,
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 10,
|
||||
// )
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
_unfocus() {
|
||||
FocusScope.of(context).unfocus();
|
||||
@@ -163,11 +163,11 @@ class _TermEditState extends State<TermEdit> {
|
||||
_isLoading = true;
|
||||
});
|
||||
try {
|
||||
final contentsEng = jsonEncode(_controllerEng.document);
|
||||
final contentsMm = jsonEncode(_controllerMm.document);
|
||||
// print('contents => $contentsEng');
|
||||
TermModel termModel = Provider.of<TermModel>(context, listen: false);
|
||||
await termModel.saveTerm(Term(termEng: contentsEng, termMm: contentsMm));
|
||||
// final contentsEng = jsonEncode(_controllerEng.document);
|
||||
// final contentsMm = jsonEncode(_controllerMm.document);
|
||||
// // print('contents => $contentsEng');
|
||||
// TermModel termModel = Provider.of<TermModel>(context, listen: false);
|
||||
// await termModel.saveTerm(Term(termEng: contentsEng, termMm: contentsMm));
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:zefyrka/zefyrka.dart';
|
||||
// import 'package:zefyrka/zefyrka.dart';
|
||||
|
||||
typedef void ProfileCallback();
|
||||
|
||||
@@ -23,9 +23,9 @@ class TermPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _TermPageState extends State<TermPage> {
|
||||
late ZefyrController _controller;
|
||||
// late ZefyrController _controller;
|
||||
late FocusNode _focusNode;
|
||||
late NotusDocument document = new NotusDocument();
|
||||
// late NotusDocument document = new NotusDocument();
|
||||
bool isLoading = false;
|
||||
|
||||
@override
|
||||
@@ -34,18 +34,18 @@ class _TermPageState extends State<TermPage> {
|
||||
_focusNode = FocusNode();
|
||||
}
|
||||
|
||||
NotusDocument _loadDocument(Setting? setting) {
|
||||
bool isEng = Provider.of<LanguageModel>(context).isEng;
|
||||
String? term = isEng ? (setting!.termsEng ?? "") : (setting!.termsMm ?? "");
|
||||
late NotusDocument doc;
|
||||
try {
|
||||
doc = NotusDocument.fromJson(jsonDecode(term));
|
||||
} catch (e) {}
|
||||
if (doc == null) {
|
||||
doc = NotusDocument();
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
// NotusDocument _loadDocument(Setting? setting) {
|
||||
// bool isEng = Provider.of<LanguageModel>(context).isEng;
|
||||
// String? term = isEng ? (setting!.termsEng ?? "") : (setting!.termsMm ?? "");
|
||||
// late NotusDocument doc;
|
||||
// try {
|
||||
// doc = NotusDocument.fromJson(jsonDecode(term));
|
||||
// } catch (e) {}
|
||||
// if (doc == null) {
|
||||
// doc = NotusDocument();
|
||||
// }
|
||||
// return doc;
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -85,11 +85,11 @@ class _TermPageState extends State<TermPage> {
|
||||
]
|
||||
: [],
|
||||
),
|
||||
body: ZefyrEditor(
|
||||
padding: EdgeInsets.all(16),
|
||||
controller: ZefyrController(_loadDocument(setting)),
|
||||
focusNode: _focusNode,
|
||||
),
|
||||
// body: ZefyrEditor(
|
||||
// padding: EdgeInsets.all(16),
|
||||
// controller: ZefyrController(_loadDocument(setting)),
|
||||
// focusNode: _focusNode,
|
||||
// ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user