Common Setup 1
parent
908e9efe58
commit
237911d711
@ -1,8 +1,10 @@
|
|||||||
|
import 'package:car_customer_app/repositories/provider_repo.dart';
|
||||||
import 'package:mc_common_app/config/dependencies.dart';
|
import 'package:mc_common_app/config/dependencies.dart';
|
||||||
|
|
||||||
class CustomerDependencies {
|
class CustomerDependencies {
|
||||||
static void addDependencies() {
|
static void addDependencies() {
|
||||||
AppDependencies.addDependencies();
|
AppDependencies.addDependencies();
|
||||||
|
injector.registerSingleton<ProviderRepo>(() => ProviderRepoImp());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
import 'package:mc_common_app/api/api_client.dart';
|
||||||
|
import 'package:mc_common_app/classes/app_state.dart';
|
||||||
|
|
||||||
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
|
import 'package:mc_common_app/config/dependencies.dart';
|
||||||
|
import 'package:mc_common_app/models/m_response.dart';
|
||||||
|
import 'package:mc_common_app/models/model/branch2.dart';
|
||||||
|
import 'package:mc_common_app/models/profile/branch.dart';
|
||||||
|
import 'package:mc_common_app/models/profile/categroy.dart';
|
||||||
|
import 'package:mc_common_app/models/profile/document.dart';
|
||||||
|
import 'package:mc_common_app/models/profile/services.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
abstract class ProviderRepo {
|
||||||
|
Future<Branch2> getBranchAndServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProviderRepoImp implements ProviderRepo {
|
||||||
|
@override
|
||||||
|
Future<Branch2> getBranchAndServices() async {
|
||||||
|
// var postParams = {"serviceProviderID": AppState().getUser.data?.userInfo?.providerId.toString() ?? ""};
|
||||||
|
String t = AppState().getUser.data!.accessToken ?? "";
|
||||||
|
return await injector.get<ApiClient>().getJsonForObject((json) => Branch2.fromJson(json), ApiConsts.BranchesAndServices, token: t);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,167 @@
|
|||||||
|
import 'package:car_customer_app/view_models/providers_view_model.dart';
|
||||||
|
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/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/utils/enums.dart';
|
||||||
|
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/categories_list.dart';
|
||||||
|
|
||||||
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
|
||||||
|
class BranchesFragment extends StatelessWidget {
|
||||||
|
const BranchesFragment({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: MyColors.backgroundColor,
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Consumer(
|
||||||
|
builder: (BuildContext context, ProvidersVM providersVM, Widget? child) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
16.height,
|
||||||
|
FiltersList(
|
||||||
|
filterList: providersVM.providersFilterOptions,
|
||||||
|
onFilterTapped: (index, selectedFilterId) => providersVM.applyFilterOnProviders(index: index),
|
||||||
|
),
|
||||||
|
16.height,
|
||||||
|
// Expanded(
|
||||||
|
// child: Container(
|
||||||
|
// child: ListView.builder(
|
||||||
|
// shrinkWrap: true,
|
||||||
|
// itemCount: 30,
|
||||||
|
// itemBuilder: (BuildContext context, int index) {
|
||||||
|
// return ProviderDetailsCard(
|
||||||
|
// onCardTapped: () {
|
||||||
|
// if (context.read<AppointmentsVM>().providerCategories.isEmpty) {
|
||||||
|
// context.read<AppointmentsVM>().getProviderCategories();
|
||||||
|
// }
|
||||||
|
// navigateWithName(context, AppRoutes.bookAppointmenServicesView);
|
||||||
|
// },
|
||||||
|
// providerImageUrl: MyAssets.bnCar,
|
||||||
|
// providerLocation: " 3km",
|
||||||
|
// providerName: "Al Ahmed Maintenance",
|
||||||
|
// providerRatings: "4.9",
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
|
||||||
|
Expanded(
|
||||||
|
child: RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
context.read<ProvidersVM>().getAllNearBranches();
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Consumer<ProvidersVM>(
|
||||||
|
builder: (context, model, _) {
|
||||||
|
if (model.state == ViewState.busy) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
} else {
|
||||||
|
return model.branches?.data == null
|
||||||
|
? const Center(child: Text("No Branch Found"))
|
||||||
|
: model.branches!.data!.serviceProviderBranch!.isEmpty
|
||||||
|
? Center(child: Text(LocaleKeys.no_branch.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,
|
||||||
|
),
|
||||||
|
//TODO: needs to implement get user location after login
|
||||||
|
Geolocator.distanceBetween(
|
||||||
|
// AppState().currentLocation.latitude,
|
||||||
|
// AppState().currentLocation.latitude,
|
||||||
|
24.700590,
|
||||||
|
46.670110,
|
||||||
|
double.parse(model.branches!.data!.serviceProviderBranch![index].latitude ?? "0"),
|
||||||
|
double.parse(model.branches!.data!.serviceProviderBranch![index].longitude ?? "0"))
|
||||||
|
.toStringAsFixed(2)
|
||||||
|
.toText(
|
||||||
|
fontSize: 12,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
model.branches!.data!.serviceProviderBranch![index].branchName ?? "",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
LocaleKeys.tapToEdit.tr().toText(fontSize: 10, color: MyColors.grey70Color),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
12.width,
|
||||||
|
const Icon(
|
||||||
|
Icons.arrow_forward_rounded,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).toContainer().onPress(() async {
|
||||||
|
// await navigateWithName(context, AppRoutes.defineBranch, arguments: snapshot.data!.data![index]);
|
||||||
|
// setState(() {});
|
||||||
|
// model.branchs!.data!.serviceProviderBranch![index].countryID = model.branchs!.data!.countryID;
|
||||||
|
// model.branchs!.data!.serviceProviderBranch![index].countryName = model.branchs!.data!.countryName;
|
||||||
|
// navigateWithName(context, ProviderAppRoutes.branchDetail, arguments: model.branchs!.data!.serviceProviderBranch![index]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return 12.height;
|
||||||
|
},
|
||||||
|
itemCount: model.branches!.data!.serviceProviderBranch!.length,
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue