fixing jira bugs

faiz_development_common
Faiz Hashmi 2 weeks ago
parent 9bdb105212
commit e6fc99839f

@ -275,11 +275,7 @@ class ServiceVM extends BaseVM {
context, context,
allowMultiple: false, allowMultiple: false,
); );
if (files != null && files.any((element) => if (files != null && files.any((element) => element.path.split('.').last.toLowerCase() != 'pdf')) {
element.path
.split('.')
.last
.toLowerCase() != 'pdf')) {
Utils.showToast("Only PDF Files are allowed"); Utils.showToast("Only PDF Files are allowed");
return; return;
} }
@ -531,10 +527,10 @@ class ServiceVM extends BaseVM {
DropValue( DropValue(
element.id ?? 0, element.id ?? 0,
((element.categoryName!.isEmpty ((element.categoryName!.isEmpty
? "N/A" ? "N/A"
: countryCode == "SA" : countryCode == "SA"
? element.categoryNameN ? element.categoryNameN
: element.categoryName) ?? : element.categoryName) ??
"N/A"), "N/A"),
"", "",
), ),
@ -841,9 +837,7 @@ class ServiceVM extends BaseVM {
File file = File(imageModel.filePath!); File file = File(imageModel.filePath!);
List<int> imageBytes = await file.readAsBytes(); List<int> imageBytes = await file.readAsBytes();
String image = base64Encode(imageBytes); String image = base64Encode(imageBytes);
String fileName = file.path String fileName = file.path.split('/').last;
.split('/')
.last;
branchPostingImages = BranchPostingImages( branchPostingImages = BranchPostingImages(
imageName: fileName, imageName: fileName,
imageStr: image, imageStr: image,

@ -37,6 +37,8 @@ class _PickLocationPageState extends State<PickLocationPage> {
late LatLng currentPosition; late LatLng currentPosition;
Completer<GoogleMapController> mapController = Completer(); Completer<GoogleMapController> mapController = Completer();
final ValueNotifier<String> _counter = ValueNotifier<String>(""); final ValueNotifier<String> _counter = ValueNotifier<String>("");
final ValueNotifier<bool> _isLoadingAddress = ValueNotifier<bool>(false);
String actualAddress = ""; // Store the actual address to return
@override @override
void initState() { void initState() {
@ -74,7 +76,7 @@ class _PickLocationPageState extends State<PickLocationPage> {
Expanded( Expanded(
child: Stack( child: Stack(
children: [ children: [
if (appMap != null) appMap, appMap,
ValueListenableBuilder<String>( ValueListenableBuilder<String>(
builder: (BuildContext context, String value, Widget? child) { builder: (BuildContext context, String value, Widget? child) {
// This builder will only get called when the _counter // This builder will only get called when the _counter
@ -86,13 +88,42 @@ class _PickLocationPageState extends State<PickLocationPage> {
child: Card( child: Card(
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Text(value ?? ""), child: Text(value),
)), )),
) )
: Container(); : Container();
}, },
valueListenable: _counter, valueListenable: _counter,
), ),
ValueListenableBuilder<bool>(
builder: (BuildContext context, bool isLoading, Widget? child) {
return isLoading
? Container(
width: double.infinity,
margin: const EdgeInsets.only(top: 70),
alignment: Alignment.topCenter,
child: const Card(
child: Padding(
padding: EdgeInsets.all(12.0),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
SizedBox(width: 12),
Text('Loading address...'),
],
),
),
),
)
: const SizedBox.shrink();
},
valueListenable: _isLoadingAddress,
),
const Align( const Align(
alignment: Alignment.center, alignment: Alignment.center,
child: Icon( child: Icon(
@ -108,12 +139,20 @@ class _PickLocationPageState extends State<PickLocationPage> {
width: double.infinity, width: double.infinity,
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: ShowFillButton( child: ValueListenableBuilder<bool>(
maxHeight: 55, valueListenable: _isLoadingAddress,
title: LocaleKeys.pickAddress.tr(), builder: (context, isLoading, child) {
onPressed: () { return ShowFillButton(
widget.onPickAddress(latitude, longitude, _counter.value); maxHeight: 55,
pop(context); title: isLoading ? 'Loading Address...' : LocaleKeys.pickAddress.tr(),
isDisabled: isLoading || _counter.value.isEmpty,
onPressed: () {
if (!isLoading && _counter.value.isNotEmpty) {
widget.onPickAddress(latitude, longitude, actualAddress);
pop(context);
}
},
);
}, },
), ),
), ),
@ -157,8 +196,33 @@ class _PickLocationPageState extends State<PickLocationPage> {
} }
updateAddress(double latitude, double longitude) async { updateAddress(double latitude, double longitude) async {
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude); _isLoadingAddress.value = true;
_counter.value = '${placemarks.first.street}, ${placemarks.first.subLocality}, ${placemarks.first.locality}, ${placemarks.first.postalCode}, ${placemarks.first.country}';
try {
List<Placemark> placemarks = await placemarkFromCoordinates(latitude, longitude).timeout(
const Duration(seconds: 5),
onTimeout: () {
throw TimeoutException('Geocoding request timed out');
},
);
if (placemarks.isNotEmpty) {
final placemark = placemarks.first;
// Restore original format - building address string from individual fields
actualAddress = '${placemark.street}, ${placemark.subLocality}, ${placemark.locality}, ${placemark.postalCode}, ${placemark.country}';
_counter.value = actualAddress;
} else {
actualAddress = "";
_counter.value = "";
}
} catch (e) {
log('Error getting address: $e');
// On error, leave address empty - user can try again by moving the map
actualAddress = "";
_counter.value = "";
} finally {
_isLoadingAddress.value = false;
}
} }
setMap() { setMap() {

Loading…
Cancel
Save