add structure
This commit is contained in:
234
lib/pages/manual/manual_page.dart
Normal file
234
lib/pages/manual/manual_page.dart
Normal file
@@ -0,0 +1,234 @@
|
||||
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';
|
||||
|
||||
import 'slide_page.dart';
|
||||
|
||||
class ManualPage extends StatefulWidget {
|
||||
@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(
|
||||
backgroundColor: Colors.white,
|
||||
actions: <Widget>[
|
||||
mainModel.isSysAdmin()
|
||||
? Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
versionName,
|
||||
style: TextStyle(fontSize: 15, color: Colors.black),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
color: Colors.blue,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
manualModel.resetManualItems();
|
||||
helpList =
|
||||
manualModel.getHelpList(mainModel.isBuyer());
|
||||
});
|
||||
}),
|
||||
IconButton(
|
||||
icon: Icon(Icons.cloud_upload),
|
||||
color: Colors.blue,
|
||||
onPressed: () {
|
||||
_inputManualVersion(context, manualModel);
|
||||
})
|
||||
],
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
iconTheme: IconThemeData(
|
||||
color: Colors.grey,
|
||||
),
|
||||
centerTitle: true,
|
||||
title: Stack(
|
||||
children: <Widget>[
|
||||
LocalText(
|
||||
context,
|
||||
"manual.title",
|
||||
fontSize: 25,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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'))
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user