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.
188 lines
7.0 KiB
Dart
188 lines
7.0 KiB
Dart
import 'package:car_provider_app/config/provider_routes.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
import 'package:car_provider_app/view_models/branch_view_model.dart';
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
import 'package:mc_common_app/config/routes.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/models/model/branch2.dart';
|
|
import 'package:mc_common_app/models/profile/categroy.dart';
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
import 'package:mc_common_app/utils/navigator.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:provider/provider.dart';
|
|
|
|
|
|
import '../../../generated/locale_keys.g.dart';
|
|
|
|
|
|
class BranchDetailPage extends StatelessWidget {
|
|
ServiceProviderBranch branchData;
|
|
|
|
BranchDetailPage(this.branchData);
|
|
|
|
List<CategoryData> categories = [];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
branchData.serviceProviderServices!.forEach((element) {
|
|
categories.add(
|
|
CategoryData(
|
|
id: element.categoryId,
|
|
categoryName: element.categoryName,
|
|
categoryNameN: element.categoryName,
|
|
),
|
|
);
|
|
});
|
|
categories = categories.toSet().toList();
|
|
for (var payment in categories) {
|
|
branchData.serviceProviderServices!.forEach((element) {
|
|
if (payment.id == element.categoryId) {
|
|
payment.services ??= [];
|
|
payment.services!.add(element);
|
|
}
|
|
});
|
|
}
|
|
branchData.categories = categories;
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: LocaleKeys.branchName.tr(),
|
|
),
|
|
body: Consumer<BranchVM>(builder: (context, model, _) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
padding: EdgeInsets.all(20),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: titleWidget(MyAssets.icBranches, LocaleKeys.branchInfo),
|
|
),
|
|
IconButton(
|
|
onPressed: () {
|
|
navigateWithName(context, ProviderAppRoutes.defineBranch, arguments: branchData);
|
|
},
|
|
icon: const Icon(
|
|
Icons.edit,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
8.height,
|
|
Column(
|
|
children: [
|
|
showData("${LocaleKeys.country.tr()}:", branchData.countryName.toString()),
|
|
showData("${LocaleKeys.city.tr()}:", branchData.cityName.toString()),
|
|
showData("${LocaleKeys.branchName.tr()}:", branchData.branchName.toString()),
|
|
showData("${LocaleKeys.branchDescription.tr()}:", branchData.branchDescription.toString()),
|
|
showData("${LocaleKeys.address.tr()}:", branchData.address.toString()),
|
|
],
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
height: 1,
|
|
color: Colors.grey,
|
|
margin: EdgeInsets.symmetric(vertical: 12),
|
|
),
|
|
categories.isEmpty
|
|
? LocaleKeys.no_branch.tr().toText(fontSize: 12)
|
|
: ListView.builder(
|
|
itemBuilder: (context, pIndex) {
|
|
return Container(
|
|
width: double.infinity,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
categories[pIndex].categoryName.toString().toText(fontSize: 16, isBold: true),
|
|
ListView.builder(
|
|
itemBuilder: (context, index) {
|
|
return Container(
|
|
child:
|
|
("- ${EasyLocalization.of(context)?.currentLocale?.countryCode == "SA" ? categories[pIndex].services![index].serviceNameN.toString() : categories[pIndex].services![index].serviceName.toString()}")
|
|
.toText(fontSize: 14),
|
|
);
|
|
},
|
|
itemCount: categories[pIndex].services?.length,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
)
|
|
],
|
|
),
|
|
);
|
|
},
|
|
itemCount: categories.length,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
height: 1,
|
|
color: Colors.grey,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: ShowFillButton(
|
|
title: LocaleKeys.editServices,
|
|
maxWidth: double.infinity,
|
|
onPressed: () {
|
|
navigateWithName(
|
|
context,
|
|
ProviderAppRoutes.createServices,
|
|
arguments: branchData,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
Widget titleWidget(String icon, String title) {
|
|
return Row(
|
|
children: [
|
|
SvgPicture.asset(
|
|
icon,
|
|
width: 18,
|
|
height: 18,
|
|
color: MyColors.darkPrimaryColor,
|
|
),
|
|
12.width,
|
|
title.toText(fontSize: 16, color: Colors.black, isBold: true),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget showData(String title, String value) {
|
|
return Row(
|
|
children: [
|
|
title.toText(fontSize: 10, color: Colors.black, isBold: true),
|
|
8.width,
|
|
value.toText(
|
|
fontSize: 12,
|
|
color: MyColors.textColor,
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|