199 lines
6.4 KiB
Dart
199 lines
6.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:fcs/model/main_model.dart';
|
|
import 'package:fcs/pages/setting_editor.dart';
|
|
import 'package:fcs/pages/setting_editor_byOwner.dart';
|
|
import 'package:fcs/vo/setting.dart';
|
|
import 'package:fcs/widget/local_text.dart';
|
|
import 'package:fcs/widget/progress.dart';
|
|
|
|
import '../theme/theme.dart';
|
|
|
|
class Settings extends StatefulWidget {
|
|
@override
|
|
_SettingState createState() => _SettingState();
|
|
}
|
|
|
|
class _SettingState extends State<Settings> {
|
|
bool _isLoading = false;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
MainModel mainModel = Provider.of<MainModel>(context);
|
|
|
|
return LocalProgress(
|
|
inAsyncCall: _isLoading,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
title: LocalText(
|
|
context,
|
|
"setting.title",
|
|
fontSize: 20,
|
|
color: Colors.white,
|
|
),
|
|
backgroundColor: primaryColor,
|
|
actions: <Widget>[
|
|
mainModel.isBizAdmin() || mainModel.isSysAdmin()
|
|
? IconButton(
|
|
icon: Icon(Icons.edit),
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => SettingEidtor(
|
|
setting: mainModel.setting,
|
|
)),
|
|
);
|
|
})
|
|
: Container()
|
|
],
|
|
),
|
|
body: SingleChildScrollView(
|
|
padding: EdgeInsets.only(
|
|
left: 25.0,
|
|
right: 25.0,
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
ListTile(
|
|
dense: true,
|
|
title: Text("PO will expire in"),
|
|
subtitle: Text("After PO is submitted"),
|
|
trailing: Text(
|
|
mainModel.setting.poExpireInHours.toString() + " hours"),
|
|
),
|
|
Divider(color: secondaryColor),
|
|
Container(
|
|
alignment: Alignment.topRight,
|
|
child: mainModel.isOwnerAndAbove() || mainModel.isAdmin()
|
|
? IconButton(
|
|
padding: EdgeInsets.all(0),
|
|
visualDensity: VisualDensity.compact,
|
|
icon: Icon(Icons.edit),
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => SettingOwner(
|
|
setting: mainModel.setting,
|
|
)),
|
|
);
|
|
})
|
|
: SizedBox(),
|
|
),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text("PO submission opened at"),
|
|
trailing: Text("${mainModel.setting.getPoOpenAt}"),
|
|
),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text("PO submission closed at"),
|
|
trailing: Text("${mainModel.setting.getPoCloseAt}"),
|
|
),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text("PO submission closed on"),
|
|
subtitle: Text(
|
|
mainModel.setting.getPoCloseOn,
|
|
style: textStyleOdd,
|
|
),
|
|
),
|
|
Divider(color: secondaryColor),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text("Latest Delivery Day at"),
|
|
trailing: Text("${mainModel.setting.latestDeliveryDay} days"),
|
|
),
|
|
Divider(color: secondaryColor),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text("First storage charge starts in"),
|
|
subtitle: Text("After PO is approved"),
|
|
trailing:
|
|
Text("${mainModel.setting.firstStorageChargeIn} days"),
|
|
),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text(
|
|
"First storage charge ",
|
|
style: TextStyle(backgroundColor: Colors.greenAccent),
|
|
),
|
|
trailing:
|
|
Text("${mainModel.setting.firstStorageCharge} Kyats/Liter"),
|
|
),
|
|
Divider(color: secondaryColor),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text("Second storage charge starts in"),
|
|
subtitle: Text("After PO is approved"),
|
|
trailing:
|
|
Text("${mainModel.setting.secondStorageChargeIn} days"),
|
|
),
|
|
ListTile(
|
|
dense: true,
|
|
title: Text(
|
|
"Second storage charge ",
|
|
style: TextStyle(backgroundColor: Colors.amber),
|
|
),
|
|
trailing: Text(
|
|
"${mainModel.setting.secondStorageCharge} Kyats/Liter"),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget buildSettingTile(
|
|
{@required String text,
|
|
@required BuildContext context,
|
|
@required String image,
|
|
@required GestureTapCallback tap}) {
|
|
return InkWell(
|
|
onTap: () {
|
|
tap();
|
|
},
|
|
child: Column(
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 8.0, bottom: 5),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
child: Row(
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 12.0, right: 20.0),
|
|
child: Image.asset(
|
|
image,
|
|
width: 28,
|
|
height: 28,
|
|
color: primaryColor,
|
|
),
|
|
),
|
|
LocalText(
|
|
context,
|
|
text,
|
|
fontSize: 15.0,
|
|
color: Colors.black87,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Icon(Icons.keyboard_arrow_right)
|
|
],
|
|
),
|
|
),
|
|
Divider(
|
|
color: Colors.grey,
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|