2020-05-29 07:45:27 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:fcs/model/language_model.dart';
|
|
|
|
|
import 'package:fcs/model/main_model.dart';
|
|
|
|
|
import 'package:fcs/model/manual_model.dart';
|
|
|
|
|
import 'package:fcs/pages/manual/manual_item_title_dialog.dart';
|
|
|
|
|
import 'package:fcs/pages/util.dart';
|
|
|
|
|
import 'package:fcs/vo/manual.dart';
|
|
|
|
|
import 'package:fcs/widget/local_text.dart';
|
|
|
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
|
|
2020-05-29 16:14:17 +06:30
|
|
|
import '../../theme/theme.dart';
|
2020-05-29 07:45:27 +06:30
|
|
|
import 'slide_page.dart';
|
|
|
|
|
|
|
|
|
|
class ManualPage extends StatefulWidget {
|
2020-05-29 16:14:17 +06:30
|
|
|
final String marketplace;
|
|
|
|
|
|
|
|
|
|
const ManualPage({Key key, this.marketplace}) : super(key: key);
|
2020-05-29 07:45:27 +06:30
|
|
|
@override
|
|
|
|
|
_ManualPageState createState() => _ManualPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ManualPageState extends State<ManualPage> {
|
|
|
|
|
TextEditingController _manualVersionController = TextEditingController();
|
|
|
|
|
final double dotSize = 10.0;
|
|
|
|
|
List<ManualItem> helpList = new List();
|
|
|
|
|
bool isEng;
|
|
|
|
|
String versionName;
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
helpList.clear();
|
|
|
|
|
var manualModel = Provider.of<ManualModel>(context, listen: false);
|
|
|
|
|
var mainModel = Provider.of<MainModel>(context, listen: false);
|
|
|
|
|
versionName = manualModel.version;
|
|
|
|
|
helpList = manualModel.getHelpList(mainModel.isBuyer());
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
var manualModel = Provider.of<ManualModel>(context);
|
|
|
|
|
var mainModel = Provider.of<MainModel>(context);
|
|
|
|
|
var languageModel = Provider.of<LanguageModel>(context);
|
|
|
|
|
isEng = languageModel.isEng;
|
|
|
|
|
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
2020-05-31 15:00:11 +06:30
|
|
|
leading: new IconButton(
|
2020-06-01 14:24:45 +06:30
|
|
|
icon: new Icon(Icons.close, color: Colors.white),
|
2020-05-31 15:00:11 +06:30
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
2020-05-29 16:14:17 +06:30
|
|
|
title: Text(widget.marketplace == null ? '' : widget.marketplace),
|
|
|
|
|
backgroundColor: primaryColor,
|
2020-05-29 07:45:27 +06:30
|
|
|
),
|
|
|
|
|
body: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Expanded(
|
|
|
|
|
child: new ListView.builder(
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
padding: EdgeInsets.only(left: 15, right: 15, top: 5),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: helpList.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return Card(
|
|
|
|
|
elevation: 10,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => SlidePage(
|
|
|
|
|
helpDetail: helpList[index],
|
|
|
|
|
index: index,
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
child: Row(children: <Widget>[
|
|
|
|
|
Expanded(
|
|
|
|
|
child: new Padding(
|
|
|
|
|
padding:
|
|
|
|
|
const EdgeInsets.symmetric(vertical: 5.0),
|
|
|
|
|
child: new Row(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
new Padding(
|
|
|
|
|
padding: new EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 15.0 - dotSize / 2),
|
|
|
|
|
child: Container(
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
"assets/page.png",
|
|
|
|
|
width: 50,
|
|
|
|
|
height: 50,
|
|
|
|
|
)),
|
|
|
|
|
),
|
|
|
|
|
new Expanded(
|
|
|
|
|
child: new Column(
|
|
|
|
|
crossAxisAlignment:
|
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Text(
|
|
|
|
|
isEng
|
|
|
|
|
? helpList[index].title
|
|
|
|
|
: helpList[index].titlemm,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 15,
|
|
|
|
|
color: Colors.grey),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
mainModel.isSysAdmin()
|
|
|
|
|
? Container(
|
|
|
|
|
padding: EdgeInsets.only(right: 20),
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
showConfirmDialog(
|
|
|
|
|
context, "manual.confirm", () {
|
|
|
|
|
setState(() {
|
|
|
|
|
manualModel.deleteManualItem(
|
|
|
|
|
helpList[index]);
|
|
|
|
|
helpList = manualModel.getHelpList(
|
|
|
|
|
mainModel.isBuyer());
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Icon(Icons.delete),
|
|
|
|
|
))
|
|
|
|
|
: Container()
|
|
|
|
|
])),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
floatingActionButton: mainModel.isSysAdmin()
|
|
|
|
|
? FloatingActionButton(
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
ManualItem newItem = await showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (_) => ManualItemTitleDialog());
|
|
|
|
|
if (helpList.toList().length == 0) {
|
|
|
|
|
newItem.id = 1;
|
|
|
|
|
} else {
|
|
|
|
|
dynamic max = helpList.first;
|
|
|
|
|
helpList.forEach((e) {
|
|
|
|
|
if (e.id > max.id) max = e;
|
|
|
|
|
});
|
|
|
|
|
newItem.id = max.id + 1;
|
|
|
|
|
}
|
|
|
|
|
setState(() {
|
|
|
|
|
helpList.add(newItem);
|
|
|
|
|
});
|
|
|
|
|
manualModel.addManualTitle(newItem);
|
|
|
|
|
},
|
|
|
|
|
child: Icon(Icons.add),
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_deleteManualItem(ManualItem item, ManualModel manualModel) {
|
|
|
|
|
return showConfirmDialog(context, "manual.confirm", () {
|
|
|
|
|
setState(() {
|
|
|
|
|
manualModel.deleteManualItem(item);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_inputManualVersion(BuildContext context, ManualModel manModel) async {
|
|
|
|
|
return showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) {
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
title: new Text('Version'),
|
|
|
|
|
content: TextField(
|
|
|
|
|
controller: _manualVersionController,
|
|
|
|
|
decoration: InputDecoration(hintText: "Enter manual version"),
|
|
|
|
|
),
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
new FlatButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
String version = _manualVersionController.text;
|
|
|
|
|
String dir = manModel.dataDir;
|
|
|
|
|
manModel.uploadStorageManualData(version, dir);
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
child: new Text('Save'))
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|