Reformatting

master_new_changes
Faiz Hashmi 1 year ago
parent 623d21fc80
commit 55363e4e9f

@ -562,7 +562,7 @@
"inviteFriends": "Invite Friends",
"more": "More",
"language": "Language",
"mySubscriptions": "My Subscription",
"mySubscription": "My Subscription",
"subscriptions": "Subscriptions",
"defineLicenses": "Define Licenses",
"logOut": "Log Out",

@ -1176,7 +1176,7 @@ static const Map<String,dynamic> en_US = {
"inviteFriends": "Invite Friends",
"more": "More",
"language": "Language",
"mySubscriptions": "My Subscription",
"mySubscription": "My Subscription",
"subscriptions": "Subscriptions",
"defineLicenses": "Define Licenses",
"logOut": "Log Out",

@ -2,62 +2,6 @@ import 'package:logger/logger.dart';
Logger logger = Logger(printer: PrettyPrinter(printEmojis: false, colors: true, printTime: false));
// class MyHttpOverrides extends HttpOverrides {
// @override
// HttpClient createHttpClient(SecurityContext? context) {
// return super.createHttpClient(context)..badCertificateCallback = (X509Certificate cert, String host, int port) => true;
// }
// }
// Future<void> main() async {
// WidgetsFlutterBinding.ensureInitialized();
//
// await EasyLocalization.ensureInitialized();
// // AppState().setPostParamsInitConfig();
// HttpOverrides.global = MyHttpOverrides();
//
// runApp(
// EasyLocalization(
// supportedLocales: const <Locale>[
// Locale('en', 'US'),
// Locale('ar', 'SA'),
// ],
// path: 'resources',
// // assetLoader: const CodegenLoader(),
// child: const MyApp(),
// ),
// );
// }
// class MyApp extends StatelessWidget {
// const MyApp({super.key});
//
// @override
// Widget build(BuildContext context) {
// return LayoutBuilder(builder: (context, constraints) {
// return Sizer(
// builder: (
// BuildContext context,
// Orientation orientation,
// DeviceType deviceType,
// ) {
// List<LocalizationsDelegate<dynamic>> delegates = context.localizationDelegates;
// return MaterialApp(
// // key: navigatorKey,
// navigatorKey: navigatorKey,
// theme: AppTheme.getTheme(
// isArabic: EasyLocalization.of(context)?.locale.languageCode == "ar",
// ),
// debugShowCheckedModeBanner: false,
// localizationsDelegates: delegates,
// supportedLocales: context.supportedLocales,
// locale: context.locale,
// );
// },
// );
// });
// }
// }
// todo terminal command to genertate translation files
// flutter pub run easy_localization:generate --source-dir ./assets/langs

@ -8,6 +8,7 @@ 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/generated/locale_keys.g.dart';
import 'package:mc_common_app/main.dart';
import 'package:mc_common_app/models/appointments_models/appointment_list_model.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/enums.dart';
@ -16,7 +17,9 @@ import 'package:mc_common_app/view_models/appointments_view_model.dart';
import 'package:mc_common_app/view_models/dashboard_view_model_customer.dart';
import 'package:mc_common_app/widgets/common_widgets/custom_add_button_widget.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
import 'package:mc_common_app/widgets/row_with_arrow.dart';
import 'package:provider/provider.dart';
import 'package:signalr_core/signalr_core.dart';
import 'package:sizer/sizer.dart';
class CommonAppointmentSliderWidget extends StatelessWidget {
@ -28,25 +31,25 @@ class CommonAppointmentSliderWidget extends StatelessWidget {
return CarouselSlider.builder(
options: CarouselOptions(
height: appType == AppType.provider ? 121 : 96,
// TODO LATER FIX THIS HEIGHT
viewportFraction: 1,
pageSnapping: true,
enlargeCenterPage: false,
enableInfiniteScroll: false,
),
itemCount: appointmentsVM.myUpComingAppointments.length,
itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
BuildAppointmentContainerForCustomer(
isForProvider: appType == AppType.provider,
isForCustomerHome: true,
appointmentListModel: appointmentsVM.myUpComingAppointments[itemIndex],
onTapped: () {
if (appType == AppType.provider) {
onAppointmentClick!(appointmentsVM.myUpComingAppointments[itemIndex]);
} else {
navigateWithName(context, AppRoutes.appointmentDetailView, arguments: appointmentsVM.myUpComingAppointments[itemIndex]);
}
},
),
itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) => AppointmentHomeTileWidget(
isForProvider: appType == AppType.provider,
isForCustomerHome: true,
appointmentListModel: appointmentsVM.myUpComingAppointments[itemIndex],
onTapped: () {
if (appType == AppType.provider) {
onAppointmentClick!(appointmentsVM.myUpComingAppointments[itemIndex]);
} else {
navigateWithName(context, AppRoutes.appointmentDetailView, arguments: appointmentsVM.myUpComingAppointments[itemIndex]);
}
},
),
);
}
@ -83,73 +86,15 @@ class CommonAppointmentSliderWidget extends StatelessWidget {
}
});
}
// if (myUpComingAppointments.isEmpty) {
// if (isNeedToShowEmptyMessage)
// return "No Upcoming Appointment Available".toText().paddingAll(21);
// return CustomAddButton(
// needsBorder: true,
// bgColor: MyColors.white,
// onTap: () => context.read<DashboardVmCustomer>().onNavbarTapped(0),
// text: "Add New Appointment",
// icon: Container(
// height: 24,
// width: 24,
// decoration: const BoxDecoration(
// shape: BoxShape.circle, color: MyColors.darkTextColor),
// child: const Icon(Icons.add, color: MyColors.white),
// ),
// ).padding(EdgeInsets.symmetric(vertical: 10, horizontal: 21));
// return Container(
// height: 86,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Container(
// height: 24,
// width: 24,
// decoration: BoxDecoration(
// shape: BoxShape.circle, color: MyColors.darkTextColor),
// child: Icon(
// Icons.add,
// color: MyColors.white,
// ),
// ),
// SizedBox(width: 10),
// "Add New Appointment".toText(
// fontSize: 15,
// isBold: true,
// color: MyColors.lightTextColor,
// ),
// ],
// ),
// ).onPress(() {}).toWhiteContainer(
// width: double.infinity,
// margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
// }
// return CarouselSlider.builder(
// options: CarouselOptions(
// height: 140,
// viewportFraction: 1.0,
// enlargeCenterPage: false,
// enableInfiniteScroll: false,
// ),
// itemCount: myUpComingAppointments.length,
// itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) => BuildAppointmentContainerForCustomer(
// isForHome: true,
// appointmentListModel: myUpComingAppointments[itemIndex],
// onTapped: isNeedToShowEmptyMessage ? onAppointmentClick! : () => navigateWithName(context, AppRoutes.appointmentDetailView, arguments: myUpComingAppointments[itemIndex]),
// ),
// );
}
class BuildAppointmentContainerForCustomer extends StatelessWidget {
class AppointmentHomeTileWidget extends StatelessWidget {
final bool isForProvider;
final bool isForCustomerHome;
final AppointmentListModel? appointmentListModel;
final Function()? onTapped;
const BuildAppointmentContainerForCustomer({Key? key, this.isForProvider = false, this.onTapped, required this.appointmentListModel, this.isForCustomerHome = false}) : super(key: key);
const AppointmentHomeTileWidget({Key? key, this.isForProvider = false, this.onTapped, required this.appointmentListModel, this.isForCustomerHome = false}) : super(key: key);
Widget showServices(String title, String icon, {bool isMoreText = false}) {
return Row(
@ -183,18 +128,11 @@ class BuildAppointmentContainerForCustomer extends StatelessWidget {
];
}
List<Widget> servicesList = List.generate(
2,
(index) => showServices(appointmentListModel.appointmentServicesList![index].providerServiceDescription, MyAssets.modificationsIcon),
);
List<Widget> servicesList = List.generate(2, (index) => showServices(appointmentListModel.appointmentServicesList![index].providerServiceDescription, MyAssets.modificationsIcon));
if (appointmentListModel.appointmentServicesList!.length > 1) {
servicesList.add(
showServices(
"+ ${appointmentListModel.appointmentServicesList!.length - 1} More",
"",
isMoreText: true,
),
showServices("+ ${appointmentListModel.appointmentServicesList!.length - 1} More", "", isMoreText: true),
);
}
return servicesList;
@ -206,55 +144,166 @@ class BuildAppointmentContainerForCustomer extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
isForProvider // need to be updated through backend
? SizedBox()
? const SizedBox()
: Image.asset(
MyAssets.bnCar,
width: isForCustomerHome ? 46 : 77,
height: isForCustomerHome ? 46 : 113,
fit: BoxFit.cover,
).toCircle(
borderRadius: isForCustomerHome ? 100 : 0,
),
MyAssets.bnCar,
width: isForCustomerHome ? 46 : 70,
height: isForCustomerHome ? 46 : 90,
fit: BoxFit.cover,
).toCircle(
borderRadius: isForCustomerHome ? 100 : 0,
),
8.width,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
AppState().currentAppType == AppType.provider ? (AppState().currentAppType == AppType.provider ? appointmentListModel!.branchName ?? "" : appointmentListModel!.branchName ?? "")
.toText(color: MyColors.greyColor, fontSize: 12, letterSpacing: 0, height: 19 / 12) : SizedBox(),
(AppState().currentAppType == AppType.provider ? appointmentListModel!.providerName ?? "" : appointmentListModel!.branchName ?? "")
.toText(color: MyColors.black, fontSize: 16, letterSpacing: -0.64, height: 24 / 16)
, Row(
AppState().currentAppType == AppType.provider
? (appointmentListModel!.branchName ?? "").toText(
color: MyColors.greyColor,
fontSize: 12,
letterSpacing: 0,
height: 19 / 12,
)
: const SizedBox(),
(AppState().currentAppType == AppType.provider ? appointmentListModel!.providerName ?? "" : appointmentListModel!.branchName ?? "").toText(color: MyColors.black, fontSize: 16, letterSpacing: -0.64, height: 24 / 16),
Row(
children: [
!isForProvider ? MyAssets.miniClock.buildSvg(height: 12) : SizedBox(),
!isForProvider ? MyAssets.miniClock.buildSvg(height: 12) : const SizedBox(),
2.width,
"${isForProvider ? "Appt. on:" : ""} ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}"
.toText(color: MyColors.lightTextColor, fontSize: 12, letterSpacing: -0.48, height: 19 / 12),
],
),
8.height,
!isForProvider
!isForCustomerHome
? Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Column(
children: buildServicesFromAppointment(appointmentListModel: appointmentListModel!),
),
),
//ic_arrow_right.svg
SvgPicture.asset(
MyAssets.arrowRight,
height: 9.69,
width: 13,
),
],
)
: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
LocaleKeys.appointment_details.tr().toText(
color: MyColors.primaryColor,
isUnderLine: true,
fontSize: 14,
letterSpacing: -0.56,
),
SvgPicture.asset(
MyAssets.arrowRight,
height: 9.69,
width: 13,
),
],
)
],
),
),
],
).onPress(onTapped!).toWhiteContainer(
width: double.infinity,
allPading: 12,
);
}
}
class AppointmentFragmentTileWidget extends StatelessWidget {
final AppointmentListModel? appointmentListModel;
final Function()? onTapped;
const AppointmentFragmentTileWidget({Key? key, this.onTapped, required this.appointmentListModel}) : super(key: key);
Widget showServices(String title, String icon, {bool isMoreText = false}) {
return Row(
children: [
if (icon != "") ...[
SvgPicture.asset(icon),
8.width,
],
Flexible(
child: title.toText(
fontSize: 12,
letterSpacing: -0.48,
color: isMoreText ? MyColors.primaryColor : MyColors.black,
),
),
],
);
}
List<Widget> buildServicesFromAppointment({required AppointmentListModel appointmentListModel}) {
if (appointmentListModel.appointmentServicesList == null || appointmentListModel.appointmentServicesList!.isEmpty) {
return [const SizedBox()];
}
if (appointmentListModel.appointmentServicesList!.length == 1) {
return [
showServices(
appointmentListModel.appointmentServicesList![0].providerServiceDescription,
MyAssets.modificationsIcon,
)
];
}
List<Widget> servicesList = List.generate(1, (index) => showServices(appointmentListModel.appointmentServicesList![index].providerServiceDescription, MyAssets.modificationsIcon));
if (appointmentListModel.appointmentServicesList!.length > 1) {
servicesList.add(
showServices("+ ${appointmentListModel.appointmentServicesList!.length - 1} More", "", isMoreText: true),
);
}
return servicesList;
}
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Image.asset(
MyAssets.bnCar,
width: 72,
height: 95,
fit: BoxFit.cover,
),
8.width,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
(appointmentListModel!.providerName ?? "").toText(color: MyColors.darkTextColor, fontSize: 16, letterSpacing: -0.64, height: 24 / 16),
Row(
children: [
LocaleKeys.appointment_details.tr().toText(
color: MyColors.primaryColor,
isUnderLine: true,
fontSize: 14,
letterSpacing: -0.56,
),
SvgPicture.asset(
MyAssets.arrowRight,
height: 9.69,
width: 13,
),
('Branch:').toText(color: MyColors.greyColor, fontSize: 12, letterSpacing: -0.48, height: 18 / 12),
2.width,
(appointmentListModel!.branchName ?? "").toText(color: MyColors.darkTextColor, fontSize: 12, letterSpacing: -0.48, height: 18 / 12),
],
)
: Row(
),
Row(
children: [
MyAssets.miniClock.buildSvg(height: 12),
2.width,
" ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}".toText(color: MyColors.lightTextColor, fontSize: 12, letterSpacing: -0.48, height: 19 / 12),
],
),
5.height,
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
@ -263,20 +312,15 @@ class BuildAppointmentContainerForCustomer extends StatelessWidget {
),
),
//ic_arrow_right.svg
SvgPicture.asset(
MyAssets.arrowRight,
height: 9.69,
width: 13,
),
],
),
).withArrow(isArrowEnabled: true)
],
),
),
],
).onPress(onTapped!).toWhiteContainer(
width: double.infinity,
allPading: 12,
);
width: double.infinity,
allPading: 12,
);
}
}

