|
|
|
|
@ -1,16 +1,32 @@
|
|
|
|
|
import 'package:auto_size_text/auto_size_text.dart';
|
|
|
|
|
import 'package:badges/badges.dart';
|
|
|
|
|
import 'package:barcode_scan_fix/barcode_scan.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/config/config.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/PharmacyPagesViewModel.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/pharmacy_categorise.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/search_products_page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/routes.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/navigation_service.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_loader_widget.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
|
|
|
@ -25,7 +41,9 @@ import 'not_auh_page.dart';
|
|
|
|
|
|
|
|
|
|
VoidCallback _onCartClick;
|
|
|
|
|
|
|
|
|
|
class AppScaffold extends StatelessWidget {
|
|
|
|
|
class AppScaffold extends StatefulWidget {
|
|
|
|
|
AppBarWidget appBar;
|
|
|
|
|
|
|
|
|
|
final String appBarTitle;
|
|
|
|
|
final Widget body;
|
|
|
|
|
final Widget bottomSheet;
|
|
|
|
|
@ -39,9 +57,11 @@ class AppScaffold extends StatelessWidget {
|
|
|
|
|
final bool isBottomBar;
|
|
|
|
|
final Widget floatingActionButton;
|
|
|
|
|
final bool isPharmacy;
|
|
|
|
|
final bool isMainPharmacyPages;
|
|
|
|
|
final bool isOfferPackages;
|
|
|
|
|
final bool showPharmacyCart;
|
|
|
|
|
final bool showOfferPackagesCart;
|
|
|
|
|
final bool extendBody;
|
|
|
|
|
final String title;
|
|
|
|
|
final String description;
|
|
|
|
|
final bool isShowDecPage;
|
|
|
|
|
@ -64,7 +84,14 @@ class AppScaffold extends StatelessWidget {
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
|
|
|
|
|
|
|
|
AppBarWidget appBar;
|
|
|
|
|
final ValueChanged<int> changeCurrentTab;
|
|
|
|
|
final Widget customAppBar;
|
|
|
|
|
final int currentTab;
|
|
|
|
|
final bool isShowPharmacyAppbar;
|
|
|
|
|
AppScaffold setOnAppBarCartClick(VoidCallback onClick) {
|
|
|
|
|
_onCartClick = onClick;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppScaffold(
|
|
|
|
|
{@required this.body,
|
|
|
|
|
@ -79,13 +106,15 @@ class AppScaffold extends StatelessWidget {
|
|
|
|
|
this.baseViewModel,
|
|
|
|
|
this.floatingActionButton,
|
|
|
|
|
this.isPharmacy = false,
|
|
|
|
|
this.isMainPharmacyPages = false,
|
|
|
|
|
this.showPharmacyCart = true,
|
|
|
|
|
this.isOfferPackages = false,
|
|
|
|
|
this.showOfferPackagesCart = false,
|
|
|
|
|
this.extendBody = false,
|
|
|
|
|
this.title,
|
|
|
|
|
this.description,
|
|
|
|
|
this.isShowDecPage = true,
|
|
|
|
|
this.isBottomBar,
|
|
|
|
|
this.isBottomBar = false,
|
|
|
|
|
this.backgroundColor,
|
|
|
|
|
this.preferredSize = 0.0,
|
|
|
|
|
this.appBarIcons,
|
|
|
|
|
@ -102,20 +131,100 @@ class AppScaffold extends StatelessWidget {
|
|
|
|
|
appBar,
|
|
|
|
|
this.customAppBar,
|
|
|
|
|
this.isLocalLoader = false,
|
|
|
|
|
this.backButtonTab});
|
|
|
|
|
this.backButtonTab,
|
|
|
|
|
this.changeCurrentTab,
|
|
|
|
|
this.currentTab,
|
|
|
|
|
this.isShowPharmacyAppbar = false});
|
|
|
|
|
|
|
|
|
|
AppScaffold setOnAppBarCartClick(VoidCallback onClick) {
|
|
|
|
|
_onCartClick = onClick;
|
|
|
|
|
return this;
|
|
|
|
|
@override
|
|
|
|
|
_AppScaffoldState createState() => _AppScaffoldState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _AppScaffoldState extends State<AppScaffold> {
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject =
|
|
|
|
|
locator<AuthenticatedUserObject>();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppBar pharmacyAppbar() {
|
|
|
|
|
return AppBar(
|
|
|
|
|
backgroundColor: Color(0xff5AB145),
|
|
|
|
|
elevation: 0,
|
|
|
|
|
title: Container(
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.056,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: InkWell(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.all(5.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
//crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Icon(Icons.search, size: 25.0),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 15.0,
|
|
|
|
|
),
|
|
|
|
|
Texts(
|
|
|
|
|
TranslationBase.of(context).searchProductHere,
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
FadePage(page: SearchProductsPage()),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
leading: Builder(
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
Provider.of<PharmacyPagesViewModel>(context, listen: false)
|
|
|
|
|
.changeCurrentTab(0);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
height: 2.0,
|
|
|
|
|
width: 10.0,
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'assets/images/pharmacy_logo.png',
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
actions: [
|
|
|
|
|
IconButton(
|
|
|
|
|
// iconSize: 70,
|
|
|
|
|
icon: Image.asset(
|
|
|
|
|
'assets/images/new-design/qr-code.png',
|
|
|
|
|
),
|
|
|
|
|
onPressed: _scanQrAndGetProduct //do something,
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
PharmacyPagesViewModel pagesViewModel = Provider.of(context);
|
|
|
|
|
AppGlobal.context = context;
|
|
|
|
|
|
|
|
|
|
bool isUserNotLogin = (!Provider.of<ProjectViewModel>(context, listen: false).isLogin && isShowDecPage);
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: backgroundColor ?? CustomColors.appBackgroudGrey2Color,
|
|
|
|
|
extendBody: widget.extendBody,
|
|
|
|
|
|
|
|
|
|
appBar: isUserNotLogin
|
|
|
|
|
? null
|
|
|
|
|
: (showNewAppBar
|
|
|
|
|
@ -129,7 +238,9 @@ class AppScaffold extends StatelessWidget {
|
|
|
|
|
appBarIcons: appBarIcons,
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
)
|
|
|
|
|
: (isShowAppBar
|
|
|
|
|
: widget.isShowPharmacyAppbar
|
|
|
|
|
? pharmacyAppbar()
|
|
|
|
|
:(isShowAppBar
|
|
|
|
|
? customAppBar != null
|
|
|
|
|
? customAppBar
|
|
|
|
|
: appBar = AppBarWidget(
|
|
|
|
|
@ -144,30 +255,55 @@ class AppScaffold extends StatelessWidget {
|
|
|
|
|
backButtonTab: backButtonTab,
|
|
|
|
|
)
|
|
|
|
|
: null)),
|
|
|
|
|
bottomSheet: bottomSheet,
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
top: true,
|
|
|
|
|
bottom: true,
|
|
|
|
|
child: isUserNotLogin
|
|
|
|
|
? NotAutPage(
|
|
|
|
|
title: title ?? appBarTitle,
|
|
|
|
|
description: description,
|
|
|
|
|
infoList: infoList,
|
|
|
|
|
imagesInfo: imagesInfo,
|
|
|
|
|
icon: icon,
|
|
|
|
|
)
|
|
|
|
|
: baseViewModel != null
|
|
|
|
|
? NetworkBaseView(
|
|
|
|
|
child: buildBodyWidget(context),
|
|
|
|
|
baseViewModel: baseViewModel,
|
|
|
|
|
)
|
|
|
|
|
: buildBodyWidget(context),
|
|
|
|
|
),
|
|
|
|
|
bottomNavigationBar: bottomNavigationBar,
|
|
|
|
|
floatingActionButton: floatingActionButton,
|
|
|
|
|
bottomSheet: widget.bottomSheet,
|
|
|
|
|
body: (!Provider.of<ProjectViewModel>(context, listen: false).isLogin &&
|
|
|
|
|
widget.isShowDecPage)
|
|
|
|
|
? NotAutPage(
|
|
|
|
|
title: widget.title ?? widget.appBarTitle,
|
|
|
|
|
description: widget.description,
|
|
|
|
|
infoList: widget.infoList,
|
|
|
|
|
imagesInfo: widget.imagesInfo,
|
|
|
|
|
)
|
|
|
|
|
: widget.baseViewModel != null
|
|
|
|
|
? NetworkBaseView(
|
|
|
|
|
child: buildBodyWidget(context),
|
|
|
|
|
baseViewModel: widget.baseViewModel,
|
|
|
|
|
)
|
|
|
|
|
: buildBodyWidget(context),
|
|
|
|
|
floatingActionButton: widget.floatingActionButton,
|
|
|
|
|
bottomNavigationBar: widget.isBottomBar
|
|
|
|
|
? BottomNavPharmacyBar(
|
|
|
|
|
changeIndex: changeCurrentTab,
|
|
|
|
|
index: widget.currentTab,
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _scanQrAndGetProduct() async {
|
|
|
|
|
try {
|
|
|
|
|
String result = await BarcodeScanner.scan();
|
|
|
|
|
try {
|
|
|
|
|
String barcode = result;
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await BaseAppClient()
|
|
|
|
|
.getPharmacy("$GET_PHARMACY_PRODUCTs_BY_SKU$barcode",
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
print(response);
|
|
|
|
|
var product = PharmacyProduct.fromJson(response["products"][0]);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Navigator.push(context, FadePage(page: ProductDetailPage(product)));
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: "Product not found");
|
|
|
|
|
});
|
|
|
|
|
} catch (apiEx) {
|
|
|
|
|
AppToast.showErrorToast(
|
|
|
|
|
message: "Something went wrong, please try again");
|
|
|
|
|
}
|
|
|
|
|
} catch (barcodeEx) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buildAppLoaderWidget(bool isLoading) {
|
|
|
|
|
return isLoading ? AppLoaderWidget() : Container();
|
|
|
|
|
}
|
|
|
|
|
|