You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/pages/pharmacies/compare.dart

482 lines
23 KiB
Dart

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: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:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
int counter = 0;
dynamic languageID;
class ComparePage extends StatefulWidget {
@override
_ComparePageState createState() => _ComparePageState();
}
//CompareList compareItems = CompareList();
class _ComparePageState extends State<ComparePage> {
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,
showPharmacyCart: false,
showHomeAppBarIcon: false,
isBottomBar: true,
body: SingleChildScrollView(
child: Container(
child: compareList(),
),
),
);
}
}
class compareList extends StatelessWidget {
@override
Widget build(BuildContext context) {
final productItemData = Provider.of<CompareList>(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,
style: TextStyle(fontSize: 30),
),
)
],
),
),
)
: Container(
margin: EdgeInsets.only(top: 12.0),
width: double.infinity,
height: MediaQuery.of(context).size.height,
child: slideDetail(productItem),
);
}
}
class slideDetail extends StatefulWidget {
final List<PharmacyProduct> data;
slideDetail(this.data);
@override
_slideDetailState createState() => _slideDetailState();
}
class _slideDetailState extends State<slideDetail> {
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(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: 760,
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<CompareList>(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: 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),
),
),
),
),
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
height: 1.0,
width: 300.0,
color: Colors.grey,
),
),
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),
)),
)),
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),
)),
)),
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
height: 1.0,
width: 300.0,
color: Colors.grey,
),
),
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),
)),
)),
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),
)),
)),
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
height: 1.0,
width: 300.0,
color: Colors.grey,
),
),
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),
)),
)),
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),
)),
)),
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
height: 1.0,
width: 300.0,
color: Colors.grey,
),
),
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),
)),
)),
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),
)),
)),
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
height: 1.0,
width: 300.0,
color: Colors.grey,
),
),
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),
)),
)),
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),
)),
)),
Padding(
padding: EdgeInsets.only(top: 8.0),
child: Container(
height: 1.0,
width: 300.0,
color: Colors.grey,
),
),
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),
)),
)),
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),
)),
)),
],
),
),
),
],
);
},
);
}
}