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.
373 lines
17 KiB
Dart
373 lines
17 KiB
Dart
import 'dart:convert';
|
|
import 'dart:developer';
|
|
|
|
import 'package:car_provider_app/config/provider_routes.dart';
|
|
import 'package:car_provider_app/view_models/service_view_model.dart';
|
|
import 'package:car_provider_app/views/settings/services/services_list_page.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/app_state.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/provider_branches_models/branch_detail_model.dart';
|
|
import 'package:mc_common_app/models/provider_branches_models/profile/categroy.dart';
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
import 'package:mc_common_app/utils/enums.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:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../generated/locale_keys.g.dart';
|
|
|
|
class BranchDetailPage extends StatelessWidget {
|
|
BranchDetailModel branchData;
|
|
|
|
BranchDetailPage(this.branchData);
|
|
|
|
List<CategoryData> categories = [];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
branchData.branchServices!.forEach((element) {
|
|
categories.add(
|
|
CategoryData(
|
|
id: element.categoryId,
|
|
categoryName: element.categoryName,
|
|
categoryNameN: element.categoryName,
|
|
),
|
|
);
|
|
});
|
|
categories = categories.toSet().toList();
|
|
for (var payment in categories) {
|
|
branchData.branchServices!.forEach((element) {
|
|
if (payment.id == element.categoryId) {
|
|
payment.services ??= [];
|
|
payment.services!.add(element);
|
|
}
|
|
});
|
|
}
|
|
branchData.categories = categories;
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: branchData.branchName.toString(),
|
|
),
|
|
body: Consumer<ServiceVM>(builder: (context, model, _) {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: titleWidget(MyAssets.icBranches,
|
|
LocaleKeys.branchInfo.tr()),
|
|
),
|
|
IconButton(
|
|
onPressed: () {
|
|
navigateWithName(
|
|
context, ProviderAppRoutes.defineBranch,
|
|
arguments: branchData);
|
|
},
|
|
icon: SvgPicture.asset(MyAssets.icEdit),
|
|
)
|
|
],
|
|
),
|
|
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,
|
|
color: MyColors.darkIconColor,
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 20, vertical: 8),
|
|
child: Row(
|
|
children: [
|
|
const Icon(
|
|
Icons.calendar_month,
|
|
color: Colors.white,
|
|
),
|
|
8.width,
|
|
Expanded(
|
|
child: "Set or Edit Branch Schedule".toText(
|
|
isUnderLine: true,
|
|
fontSize: 14,
|
|
isBold: true,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const Icon(
|
|
Icons.arrow_forward,
|
|
size: 20,
|
|
color: Colors.white,
|
|
),
|
|
],
|
|
),
|
|
).onPress(() {
|
|
navigateWithName(
|
|
context, ProviderAppRoutes.schedulesList,
|
|
arguments: branchData.id.toString());
|
|
}),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(
|
|
Icons.add,
|
|
color: Colors.white,
|
|
).toContainer(
|
|
borderRadius: 100,
|
|
paddingAll: 3,
|
|
backgroundColor: MyColors.darkIconColor,
|
|
),
|
|
8.width,
|
|
"Add Services".toText(
|
|
fontSize: 14,
|
|
color: MyColors.lightTextColor,
|
|
isBold: true,
|
|
),
|
|
],
|
|
)
|
|
.toContainer(
|
|
borderRadius: 0,
|
|
backgroundColor: MyColors.darkWhiteColor,
|
|
width: double.infinity,
|
|
paddingAll: 20,
|
|
margin:
|
|
const EdgeInsets.only(left: 20, right: 20, top: 20),
|
|
)
|
|
.onPress(() {
|
|
navigateWithName(
|
|
context,
|
|
ProviderAppRoutes.createServices3,
|
|
arguments: CreateBranchModel(
|
|
branchId: branchData.id.toString(),
|
|
branchName: branchData.branchName.toString(),
|
|
),
|
|
);
|
|
}),
|
|
categories.isEmpty
|
|
? "No Service Added Yet".toText(fontSize: 12)
|
|
: ListView.separated(
|
|
itemBuilder: (context, pIndex) {
|
|
return InkWell(
|
|
onTap: () {
|
|
categories[pIndex].branchId =
|
|
branchData.id.toString();
|
|
categories[pIndex].branchName =
|
|
branchData.branchName.toString();
|
|
navigateWithName(
|
|
context, ProviderAppRoutes.servicesList,
|
|
arguments: categories[pIndex]);
|
|
},
|
|
child: Row(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 5),
|
|
child: SvgPicture.asset(
|
|
MyAssets.maintenanceIcon,
|
|
width: 16,
|
|
height: 16,
|
|
),
|
|
),
|
|
8.width,
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
categories[pIndex]
|
|
.categoryName
|
|
.toString()
|
|
.toText(
|
|
fontSize: 16,
|
|
isBold: true),
|
|
// Padding(
|
|
// padding: const EdgeInsets.all(4.0),
|
|
// child: SvgPicture.asset(
|
|
// MyAssets.icEdit,
|
|
// width: 16,
|
|
// height: 16,
|
|
// ),
|
|
// ),
|
|
],
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceBetween,
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: ListView.builder(
|
|
itemBuilder:
|
|
(context, index) {
|
|
return Container(
|
|
child: (EasyLocalization.of(
|
|
context)
|
|
?.currentLocale
|
|
?.countryCode ==
|
|
"SA"
|
|
? categories[
|
|
pIndex]
|
|
.services![
|
|
index]
|
|
.serviceDescriptionN
|
|
.toString()
|
|
: categories[
|
|
pIndex]
|
|
.services![
|
|
index]
|
|
.serviceDescription
|
|
.toString())
|
|
.toText(
|
|
fontSize: 12,
|
|
color: MyColors
|
|
.lightTextColor,
|
|
isBold: true,
|
|
),
|
|
);
|
|
},
|
|
itemCount: categories[pIndex]
|
|
.services
|
|
?.length,
|
|
physics:
|
|
const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
padding: EdgeInsets.zero,
|
|
),
|
|
),
|
|
const Padding(
|
|
padding: EdgeInsets.all(4.0),
|
|
child: Icon(
|
|
Icons.arrow_forward,
|
|
size: 20,
|
|
),
|
|
),
|
|
],
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.end,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.end,
|
|
)
|
|
],
|
|
)),
|
|
],
|
|
).toContainer(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 12, vertical: 8),
|
|
isShadowEnabled: true,
|
|
),
|
|
);
|
|
},
|
|
itemCount: categories.length,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
padding: const EdgeInsets.all(20),
|
|
separatorBuilder:
|
|
(BuildContext context, int index) {
|
|
return 12.height;
|
|
},
|
|
),
|
|
12.height,
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: double.infinity,
|
|
height: 1,
|
|
color: Colors.grey[100],
|
|
),
|
|
if (AppState().userType == UserType.providerDealer)
|
|
Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: ShowFillButton(
|
|
title: "Assign Dealer User",
|
|
maxWidth: double.infinity,
|
|
backgroundColor: Colors.transparent,
|
|
borderColor: MyColors.darkPrimaryColor,
|
|
txtColor: MyColors.darkPrimaryColor,
|
|
isFilled: false,
|
|
onPressed: () {
|
|
navigateWithName(context, ProviderAppRoutes.dealerUser,
|
|
arguments: branchData.id.toString());
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
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(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
title.toText(fontSize: 10, color: Colors.black, isBold: true),
|
|
8.width,
|
|
Flexible(
|
|
child: value.toText(
|
|
fontSize: 12,
|
|
color: MyColors.textColor,
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|