fix bottomsheel

This commit is contained in:
Mohamed Nouffer
2023-09-06 21:36:11 +05:30
parent 36751f6ef7
commit 44a3fc21fb
7 changed files with 676 additions and 547 deletions

View File

@ -9,40 +9,44 @@ import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:timeline_tile/timeline_tile.dart';
class DestinationWidget extends StatelessWidget {
DestinationWidget({ Key? key }) : super(key: key);
DestinationWidget({Key? key}) : super(key: key);
final DestinationController destinationController = Get.find<DestinationController>();
final DestinationController destinationController =
Get.find<DestinationController>();
final IndexController indexController = Get.find<IndexController>();
final List<int> _items = List<int>.generate(50, (int index) => index);
Image getImage(int index){
if(destinationController.destinations[index].photos== null || destinationController.destinations[index].photos == ""){
Image getImage(int index) {
if (destinationController.destinations[index].photos == null ||
destinationController.destinations[index].photos == "") {
return const Image(image: AssetImage('assets/images/empty_image.png'));
}
else{
print("------- image is ${destinationController.destinations[index].photos!}------");
} else {
print(
"------- image is ${destinationController.destinations[index].photos!}------");
String _photo = destinationController.destinations[index].photos!;
if(_photo.contains('http')){
return Image(image: NetworkImage(
destinationController.destinations[index].photos!),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
else {
String serverUrl = ConstValues.currentServer();
//print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ===");
return Image(image: NetworkImage(
'$serverUrl/media/compressed/' + destinationController.destinations[index].photos!),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
if (_photo.contains('http')) {
return Image(
image:
NetworkImage(destinationController.destinations[index].photos!),
errorBuilder:
(BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
} else {
String serverUrl = ConstValues.currentServer();
//print("==== photo is ${server_url + '/media/compressed/' + destinationController.destinations[index].photos!} ===");
return Image(
image: NetworkImage('$serverUrl/media/compressed/' +
destinationController.destinations[index].photos!),
errorBuilder:
(BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
}
}
@ -73,13 +77,13 @@ class DestinationWidget extends StatelessWidget {
void moveUp() {
Destination? d;
for(Destination ad in destinationController.destinations){
if(ad.selected == true){
for (Destination ad in destinationController.destinations) {
if (ad.selected == true) {
d = ad;
break;
}
}
if(d != null){
if (d != null) {
print("--- selected destination is ${d.list_order}");
destinationController.makeOrder(d, -1);
}
@ -87,42 +91,41 @@ class DestinationWidget extends StatelessWidget {
void moveDown() {
Destination? d;
for(Destination ad in destinationController.destinations){
if(ad.selected == true){
for (Destination ad in destinationController.destinations) {
if (ad.selected == true) {
d = ad;
break;
}
}
if(d != null){
if (d != null) {
print("--- selected destination is ${d.list_order}");
destinationController.makeOrder(d, 1);
}
}
void clearall(){
void clearall() {
Get.defaultDialog(
title: "are_you_sure_want_to_delete_all".tr,
middleText: "all_added_destination_will_be_deleted".tr,
backgroundColor: Colors.blue.shade300,
titleStyle: const TextStyle(color: Colors.white),
middleTextStyle: const TextStyle(color: Colors.white),
textConfirm: "confirm".tr,
textCancel: "cancel".tr,
cancelTextColor: Colors.white,
confirmTextColor: Colors.blue,
buttonColor: Colors.white,
barrierDismissible: false,
radius: 10,
content: const Column(
children: [
],
),
onConfirm: (){
destinationController.deleteAllDestinations();
Get.back();
Get.snackbar("deleted".tr, "all_destinations_are_deleted_successfully".tr);
}
);
title: "are_you_sure_want_to_delete_all".tr,
middleText: "all_added_destination_will_be_deleted".tr,
backgroundColor: Colors.blue.shade300,
titleStyle: const TextStyle(color: Colors.white),
middleTextStyle: const TextStyle(color: Colors.white),
textConfirm: "confirm".tr,
textCancel: "cancel".tr,
cancelTextColor: Colors.white,
confirmTextColor: Colors.blue,
buttonColor: Colors.white,
barrierDismissible: false,
radius: 10,
content: const Column(
children: [],
),
onConfirm: () {
destinationController.deleteAllDestinations();
Get.back();
Get.snackbar(
"deleted".tr, "all_destinations_are_deleted_successfully".tr);
});
}
void interChange() {
@ -142,123 +145,157 @@ class DestinationWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
print(
"------ destination widget------ ${destinationController.destinationCount.value} ----------");
print("------ destination widget------ ${destinationController.destinationCount.value} ----------");
return
Obx(() =>
Stack(
return Obx(() => Stack(
children: [
Padding(
padding: const EdgeInsets.only(top:45.0),
child: ListView.builder(
Padding(
padding: const EdgeInsets.only(top: 45.0),
child: ListView.builder(
itemCount: destinationController.destinationCount.value,
itemBuilder: (BuildContext context, int index) {
return
TimelineTile(
alignment: TimelineAlign.manual,
lineXY: 0.2,
isFirst: index == 0 ? true : false,
indicatorStyle: IndicatorStyle(
indicator: CircleAvatar(
child: Text(destinationController.destinations[index].list_order.toString(), style: const TextStyle(color: Colors.white),),
backgroundColor: Colors.red,
),
),
key: Key(index.toString()),
endChild: Card(
child: Container(
constraints: const BoxConstraints(
minHeight: 80,
),
child: ListTile(
onTap: () async {
{
Destination? fs = destinationController.destinations[index];
print("----fsf-----$index");
if(indexController.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature.clear();
}
indexController.currentDestinationFeature.add(fs);
print("--- ndexController.currentDestinationFeature ----- ${ indexController.currentDestinationFeature[0].name} ----");
//indexController.getAction();
showModalBottomSheet(context: context, isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
builder:((context) => BottomSheetNew())
);
}
},
onLongPress: (){
destinationController.toggleSelection(destinationController.destinations[index]);
},
selectedTileColor: Colors.amberAccent,
selected:destinationController.destinations[index].selected!,
leading: getImage(index),
title: Text(destinationController.destinations[index].name!),
subtitle: Text(destinationController.destinations[index].category!),
return TimelineTile(
alignment: TimelineAlign.manual,
lineXY: 0.2,
isFirst: index == 0 ? true : false,
indicatorStyle: IndicatorStyle(
indicator: CircleAvatar(
child: Text(
destinationController.destinations[index].list_order
.toString(),
style: const TextStyle(color: Colors.white),
),
backgroundColor: Colors.red,
),
),
),
startChild:
index > 0 && destinationController.matrix["routes"][0]["legs"] != null ?
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(destinationController.matrix["routes"][0]["legs"][index -1]["distance"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["distance"]["text"].toString(): ''),
Text(destinationController.matrix["routes"][0]["legs"][index -1]["duration"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["duration"]["text"].toString() : '')
],
):
Container()
,
);
}
),
key: Key(index.toString()),
endChild: Card(
child: Container(
constraints: const BoxConstraints(
minHeight: 80,
),
child: ListTile(
onTap: () async {
{
Destination? fs =
destinationController.destinations[index];
print("----fsf-----$index");
if (indexController
.currentDestinationFeature.isNotEmpty) {
indexController.currentDestinationFeature
.clear();
}
indexController.currentDestinationFeature
.add(fs);
print(
"--- ndexController.currentDestinationFeature ----- ${indexController.currentDestinationFeature[0].name} ----");
//indexController.getAction();
showModalBottomSheet(
constraints: BoxConstraints.loose(
Size(Get.width, Get.height * 0.75)),
context: context,
isScrollControlled: true,
//builder:((context) => BottomSheetWidget())
builder: ((context) => BottomSheetNew()));
}
},
onLongPress: () {
destinationController.toggleSelection(
destinationController.destinations[index]);
},
selectedTileColor: Colors.amberAccent,
selected: destinationController
.destinations[index].selected!,
leading: getImage(index),
title: Text(destinationController
.destinations[index].name!),
subtitle: Text(destinationController
.destinations[index].category!),
),
),
),
startChild: index > 0 &&
destinationController.matrix["routes"][0]
["legs"] !=
null
? Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(destinationController.matrix["routes"][0]
["legs"][index - 1]["distance"] !=
null
? destinationController.matrix["routes"][0]
["legs"][index - 1]["distance"]
["text"]
.toString()
: ''),
Text(destinationController.matrix["routes"][0]
["legs"][index - 1]["duration"] !=
null
? destinationController.matrix["routes"][0]
["legs"][index - 1]["duration"]
["text"]
.toString()
: '')
],
)
: Container(),
);
}),
),
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 5,
blurRadius: 3,
offset: const Offset(0, 7), // changes position of shadow
),
],
),
height: 44.0,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon:const Icon(Icons.delete_forever),
//onPressed: (){doDelete();},
onPressed: clearall,
),
IconButton(
icon:const Icon(Icons.cancel),
//onPressed: (){doDelete();},
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? doDelete : null,
),
IconButton(
icon:const Icon(Icons.move_up),
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? moveUp : null,
),
IconButton(
icon:const Icon(Icons.move_down),
onPressed: destinationController.currentSelectedDestinations.isNotEmpty ? moveDown : null,
),
// IconButton(
// icon:Icon(Icons.sync),
// onPressed: destinationController.destination_index_data.length == 2 ? interChange : null,
// ),
],
),
)
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.3),
spreadRadius: 5,
blurRadius: 3,
offset: const Offset(0, 7), // changes position of shadow
),
],
),
height: 44.0,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: const Icon(Icons.delete_forever),
//onPressed: (){doDelete();},
onPressed: clearall,
),
IconButton(
icon: const Icon(Icons.cancel),
//onPressed: (){doDelete();},
onPressed: destinationController
.currentSelectedDestinations.isNotEmpty
? doDelete
: null,
),
IconButton(
icon: const Icon(Icons.move_up),
onPressed: destinationController
.currentSelectedDestinations.isNotEmpty
? moveUp
: null,
),
IconButton(
icon: const Icon(Icons.move_down),
onPressed: destinationController
.currentSelectedDestinations.isNotEmpty
? moveDown
: null,
),
// IconButton(
// icon:Icon(Icons.sync),
// onPressed: destinationController.destination_index_data.length == 2 ? interChange : null,
// ),
],
),
)
],
)
);
));
}
}
}