Files
fcs/lib/pages/home_page.dart

484 lines
17 KiB
Dart
Raw Normal View History

2020-06-02 00:00:05 +06:30
import 'package:country_code_picker/country_code.dart';
2020-05-31 15:00:11 +06:30
import 'package:fcs/model/main_model.dart';
2020-06-01 14:24:45 +06:30
import 'package:fcs/pages/shipment_list.dart';
2020-06-04 01:36:49 +06:30
import 'package:fcs/pages_fcs/box_list.dart';
2020-06-01 11:52:12 +06:30
import 'package:fcs/pages_fcs/package_list.dart';
2020-05-31 15:00:11 +06:30
import 'package:fcs/widget/bottom_up_page_route.dart';
2020-06-02 14:56:51 +06:30
import 'package:fcs/widget/localization/transalation.dart';
2020-05-29 07:45:27 +06:30
import 'package:flutter/material.dart';
2020-05-31 15:00:11 +06:30
import 'package:flutter_icons/flutter_icons.dart';
2020-05-29 07:45:27 +06:30
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
2020-05-29 15:53:37 +06:30
import 'dart:math' as math;
2020-05-29 07:45:27 +06:30
import 'package:fcs/charts/bar_chart.dart';
import 'package:fcs/charts/delivery_do_line.dart';
import 'package:fcs/charts/delivery_do_summary.dart';
import 'package:fcs/charts/delivery_line.dart';
import 'package:fcs/charts/delivery_summary.dart';
import 'package:fcs/charts/do_line.dart';
import 'package:fcs/charts/po_balance_chart.dart';
import 'package:fcs/charts/po_line.dart';
import 'package:fcs/charts/revenue_line.dart';
import 'package:fcs/model/language_model.dart';
import 'package:fcs/model/product_model.dart';
import 'package:fcs/pages/banks/banks.dart';
import 'package:fcs/pages/buyer_list.dart';
import 'package:fcs/pages/contact.dart';
import 'package:fcs/pages/delivery/delivery_list.dart';
import 'package:fcs/pages/manual/manual_page.dart';
import 'package:fcs/pages/notification_list.dart';
import 'package:fcs/pages/term.dart';
import 'package:fcs/reports/report_list.dart';
import 'package:fcs/widget/banner.dart';
import 'package:fcs/widget/local_text.dart';
import 'package:fcs/widget/localization/app_translations.dart';
import 'package:fcs/widget/offline_redirect.dart';
2020-05-29 15:53:37 +06:30
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
2020-05-29 07:45:27 +06:30
import '../theme/theme.dart';
import 'announcement_list.dart';
2020-05-29 16:14:17 +06:30
import 'buying_online.dart';
2020-06-02 14:52:31 +06:30
import 'customer_list.dart';
2020-05-29 07:45:27 +06:30
import 'do/do_list.dart';
2020-06-02 14:56:51 +06:30
import 'invoice/invoce_list.dart';
2020-05-29 07:45:27 +06:30
import 'my_registeration.dart';
import 'pd/pd_list.dart';
import 'products_list.dart';
import 'profile_page.dart';
2020-05-29 16:14:17 +06:30
import 'signin_page.dart';
import 'staff_list.dart';
2020-05-29 15:57:08 +06:30
import 'fcs_profile_page.dart';
2020-05-29 07:45:27 +06:30
import 'pd/pd_list.dart';
2020-05-29 15:57:08 +06:30
import 'pickup_list.dart';
2020-05-29 07:45:27 +06:30
import 'products_list.dart';
import 'profile_page.dart';
2020-05-29 15:57:08 +06:30
import 'shipment_rates.dart';
2020-05-29 07:45:27 +06:30
import 'storage/storage_list.dart';
import 'user_list.dart';
final msgLog = Logger('backgroundMessageHandler');
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
typedef BtnCallback();
class _HomePageState extends State<HomePage> {
final log = Logger('_HomePageState');
2020-05-31 15:00:11 +06:30
bool login = false;
bool customer = true;
2020-05-29 07:45:27 +06:30
@override
void initState() {
super.initState();
}
void dispose() {
super.dispose();
}
static final List<String> chartDropdownItems = [
'Last 7 days',
'Last month',
'Last three months'
];
String actualDropdown = chartDropdownItems[0];
int actualChart = 0;
final numberFormatter = new NumberFormat("#,###");
String pin;
2020-06-02 00:00:05 +06:30
List<bool> isSelected = [true, false];
2020-05-29 07:45:27 +06:30
@override
Widget build(BuildContext context) {
2020-06-01 14:24:45 +06:30
login = Provider.of<MainModel>(context).isLogin();
2020-06-03 00:42:31 +06:30
var owner = Provider.of<MainModel>(context).isOwner();
var customer = Provider.of<MainModel>(context).isCustomer();
2020-06-01 11:52:12 +06:30
final packagesBtn = _buildBtn2("package.name",
icon: Octicons.package,
2020-06-02 00:00:05 +06:30
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(PackageList())));
2020-05-29 07:45:27 +06:30
2020-06-04 01:36:49 +06:30
final boxesBtn = _buildBtn2("boxes.name",
icon: MaterialCommunityIcons.package,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(BoxList())));
2020-05-31 15:00:11 +06:30
final pickUpBtn = _buildBtn2("pickup",
2020-06-03 00:42:31 +06:30
icon: SimpleLineIcons.direction,
2020-06-01 14:24:45 +06:30
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(PickUpList())));
2020-05-29 15:54:26 +06:30
2020-05-31 15:00:11 +06:30
final shipmentCostBtn = _buildBtn2("rate",
icon: FontAwesomeIcons.calculator,
2020-06-01 14:24:45 +06:30
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(ShipmentRates())));
2020-05-29 15:54:26 +06:30
2020-06-03 00:42:31 +06:30
final fcsProfileBtn = _buildBtn2("fcs.btn",
2020-06-02 00:00:05 +06:30
// imgIcon: Image.asset("assets/logo_btn.png", height: 25,color:Colors.white),
icon: MaterialCommunityIcons.home_city,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(FCSProfilePage())));
2020-05-29 15:54:26 +06:30
2020-05-31 15:00:11 +06:30
final shipmentBtn = _buildBtn2("shipment.title",
icon: Ionicons.ios_airplane,
2020-05-29 07:45:27 +06:30
imgIcon: Image.asset(
"assets/truck.png",
width: 50,
height: 50,
color: primaryColor,
),
2020-06-02 00:00:05 +06:30
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(ShipmentList())));
2020-05-29 07:45:27 +06:30
2020-05-31 15:00:11 +06:30
final buyingBtn = _buildBtn2("buy_online",
icon: MaterialCommunityIcons.cart_outline, btnCallback: () {
2020-06-01 14:24:45 +06:30
Navigator.push(context, BottomUpPageRoute(BuyingOnlinePage())
// MaterialPageRoute(builder: (context) => BuyingOnlinePage()),
);
2020-05-29 16:14:17 +06:30
});
2020-06-02 00:00:05 +06:30
final notiBtn =
_buildBtn2("message.btn", icon: Icons.message, btnCallback: () {
2020-05-29 07:45:27 +06:30
Navigator.push(
context,
2020-05-31 15:00:11 +06:30
BottomUpPageRoute(NotificationList()),
2020-05-29 07:45:27 +06:30
);
});
2020-05-31 15:00:11 +06:30
final staffBtn = _buildBtn2("staff.title",
2020-06-02 00:00:05 +06:30
icon: MaterialCommunityIcons.worker,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(StaffList())));
2020-05-29 16:14:17 +06:30
2020-06-02 00:00:05 +06:30
final customersBtn = _buildBtn2("customers.btn",
icon: Feather.users,
btnCallback: () =>
2020-06-02 14:52:31 +06:30
Navigator.of(context).push(BottomUpPageRoute(CustomerList())));
2020-06-02 00:00:05 +06:30
final invoicesBtn = _buildBtn2("invoices.btn",
icon: FontAwesomeIcons.fileInvoice,
btnCallback: () =>
2020-06-02 14:56:51 +06:30
Navigator.of(context).push(BottomUpPageRoute(InvoiceList())));
2020-05-29 07:45:27 +06:30
2020-06-02 14:52:31 +06:30
final termBtn = _buildBtn2("term.btn",
icon: FontAwesomeIcons.info,
btnCallback: () =>
Navigator.of(context).push(BottomUpPageRoute(Term())));
2020-05-31 15:00:11 +06:30
List<Widget> widgets = [];
2020-06-03 00:42:31 +06:30
customer ? widgets.add(buyingBtn) : "";
customer || owner ? widgets.add(pickUpBtn) : "";
owner ? widgets.add(shipmentBtn) : "";
customer || owner ? widgets.add(notiBtn) : "";
owner ? widgets.add(staffBtn) : "";
owner ? widgets.add(fcsProfileBtn) : "";
2020-05-29 15:54:26 +06:30
widgets.add(shipmentCostBtn);
2020-06-03 00:42:31 +06:30
customer || owner ? widgets.add(packagesBtn) : "";
2020-06-04 01:36:49 +06:30
customer || owner ? widgets.add(boxesBtn) : "";
2020-06-03 00:42:31 +06:30
owner ? widgets.add(customersBtn) : "";
customer || owner ? widgets.add(invoicesBtn) : "";
2020-06-02 14:52:31 +06:30
widgets.add(termBtn);
2020-05-29 07:45:27 +06:30
return OfflineRedirect(
child: FlavorBanner(
child: Scaffold(
appBar: AppBar(
2020-05-29 15:53:37 +06:30
elevation: 0,
2020-05-29 07:45:27 +06:30
backgroundColor: primaryColor,
title: ClipRRect(
2020-05-29 15:53:37 +06:30
child: Image.asset("assets/logo.jpg", height: 40),
2020-05-31 16:14:56 +06:30
borderRadius: new BorderRadius.circular(30.0),
2020-05-29 07:45:27 +06:30
),
2020-05-31 15:00:11 +06:30
actions: login
? <Widget>[
2020-06-02 00:00:05 +06:30
ToggleButtons(
children: <Widget>[
Image.asset(
'icons/flags/png/gb.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
),
Image.asset(
'icons/flags/png/mm.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)
],
onPressed: _langChange,
isSelected: isSelected,
2020-05-31 15:00:11 +06:30
),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Profile()),
);
},
iconSize: 30,
icon: Icon(Icons.tune),
),
]
2020-05-31 16:14:56 +06:30
: <Widget>[
2020-06-02 00:00:05 +06:30
ToggleButtons(
children: <Widget>[
Image.asset(
'icons/flags/png/gb.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
),
Image.asset(
'icons/flags/png/mm.png',
package: 'country_icons',
fit: BoxFit.fitWidth,
width: 25,
)
],
onPressed: _langChange,
isSelected: isSelected,
),
2020-06-01 14:24:45 +06:30
FlatButton(
2020-05-31 15:00:11 +06:30
onPressed: () {
2020-06-02 14:56:51 +06:30
Navigator.of(context)
.push(BottomUpPageRoute(SigninPage()));
2020-05-31 15:00:11 +06:30
},
// iconSize: 30,
2020-06-01 14:24:45 +06:30
child: Text(
2020-06-02 00:00:05 +06:30
"Sign In",
2020-06-01 14:24:45 +06:30
style: siginButtonStyle,
),
2020-06-02 14:52:31 +06:30
),
2020-05-31 15:00:11 +06:30
]),
2020-05-29 15:53:37 +06:30
body: Container(
decoration: BoxDecoration(
gradient:
// RadialGradient(
// center: const Alignment(-0.7, 0.6), // near the top right
// radius: 0.6,
// colors: [
// secondaryColor,
// primaryColor, // yellow sun
// ],
// stops: [0.4, 1.0],
// )
2020-05-31 15:00:11 +06:30
LinearGradient(
begin: Alignment.topCenter,
end: Alignment
.bottomCenter, // 10% of the width, so there are ten blinds.
colors: [
Color(0xd0272262),
Color(0xfa272262),
// Color(0xa0ff4400),
// secondaryColor,
], // whitish to gray
),
2020-05-29 21:42:00 +06:30
// SweepGradient(
// center: FractionalOffset.centerLeft,
// startAngle: 0.0,
// endAngle: math.pi * 2,
// colors: const <Color>[
// secondaryColor,
// primaryColor,
// secondaryColor,
// primaryColor,
// secondaryColor,
// ],
// stops: const <double>[0.0, 0.25, 0.5, 0.75, 1.0],
// ),
2020-05-29 07:45:27 +06:30
),
2020-05-31 15:00:11 +06:30
child: Column(
children: <Widget>[
Expanded(
child: ListView(children: [
Wrap(
alignment: WrapAlignment.center,
children: widgets,
),
]),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
2020-06-02 16:19:10 +06:30
// _buildSmallButton(
// "Policies", FontAwesomeIcons.fileContract),
2020-05-31 15:00:11 +06:30
_buildSmallButton("Support", SimpleLineIcons.support),
],
)
],
2020-06-01 11:52:12 +06:30
))),
2020-05-29 07:45:27 +06:30
),
);
}
2020-06-02 00:00:05 +06:30
_langChange(index) {
2020-06-02 14:56:51 +06:30
var languageModel = Provider.of<LanguageModel>(context);
languageModel.saveLanguage(Translation().supportedLanguages[index]);
2020-06-02 00:00:05 +06:30
setState(() {
isSelected.asMap().forEach((i, e) {
isSelected[i] = false;
});
isSelected[index] = !isSelected[index];
});
}
2020-05-29 07:45:27 +06:30
Widget _buildTile(Widget child, {Function() onTap}) {
return Material(
2020-05-29 15:53:37 +06:30
elevation: 0,
2020-05-29 07:45:27 +06:30
borderRadius: BorderRadius.circular(12.0),
2020-05-29 15:53:37 +06:30
// shadowColor: Colors.transparent,
color: Colors.transparent,
2020-05-29 07:45:27 +06:30
child: InkWell(
onTap: onTap != null
? () => onTap()
: () {
log.info('Not set yet');
},
child: child));
}
Widget _buildBtn(String title,
{Image imgIcon, IconData icon, BtnCallback btnCallback}) {
var languageModel = Provider.of<LanguageModel>(context);
return _buildTile(
Padding(
padding: const EdgeInsets.all(5.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
icon != null
? Material(
child: Padding(
padding: EdgeInsets.only(top: 10),
child: Icon(icon, color: primaryColor, size: 35.0)))
: Container(
padding: EdgeInsets.only(top: 3),
child: imgIcon,
),
Padding(padding: EdgeInsets.only(bottom: 10.0)),
Text(AppTranslations.of(context).text(title),
style: languageModel.isEng
? TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 12.0)
: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 12.0,
fontFamily: "MyanmarUnicode")),
]),
),
onTap: btnCallback,
);
}
2020-05-29 15:53:37 +06:30
Widget _buildBtn2(String title,
{Image imgIcon, IconData icon, BtnCallback btnCallback}) {
var languageModel = Provider.of<LanguageModel>(context);
return Container(
2020-05-29 21:42:00 +06:30
width: 100,
height: 100,
2020-05-29 15:53:37 +06:30
decoration: new BoxDecoration(
color: Colors.transparent, //new Color.fromRGBO(255, 0, 0, 0.0),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(40.0),
topRight: const Radius.circular(40.0))),
// color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// Padding(
// padding: EdgeInsets.only(top: 10),
// child: Icon(icon, color: Colors.white, size: 35.0)),
// Padding(padding: EdgeInsets.only(bottom: 10.0)),
ClipOval(
child: Material(
2020-05-29 21:42:00 +06:30
color: Colors.black54, // button color
2020-05-29 15:53:37 +06:30
child: InkWell(
2020-05-29 21:42:00 +06:30
splashColor: primaryColor, // inkwell color
2020-05-29 15:57:08 +06:30
child: SizedBox(
2020-05-31 15:00:11 +06:30
width: 60,
height: 60,
2020-06-02 00:00:05 +06:30
child: icon == null
? Container(width: 10, height: 10, child: imgIcon)
: Icon(icon, color: Colors.white, size: 30)),
2020-05-29 15:53:37 +06:30
onTap: btnCallback,
),
),
),
2020-05-29 21:42:00 +06:30
FittedBox(
2020-05-31 15:00:11 +06:30
fit: BoxFit.fitWidth,
child: Text(AppTranslations.of(context).text(title),
style: languageModel.isEng
? TextStyle(
2020-05-29 21:42:00 +06:30
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 14.0,
fontFamily: "Roboto")
2020-05-31 15:00:11 +06:30
: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 12.0,
fontFamily: "MyanmarUnicode")),
2020-05-29 21:42:00 +06:30
),
2020-05-29 15:53:37 +06:30
]),
),
2020-05-29 07:45:27 +06:30
);
}
2020-05-31 15:00:11 +06:30
Widget _buildSmallButton(String text, IconData iconData) {
return InkWell(
2020-06-02 14:52:31 +06:30
onTap: () => {
Navigator.of(context)
.push(MaterialPageRoute(builder: (_) => Contact())),
},
2020-05-31 15:00:11 +06:30
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Row(
children: <Widget>[
IconButton(
icon: Icon(iconData, color: Colors.white70),
color: Colors.white70,
onPressed: null),
// RaisedButton(onPressed: ()=>{},child: Row(
// children: <Widget>[
// IconButton(
// icon: Icon(iconData, ),
// onPressed: null),
// Text(text),
// ],
// ),color: Colors.transparent,
// focusColor: Colors.transparent,),
Text(
text,
style: subMenuStyle,
)
],
),
),
);
}
2020-05-29 07:45:27 +06:30
}