Fetch Branches & services
parent
237911d711
commit
4ccbf361fe
@ -0,0 +1,208 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mc_common_app/classes/consts.dart';
|
||||
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
||||
import 'package:mc_common_app/models/services/branch_model.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:mc_common_app/models/services/service_model.dart';
|
||||
import 'package:mc_common_app/theme/colors.dart';
|
||||
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
||||
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
||||
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||
|
||||
class BranchDetailPage extends StatefulWidget {
|
||||
BranchModel branchModel;
|
||||
|
||||
BranchDetailPage({required this.branchModel});
|
||||
|
||||
@override
|
||||
State<BranchDetailPage> createState() => _BranchDetailPageState();
|
||||
}
|
||||
|
||||
class _BranchDetailPageState extends State<BranchDetailPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: "Branch Detail",
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(21),
|
||||
child: Column(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Image.asset(MyAssets.bnCar),
|
||||
12.height,
|
||||
"${widget.branchModel.branchName} | ${widget.branchModel.serviceProviderName}".toString().toText(
|
||||
fontSize: 16,
|
||||
isBold: true,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
(LocaleKeys.location.tr() + ":").toText(color: MyColors.lightTextColor, fontSize: 12),
|
||||
4.width,
|
||||
(widget.branchModel.distanceKm.toString() + " km").toText(fontSize: 12, isBold: true),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
("Time" + ":").toText(color: MyColors.lightTextColor, fontSize: 12),
|
||||
4.width,
|
||||
"${widget.branchModel.openTime} - ${widget.branchModel.closeTime}".toText(fontSize: 12, isBold: true),
|
||||
],
|
||||
),
|
||||
2.height,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
"Open Map Location".toText(
|
||||
fontSize: 12,
|
||||
isBold: true,
|
||||
color: MyColors.primaryColor,
|
||||
isUnderLine: true,
|
||||
),
|
||||
4.width,
|
||||
Image.asset(
|
||||
MyAssets.icRightUpPng,
|
||||
height: 6,
|
||||
width: 6,
|
||||
color: MyColors.primaryColor,
|
||||
),
|
||||
],
|
||||
)
|
||||
.padding(
|
||||
EdgeInsets.symmetric(vertical: 6, horizontal: 2),
|
||||
)
|
||||
.onPress(
|
||||
() {},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
"Provider Profile".toText(
|
||||
fontSize: 12,
|
||||
isBold: true,
|
||||
color: MyColors.primaryColor,
|
||||
isUnderLine: true,
|
||||
),
|
||||
2.width,
|
||||
Icon(
|
||||
Icons.arrow_forward,
|
||||
size: 12,
|
||||
color: MyColors.primaryColor,
|
||||
),
|
||||
],
|
||||
)
|
||||
.padding(
|
||||
EdgeInsets.symmetric(vertical: 6, horizontal: 2),
|
||||
)
|
||||
.onPress(
|
||||
() {},
|
||||
),
|
||||
],
|
||||
),
|
||||
20.height,
|
||||
"Services Offer".toText(
|
||||
fontSize: 16,
|
||||
color: MyColors.lightTextColor,
|
||||
isBold: true,
|
||||
),
|
||||
showServicesList(),
|
||||
],
|
||||
).toWhiteContainer(
|
||||
width: double.infinity,
|
||||
allPading: 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
ShowFillButton(
|
||||
title: "Book Appointment",
|
||||
maxWidth: double.infinity,
|
||||
margin: EdgeInsets.all(21),
|
||||
onPressed: () {},
|
||||
).toContainer(
|
||||
paddingAll: 0,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget showServicesList() {
|
||||
return ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return ExpansionTile(
|
||||
tilePadding: EdgeInsets.zero,
|
||||
title: (widget.branchModel.branchServices![index].serviceDescription ?? "").toText(
|
||||
fontSize: 16,
|
||||
isBold: true,
|
||||
),
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
showItem("Allowing home service:", (widget.branchModel.branchServices![index].isAllowAppointment ?? false) ? "Yes" : "No", valueColor: Colors.green),
|
||||
showItem("Home service range", widget.branchModel.branchServices![index].customerLocationRange.toString() + "KM"),
|
||||
showItem("Charges per KM", widget.branchModel.branchServices![index].customerLocationRange.toString() + "SAR"),
|
||||
8.height,
|
||||
(widget.branchModel.branchServices![index].itemsCount.toString() + "+ services").toText(
|
||||
fontSize: 12,
|
||||
isBold: true,
|
||||
color: MyColors.primaryColor,
|
||||
isUnderLine: true,
|
||||
),
|
||||
20.height,
|
||||
],
|
||||
).onPress(() {}),
|
||||
],
|
||||
onExpansionChanged: (value) {
|
||||
setState(() {
|
||||
widget.branchModel.branchServices![index].isExpanded = value;
|
||||
});
|
||||
},
|
||||
backgroundColor: Colors.transparent,
|
||||
collapsedBackgroundColor: Colors.transparent,
|
||||
initiallyExpanded: widget.branchModel.branchServices![index].isExpanded,
|
||||
trailing: widget.branchModel.branchServices![index].isExpanded ? Icon(Icons.keyboard_arrow_up) : Icon(Icons.keyboard_arrow_down),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return Divider(
|
||||
height: 1,
|
||||
);
|
||||
},
|
||||
itemCount: widget.branchModel.branchServices!.length,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
);
|
||||
}
|
||||
|
||||
Widget showItem(String item, String value, {Color valueColor = Colors.black}) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
item.toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
||||
4.width,
|
||||
value.toText(fontSize: 12, color: valueColor, isBold: true),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue