import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:carousel_slider/carousel_slider.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(); } //CompareList compareItems = CompareList(); class _ComparePageState extends State { getLanguageID() async { languageID = await sharedPref.getString(APP_LANGUAGE); } void initState() { getLanguageID(); super.initState(); } @override Widget build(BuildContext context) { return AppScaffold( appBarTitle: TranslationBase.of(context).compare, isShowAppBar: true, isPharmacy: true, body: SingleChildScrollView( child: Container( child: compareList(), ), ), ); } } class compareList extends StatelessWidget { @override Widget build(BuildContext context) { final productItemData = Provider.of(context); final productItem = productItemData.productListItems; return productItem.length == 0 ? 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), ), ) ], ), ), ) : 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(), ); } } class slideDetail extends StatefulWidget { final List data; slideDetail(this.data); @override _slideDetailState createState() => _slideDetailState(); } class _slideDetailState extends State { @override Widget build(BuildContext context) { return ListView.builder( scrollDirection: Axis.horizontal, itemCount: widget.data.length, itemBuilder: (BuildContext contx, int index) { return Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Container( height: 750, width: 150, margin: EdgeInsets.symmetric(horizontal: 10.0), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border( top: BorderSide(width: 0.5, color: Colors.grey), left: BorderSide(width: 0.5, color: Colors.grey), right: BorderSide(width: 0.5, color: Colors.grey), bottom: BorderSide(width: 0.5, color: Colors.grey), ), color: Colors.white), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( children: [ Container( child: Align( alignment: Alignment.topRight, child: IconButton( icon: Icon(FontAwesomeIcons.trashAlt, size: 15), onPressed: () { setState(() { Provider.of(context, listen: false) .deleteItem(widget.data[index].id); }); }, ), ), ), SizedBox( height: 20, ), Image.network( widget.data[index].images[0].src.trim(), fit: BoxFit.cover, width: 100, height: 60, ), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? 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: 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), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[0].nameN : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ) :TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[0].name : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ), ), ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[0].defaultValuen : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[0].defaultValue : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ), ), ), ), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[1].nameN : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[1].name : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ), ), ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[1].defaultValuen : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[1].defaultValue : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ), ), ), ), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[2].nameN : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[2].name : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ), ), ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[2].defaultValuen : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[2].defaultValue : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ), ), ), ), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[3].nameN : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[3].name : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ), ), ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[3].defaultValuen : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[3].defaultValue : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ), ), ), ), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[4].nameN : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[4].name : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ), ), ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[4].defaultValuen : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[4].defaultValue : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ), ), ), ), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[5].nameN : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[5].name : // "No data", TranslationBase.of(context).no_data, style: TextStyle( fontWeight: FontWeight.bold, color: Colors.black, fontSize: 13), ), ), ), ), Container( margin: EdgeInsets.all(5), child: Align( alignment: Alignment.topLeft, child: RichText( text: languageID == "ar"? TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[5].defaultValuen : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ):TextSpan( text: widget.data[index].specifications != null ? widget.data[index].specifications[5].defaultValue : // "No data", TranslationBase.of(context).no_data, style: TextStyle( color: Colors.black54, fontSize: 15, fontWeight: FontWeight.bold), ), ), ), ), Padding( padding: EdgeInsets.only(top: 8.0), child: Container( height: 1.0, width: 300.0, color: Colors.grey, ), ), ], ), ), ), ], ); }, ); } } String returnString(data) { for (int i = 0; i < data.length; i++) { print(data[i]); // if(data[i] == null){ // if(counter == i){ // // } // } } return "ENAD HILAL"; }