From 8b1733e91734346fa2f4ac969b914f1f9db953fb Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 23 Nov 2021 09:48:56 +0300 Subject: [PATCH] no message --- android/app/src/main/AndroidManifest.xml | 1 + lib/pages/parent_categorise_page.dart | 1918 +++++++---------- .../shared/product_details_app_bar.dart | 46 +- lib/pages/webRTC/call_page.dart | 12 +- lib/pages/webRTC/signaling.dart | 364 ++-- pubspec.yaml | 6 +- 6 files changed, 965 insertions(+), 1382 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 61472941..eb397698 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -20,6 +20,7 @@ + diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 5a917897..4e58225e 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -5,7 +5,6 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_deta import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categories_modalsheet.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; @@ -14,10 +13,8 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; -import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; @@ -34,14 +31,12 @@ class ParentCategorisePage extends StatefulWidget { String id; String titleName; - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); ParentCategorisePage({this.id, this.titleName}); @override - _ParentCategorisePageState createState() => - _ParentCategorisePageState(id: id, titleName: titleName); + _ParentCategorisePageState createState() => _ParentCategorisePageState(id: id, titleName: titleName); } class _ParentCategorisePageState extends State { @@ -80,768 +75,558 @@ class _ParentCategorisePageState extends State { ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context); return BaseView( - onModelReady: (model) => model.getCategoriseParent( - i: id, pageIndex: pageIndex, isLoading: false, context: context), + onModelReady: (model) => model.getCategoriseParent(i: id, pageIndex: pageIndex, isLoading: false, context: context), allowAny: true, - builder: - (BuildContext context, PharmacyCategoriseViewModel model, - Widget child) => - AppScaffold( - isPharmacy: true, - appBarTitle: titleName, - isBottomBar: true, - isShowAppBar: true, - backgroundColor: Colors.white, - isShowDecPage: false, - baseViewModel: model, - body: SmartRefresher( - enablePullDown: false, - controller: controller, - enablePullUp: true, - onLoading: () async { - setState(() { - ++pageIndex; - }); - await model.getParentProducts( - pageIndex: pageIndex, - i: id, - isLoading: true, - context: context); - if (model.state != ViewState.BusyLocal && - pageIndex < 5) { - controller.loadComplete(); - } else { - controller.loadFailed(); - } - }, - child: SingleChildScrollView( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - child: Image.network( - id == '1' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' - : id == '2' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' - : id == '3' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' - : id == '4' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' - : id == '5' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' - : id == '6' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' - : id == '7' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' - : id == '8' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' - : id == '9' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' - : id == '10' - ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' - : '', - fit: BoxFit.fill, - height: 160.0, - width: double.infinity), - ), - if (model.categoriseParent.length > 8) - Column( - crossAxisAlignment: CrossAxisAlignment.start, + builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => AppScaffold( + isPharmacy: true, + appBarTitle: titleName, + isBottomBar: true, + isShowAppBar: true, + backgroundColor: Colors.white, + isShowDecPage: false, + baseViewModel: model, + body: SmartRefresher( + enablePullDown: false, + controller: controller, + enablePullUp: true, + onLoading: () async { + setState(() { + ++pageIndex; + }); + await model.getParentProducts(pageIndex: pageIndex, i: id, isLoading: true, context: context); + if (model.state != ViewState.BusyLocal && pageIndex < 5) { + controller.loadComplete(); + } else { + controller.loadFailed(); + } + }, + child: SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: Image.network( + id == '1' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089188_personal-care_2.png' + : id == '2' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089189_skin-care_2.png' + : id == '3' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089190_health-care_2.png' + : id == '4' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089191_sexual-health_2.png' + : id == '5' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089192_beauty_2.png' + : id == '6' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089193_baby-child_2.png' + : id == '7' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089194_vitamins-supplements_2.png' + : id == '8' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089195_diet-nutrition_2.png' + : id == '9' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089196_household_2.png' + : id == '10' + ? 'https://uat.hmgwebservices.com/epharmacy/content/images/thumbs/0089197_home-care-appliances_2.png' + : '', + fit: BoxFit.fill, + height: 160.0, + width: double.infinity), + ), + if (model.categoriseParent.length > 8) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + InkWell( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - InkWell( - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: Container( - child: Texts( - TranslationBase.of(context) - .viewCategorise, + Padding( + padding: EdgeInsets.all(10.0), + child: Container( + child: Texts( + TranslationBase.of(context).viewCategorise, // 'View All Categories', - fontWeight: FontWeight.w300, - ), - ), - ), - Icon(Icons.arrow_forward) - ], + fontWeight: FontWeight.w300, ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategoriseModalsheet( -// id: model.categorise[0].id, -// titleName: model.categorise[0].name, - )), - ); - }), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, + ), ), + Icon(Icons.arrow_forward) ], ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategoriseModalsheet( +// id: model.categorise[0].id, +// titleName: model.categorise[0].name, + )), + ); + }), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + ], + ), //Expanded widget heree if nassery - Padding( - padding: EdgeInsets.only(top: 35.0), - child: Container( - height: - MediaQuery.of(context).size.height * 0.2, - child: Center( - child: ListView.builder( - scrollDirection: Axis.horizontal, - itemCount: - model.categoriseParent.length > 8 - ? 8 - : model.categoriseParent.length, - itemBuilder: - (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.symmetric( - horizontal: 8.0), - child: InkWell( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Padding( - padding: - EdgeInsets.symmetric( - horizontal: 13.0), - child: Container( - height: 60.0, - width: 65.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors - .orange.shade200 - .withOpacity(0.45), - ), - child: Center( - child: Icon( - Icons.apps_sharp, - size: 32.0, - ), - ), - ), - ), - Container( - width: - MediaQuery.of(context) - .size - .width * - 0.197, - // height: MediaQuery.of(context) - // .size - // .height * - // 0.08, - child: Center( - child: Texts( - projectViewModel - .isArabic - ? model - .categoriseParent[ - index] - .namen - : model - .categoriseParent[ - index] - .name, - fontSize: 13.4, - fontWeight: - FontWeight.w600, - maxLines: 3, - ), - ), - ), - ], + Padding( + padding: EdgeInsets.only(top: 35.0), + child: Container( + height: MediaQuery.of(context).size.height * 0.2, + child: Center( + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: model.categoriseParent.length > 8 ? 8 : model.categoriseParent.length, + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), + child: InkWell( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: 13.0), + child: Container( + height: 60.0, + width: 65.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.orange.shade200.withOpacity(0.45), + ), + child: Center( + child: Icon( + Icons.apps_sharp, + size: 32.0, + ), ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategorisePage( - title: projectViewModel - .isArabic - ? model - .categoriseParent[ - index] - .namen - : model - .categoriseParent[ - index] - .name, - id: model - .categoriseParent[index] - .id, - parentId: id, - )), - ); - print(id); - }, ), - ); - }), - ), - ), - ), - - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - InkWell( - child: Row( - children: [ - Icon( - Icons.wrap_text, ), - SizedBox( - width: 10.0, - ), - Texts( - TranslationBase.of(context).refine, - fontWeight: FontWeight.w600, + Container( + width: MediaQuery.of(context).size.width * 0.197, + // height: MediaQuery.of(context) + // .size + // .height * + // 0.08, + child: Center( + child: Texts( + projectViewModel.isArabic ? model.categoriseParent[index].namen : model.categoriseParent[index].name, + fontSize: 13.4, + fontWeight: FontWeight.w600, + maxLines: 3, + ), + ), ), ], ), onTap: () { - showModalBottomSheet( - isScrollControlled: true, - context: context, - builder: (BuildContext context) { - return DraggableScrollableSheet( - initialChildSize: 0.95, - maxChildSize: 0.95, - minChildSize: 0.9, - builder: (BuildContext context, - ScrollController - scrollController) { - return SingleChildScrollView( - controller: - scrollController, - child: Container( - color: Colors.white, - height: - MediaQuery.of(context) - .size - .height * - 1.95, - child: Column( - children: [ - Padding( - padding: - EdgeInsets.all( - 8.0), - child: Row( - children: [ - Icon( - Icons - .wrap_text, - ), - SizedBox( - width: 10.0, - ), - Texts( - TranslationBase.of( - context) - .refine, + Navigator.push( + context, + FadePage( + page: SubCategorisePage( + title: projectViewModel.isArabic ? model.categoriseParent[index].namen : model.categoriseParent[index].name, + id: model.categoriseParent[index].id, + parentId: id, + )), + ); + print(id); + }, + ), + ); + }), + ), + ), + ), + + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Row( + children: [ + Icon( + Icons.wrap_text, + ), + SizedBox( + width: 10.0, + ), + Texts( + TranslationBase.of(context).refine, + fontWeight: FontWeight.w600, + ), + ], + ), + onTap: () { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return DraggableScrollableSheet( + initialChildSize: 0.95, + maxChildSize: 0.95, + minChildSize: 0.9, + builder: (BuildContext context, ScrollController scrollController) { + return SingleChildScrollView( + controller: scrollController, + child: Container( + color: Colors.white, + height: MediaQuery.of(context).size.height * 1.95, + child: Column( + children: [ + Padding( + padding: EdgeInsets.all(8.0), + child: Row( + children: [ + Icon( + Icons.wrap_text, + ), + SizedBox( + width: 10.0, + ), + Texts( + TranslationBase.of(context).refine, // 'Refine', - fontWeight: - FontWeight - .w600, - ), - SizedBox( - width: 250.0, - ), - InkWell( - child: Texts( + fontWeight: FontWeight.w600, + ), + SizedBox( + width: 250.0, + ), + InkWell( + child: Texts( // 'Close', - TranslationBase.of( - context) - .closeIt, - color: Colors - .red, - fontWeight: - FontWeight - .w600, - fontSize: - 15.0, - ), - onTap: () { - Navigator.pop( - context); - }, - ), - ], - ), + TranslationBase.of(context).closeIt, + color: Colors.red, + fontWeight: FontWeight.w600, + fontSize: 15.0, ), - Divider( - thickness: 1.0, - color: - Colors.black12, - ), - Column( - children: [ - ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .categorise), - children: [ - ProcedureListWidget( - model: - model, - masterList: - model - .categoriseParent, - removeHistory: - (item) { - setState( - () { - entityList - .remove(item); - }); - }, - addHistory: - (history) { - setState( - () { - entityList - .add(history); - }); - }, - addSelectedHistories: - () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: - (master) => - isEntityListSelected(master), - ) - ], - ), - Divider( - thickness: 1.0, - color: Colors - .black12, - ), - ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .brands), - children: [ - ProcedureListWidget( - model: - model, - masterList: - model - .brandsList, - removeHistory: - (item) { - setState( - () { - entityListBrands - .remove(item); - }); - }, - addHistory: - (history) { - setState( - () { - entityListBrands - .add(history); - }); - }, - addSelectedHistories: - () { - //TODO build your fun herr - // widget.addSelectedHistories(); - }, - isEntityListSelected: - (master) => - isEntityListSelectedBrands(master), - ) - ], - ), - Divider( - thickness: 1.0, - color: Colors - .black12, - ), - ExpansionTile( - title: Texts( - TranslationBase.of( - context) - .price), - children: [ - Container( - color: Color( - 0xffEEEEEE), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Texts(TranslationBase.of(context).min), - Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - ), - controller: minField, - ), - ), - ], - ), - Column( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - Texts(TranslationBase.of(context).max), - Container( - color: Colors.white, - width: 200, - height: 40, - child: TextFormField( - decoration: InputDecoration( - border: OutlineInputBorder(), - ), - controller: maxField, - ), - ), - ], - ), - ], - ), - ) - ], - ), - Divider( - thickness: 1.0, - color: Colors - .black12, - ), - SizedBox( - height: MediaQuery.of( - context) - .size - .height * - 0.4, - ), - Padding( - padding: - EdgeInsets - .all( - 8.0), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceEvenly, + onTap: () { + Navigator.pop(context); + }, + ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + Column( + children: [ + ExpansionTile( + title: Texts(TranslationBase.of(context).categorise), + children: [ + ProcedureListWidget( + model: model, + masterList: model.categoriseParent, + removeHistory: (item) { + setState(() { + entityList.remove(item); + }); + }, + addHistory: (history) { + setState(() { + entityList.add(history); + }); + }, + addSelectedHistories: () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: (master) => isEntityListSelected(master), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + ExpansionTile( + title: Texts(TranslationBase.of(context).brands), + children: [ + ProcedureListWidget( + model: model, + masterList: model.brandsList, + removeHistory: (item) { + setState(() { + entityListBrands.remove(item); + }); + }, + addHistory: (history) { + setState(() { + entityListBrands.add(history); + }); + }, + addSelectedHistories: () { + //TODO build your fun herr + // widget.addSelectedHistories(); + }, + isEntityListSelected: (master) => isEntityListSelectedBrands(master), + ) + ], + ), + Divider( + thickness: 1.0, + color: Colors.black12, + ), + ExpansionTile( + title: Texts(TranslationBase.of(context).price), + children: [ + Container( + color: Color(0xffEEEEEE), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, children: [ + Texts(TranslationBase.of(context).min), Container( - width: - 100, - child: - Button( - label: TranslationBase.of(context) - .reset, - backgroundColor: - Colors.red, + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), + ), + controller: minField, ), ), - SizedBox( - width: 30, - ), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Texts(TranslationBase.of(context).max), Container( - width: - 200, - child: - Button( - onTap: - () async { - String - categoriesId = - ""; - for (CategoriseParentModel category - in entityList) { - if (categoriesId == - "") { - categoriesId = category.id; - } else { - categoriesId = "$categoriesId,${category.id}"; - } - } - String - brandIds = - ""; - for (CategoriseParentModel brand - in entityListBrands) { - if (brandIds == - "") { - brandIds = brand.id; - } else { - brandIds = "$brandIds,${brand.id}"; - } - } - - GifLoaderDialogUtils.showMyDialog( - context); - - await model.getFilteredProducts( - min: minField.text.toString(), - max: maxField.text.toString(), - categoryId: categoriesId, - brandId: brandIds); - GifLoaderDialogUtils.hideDialog( - context); - - Navigator.pop( - context); - }, - label: TranslationBase.of(context) - .apply, - backgroundColor: - Colors.green, + color: Colors.white, + width: 200, + height: 40, + child: TextFormField( + decoration: InputDecoration( + border: OutlineInputBorder(), + ), + controller: maxField, ), ), ], ), - ), - ], - ), + ], + ), + ) ], ), - ), - ); - }); - }, - ); - }, - ), - Row( - children: [ - Container( - height: 44.0, - child: VerticalDivider( - color: Colors.black45, - thickness: 1.0, + Divider( + thickness: 1.0, + color: Colors.black12, + ), + SizedBox( + height: MediaQuery.of(context).size.height * 0.4, + ), + Padding( + padding: EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + width: 150, + child: Button( + label: TranslationBase.of(context).reset, + backgroundColor: Colors.red, + ), + ), + SizedBox( + width: 10, + ), + Container( + width: 150, + child: Button( + onTap: () async { + String categoriesId = ""; + for (CategoriseParentModel category in entityList) { + if (categoriesId == "") { + categoriesId = category.id; + } else { + categoriesId = "$categoriesId,${category.id}"; + } + } + String brandIds = ""; + for (CategoriseParentModel brand in entityListBrands) { + if (brandIds == "") { + brandIds = brand.id; + } else { + brandIds = "$brandIds,${brand.id}"; + } + } + + GifLoaderDialogUtils.showMyDialog(context); + + await model.getFilteredProducts( + min: minField.text.toString(), max: maxField.text.toString(), categoryId: categoriesId, brandId: brandIds); + GifLoaderDialogUtils.hideDialog(context); + + Navigator.pop(context); + }, + label: TranslationBase.of(context).apply, + backgroundColor: Colors.green, + ), + ), + ], + ), + ), + ], + ), + ], + ), + ), + ); + }); + }, + ); + }, + ), + Row( + children: [ + Container( + height: 44.0, + child: VerticalDivider( + color: Colors.black45, + thickness: 1.0, //width: 0.3, // indent: 0.0, - ), - ), - Padding( - padding: EdgeInsets.all(8.0), - child: InkWell( - child: styleIcon, - onTap: () { - setState(() { - if (styleOne == true) { - styleOne = false; - styleTwo = true; - styleIcon = Icon( - Icons.auto_awesome_mosaic, - color: CustomColors.green, - size: 29.0, - ); - } else { - styleOne = true; - styleTwo = false; - styleIcon = Icon( - Icons.widgets_sharp, - color: CustomColors.green, - size: 29.0, - ); - } - }); - }, - ), - ), - ], - ), - ], + ), ), - ), - Divider( - thickness: 1.0, - color: Colors.grey.shade400, - ), - model.parentProducts.isNotEmpty - ? styleOne == true - ? Container( - height: model.parentProducts.length * - MediaQuery.of(context) - .size - .height * - 0.15, - child: GridView.builder( - physics: - NeverScrollableScrollPhysics(), - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 0.5, - mainAxisSpacing: 2.0, - childAspectRatio: 0.9, - ), - itemCount: - model.parentProducts.length, - itemBuilder: (BuildContext context, - int index) { - return NetworkBaseView( - baseViewModel: model, - child: InkWell( - child: Card( - color: model - .parentProducts[ - index] - .discountName != - null - ? Color(0xffFFFF00) - : Colors.white, - elevation: 0, - shape: Border( - right: BorderSide( - color: Colors - .grey.shade300, - width: 1, - ), - left: BorderSide( - color: Colors - .grey.shade300, - width: 1, - ), - bottom: BorderSide( - color: Colors - .grey.shade300, - width: 1, - ), - top: BorderSide( - color: Colors - .grey.shade300, - width: 1, - ), - ), - margin: - EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - child: Container( - decoration: - BoxDecoration( - borderRadius: - BorderRadius.only( - topLeft: - Radius.circular( - 110.0), + Padding( + padding: EdgeInsets.all(8.0), + child: InkWell( + child: styleIcon, + onTap: () { + setState(() { + if (styleOne == true) { + styleOne = false; + styleTwo = true; + styleIcon = Icon( + Icons.auto_awesome_mosaic, + color: CustomColors.green, + size: 29.0, + ); + } else { + styleOne = true; + styleTwo = false; + styleIcon = Icon( + Icons.widgets_sharp, + color: CustomColors.green, + size: 29.0, + ); + } + }); + }, + ), + ), + ], + ), + ], + ), + ), + Divider( + thickness: 1.0, + color: Colors.grey.shade400, + ), + model.parentProducts.isNotEmpty + ? styleOne == true + ? Container( + height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.15, + child: GridView.builder( + physics: NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 0.5, + mainAxisSpacing: 2.0, + childAspectRatio: 0.9, + ), + itemCount: model.parentProducts.length, + itemBuilder: (BuildContext context, int index) { + return NetworkBaseView( + baseViewModel: model, + child: InkWell( + child: Card( + color: model.parentProducts[index].discountName != null ? Color(0xffFFFF00) : Colors.white, + elevation: 0, + shape: Border( + right: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + left: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + bottom: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + top: BorderSide( + color: Colors.grey.shade300, + width: 1, + ), + ), + margin: EdgeInsets.symmetric( + horizontal: 8, + vertical: 4, + ), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(110.0), + ), + color: Colors.white, + ), + padding: EdgeInsets.symmetric(horizontal: 0), + width: MediaQuery.of(context).size.width / 3, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + if (model.parentProducts[index].discountName != null) + RotatedBox( + quarterTurns: 4, + child: Container( + decoration: BoxDecoration(), + child: Padding( + padding: EdgeInsets.only( + right: 5.0, + top: 20.0, + bottom: 5.0, + ), + child: Texts( + TranslationBase.of(context).offers.toUpperCase(), + color: Colors.red, + fontSize: 13.0, + fontWeight: FontWeight.w900, + ), + ), + transform: new Matrix4.rotationZ(5.837200), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0, 16, 0, 0), + alignment: Alignment.center, + child: Image.network( + model.parentProducts[index].images.isNotEmpty + ? model.parentProducts[index].images[0].thumb + : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', + fit: BoxFit.cover, + height: 80, ), - color: Colors.white, ), - padding: EdgeInsets - .symmetric( - horizontal: 0), - width: MediaQuery.of( - context) - .size - .width / - 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Stack( - children: [ - if (model - .parentProducts[ - index] - .discountName != - null) - RotatedBox( - quarterTurns: - 4, - child: - Container( - decoration: - BoxDecoration(), - child: - Padding( - padding: - EdgeInsets.only( - right: - 5.0, - top: - 20.0, - bottom: - 5.0, - ), - child: - Texts( - TranslationBase.of(context) - .offers - .toUpperCase(), - color: - Colors.red, - fontSize: - 13.0, - fontWeight: - FontWeight.w900, - ), - ), - transform: - new Matrix4.rotationZ( - 5.837200), - ), - ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, - 16, - 0, - 0), - alignment: - Alignment - .center, - child: Image - .network( - model - .parentProducts[ - index] - .images - .isNotEmpty - ? model - .parentProducts[index] - .images[0] - .thumb - : 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6c/No_image_3x4.svg/1200px-No_image_3x4.svg.png', - fit: BoxFit - .cover, - height: 80, - ), - ), // Container( // width: model.parentProducts[index].rxMessage != // null @@ -891,251 +676,144 @@ class _ParentCategorisePageState extends State { // .w400, // // ), // ), - ], - ), + ], + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (model.parentProducts[index].discountName != null) Container( - margin: EdgeInsets - .symmetric( - horizontal: 6, - vertical: 0, + width: double.infinity, + height: 13.0, + decoration: BoxDecoration( + color: Color(0xff5AB145), ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - if (model - .parentProducts[ - index] - .discountName != - null) - Container( - width: double - .infinity, - height: - 13.0, - decoration: - BoxDecoration( - color: Color( - 0xff5AB145), - ), - child: - Center( - child: - Texts( - model - .parentProducts[index] - .discountName, - regular: - true, - color: - Colors.white, - fontSize: - 10.4, - ), - ), - ), - Texts( - projectViewModel - .isArabic - ? model - .parentProducts[ - index] - .namen - : model - .parentProducts[index] - .name, - regular: - true, - fontSize: - 12, - fontWeight: - FontWeight - .w700, - ), - Padding( - padding: const EdgeInsets - .only( - top: 4, - bottom: - 4), - child: - Texts( - "SAR ${model.parentProducts[index].price}", - bold: - true, - fontSize: - 14, - ), - ), - Row( - children: [ + child: Center( + child: Texts( + model.parentProducts[index].discountName, + regular: true, + color: Colors.white, + fontSize: 10.4, + ), + ), + ), + Texts( + projectViewModel.isArabic ? model.parentProducts[index].namen : model.parentProducts[index].name, + regular: true, + fontSize: 12, + fontWeight: FontWeight.w700, + ), + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ // StarRating( // totalAverage: model.parentProducts[index].approvedRatingSum > 0 // ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar - .readOnly( - initialRating: model - .parentProducts[index] - .approvedRatingSum - .toDouble(), - size: - 15.0, - filledColor: - Colors.yellow[700], - emptyColor: - Colors.grey[500], - isHalfAllowed: - true, - halfFilledIcon: - Icons.star_half, - filledIcon: - Icons.star, - emptyIcon: - Icons.star, - ), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight.w400, - ) - ], - ), - ], + RatingBar.readOnly( + initialRating: model.parentProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, ), - ), - ], - ), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + ], + ), + ], ), ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.parentProducts[ - index]), - )), - }, - )); + ], + ), + ), + ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model.parentProducts[index]), + )), }, - ), - ) - : Container( - height: model.parentProducts.length * - MediaQuery.of(context) - .size - .height * - 0.122, - child: ListView.builder( - physics: - NeverScrollableScrollPhysics(), - itemCount: - model.parentProducts.length, - itemBuilder: - (BuildContext context, - int index) { - return InkWell( - child: Card( - child: Row( + )); + }, + ), + ) + : Container( + height: model.parentProducts.length * MediaQuery.of(context).size.height * 0.122, + child: ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemCount: model.parentProducts.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: Card( + child: Row( + children: [ + Stack( + children: [ + Column( children: [ - Stack( - children: [ - Column( - children: [ - Container( - decoration: - BoxDecoration(), - child: - Padding( - padding: - EdgeInsets - .only( - left: 9.0, - top: 8.0, - right: - 10.0, - ), - ), - ), - Container( - margin: EdgeInsets - .fromLTRB( - 0, - 0, - 0, - 0), - alignment: - Alignment - .center, - child: model - .parentProducts[ - index] - .images - .isNotEmpty - ? Image - .network( - model - .parentProducts[index] - .images[0] - .thumb, - fit: BoxFit - .contain, - height: - 70, - ) - : Text(TranslationBase.of( - context) - .noImage), - ), - ], + Container( + decoration: BoxDecoration(), + child: Padding( + padding: EdgeInsets.only( + left: 9.0, + top: 8.0, + right: 10.0, ), - Column( - children: [ - Container( - width: model.parentProducts[index].rxMessage != - null - ? MediaQuery.of(context) - .size - .width / - 5.3 - : 0, - padding: - EdgeInsets - .all( - 4), - decoration: - BoxDecoration( - color: Color( - 0xffb23838), - borderRadius: - BorderRadius.only( - topLeft: - Radius.circular(6)), - ), - child: model.parentProducts[index] - .rxMessage != - null - ? Texts( - projectProvider.isArabic - ? model.parentProducts[index].rxMessagen - : model.parentProducts[index].rxMessage, - color: - Colors.white, - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight.w400, - ) - : Texts(""), + ), + ), + Container( + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: model.parentProducts[index].images.isNotEmpty + ? Image.network( + model.parentProducts[index].images[0].thumb, + fit: BoxFit.contain, + height: 70, + ) + : Text(TranslationBase.of(context).noImage), + ), + ], + ), + Column( + children: [ + Container( + width: model.parentProducts[index].rxMessage != null ? MediaQuery.of(context).size.width / 5.3 : 0, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffb23838), + borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), + ), + child: model.parentProducts[index].rxMessage != null + ? Texts( + projectProvider.isArabic ? model.parentProducts[index].rxMessagen : model.parentProducts[index].rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + : Texts(""), // Texts( // model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", // color: Colors.white, @@ -1143,201 +821,139 @@ class _ParentCategorisePageState extends State { // fontSize: 10, // fontWeight: FontWeight.w400, // ), - ), - ], - ), - ], ), - Container( - margin: EdgeInsets - .symmetric( - horizontal: 0, - vertical: 0, - ), - child: Column( - mainAxisAlignment: - MainAxisAlignment - .spaceAround, - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - SizedBox( - height: 4.0, - ), - Container( - width: MediaQuery.of( - context) - .size - .width * - 0.635, - child: Texts( - projectViewModel - .isArabic - ? model - .parentProducts[ - index] - .namen - : model - .parentProducts[ - index] - .name, - regular: true, - fontSize: - 13.2, - fontWeight: - FontWeight - .w500, - maxLines: 5, - ), - ), - SizedBox( - height: 8.0, - ), - Padding( - padding: - const EdgeInsets - .only( - top: 4, - bottom: - 4), - child: Texts( - "SAR ${model.parentProducts[index].price}", - bold: true, - fontSize: 14, - ), - ), - Row( - children: [ + ], + ), + ], + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 0, + vertical: 0, + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 4.0, + ), + Container( + width: MediaQuery.of(context).size.width * 0.635, + child: Texts( + projectViewModel.isArabic ? model.parentProducts[index].namen : model.parentProducts[index].name, + regular: true, + fontSize: 13.2, + fontWeight: FontWeight.w500, + maxLines: 5, + ), + ), + SizedBox( + height: 8.0, + ), + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 4), + child: Texts( + "SAR ${model.parentProducts[index].price}", + bold: true, + fontSize: 14, + ), + ), + Row( + children: [ // StarRating( // totalAverage: model.parentProducts[index].approvedRatingSum > 0 // ? (model.parentProducts[index].approvedRatingSum.toDouble() / model.parentProducts[index].approvedRatingSum.toDouble()).toDouble() // : 0, // forceStars: true), - RatingBar - .readOnly( - initialRating: model - .parentProducts[ - index] - .approvedRatingSum - .toDouble(), - size: 15.0, - filledColor: - Colors.yellow[ - 700], - emptyColor: - Colors.grey[ - 500], - isHalfAllowed: - true, - halfFilledIcon: - Icons - .star_half, - filledIcon: - Icons - .star, - emptyIcon: - Icons - .star, - ), - Texts( - "(${model.parentProducts[index].approvedTotalReviews})", - regular: - true, - fontSize: - 10, - fontWeight: - FontWeight - .w400, - ) - ], - ), - ], + RatingBar.readOnly( + initialRating: model.parentProducts[index].approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, ), - ), - widget.authenticatedUserObject - .isLogin - ? Container( - child: - IconButton( - icon: - Icon( - Icons - .shopping_cart, - size: - 18, - color: - CustomColors.green, - ), - onPressed: - () async { - if (model.parentProducts[index].rxMessage == - null) { - GifLoaderDialogUtils.showMyDialog(context); - await addToCartFunction(1, - model.parentProducts[index].id); - GifLoaderDialogUtils.hideDialog(context); - Utils.navigateToCartPage(); - } else { - AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); - } - }), - ) - : Container(), - ], - ), + Texts( + "(${model.parentProducts[index].approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + ], + ), + ], ), - onTap: () => { - Navigator.push( - context, - FadePage( - page: ProductDetailPage( - model.parentProducts[ - index]), - )), - }, - ); - }), - ) - : Padding( - padding: const EdgeInsets.all(12.0), - child: Container( - child: Center( - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Padding( - padding: - const EdgeInsets.all(8.0), - child: Image.asset( - 'assets/images/new-design/empty_box.png', - width: 100, - height: 100, - fit: BoxFit.cover, - ), - ), - Padding( - padding: - const EdgeInsets.all(8.0), - child: Text( - TranslationBase.of(context) - .noData, - // 'There is no data', - style: - TextStyle(fontSize: 30), ), - ) - ], + widget.authenticatedUserObject.isLogin + ? Container( + child: IconButton( + icon: Icon( + Icons.shopping_cart, + size: 18, + color: CustomColors.green, + ), + onPressed: () async { + if (model.parentProducts[index].rxMessage == null) { + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.parentProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Utils.navigateToCartPage(); + } else { + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + }), + ) + : Container(), + ], + ), ), + onTap: () => { + Navigator.push( + context, + FadePage( + page: ProductDetailPage(model.parentProducts[index]), + )), + }, + ); + }), + ) + : Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + child: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, ), ), - ) - ], - ), - ), - ), - ))); + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noData, + // 'There is no data', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), + ), + ), + ) + ], + ), + ), + ), + ))); } addToCartFunction(quantity, itemID) async { @@ -1346,8 +962,7 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelected(CategoriseParentModel masterKey) { - Iterable history = - entityList.where((element) => masterKey.id == element.id); + Iterable history = entityList.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } @@ -1355,8 +970,7 @@ class _ParentCategorisePageState extends State { } bool isEntityListSelectedBrands(CategoriseParentModel masterKey) { - Iterable history = - entityListBrands.where((element) => masterKey.id == element.id); + Iterable history = entityListBrands.where((element) => masterKey.id == element.id); if (history.length > 0) { return true; } diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index fb608953..9ed3c037 100644 --- a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -3,7 +3,6 @@ import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.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/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; @@ -27,19 +26,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final bool isInWishList; final Function addToCartFunction; - ProductAppBar( - {Key key, - this.product, - this.model, - this.addToWishlistFunction, - this.quantity, - this.deleteFromWishlistFunction, - this.isInWishList, - this.addToCartFunction}) - : super(key: key); + ProductAppBar({Key key, this.product, this.model, this.addToWishlistFunction, this.quantity, this.deleteFromWishlistFunction, this.isInWishList, this.addToCartFunction}) : super(key: key); - AuthenticatedUserObject authenticatedUserObject = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); @override Widget build(BuildContext context) { @@ -76,7 +65,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { icon: Icons.shopping_cart, color: Colors.grey[800], onPress: () { - Navigator.pushAndRemoveUntil( locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route r) => false); // Navigator.push( @@ -84,11 +72,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { // MaterialPageRoute(builder: (context) => CartOrderPage()), // ); }), - if (Provider.of(context, - listen: false) - .cartResponse - .quantityCount != - 0) + if (Provider.of(context, listen: false).cartResponse.quantityCount != 0) Positioned( top: 0, right: -1.0, @@ -101,11 +85,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { height: 18, child: Center( child: Texts( - Provider.of(context, - listen: false) - .cartResponse - .quantityCount - .toString(), + Provider.of(context, listen: false).cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white, @@ -144,7 +124,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { return Container( child: new Wrap( children: [ - if (product.stockAvailability != 'Out of stock') + if (product.stockAvailability != 'Out of stock' && !product.isRx) new ListTile( leading: Icon(Icons.shopping_cart), title: Text( @@ -153,17 +133,12 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { onTap: () async { if (quantity > 0) { { - await addToCartFunction( - quantity: quantity, - itemID: itemID, - model: model); + await addToCartFunction(quantity: quantity, itemID: itemID, model: model); Navigator.of(context).pop(); } } else { - AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity - // "you should add quantity" - ); + AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity); } }), ListTile( @@ -172,9 +147,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { color: !isInWishList ? Colors.white : Colors.red[800], ), title: Text( - isInWishList - ? TranslationBase.of(context).removeFromWishlist - : TranslationBase.of(context).addToWishlist, + isInWishList ? TranslationBase.of(context).removeFromWishlist : TranslationBase.of(context).addToWishlist, ), onTap: () async { if (isInWishList) @@ -189,8 +162,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { TranslationBase.of(context).compare, ), onTap: () { - Provider.of(context, listen: false) - .addItem(specificationData,context); + Provider.of(context, listen: false).addItem(specificationData, context); Navigator.of(context).pop(); }, ), diff --git a/lib/pages/webRTC/call_page.dart b/lib/pages/webRTC/call_page.dart index 4c8ac4f5..c5b41aa3 100644 --- a/lib/pages/webRTC/call_page.dart +++ b/lib/pages/webRTC/call_page.dart @@ -77,7 +77,7 @@ class _CallPageState extends State { ), ElevatedButton( onPressed: () async { - roomId = await signaling.createRoom(_remoteRenderer); + // roomId = await signaling.createRoom(_remoteRenderer); textEditingController.text = roomId; setState(() {}); }, @@ -89,10 +89,10 @@ class _CallPageState extends State { ElevatedButton( onPressed: () { // Add roomId - signaling.joinRoom( - textEditingController.text, - _remoteRenderer, - ); + // signaling.joinRoom( + // textEditingController.text, + // _remoteRenderer, + // ); }, child: Text("Join room"), ), @@ -101,7 +101,7 @@ class _CallPageState extends State { ), ElevatedButton( onPressed: () { - signaling.hangUp(_localRenderer); + // signaling.hangUp(_localRenderer); }, child: Text("Hangup"), ) diff --git a/lib/pages/webRTC/signaling.dart b/lib/pages/webRTC/signaling.dart index f987e285..3f840854 100644 --- a/lib/pages/webRTC/signaling.dart +++ b/lib/pages/webRTC/signaling.dart @@ -1,6 +1,6 @@ import 'dart:convert'; -import 'package:cloud_firestore/cloud_firestore.dart'; +// import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart'; typedef void StreamStateCallback(MediaStream stream); @@ -21,161 +21,161 @@ class Signaling { String currentRoomText; StreamStateCallback onAddRemoteStream; - Future createRoom(RTCVideoRenderer remoteRenderer) async { - FirebaseFirestore db = FirebaseFirestore.instance; - DocumentReference roomRef = db.collection('rooms').doc(); - - print('Create PeerConnection with configuration: $configuration'); - - peerConnection = await createPeerConnection(configuration); - - registerPeerConnectionListeners(); - - localStream.getTracks().forEach((track) { - peerConnection?.addTrack(track, localStream); - }); - - // Code for collecting ICE candidates below - var callerCandidatesCollection = roomRef.collection('callerCandidates'); - - peerConnection?.onIceCandidate = (RTCIceCandidate candidate) { - print('Got candidate: ${candidate.toMap()}'); - callerCandidatesCollection.add(candidate.toMap()); - }; - // Finish Code for collecting ICE candidate - - // Add code for creating a room - RTCSessionDescription offer = await peerConnection.createOffer(); - await peerConnection.setLocalDescription(offer); - print('Created offer: $offer'); - - Map roomWithOffer = {'offer': offer.toMap()}; - - await roomRef.set(roomWithOffer); - var roomId = roomRef.id; - print('New room created with SDK offer. Room ID: $roomId'); - currentRoomText = 'Current room is $roomId - You are the caller!'; - // Created a Room - - peerConnection?.onTrack = (RTCTrackEvent event) { - print('Got remote track: ${event.streams[0]}'); - - event.streams[0].getTracks().forEach((track) { - print('Add a track to the remoteStream $track'); - remoteStream?.addTrack(track); - }); - }; - - // Listening for remote session description below - roomRef.snapshots().listen((snapshot) async { - print('Got updated room: ${snapshot.data()}'); - - Map data = snapshot.data() as Map; - if (peerConnection?.getRemoteDescription() != null && data['answer'] != null) { - var answer = RTCSessionDescription( - data['answer']['sdp'], - data['answer']['type'], - ); - - print("Someone tried to connect"); - await peerConnection?.setRemoteDescription(answer); - } - }); - // Listening for remote session description above - - // Listen for remote Ice candidates below - roomRef.collection('calleeCandidates').snapshots().listen((snapshot) { - snapshot.docChanges.forEach((change) { - if (change.type == DocumentChangeType.added) { - Map data = change.doc.data() as Map; - print('Got new remote ICE candidate: ${jsonEncode(data)}'); - peerConnection.addCandidate( - RTCIceCandidate( - data['candidate'], - data['sdpMid'], - data['sdpMLineIndex'], - ), - ); - } - }); - }); - // Listen for remote ICE candidates above - - return roomId; - } - - Future joinRoom(String roomId, RTCVideoRenderer remoteVideo) async { - FirebaseFirestore db = FirebaseFirestore.instance; - DocumentReference roomRef = db.collection('rooms').doc('$roomId'); - var roomSnapshot = await roomRef.get(); - print('Got room ${roomSnapshot.exists}'); - - if (roomSnapshot.exists) { - print('Create PeerConnection with configuration: $configuration'); - peerConnection = await createPeerConnection(configuration); - - registerPeerConnectionListeners(); - - localStream.getTracks().forEach((track) { - peerConnection?.addTrack(track, localStream); - }); - - // Code for collecting ICE candidates below - var calleeCandidatesCollection = roomRef.collection('calleeCandidates'); - peerConnection.onIceCandidate = (RTCIceCandidate candidate) { - if (candidate == null) { - print('onIceCandidate: complete!'); - return; - } - print('onIceCandidate: ${candidate.toMap()}'); - calleeCandidatesCollection.add(candidate.toMap()); - }; - // Code for collecting ICE candidate above - - peerConnection?.onTrack = (RTCTrackEvent event) { - print('Got remote track: ${event.streams[0]}'); - event.streams[0].getTracks().forEach((track) { - print('Add a track to the remoteStream: $track'); - remoteStream?.addTrack(track); - }); - }; - - // Code for creating SDP answer below - var data = roomSnapshot.data() as Map; - print('Got offer $data'); - var offer = data['offer']; - await peerConnection?.setRemoteDescription( - RTCSessionDescription(offer['sdp'], offer['type']), - ); - var answer = await peerConnection.createAnswer(); - print('Created Answer $answer'); - - await peerConnection.setLocalDescription(answer); - - Map roomWithAnswer = { - 'answer': {'type': answer.type, 'sdp': answer.sdp} - }; - - await roomRef.update(roomWithAnswer); - // Finished creating SDP answer - - // Listening for remote ICE candidates below - // roomRef.collection('callerCandidates').snapshots().listen((snapshot) { - // snapshot.docChanges.forEach((document) { - // var data = document.doc.data() as Map; - // print(data); - // print('Got new remote ICE candidate: $data'); - // peerConnection.addCandidate( - // RTCIceCandidate( - // data['candidate'], - // data['sdpMid'], - // data['sdpMLineIndex'], - // ), - // ); - // }); - // }); - } - } + // Future createRoom(RTCVideoRenderer remoteRenderer) async { + // // FirebaseFirestore db = FirebaseFirestore.instance; + // // DocumentReference roomRef = db.collection('rooms').doc(); + // + // print('Create PeerConnection with configuration: $configuration'); + // + // peerConnection = await createPeerConnection(configuration); + // + // registerPeerConnectionListeners(); + // + // localStream.getTracks().forEach((track) { + // peerConnection?.addTrack(track, localStream); + // }); + // + // // Code for collecting ICE candidates below + // var callerCandidatesCollection = roomRef.collection('callerCandidates'); + // + // peerConnection?.onIceCandidate = (RTCIceCandidate candidate) { + // print('Got candidate: ${candidate.toMap()}'); + // callerCandidatesCollection.add(candidate.toMap()); + // }; + // // Finish Code for collecting ICE candidate + // + // // Add code for creating a room + // RTCSessionDescription offer = await peerConnection.createOffer(); + // await peerConnection.setLocalDescription(offer); + // print('Created offer: $offer'); + // + // Map roomWithOffer = {'offer': offer.toMap()}; + // + // await roomRef.set(roomWithOffer); + // var roomId = roomRef.id; + // print('New room created with SDK offer. Room ID: $roomId'); + // currentRoomText = 'Current room is $roomId - You are the caller!'; + // // Created a Room + // + // peerConnection?.onTrack = (RTCTrackEvent event) { + // print('Got remote track: ${event.streams[0]}'); + // + // event.streams[0].getTracks().forEach((track) { + // print('Add a track to the remoteStream $track'); + // remoteStream?.addTrack(track); + // }); + // }; + // + // // Listening for remote session description below + // roomRef.snapshots().listen((snapshot) async { + // print('Got updated room: ${snapshot.data()}'); + // + // Map data = snapshot.data() as Map; + // if (peerConnection?.getRemoteDescription() != null && data['answer'] != null) { + // var answer = RTCSessionDescription( + // data['answer']['sdp'], + // data['answer']['type'], + // ); + // + // print("Someone tried to connect"); + // await peerConnection?.setRemoteDescription(answer); + // } + // }); + // // Listening for remote session description above + // + // // Listen for remote Ice candidates below + // roomRef.collection('calleeCandidates').snapshots().listen((snapshot) { + // snapshot.docChanges.forEach((change) { + // if (change.type == DocumentChangeType.added) { + // Map data = change.doc.data() as Map; + // print('Got new remote ICE candidate: ${jsonEncode(data)}'); + // peerConnection.addCandidate( + // RTCIceCandidate( + // data['candidate'], + // data['sdpMid'], + // data['sdpMLineIndex'], + // ), + // ); + // } + // }); + // }); + // // Listen for remote ICE candidates above + // + // return roomId; + // } + + // Future joinRoom(String roomId, RTCVideoRenderer remoteVideo) async { + // FirebaseFirestore db = FirebaseFirestore.instance; + // DocumentReference roomRef = db.collection('rooms').doc('$roomId'); + // var roomSnapshot = await roomRef.get(); + // print('Got room ${roomSnapshot.exists}'); + // + // if (roomSnapshot.exists) { + // print('Create PeerConnection with configuration: $configuration'); + // peerConnection = await createPeerConnection(configuration); + // + // registerPeerConnectionListeners(); + // + // localStream.getTracks().forEach((track) { + // peerConnection?.addTrack(track, localStream); + // }); + // + // // Code for collecting ICE candidates below + // var calleeCandidatesCollection = roomRef.collection('calleeCandidates'); + // peerConnection.onIceCandidate = (RTCIceCandidate candidate) { + // if (candidate == null) { + // print('onIceCandidate: complete!'); + // return; + // } + // print('onIceCandidate: ${candidate.toMap()}'); + // calleeCandidatesCollection.add(candidate.toMap()); + // }; + // // Code for collecting ICE candidate above + // + // peerConnection?.onTrack = (RTCTrackEvent event) { + // print('Got remote track: ${event.streams[0]}'); + // event.streams[0].getTracks().forEach((track) { + // print('Add a track to the remoteStream: $track'); + // remoteStream?.addTrack(track); + // }); + // }; + // + // // Code for creating SDP answer below + // var data = roomSnapshot.data() as Map; + // print('Got offer $data'); + // var offer = data['offer']; + // await peerConnection?.setRemoteDescription( + // RTCSessionDescription(offer['sdp'], offer['type']), + // ); + // var answer = await peerConnection.createAnswer(); + // print('Created Answer $answer'); + // + // await peerConnection.setLocalDescription(answer); + // + // Map roomWithAnswer = { + // 'answer': {'type': answer.type, 'sdp': answer.sdp} + // }; + // + // await roomRef.update(roomWithAnswer); + // // Finished creating SDP answer + // + // // Listening for remote ICE candidates below + // // roomRef.collection('callerCandidates').snapshots().listen((snapshot) { + // // snapshot.docChanges.forEach((document) { + // // var data = document.doc.data() as Map; + // // print(data); + // // print('Got new remote ICE candidate: $data'); + // // peerConnection.addCandidate( + // // RTCIceCandidate( + // // data['candidate'], + // // data['sdpMid'], + // // data['sdpMLineIndex'], + // // ), + // // ); + // // }); + // // }); + // } + // } Future openUserMedia( RTCVideoRenderer localVideo, @@ -189,32 +189,32 @@ class Signaling { remoteVideo.srcObject = await createLocalMediaStream('key'); } - Future hangUp(RTCVideoRenderer localVideo) async { - List tracks = localVideo.srcObject.getTracks(); - tracks.forEach((track) { - track.stop(); - }); - - if (remoteStream != null) { - remoteStream.getTracks().forEach((track) => track.stop()); - } - if (peerConnection != null) peerConnection.close(); - - if (roomId != null) { - var db = FirebaseFirestore.instance; - var roomRef = db.collection('rooms').doc(roomId); - var calleeCandidates = await roomRef.collection('calleeCandidates').get(); - calleeCandidates.docs.forEach((document) => document.reference.delete()); - - var callerCandidates = await roomRef.collection('callerCandidates').get(); - callerCandidates.docs.forEach((document) => document.reference.delete()); - - await roomRef.delete(); - } - - localStream.dispose(); - remoteStream?.dispose(); - } + // Future hangUp(RTCVideoRenderer localVideo) async { + // List tracks = localVideo.srcObject.getTracks(); + // tracks.forEach((track) { + // track.stop(); + // }); + // + // if (remoteStream != null) { + // remoteStream.getTracks().forEach((track) => track.stop()); + // } + // if (peerConnection != null) peerConnection.close(); + // + // if (roomId != null) { + // var db = FirebaseFirestore.instance; + // var roomRef = db.collection('rooms').doc(roomId); + // var calleeCandidates = await roomRef.collection('calleeCandidates').get(); + // calleeCandidates.docs.forEach((document) => document.reference.delete()); + // + // var callerCandidates = await roomRef.collection('callerCandidates').get(); + // callerCandidates.docs.forEach((document) => document.reference.delete()); + // + // await roomRef.delete(); + // } + // + // localStream.dispose(); + // remoteStream?.dispose(); + // } void registerPeerConnectionListeners() { peerConnection?.onIceGatheringState = (RTCIceGatheringState state) { diff --git a/pubspec.yaml b/pubspec.yaml index c7cda641..744929f6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,8 +36,7 @@ dependencies: fl_chart: ^0.12.3 # Permissions - permission_handler: ^5.0.0+hotfix.3 - device_info: ^0.4.2+4 + permission_handler: ^5.1.0+2 # Flutter Html View flutter_html: ^1.2.0 @@ -46,7 +45,6 @@ dependencies: pull_to_refresh: 1.6.2 # Native - flutter_device_type: ^0.2.0 local_auth: ^0.6.2+3 localstorage: ^3.0.3+6 maps_launcher: ^1.2.1 @@ -55,7 +53,6 @@ dependencies: flutter_flexible_toast: ^0.1.4 firebase_messaging: ^7.0.3 firebase_analytics: ^6.3.0 - cloud_firestore: ^0.14.3 # Progress bar progress_hud_v2: ^2.0.0 percent_indicator: ^2.1.5 @@ -156,7 +153,6 @@ dependencies: cached_network_image: ^2.4.1 flutter_tts: path: flutter_tts-voice_enhancement - # flutter_tts: ^1.2.6 sms_otp_auto_verify: ^1.2.2 wifi: ^0.1.5