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.
257 lines
11 KiB
Dart
257 lines
11 KiB
Dart
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:doctor_app_flutter/providers/medicine_provider.dart';
|
|
import 'package:doctor_app_flutter/providers/project_provider.dart';
|
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:maps_launcher/maps_launcher.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
|
|
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
|
|
|
|
class PharmaciesListScreen extends StatefulWidget {
|
|
final int itemID;
|
|
|
|
final String url;
|
|
|
|
// In the constructor, require a item id.
|
|
PharmaciesListScreen({Key key, @required this.itemID, this.url})
|
|
: super(key: key);
|
|
|
|
@override
|
|
_PharmaciesListState createState() => _PharmaciesListState();
|
|
}
|
|
|
|
class _PharmaciesListState extends State<PharmaciesListScreen> {
|
|
var _data;
|
|
Helpers helpers = new Helpers();
|
|
MedicineProvider _medicineProvider;
|
|
ProjectProvider projectsProvider;
|
|
|
|
bool _isInit = true;
|
|
//bool _isOutOfStuck = false;
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
super.didChangeDependencies();
|
|
if (_isInit) {
|
|
_medicineProvider = Provider.of<MedicineProvider>(context);
|
|
pharmaciesList();
|
|
}
|
|
_isInit = false;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
projectsProvider = Provider.of(context);
|
|
return AppScaffold(
|
|
appBarTitle: TranslationBase.of(context).pharmaciesList,
|
|
body: !_medicineProvider.isFinished
|
|
? DrAppCircularProgressIndeicator()
|
|
: _medicineProvider.hasError
|
|
? Center(
|
|
child: Text(
|
|
_medicineProvider.errorMsg,
|
|
style: TextStyle(
|
|
color: Theme.of(context).errorColor),
|
|
),
|
|
)
|
|
:Container(
|
|
height: SizeConfig.screenHeight,
|
|
child: ListView(
|
|
shrinkWrap: true,
|
|
scrollDirection: Axis.vertical,
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
children: <Widget>[
|
|
RoundedContainer(
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(7)),
|
|
child: Image.memory(
|
|
dataFromBase64String(widget.url),
|
|
height:
|
|
SizeConfig.imageSizeMultiplier *
|
|
21,
|
|
width:
|
|
SizeConfig.imageSizeMultiplier *
|
|
20,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 3,
|
|
child: Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.start,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
AppText(
|
|
TranslationBase.of(context)
|
|
.description,
|
|
marginLeft: 10,
|
|
marginTop: 0,
|
|
marginRight: 10,
|
|
marginBottom: 2,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
AppText(
|
|
_medicineProvider.pharmaciesList[0]["ItemDescription"],
|
|
marginLeft: 10,
|
|
marginTop: 0,
|
|
marginRight: 10,
|
|
marginBottom: 10,
|
|
),
|
|
AppText(
|
|
TranslationBase.of(context).price,
|
|
marginLeft: 10,
|
|
marginTop: 0,
|
|
marginRight: 10,
|
|
marginBottom: 2,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
AppText(
|
|
_medicineProvider.pharmaciesList[0]["SellingPrice"]
|
|
.toString(),
|
|
marginLeft: 10,
|
|
marginTop: 0,
|
|
marginRight: 10,
|
|
marginBottom: 10,
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
)),
|
|
Container(
|
|
margin: EdgeInsets.only(
|
|
top: SizeConfig.widthMultiplier * 2,
|
|
bottom: SizeConfig.widthMultiplier * 2,
|
|
right: SizeConfig.widthMultiplier * 4,
|
|
left: SizeConfig.widthMultiplier * 4,
|
|
),
|
|
child: Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: AppText(
|
|
TranslationBase.of(context).youCanFindItIn,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
alignment: projectsProvider.isArabic
|
|
? Alignment.topRight
|
|
: Alignment.topLeft,
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
width: SizeConfig.screenWidth * 0.99,
|
|
child: ListView.builder(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemCount: _medicineProvider.pharmaciesList == null ? 0 : _medicineProvider.pharmaciesList.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return RoundedContainer(
|
|
child: Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: ClipRRect(
|
|
borderRadius:
|
|
BorderRadius.all(Radius.circular(7)),
|
|
child: Image.network(
|
|
_medicineProvider.pharmaciesList[index]["ProjectImageURL"],
|
|
height:
|
|
SizeConfig.imageSizeMultiplier * 15,
|
|
width:
|
|
SizeConfig.imageSizeMultiplier * 15,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 4,
|
|
child: AppText(
|
|
_medicineProvider.pharmaciesList[index]["LocationDescription"],
|
|
margin: 10,
|
|
),
|
|
),
|
|
Expanded(
|
|
flex: 2,
|
|
child: Wrap(
|
|
direction: Axis.horizontal,
|
|
alignment: WrapAlignment.end,
|
|
crossAxisAlignment: WrapCrossAlignment.end,
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: EdgeInsets.all(5),
|
|
child: InkWell(
|
|
child: Icon(
|
|
Icons.call,
|
|
color: Colors.red,
|
|
),
|
|
onTap: () => launch("tel://" +
|
|
_medicineProvider.pharmaciesList[index]["PhoneNumber"]),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.all(5),
|
|
child: InkWell(
|
|
child: Icon(
|
|
Icons.pin_drop,
|
|
color: Colors.red,
|
|
),
|
|
onTap: () {
|
|
MapsLauncher.launchCoordinates(
|
|
double.parse(
|
|
_medicineProvider.pharmaciesList[index]["Latitude"]),
|
|
double.parse(
|
|
_medicineProvider.pharmaciesList[index]["Longitude"]),
|
|
_medicineProvider.pharmaciesList[index]
|
|
["LocationDescription"]);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
)
|
|
]),
|
|
));
|
|
}
|
|
|
|
pharmaciesList() async {
|
|
_medicineProvider.getPharmaciesList(widget.itemID);
|
|
}
|
|
|
|
Image imageFromBase64String(String base64String) {
|
|
return Image.memory(base64Decode(base64String));
|
|
}
|
|
|
|
//TODO CHECK THE URL IS NULL OR NOT
|
|
Uint8List dataFromBase64String(String base64String) {
|
|
return base64Decode(base64String);
|
|
}
|
|
|
|
String base64String(Uint8List data) {
|
|
return base64Encode(data);
|
|
}
|
|
}
|