@ -0,0 +1,69 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class AppMap extends StatefulWidget {
final CameraPositionCallback onCameraMove;
Map initialCamera;
late AppMapState _state;
final Function onMapCreated;
AppMap(this.initialCamera,
{required this.onCameraMove, required this.onMapCreated});
@override
State<StatefulWidget> createState() => _state = AppMapState();
moveTo({required CameraPosition cameraPostion}) {
_state.googleMapController
.animateCamera(CameraUpdate.newCameraPosition(cameraPostion));
}
}
class AppMapState extends State<AppMap> {
bool isHuawei = false;
Completer<GoogleMapController> _googleMapControllerComp = Completer();
late GoogleMapController googleMapController;
checkIsHuawei() async {
setState(() {});
}
@override
void initState() {}
@override
void dispose() {
super.dispose();
googleMapController.dispose();
}
@override
Widget build(BuildContext context) {
if (isHuawei == null) return CircularProgressIndicator();
return googleMap();
}
Widget googleMap() {
return GoogleMap(
mapType: MapType.normal,
zoomControlsEnabled: true,
myLocationButtonEnabled: true,
myLocationEnabled: true,
initialCameraPosition: CameraPosition.fromMap(widget.initialCamera) ??
const CameraPosition(
target: LatLng(-26.1711459, 27.9002758), zoom: 2.0),
onCameraMove: widget.onCameraMove,
onMapCreated: (GoogleMapController controller) {
googleMapController = controller;
_googleMapControllerComp.complete(controller);
widget.onMapCreated();
},
);
}
}

