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/BookAppointment/components/LaserClinic.dart

184 lines
7.3 KiB
Dart

import 'package:diplomaticquarterapp/models/Appointments/laser_body_parts.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
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/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import '../../../svg_tester.dart';
class LaserClinic extends StatefulWidget {
LaserClinic({Key key}) : super(key: key);
@override
_LaserClinicState createState() {
return _LaserClinicState();
}
}
class _LaserClinicState extends State<LaserClinic> {
List<int> _laserCategoryList = [0, 2, 11];
List<String> _selectedBodyPartList = [];
bool _isFullBody = false;
int _selectedCategoryIndex = 0;
List<LaserBodyPart> laserBodyPartsList = [];
@override
void initState() {
super.initState();
Future.delayed(Duration.zero, () {
callLaserBodyPartsAPI();
});
}
callLaserBodyPartsAPI() async {
GifLoaderDialogUtils.showMyDialog(context);
DoctorsListService service = new DoctorsListService();
service.getLaserBodyPartsList(_selectedCategoryIndex).then((res) {
GifLoaderDialogUtils.hideDialog(context);
if (res['MessageStatus'] == 1) {
setState(() {
if (res['Laser_GetBodyPartsByCategoryList'].length != 0) {
laserBodyPartsList = [];
res['Laser_GetBodyPartsByCategoryList'].forEach((v) {
laserBodyPartsList.add(LaserBodyPart.fromJson(v));
});
} else {}
});
} else {
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
AppToast.showErrorToast(message: err);
});
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return AppScaffold(
appBarTitle: TranslationBase.of(context).clinic,
showNewAppBar: true,
showNewAppBarTitle: true,
isShowDecPage: false,
backgroundColor: Color(0xfff7f7f7),
body: Column(
children: [
Expanded(
child: Padding(
padding: EdgeInsets.all(21),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
for (var index in _laserCategoryList)
InkWell(
onTap: () {
_selectedCategoryIndex = index;
setState(() {});
callLaserBodyPartsAPI();
},
child: Container(
width: 75,
height: 75,
alignment: Alignment.center,
padding: EdgeInsets.only(left: 4, right: 4),
decoration: BoxDecoration(shape: BoxShape.circle, color: _selectedCategoryIndex == index ? Colors.redAccent : Color(0xff2E303A)),
child: Text(
index == 0 ? "Body" : (index == 2 ? "Face" : "Retouch"),
style: TextStyle(color: Colors.white),
),
),
)
],
),
SizedBox(height: 12),
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: ListView.separated(
//shrinkWrap: true,
physics: BouncingScrollPhysics(),
itemBuilder: (cxt, index) {
return InkWell(
onTap: () {
if (_selectedBodyPartList.contains(laserBodyPartsList[index].bodyPart)) {
_selectedBodyPartList.remove(laserBodyPartsList[index].bodyPart);
} else {
_selectedBodyPartList.add(laserBodyPartsList[index].bodyPart);
}
setState(() {});
},
child: Row(
children: [
Container(
width: 24,
height: 24,
alignment: Alignment.center,
decoration:
BoxDecoration(shape: BoxShape.circle, color: _selectedBodyPartList.contains(laserBodyPartsList[index].bodyPart) ? Color(0xff2E303A) : Colors.transparent),
child: Icon(Icons.done, color: _selectedBodyPartList.contains(laserBodyPartsList[index].bodyPart) ? Colors.white : Color(0xff2E303A))),
SizedBox(width: 8),
Expanded(
child: Text(
laserBodyPartsList[index].bodyPart,
style: TextStyle(
color: Color(0xff2E303A),
),
),
),
],
),
);
},
separatorBuilder: (cxt, index) => Divider(
height: 1,
thickness: 1,
color: Color(0xff2E303A),
),
itemCount: laserBodyPartsList.length),
),
Expanded(
child: ListView(
physics: BouncingScrollPhysics(),
children: [
Center(
child: Text(
"Minutes",
style: TextStyle(color: Color(0xff2E303A)),
),
),
Expanded(
child: BodyPartMapper(
dataList: _selectedBodyPartList,
))
],
),
)
],
),
)
],
),
),
),
DefaultButton("Continue", () {}).insideContainer,
],
),
);
}
}