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.
163 lines
5.7 KiB
Dart
163 lines
5.7 KiB
Dart
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
// ignore: must_be_immutable
|
|
class SelectLocationDialog extends StatefulWidget {
|
|
final List<AddressInfo>? addresses;
|
|
final Function(AddressInfo)? onValueSelected;
|
|
AddressInfo? selectedAddress;
|
|
|
|
SelectLocationDialog({Key? key, this.addresses, this.onValueSelected, this.selectedAddress});
|
|
|
|
@override
|
|
_SelectLocationDialogState createState() => _SelectLocationDialogState();
|
|
}
|
|
|
|
class _SelectLocationDialogState extends State<SelectLocationDialog> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
widget.selectedAddress = widget.selectedAddress ?? widget.addresses![0];
|
|
for(int i=0;i<widget.addresses!.length;i++){
|
|
print(widget.addresses![i].latLong);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SimpleDialog(
|
|
title: Text(
|
|
TranslationBase.of(context).selectAddress,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.46,
|
|
),
|
|
),
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Container(
|
|
height: 150,
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Divider(),
|
|
...List.generate(
|
|
widget.addresses!.length,
|
|
(index) => Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
height: 2,
|
|
),
|
|
Row(
|
|
children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() {
|
|
widget.selectedAddress = widget.addresses![index];
|
|
});
|
|
},
|
|
child: ListTile(
|
|
title: Text(
|
|
widget.addresses![index].address1!,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.46,
|
|
),
|
|
),
|
|
leading: Radio(
|
|
value: widget.addresses![index],
|
|
groupValue: widget.selectedAddress,
|
|
activeColor: Colors.red[800],
|
|
onChanged: (value) {
|
|
setState(() {
|
|
widget.selectedAddress = value;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 5.0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 5.0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: InkWell(
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Container(
|
|
child: Center(
|
|
child: Text(
|
|
TranslationBase.of(context).cancel.toUpperCase(),
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.46,
|
|
color: Colors.red,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: 1,
|
|
height: 30,
|
|
color: Colors.grey[500],
|
|
),
|
|
Expanded(
|
|
flex: 1,
|
|
child: InkWell(
|
|
onTap: () {
|
|
widget.onValueSelected!(widget.selectedAddress!);
|
|
Navigator.pop(context);
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Center(
|
|
child: Text(
|
|
TranslationBase.of(context).ok.toUpperCase(),
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.46,
|
|
),
|
|
)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|