@ -0,0 +1,180 @@
import 'dart:async';
import 'package:easy_localization/src/public_ext.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:mc_common_app/generated/locale_keys.g.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:permission_handler/permission_handler.dart';
import 'map_selection_widget.dart';
import 'package:geocoding/geocoding.dart';
class PickLocationPage extends StatefulWidget {
Function(double, double, String) onPickAddress;
PickLocationPage({required this.onPickAddress});
@override
State<PickLocationPage> createState() => _PickLocationPageState();
}
class _PickLocationPageState extends State<PickLocationPage> {
double latitude = 0;
double longitude = 0;
final Set<Marker> markers = new Set();
late AppMap appMap;
static CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
late LatLng currentPostion;
Completer<GoogleMapController> mapController = Completer();
final ValueNotifier<String> _counter = ValueNotifier<String>("");
@override
void initState() {
appMap = AppMap(
_kGooglePlex.toMap() as Map,
onCameraMove: (camera) {
_updatePosition(camera);
},
onMapCreated: () {
// goToCurrentLocation();
_getUserLocation();
setState(() {});
},
);
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CustomAppBar(
title: LocaleKeys.pickLocation.tr(),
isRemoveBackButton: false,
),
body: Column(
children: [
Expanded(
child: Stack(
children: [
if (appMap != null) appMap,
ValueListenableBuilder<String>(
builder: (BuildContext context, String value, Widget? child) {
// This builder will only get called when the _counter
// is updated.
return value.isNotEmpty
? Container(
width: double.infinity,
margin: EdgeInsets.all(12),
child: Card(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Text(value ?? ""),
)),
)
: Container();
},
valueListenable: _counter,
),
const Align(
alignment: Alignment.center,
child: Icon(
Icons.place,
color: Colors.red,
size: 50,
),
),
],
),
),
Container(
width: double.infinity,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: ShowFillButton(
title: LocaleKeys.pickAddress.tr(),
onPressed: () {
widget.onPickAddress(latitude, longitude, _counter.value);
pop(context);
},
),
),
),
],
),
);
}
Future<void> _updatePosition(CameraPosition _position) async {
latitude = _position.target.latitude;
longitude = _position.target.longitude;
print(latitude);
print(latitude);
updateAddress(latitude, longitude);
}
void _getUserLocation() async {
if (await Permission.location.request().isGranted) {
var position = await GeolocatorPlatform.instance.getCurrentPosition();
currentPostion = LatLng(position.latitude, position.longitude);
latitude = position.latitude;
longitude = position.longitude;
setMap();
updateAddress(latitude, longitude);
} else {
requestPermissions().then(
(value) async {
if (value[Permission.location]!.isGranted) {
var position = await GeolocatorPlatform.instance.getCurrentPosition();
currentPostion = LatLng(position.latitude, position.longitude);
latitude = position.latitude;
longitude = position.longitude;
setMap();
updateAddress(latitude, longitude);
}
},
);
}
}
updateAddress(double latitude, double longitude) async {
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
_counter.value = '${placemarks.first.street}, ${placemarks.first.subLocality}, ${placemarks.first.locality}, ${placemarks.first.postalCode}, ${placemarks.first.country}';
}
setMap() {
setState(() {
_kGooglePlex = CameraPosition(
target: currentPostion,
zoom: 14.4746,
);
appMap.moveTo(cameraPostion: _kGooglePlex);
});
}
Future<String> getCurrentAddress() async {
// List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude);
// return placemarks.first.name ?? "";
return "";
}
}
Future<Map<Permission, PermissionStatus>> requestPermissions() async {
var permissionResults = [Permission.location].request();
return permissionResults;
}

