BASE: Update Icons & Name Of The App.
This commit is contained in:
@@ -10,7 +10,7 @@ import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
|
||||
class AddressListScreen extends StatelessWidget {
|
||||
const AddressListScreen({super.key});
|
||||
@@ -39,50 +39,120 @@ class AddressListScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("My Addresses".tr(), style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)),
|
||||
Text(
|
||||
"My Addresses".tr(),
|
||||
style: AppThemeData.boldTextStyle(
|
||||
fontSize: 24,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData.greyDark900
|
||||
: AppThemeData.grey900,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text("Allows users to view, manage, add, or edit delivery addresses.".tr(), style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey600)),
|
||||
Text(
|
||||
"Allows users to view, manage, add, or edit delivery addresses."
|
||||
.tr(),
|
||||
style: AppThemeData.mediumTextStyle(
|
||||
fontSize: 14,
|
||||
color: AppThemeData.grey600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Expanded(
|
||||
child:
|
||||
controller.shippingAddressList.isEmpty
|
||||
? Constant.showEmptyView(message: "Address not found".tr())
|
||||
? Constant.showEmptyView(
|
||||
message: "Address not found".tr(),
|
||||
)
|
||||
: ListView.separated(
|
||||
itemCount: controller.shippingAddressList.length,
|
||||
itemCount:
|
||||
controller.shippingAddressList.length,
|
||||
itemBuilder: (context, index) {
|
||||
ShippingAddress address = controller.shippingAddressList[index];
|
||||
ShippingAddress address =
|
||||
controller.shippingAddressList[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Get.back(result: address);
|
||||
},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(color: isDark ? AppThemeData.greyDark100 : AppThemeData.grey100, borderRadius: BorderRadius.circular(8)),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData
|
||||
.greyDark100
|
||||
: AppThemeData
|
||||
.grey100,
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
8,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Text(
|
||||
address.addressAs.toString(),
|
||||
style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600),
|
||||
address.addressAs
|
||||
.toString(),
|
||||
style: AppThemeData.semiBoldTextStyle(
|
||||
fontSize: 12,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData
|
||||
.greyDark600
|
||||
: AppThemeData
|
||||
.grey600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
address.isDefault == true
|
||||
? Container(
|
||||
decoration: BoxDecoration(color: isDark ? AppThemeData.success100 : AppThemeData.success100, borderRadius: BorderRadius.circular(8)),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData
|
||||
.success100
|
||||
: AppThemeData
|
||||
.success100,
|
||||
borderRadius:
|
||||
BorderRadius.circular(
|
||||
8,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(
|
||||
horizontal:
|
||||
10,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Text(
|
||||
"Default".tr(),
|
||||
style: AppThemeData.semiBoldTextStyle(fontSize: 12, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600),
|
||||
style: AppThemeData.semiBoldTextStyle(
|
||||
fontSize: 12,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData
|
||||
.greyDark600
|
||||
: AppThemeData
|
||||
.grey600,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -91,35 +161,72 @@ class AddressListScreen extends StatelessWidget {
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
Text(
|
||||
address.getFullAddress().toString(),
|
||||
style: AppThemeData.mediumTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark800 : AppThemeData.grey800),
|
||||
address
|
||||
.getFullAddress()
|
||||
.toString(),
|
||||
style:
|
||||
AppThemeData.mediumTextStyle(
|
||||
fontSize: 16,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData
|
||||
.greyDark800
|
||||
: AppThemeData
|
||||
.grey800,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
await controller.deleteAddress(index);
|
||||
await controller.deleteAddress(
|
||||
index,
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset("assets/icons/ic_delete_address.svg"),
|
||||
child: SvgPicture.asset(
|
||||
"assets/icons/ic_delete_address.svg",
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.to(EnterManuallyLocationScreen(), arguments: {"address": address, "mode": "Edit"})!.then((value) {
|
||||
Get.to(
|
||||
EnterManuallyLocationScreen(),
|
||||
arguments: {
|
||||
"address": address,
|
||||
"mode": "Edit",
|
||||
},
|
||||
)!.then((value) {
|
||||
if (value == true) {
|
||||
controller.getUser();
|
||||
}
|
||||
});
|
||||
},
|
||||
child: SvgPicture.asset("assets/icons/ic_edit_address.svg"),
|
||||
child: SvgPicture.asset(
|
||||
"assets/icons/ic_edit_address.svg",
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Padding(padding: const EdgeInsets.symmetric(vertical: 20), child: Divider(color: isDark ? AppThemeData.greyDark200 : AppThemeData.grey200, height: 1));
|
||||
separatorBuilder: (
|
||||
BuildContext context,
|
||||
int index,
|
||||
) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 20,
|
||||
),
|
||||
child: Divider(
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData.greyDark200
|
||||
: AppThemeData.grey200,
|
||||
height: 1,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -127,9 +234,14 @@ class AddressListScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 30, left: 16, right: 16, top: 20),
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 30,
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 20,
|
||||
),
|
||||
child: RoundedButtonFill(
|
||||
borderRadius: 10.r,
|
||||
borderRadius: 10.r,
|
||||
title: "Add New Address",
|
||||
onPress: () {
|
||||
Get.to(EnterManuallyLocationScreen())!.then((value) {
|
||||
@@ -140,7 +252,15 @@ class AddressListScreen extends StatelessWidget {
|
||||
},
|
||||
isRight: false,
|
||||
isCenter: true,
|
||||
icon: SvgPicture.asset(AppAssets.icPlus, width: 20, height: 18, color: isDark ? AppThemeData.greyDark900 : AppThemeData.greyDark900),
|
||||
icon: SvgPicture.asset(
|
||||
AppAssets.icPlus,
|
||||
width: 20,
|
||||
height: 18,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData.greyDark900
|
||||
: AppThemeData.greyDark900,
|
||||
),
|
||||
color: isDark ? AppThemeData.primary300 : AppThemeData.primary300,
|
||||
textColor: isDark ? AppThemeData.grey50 : AppThemeData.grey50,
|
||||
),
|
||||
|
||||
@@ -9,8 +9,7 @@ import 'package:customer/widget/place_picker/selected_location_model.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import '../../controllers/enter_manually_location_controller.dart';
|
||||
import '../../controllers/theme_controller.dart';
|
||||
import '../../themes/app_them_data.dart';
|
||||
@@ -40,23 +39,50 @@ class EnterManuallyLocationScreen extends StatelessWidget {
|
||||
controller.isLoading.value
|
||||
? Constant.loader()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
vertical: 10,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
controller.mode == "Edit" ? "Edit Address".tr() : "Add a New Address".tr(),
|
||||
style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900),
|
||||
controller.mode == "Edit"
|
||||
? "Edit Address".tr()
|
||||
: "Add a New Address".tr(),
|
||||
style: AppThemeData.boldTextStyle(
|
||||
fontSize: 24,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData.greyDark900
|
||||
: AppThemeData.grey900,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text("Enter your location details so we can deliver your orders quickly and accurately.".tr(), style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey600)),
|
||||
Text(
|
||||
"Enter your location details so we can deliver your orders quickly and accurately."
|
||||
.tr(),
|
||||
style: AppThemeData.mediumTextStyle(
|
||||
fontSize: 14,
|
||||
color: AppThemeData.grey600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(child: Text("Set as Default Address".tr(), style: AppThemeData.mediumTextStyle(fontSize: 14, color: AppThemeData.grey600))),
|
||||
Expanded(
|
||||
child: Text(
|
||||
"Set as Default Address".tr(),
|
||||
style: AppThemeData.mediumTextStyle(
|
||||
fontSize: 14,
|
||||
color: AppThemeData.grey600,
|
||||
),
|
||||
),
|
||||
),
|
||||
Transform.scale(
|
||||
scale: 0.7, // Decrease the size (try 0.5, 0.6, etc.)
|
||||
scale:
|
||||
0.7, // Decrease the size (try 0.5, 0.6, etc.)
|
||||
child: Switch(
|
||||
value: controller.isDefault.value,
|
||||
onChanged: (value) {
|
||||
@@ -74,23 +100,53 @@ class EnterManuallyLocationScreen extends StatelessWidget {
|
||||
context: context,
|
||||
onTap: () async {
|
||||
if (Constant.selectedMapType == 'osm') {
|
||||
final result = await Get.to(() => MapPickerPage());
|
||||
final result = await Get.to(
|
||||
() => MapPickerPage(),
|
||||
);
|
||||
if (result != null) {
|
||||
final firstPlace = result;
|
||||
final lat = firstPlace.coordinates.latitude;
|
||||
final lng = firstPlace.coordinates.longitude;
|
||||
final lat =
|
||||
firstPlace.coordinates.latitude;
|
||||
final lng =
|
||||
firstPlace.coordinates.longitude;
|
||||
final address = firstPlace.address;
|
||||
|
||||
controller.localityEditingController.value.text = address.toString();
|
||||
controller.location.value = UserLocation(latitude: lat, longitude: lng);
|
||||
controller
|
||||
.localityEditingController
|
||||
.value
|
||||
.text = address.toString();
|
||||
controller.location.value = UserLocation(
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Get.to(LocationPickerScreen())!.then((value) async {
|
||||
Get.to(LocationPickerScreen())!.then((
|
||||
value,
|
||||
) async {
|
||||
if (value != null) {
|
||||
SelectedLocationModel selectedLocationModel = value;
|
||||
SelectedLocationModel
|
||||
selectedLocationModel = value;
|
||||
|
||||
controller.localityEditingController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel);
|
||||
controller.location.value = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude);
|
||||
controller
|
||||
.localityEditingController
|
||||
.value
|
||||
.text = Utils.formatAddress(
|
||||
selectedLocation:
|
||||
selectedLocationModel,
|
||||
);
|
||||
controller
|
||||
.location
|
||||
.value = UserLocation(
|
||||
latitude:
|
||||
selectedLocationModel
|
||||
.latLng!
|
||||
.latitude,
|
||||
longitude:
|
||||
selectedLocationModel
|
||||
.latLng!
|
||||
.longitude,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -109,23 +165,55 @@ class EnterManuallyLocationScreen extends StatelessWidget {
|
||||
context: context,
|
||||
onTap: () async {
|
||||
if (Constant.selectedMapType == 'osm') {
|
||||
final result = await Get.to(() => MapPickerPage());
|
||||
final result = await Get.to(
|
||||
() => MapPickerPage(),
|
||||
);
|
||||
if (result != null) {
|
||||
final firstPlace = result;
|
||||
final lat = firstPlace.coordinates.latitude;
|
||||
final lng = firstPlace.coordinates.longitude;
|
||||
final lat =
|
||||
firstPlace.coordinates.latitude;
|
||||
final lng =
|
||||
firstPlace.coordinates.longitude;
|
||||
final address = firstPlace.address;
|
||||
|
||||
controller.localityEditingController.value.text = address.toString();
|
||||
controller.location.value = UserLocation(latitude: lat, longitude: lng);
|
||||
controller
|
||||
.localityEditingController
|
||||
.value
|
||||
.text = address.toString();
|
||||
controller
|
||||
.location
|
||||
.value = UserLocation(
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
Get.to(LocationPickerScreen())!.then((value) async {
|
||||
Get.to(LocationPickerScreen())!.then((
|
||||
value,
|
||||
) async {
|
||||
if (value != null) {
|
||||
SelectedLocationModel selectedLocationModel = value;
|
||||
SelectedLocationModel
|
||||
selectedLocationModel = value;
|
||||
|
||||
controller.localityEditingController.value.text = Utils.formatAddress(selectedLocation: selectedLocationModel);
|
||||
controller.location.value = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude);
|
||||
controller
|
||||
.localityEditingController
|
||||
.value
|
||||
.text = Utils.formatAddress(
|
||||
selectedLocation:
|
||||
selectedLocationModel,
|
||||
);
|
||||
controller
|
||||
.location
|
||||
.value = UserLocation(
|
||||
latitude:
|
||||
selectedLocationModel
|
||||
.latLng!
|
||||
.latitude,
|
||||
longitude:
|
||||
selectedLocationModel
|
||||
.latLng!
|
||||
.longitude,
|
||||
);
|
||||
Get.back();
|
||||
}
|
||||
});
|
||||
@@ -133,20 +221,50 @@ class EnterManuallyLocationScreen extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Padding(padding: const EdgeInsets.only(right: 10), child: Icon(Icons.gps_fixed, size: 24, color: AppThemeData.ecommerce300)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 10),
|
||||
child: Icon(
|
||||
Icons.gps_fixed,
|
||||
size: 24,
|
||||
color: AppThemeData.ecommerce300,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
TextFieldWidget(title: "Flat/House/Floor/Building*".tr(), hintText: "Enter address details".tr(), controller: controller.houseBuildingTextEditingController.value),
|
||||
TextFieldWidget(
|
||||
title: "Flat/House/Floor/Building*".tr(),
|
||||
hintText: "Enter address details".tr(),
|
||||
controller:
|
||||
controller
|
||||
.houseBuildingTextEditingController
|
||||
.value,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
TextFieldWidget(title: "Area/Sector/Locality*".tr(), hintText: "Enter area/locality".tr(), controller: controller.localityEditingController.value),
|
||||
TextFieldWidget(
|
||||
title: "Area/Sector/Locality*".tr(),
|
||||
hintText: "Enter area/locality".tr(),
|
||||
controller:
|
||||
controller.localityEditingController.value,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
TextFieldWidget(title: "Nearby Landmark".tr(), hintText: "Add a landmark".tr(), controller: controller.landmarkEditingController.value),
|
||||
TextFieldWidget(
|
||||
title: "Nearby Landmark".tr(),
|
||||
hintText: "Add a landmark".tr(),
|
||||
controller:
|
||||
controller.landmarkEditingController.value,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Container(height: 1, color: AppThemeData.grey200),
|
||||
const SizedBox(height: 25),
|
||||
Text("Save Address As".tr(), style: AppThemeData.boldTextStyle(fontSize: 14, color: AppThemeData.grey900)),
|
||||
Text(
|
||||
"Save Address As".tr(),
|
||||
style: AppThemeData.boldTextStyle(
|
||||
fontSize: 14,
|
||||
color: AppThemeData.grey900,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
@@ -155,17 +273,37 @@ class EnterManuallyLocationScreen extends StatelessWidget {
|
||||
.map(
|
||||
(item) => GestureDetector(
|
||||
onTap: () {
|
||||
controller.selectedSaveAs.value = item;
|
||||
controller.selectedSaveAs.value =
|
||||
item;
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: controller.selectedSaveAs.value == item ? AppThemeData.primary300 : AppThemeData.grey100,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color:
|
||||
controller
|
||||
.selectedSaveAs
|
||||
.value ==
|
||||
item
|
||||
? AppThemeData.primary300
|
||||
: AppThemeData.grey100,
|
||||
borderRadius: BorderRadius.circular(
|
||||
10,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
vertical: 10,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||
child: Text(
|
||||
controller.getLocalizedSaveAs(item),
|
||||
style: AppThemeData.mediumTextStyle(color: controller.selectedSaveAs.value == item ? AppThemeData.grey50 : AppThemeData.grey600),
|
||||
style: AppThemeData.mediumTextStyle(
|
||||
color:
|
||||
controller
|
||||
.selectedSaveAs
|
||||
.value ==
|
||||
item
|
||||
? AppThemeData.grey50
|
||||
: AppThemeData.grey600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
@@ -175,55 +313,111 @@ class EnterManuallyLocationScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
RoundedButtonFill(
|
||||
borderRadius: 10.r,
|
||||
borderRadius: 10.r,
|
||||
title: "Save Address".tr(),
|
||||
color: AppThemeData.primary300,
|
||||
textColor: AppThemeData.grey50,
|
||||
onPress: () async {
|
||||
if (controller.location.value.latitude == null || controller.location.value.longitude == null) {
|
||||
ShowToastDialog.showToast("Please select Location".tr());
|
||||
} else if (controller.houseBuildingTextEditingController.value.text.isEmpty) {
|
||||
ShowToastDialog.showToast("Please Enter Flat / House / Floor / Building".tr());
|
||||
} else if (controller.localityEditingController.value.text.isEmpty) {
|
||||
ShowToastDialog.showToast("Please Enter Area / Sector / Locality".tr());
|
||||
if (controller.location.value.latitude == null ||
|
||||
controller.location.value.longitude == null) {
|
||||
ShowToastDialog.showToast(
|
||||
"Please select Location".tr(),
|
||||
);
|
||||
} else if (controller
|
||||
.houseBuildingTextEditingController
|
||||
.value
|
||||
.text
|
||||
.isEmpty) {
|
||||
ShowToastDialog.showToast(
|
||||
"Please Enter Flat / House / Floor / Building"
|
||||
.tr(),
|
||||
);
|
||||
} else if (controller
|
||||
.localityEditingController
|
||||
.value
|
||||
.text
|
||||
.isEmpty) {
|
||||
ShowToastDialog.showToast(
|
||||
"Please Enter Area / Sector / Locality".tr(),
|
||||
);
|
||||
} else {
|
||||
ShowToastDialog.showLoader("Please wait...".tr());
|
||||
ShowToastDialog.showLoader(
|
||||
"Please wait...".tr(),
|
||||
);
|
||||
|
||||
//Common values
|
||||
controller.shippingModel.value.location = controller.location.value;
|
||||
controller.shippingModel.value.addressAs = controller.selectedSaveAs.value;
|
||||
controller.shippingModel.value.address = controller.houseBuildingTextEditingController.value.text;
|
||||
controller.shippingModel.value.locality = controller.localityEditingController.value.text;
|
||||
controller.shippingModel.value.landmark = controller.landmarkEditingController.value.text;
|
||||
controller.shippingModel.value.location =
|
||||
controller.location.value;
|
||||
controller.shippingModel.value.addressAs =
|
||||
controller.selectedSaveAs.value;
|
||||
controller.shippingModel.value.address =
|
||||
controller
|
||||
.houseBuildingTextEditingController
|
||||
.value
|
||||
.text;
|
||||
controller.shippingModel.value.locality =
|
||||
controller
|
||||
.localityEditingController
|
||||
.value
|
||||
.text;
|
||||
controller.shippingModel.value.landmark =
|
||||
controller
|
||||
.landmarkEditingController
|
||||
.value
|
||||
.text;
|
||||
|
||||
if (controller.mode.value == "Edit") {
|
||||
//Edit Mode
|
||||
controller.shippingAddressList.value =
|
||||
controller.shippingAddressList.map((address) {
|
||||
if (address.id == controller.shippingModel.value.id) {
|
||||
return controller.shippingModel.value; // replace existing one
|
||||
controller.shippingAddressList.map((
|
||||
address,
|
||||
) {
|
||||
if (address.id ==
|
||||
controller.shippingModel.value.id) {
|
||||
return controller
|
||||
.shippingModel
|
||||
.value; // replace existing one
|
||||
}
|
||||
return address;
|
||||
}).toList();
|
||||
Constant.selectedLocation = controller.shippingModel.value;
|
||||
Constant.selectedLocation =
|
||||
controller.shippingModel.value;
|
||||
} else {
|
||||
//Add Mode
|
||||
controller.shippingModel.value.id = Constant.getUuid();
|
||||
controller.shippingModel.value.isDefault = controller.shippingAddressList.isEmpty ? true : false;
|
||||
controller.shippingAddressList.add(controller.shippingModel.value);
|
||||
controller.shippingModel.value.id =
|
||||
Constant.getUuid();
|
||||
controller.shippingModel.value.isDefault =
|
||||
controller.shippingAddressList.isEmpty
|
||||
? true
|
||||
: false;
|
||||
controller.shippingAddressList.add(
|
||||
controller.shippingModel.value,
|
||||
);
|
||||
}
|
||||
|
||||
//Handle default address switch
|
||||
if (controller.isDefault.value) {
|
||||
controller.shippingAddressList.value =
|
||||
controller.shippingAddressList.map((address) {
|
||||
address.isDefault = address.id == controller.shippingModel.value.id ? true : false;
|
||||
controller.shippingAddressList.map((
|
||||
address,
|
||||
) {
|
||||
address.isDefault =
|
||||
address.id ==
|
||||
controller
|
||||
.shippingModel
|
||||
.value
|
||||
.id
|
||||
? true
|
||||
: false;
|
||||
return address;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
controller.userModel.value.shippingAddress = controller.shippingAddressList;
|
||||
await FireStoreUtils.updateUser(controller.userModel.value);
|
||||
controller.userModel.value.shippingAddress =
|
||||
controller.shippingAddressList;
|
||||
await FireStoreUtils.updateUser(
|
||||
controller.userModel.value,
|
||||
);
|
||||
|
||||
ShowToastDialog.closeLoader();
|
||||
Get.back(result: true);
|
||||
|
||||
@@ -14,8 +14,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:get/get.dart' hide Trans;
|
||||
import '../../constant/assets.dart';
|
||||
import '../../utils/utils.dart';
|
||||
|
||||
@@ -41,7 +40,13 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25),
|
||||
child: Text(
|
||||
"Enable Location for a Personalized Experience".tr(),
|
||||
style: AppThemeData.boldTextStyle(fontSize: 24, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900),
|
||||
style: AppThemeData.boldTextStyle(
|
||||
fontSize: 24,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData.greyDark900
|
||||
: AppThemeData.grey900,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
@@ -49,14 +54,21 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||
child: Text(
|
||||
"Allow location access to discover beauty stores and services near you.".tr(),
|
||||
style: AppThemeData.mediumTextStyle(fontSize: 14, color: isDark ? AppThemeData.greyDark600 : AppThemeData.grey600),
|
||||
"Allow location access to discover beauty stores and services near you."
|
||||
.tr(),
|
||||
style: AppThemeData.mediumTextStyle(
|
||||
fontSize: 14,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData.greyDark600
|
||||
: AppThemeData.grey600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
RoundedButtonFill(
|
||||
borderRadius: 10.r,
|
||||
borderRadius: 10.r,
|
||||
title: "Use current location".tr(),
|
||||
onPress: () async {
|
||||
Constant.checkPermission(
|
||||
@@ -66,34 +78,51 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
ShippingAddress addressModel = ShippingAddress();
|
||||
try {
|
||||
await Geolocator.requestPermission();
|
||||
Position newLocalData = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
await placemarkFromCoordinates(newLocalData.latitude, newLocalData.longitude).then((valuePlaceMaker) {
|
||||
Position newLocalData =
|
||||
await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.high,
|
||||
);
|
||||
await placemarkFromCoordinates(
|
||||
newLocalData.latitude,
|
||||
newLocalData.longitude,
|
||||
).then((valuePlaceMaker) {
|
||||
Placemark placeMark = valuePlaceMaker[0];
|
||||
addressModel.addressAs = "Home";
|
||||
addressModel.location = UserLocation(latitude: newLocalData.latitude, longitude: newLocalData.longitude);
|
||||
addressModel.location = UserLocation(
|
||||
latitude: newLocalData.latitude,
|
||||
longitude: newLocalData.longitude,
|
||||
);
|
||||
String currentLocation =
|
||||
"${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}";
|
||||
addressModel.locality = currentLocation;
|
||||
});
|
||||
|
||||
Constant.selectedLocation = addressModel;
|
||||
Constant.currentLocation = await Utils.getCurrentLocation();
|
||||
Constant.currentLocation =
|
||||
await Utils.getCurrentLocation();
|
||||
|
||||
ShowToastDialog.closeLoader();
|
||||
|
||||
Get.offAll(const ServiceListScreen());
|
||||
} catch (e) {
|
||||
await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) {
|
||||
await placemarkFromCoordinates(
|
||||
19.228825,
|
||||
72.854118,
|
||||
).then((valuePlaceMaker) {
|
||||
Placemark placeMark = valuePlaceMaker[0];
|
||||
addressModel.addressAs = "Home";
|
||||
addressModel.location = UserLocation(latitude: 19.228825, longitude: 72.854118);
|
||||
addressModel.location = UserLocation(
|
||||
latitude: 19.228825,
|
||||
longitude: 72.854118,
|
||||
);
|
||||
String currentLocation =
|
||||
"${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}";
|
||||
addressModel.locality = currentLocation;
|
||||
});
|
||||
|
||||
Constant.selectedLocation = addressModel;
|
||||
Constant.currentLocation = await Utils.getCurrentLocation();
|
||||
Constant.currentLocation =
|
||||
await Utils.getCurrentLocation();
|
||||
|
||||
ShowToastDialog.closeLoader();
|
||||
|
||||
@@ -107,7 +136,7 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
RoundedButtonFill(
|
||||
borderRadius: 10.r,
|
||||
borderRadius: 10.r,
|
||||
title: "Set from map".tr(),
|
||||
onPress: () async {
|
||||
Constant.checkPermission(
|
||||
@@ -117,7 +146,9 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
ShippingAddress addressModel = ShippingAddress();
|
||||
try {
|
||||
await Geolocator.requestPermission();
|
||||
await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
|
||||
await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy: LocationAccuracy.high,
|
||||
);
|
||||
ShowToastDialog.closeLoader();
|
||||
if (Constant.selectedMapType == 'osm') {
|
||||
final result = await Get.to(() => MapPickerPage());
|
||||
@@ -129,18 +160,29 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
|
||||
addressModel.addressAs = "Home";
|
||||
addressModel.locality = address.toString();
|
||||
addressModel.location = UserLocation(latitude: lat, longitude: lng);
|
||||
addressModel.location = UserLocation(
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
);
|
||||
Constant.selectedLocation = addressModel;
|
||||
Get.offAll(const ServiceListScreen());
|
||||
}
|
||||
} else {
|
||||
Get.to(LocationPickerScreen())!.then((value) async {
|
||||
if (value != null) {
|
||||
SelectedLocationModel selectedLocationModel = value;
|
||||
SelectedLocationModel selectedLocationModel =
|
||||
value;
|
||||
|
||||
addressModel.addressAs = "Home";
|
||||
addressModel.locality = Utils.formatAddress(selectedLocation: selectedLocationModel);
|
||||
addressModel.location = UserLocation(latitude: selectedLocationModel.latLng!.latitude, longitude: selectedLocationModel.latLng!.longitude);
|
||||
addressModel.locality = Utils.formatAddress(
|
||||
selectedLocation: selectedLocationModel,
|
||||
);
|
||||
addressModel.location = UserLocation(
|
||||
latitude:
|
||||
selectedLocationModel.latLng!.latitude,
|
||||
longitude:
|
||||
selectedLocationModel.latLng!.longitude,
|
||||
);
|
||||
Constant.selectedLocation = addressModel;
|
||||
|
||||
Get.offAll(const ServiceListScreen());
|
||||
@@ -148,10 +190,16 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
await placemarkFromCoordinates(19.228825, 72.854118).then((valuePlaceMaker) {
|
||||
await placemarkFromCoordinates(
|
||||
19.228825,
|
||||
72.854118,
|
||||
).then((valuePlaceMaker) {
|
||||
Placemark placeMark = valuePlaceMaker[0];
|
||||
addressModel.addressAs = "Home";
|
||||
addressModel.location = UserLocation(latitude: 19.228825, longitude: 72.854118);
|
||||
addressModel.location = UserLocation(
|
||||
latitude: 19.228825,
|
||||
longitude: 72.854118,
|
||||
);
|
||||
String currentLocation =
|
||||
"${placeMark.name}, ${placeMark.subLocality}, ${placeMark.locality}, ${placeMark.administrativeArea}, ${placeMark.postalCode}, ${placeMark.country}";
|
||||
addressModel.locality = currentLocation;
|
||||
@@ -181,7 +229,16 @@ class LocationPermissionScreen extends StatelessWidget {
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Text("Enter Manually location".tr(), style: AppThemeData.semiBoldTextStyle(fontSize: 16, color: isDark ? AppThemeData.greyDark900 : AppThemeData.grey900)),
|
||||
child: Text(
|
||||
"Enter Manually location".tr(),
|
||||
style: AppThemeData.semiBoldTextStyle(
|
||||
fontSize: 16,
|
||||
color:
|
||||
isDark
|
||||
? AppThemeData.greyDark900
|
||||
: AppThemeData.grey900,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user