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.
141 lines
7.0 KiB
Dart
141 lines
7.0 KiB
Dart
import 'package:geolocator/geolocator.dart';
|
|
import 'package:car_provider_app/config/provider_routes.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/classes/app_state.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/provider_branches_models/branch_detail_model.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/view_models/service_view_model.dart';
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
import 'package:mc_common_app/widgets/tab/role_type_tab.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
class BranchAppointmentFragment extends StatelessWidget {
|
|
const BranchAppointmentFragment({
|
|
Key? key,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: LocaleKeys.appointments.tr(),
|
|
isRemoveBackButton: true,
|
|
),
|
|
body: SizedBox(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 21, right: 21, top: 21),
|
|
child: RoleTypeTab(
|
|
context.watch<ServiceVM>().selectedBranchStatus == 3 ? 0 : context.watch<ServiceVM>().selectedBranchStatus,
|
|
[
|
|
DropValue(3, "Active", ""),
|
|
DropValue(1, "Requested", ""),
|
|
],
|
|
onSelect: (DropValue value) {
|
|
context.read<ServiceVM>().updateSelectedBranchType(value.id);
|
|
},
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Consumer<ServiceVM>(
|
|
builder: (context, ServiceVM serviceVM, _) {
|
|
if (serviceVM.state == ViewState.busy) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
} else {
|
|
List<BranchDetailModel> branches = [];
|
|
if (serviceVM.branches!.data != null) {
|
|
branches = serviceVM.branches!.data!.serviceProviderBranch!.where((element) => serviceVM.selectedBranchStatus == element.statusId).toList();
|
|
}
|
|
return RefreshIndicator(
|
|
onRefresh: () async => serviceVM.getBranchAndServices(),
|
|
child: branches.isEmpty
|
|
? Center(child: Text(LocaleKeys.noBranchFound.tr()))
|
|
: ListView.separated(
|
|
itemBuilder: (context, index) {
|
|
return Row(
|
|
children: [
|
|
Container(
|
|
width: 74,
|
|
height: 50,
|
|
decoration: const BoxDecoration(
|
|
color: MyColors.darkPrimaryColor,
|
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
|
),
|
|
padding: const EdgeInsets.all(6),
|
|
child: SvgPicture.asset(
|
|
MyAssets.icBranches,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
12.width,
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
const Icon(
|
|
Icons.place,
|
|
size: 12,
|
|
color: MyColors.darkPrimaryColor,
|
|
),
|
|
Geolocator.distanceBetween(AppState().currentLocation.latitude, AppState().currentLocation.latitude, double.parse(branches[index].latitude ?? "0"),
|
|
double.parse(branches[index].longitude ?? "0"))
|
|
.toStringAsFixed(2)
|
|
.toText(
|
|
fontSize: 12,
|
|
color: MyColors.darkPrimaryColor,
|
|
)
|
|
],
|
|
),
|
|
Text(
|
|
branches[index].branchName ?? "",
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
"Tap to view".toText(fontSize: 10, color: MyColors.grey70Color),
|
|
],
|
|
),
|
|
),
|
|
12.width,
|
|
],
|
|
).toContainer().onPress(() async {
|
|
branches[index].countryID = serviceVM.branches!.data!.countryID;
|
|
branches[index].countryName = serviceVM.branches!.data!.countryName;
|
|
navigateWithName(context, ProviderAppRoutes.appointment, arguments: branches[index]);
|
|
});
|
|
},
|
|
separatorBuilder: (context, index) {
|
|
return 12.height;
|
|
},
|
|
itemCount: branches.length,
|
|
padding: const EdgeInsets.all(12),
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|