modify
This commit is contained in:
@@ -31,16 +31,18 @@ class _TermState extends State<Term> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = ZefyrController(_loadDocument());
|
||||
print("controller terms => ${_controller.document}");
|
||||
_focusNode = FocusNode();
|
||||
}
|
||||
|
||||
NotusDocument _loadDocument() {
|
||||
MainModel mainModel = Provider.of<MainModel>(context, listen: false);
|
||||
String term = mainModel.setting.terms;
|
||||
|
||||
print("terms => $term");
|
||||
NotusDocument doc;
|
||||
try {
|
||||
doc = NotusDocument.fromJson(jsonDecode(term));
|
||||
print('doc=> $doc');
|
||||
} catch (e) {}
|
||||
if (doc == null) {
|
||||
doc = NotusDocument();
|
||||
@@ -51,7 +53,6 @@ class _TermState extends State<Term> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MainModel mainModel = Provider.of<MainModel>(context);
|
||||
print("controller terms => ${_controller.document}");
|
||||
|
||||
bool isOwnerAndAbove =
|
||||
mainModel.user != null && mainModel.user.isOwnerAndAbove();
|
||||
@@ -89,21 +90,41 @@ class _TermState extends State<Term> {
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: !widget.agreePage,
|
||||
leading: new IconButton(
|
||||
icon: new Icon(Icons.close),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
// automaticallyImplyLeading: !widget.agreePage,
|
||||
title: LocalText(context, 'term', color: Colors.white, fontSize: 20),
|
||||
backgroundColor: primaryColor,
|
||||
actions: <Widget>[
|
||||
isOwnerAndAbove || hasAdmin
|
||||
? IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => TermEdit()),
|
||||
);
|
||||
},
|
||||
)
|
||||
: Container()
|
||||
// isOwnerAndAbove || hasAdmin
|
||||
// ?
|
||||
IconButton(
|
||||
icon: Icon(Icons.edit),
|
||||
onPressed: () async {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TermEdit((data) {
|
||||
setState(() {
|
||||
_controller = ZefyrController(data);
|
||||
});
|
||||
})),
|
||||
);
|
||||
// print('doc=> $doc');
|
||||
|
||||
// setState(() {
|
||||
// document = doc;
|
||||
// });
|
||||
// var document = await
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) => TermEdit()),
|
||||
// );
|
||||
},
|
||||
)
|
||||
// : Container()
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
|
||||
Reference in New Issue
Block a user