diff --git a/lib/pages/pharmacies/compare.dart b/lib/pages/pharmacies/compare.dart index 34b21001..67ba25b5 100644 --- a/lib/pages/pharmacies/compare.dart +++ b/lib/pages/pharmacies/compare.dart @@ -1,18 +1,17 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:carousel_slider/carousel_slider.dart'; +import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:provider/provider.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; - int counter = 0; dynamic languageID; + class ComparePage extends StatefulWidget { @override _ComparePageState createState() => _ComparePageState(); @@ -23,6 +22,7 @@ class _ComparePageState extends State { getLanguageID() async { languageID = await sharedPref.getString(APP_LANGUAGE); } + void initState() { getLanguageID(); super.initState(); @@ -68,8 +68,8 @@ class compareList extends StatelessWidget { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text(TranslationBase.of(context).noData, -// 'There is no data', + child: Text( + TranslationBase.of(context).noData, style: TextStyle(fontSize: 30), ), ) @@ -77,27 +77,11 @@ class compareList extends StatelessWidget { ), ), ) - : CarouselSlider( - options: CarouselOptions( - height: 800.0, - viewportFraction: 0.87, - enableInfiniteScroll: false), - items: productItem.map((i) { - return Builder( - builder: (BuildContext context) { - return Padding( - padding: const EdgeInsets.only(top: 8), - child: Container( - width: MediaQuery.of(context).size.width, - margin: EdgeInsets.symmetric(horizontal: 10.0), - child: productItem.length != 0 - ? slideDetail(productItem) - : Container(), - ), - ); - }, - ); - }).toList(), + : Container( + margin: EdgeInsets.only(top: 12.0), + width: double.infinity, + height: MediaQuery.of(context).size.height, + child: slideDetail(productItem), ); } } @@ -147,8 +131,7 @@ class _slideDetailState extends State { icon: Icon(FontAwesomeIcons.trashAlt, size: 15), onPressed: () { setState(() { - Provider.of(context, listen: false) - .deleteItem(widget.data[index].id); + Provider.of(context, listen: false).deleteItem(widget.data[index].id); }); }, ), @@ -173,53 +156,42 @@ class _slideDetailState extends State { ), Container( margin: EdgeInsets.all(5), - child:Align( + child: Align( alignment: Alignment.topLeft, child: RichText( - text: projectViewModel.isArabic ? TextSpan( - text: widget.data[index].namen, - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - : TextSpan( - text: widget.data[index].name, - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ), + text: projectViewModel.isArabic + ? TextSpan( + text: widget.data[index].namen, + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + ) + : TextSpan( + text: widget.data[index].name, + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + ), ), ), ), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text: TextSpan( - text: "SAR ${widget.data[index].price.toString()}", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ), - ), - ): - Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: "SAR ${widget.data[index].price.toString()}", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ), - ), - ), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: "SAR ${widget.data[index].price.toString()}", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + ), + ), + ) + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: "SAR ${widget.data[index].price.toString()}", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + ), + ), + ), ), Padding( padding: EdgeInsets.only(top: 8.0), @@ -230,63 +202,43 @@ class _slideDetailState extends State { ), ), Container( - margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[0].nameN :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - ), - ): Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[0].name :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - ), - ) - ), + margin: EdgeInsets.all(5), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[0].nameN : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), + ) + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[0].name : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), + )), Container( - margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[0].defaultValuen:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ) - ), - ):Align( - alignment: Alignment.topLeft, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[0].defaultValue:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ) - ), - ) - ), + margin: EdgeInsets.all(5), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[0].defaultValuen : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), + ) + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[0].defaultValue : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), + )), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( @@ -297,62 +249,42 @@ class _slideDetailState extends State { ), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[1].nameN :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - ), - ): Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[1].name :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[1].nameN : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[1].name : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), + )), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[1].defaultValuen:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ) - ), - ):Align( - alignment: Alignment.topLeft, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[1].defaultValue:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[1].defaultValuen : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[1].defaultValue : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), + )), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( @@ -363,62 +295,42 @@ class _slideDetailState extends State { ), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[2].nameN :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - ), - ): Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[2].name :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[2].nameN : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[2].name : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), + )), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[2].defaultValuen:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ) - ), - ):Align( - alignment: Alignment.topLeft, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[2].defaultValue:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[2].defaultValuen : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[2].defaultValue : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), + )), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( @@ -429,62 +341,42 @@ class _slideDetailState extends State { ), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[3].nameN :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - ), - ): Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[3].name :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[3].nameN : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[3].name : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), + )), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[3].defaultValuen:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ) - ), - ):Align( - alignment: Alignment.topLeft, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[3].defaultValue:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[3].defaultValuen : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[3].defaultValue : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), + )), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( @@ -495,62 +387,42 @@ class _slideDetailState extends State { ), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[4].nameN :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - ), - ): Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[4].name :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[4].nameN : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[4].name : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), + )), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[4].defaultValuen:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ) - ), - ):Align( - alignment: Alignment.topLeft, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[4].defaultValue:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[4].defaultValuen : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[4].defaultValue : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), + )), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( @@ -561,63 +433,42 @@ class _slideDetailState extends State { ), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[5].nameN :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), - ) - ), - ): Align( - alignment: Alignment.topLeft, - child: RichText( - text: TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[5].name :"", - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.black, - fontSize: 13), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[5].nameN : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), ) - ), - ) - ), + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[5].name : "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), + )), + )), Container( margin: EdgeInsets.all(5), - child: projectViewModel.isArabic ? - Align( - alignment: Alignment.topRight, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[5].defaultValuen:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), - ) - ), - ):Align( - alignment: Alignment.topLeft, - child: RichText( - text:TextSpan( - text: widget.data[index].specifications != null ? - widget.data[index].specifications[5].defaultValue:"", - style: TextStyle( - color: Colors.black54, - fontSize: 15, - fontWeight: FontWeight.bold), + child: projectViewModel.isArabic + ? Align( + alignment: Alignment.topRight, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[5].defaultValuen : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), ) - ), - ) - ), - + : Align( + alignment: Alignment.topLeft, + child: RichText( + text: TextSpan( + text: widget.data[index].specifications != null ? widget.data[index].specifications[5].defaultValue : "", + style: TextStyle(color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), + )), + )), ], ), ), @@ -628,15 +479,3 @@ class _slideDetailState extends State { ); } } - -String returnString(data) { - for (int i = 0; i < data.length; i++) { - print(data[i]); -// if(data[i] == null){ -// if(counter == i){ -// -// } -// } - } - return "ENAD HILAL"; -}