@ -1,6 +1,7 @@
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/theme/colors.dart';
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
@ -32,10 +33,7 @@ class _RoleTypeTabState extends State<RoleTypeTab> {
});
},
child: Container(
width: widget.width ?? (MediaQuery
.of(context)
.size
.width / 2) - 30,
width: widget.width ?? (MediaQuery.of(context).size.width / 2) - 30,
height: 50,
decoration: BoxDecoration(
color: widget.selectedIndex == index ? MyColors.darkPrimaryColor : Colors.grey[200],
@ -45,24 +43,14 @@ class _RoleTypeTabState extends State<RoleTypeTab> {
),
),
child: Center(
child: Text(
(widget.dropList[index].value) == "ServiceProvider_Dealership" || (widget.dropList[index].value) == "ServiceProvider_Individual"
? "${widget.dropList[index].value
.split("_")
.first}\n${widget.dropList[index].value
.split("_")
.last}"
: widget.dropList[index].value,
child: ((widget.dropList[index].value) == "ServiceProvider_Dealership" || (widget.dropList[index].value) == "ServiceProvider_Individual"
? "${widget.dropList[index].value.split("_").first}\n${widget.dropList[index].value.split("_").last}"
: widget.dropList[index].value)
.toText(
textAlign: TextAlign.center,
style: TextStyle(
color: widget.selectedIndex == index ? MyColors.white : MyColors.darkTextColor,
fontSize: 15,
fontFamily: 'Poppins',
height: 23 / 15,
fontWeight: MyFonts.Medium
),
height: 23 / 15,
fontSize: 15,
color: widget.selectedIndex == index ? MyColors.white : MyColors.darkTextColor,
),
),
),

Loading…
Cancel
Save