1-bottom sheet
2- on tap location
3- swipe widget
This commit is contained in:
2025-04-14 16:23:09 +03:30
parent 28d43aa027
commit cf4dfb23ea
28 changed files with 349 additions and 68 deletions

View File

@@ -6,6 +6,7 @@ import 'package:flutter_map_animations/flutter_map_animations.dart';
import 'package:geolocator/geolocator.dart';
import 'package:latlong2/latlong.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/data/utils.dart';
import 'package:supervision/data/utils/marker_generator.dart';
enum BottomSheetStep { filter, markerSelected, markerDetails }
@@ -108,30 +109,35 @@ class SupervisionFilterLogic extends GetxController
DraggableBottomSheetController(
initialVisibility: false,
initialHeight: 300,
minHeight: 50,
minHeight: 70,
maxHeight: 600,
).obs;
bottomSheetStep.listen((data) {
tLog('1 bottomSheetStep -> ${data.name}');
if (data == BottomSheetStep.filter) {
sheetController =
DraggableBottomSheetController(
initialVisibility: false,
sheetController.value = DraggableBottomSheetController(
initialVisibility: true,
initialHeight: 300,
minHeight: 50,
minHeight: 70,
maxHeight: 600,
).obs;
);
} else if (data == BottomSheetStep.markerSelected) {
sheetController =
sheetController.value =
DraggableBottomSheetController(
initialVisibility: true,
initialHeight: 150,
initialHeight: 300,
minHeight: 50,
maxHeight: 150,
).obs;
sheetController.refresh();
maxHeight: 300,
);
}
sheetController.refresh();
sheetController.value.toggle();
});
}
@override

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/data/utils.dart';
import 'package:rasadyar_core/presentation/widget/buttons/fab.dart';
import 'logic.dart';
@@ -42,26 +44,7 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
ObxValue((markers) {
return MarkerLayer(
markers:
markers
.map(
(marker) => Marker(
point: marker,
child: IconButton(
onPressed: () {
controller.bottomSheetStep.value =
BottomSheetStep.markerSelected;
},
icon: Icon(
Icons.location_on,
color: Colors.red,
size: 30,
),
),
),
)
.toList(),
markers.map((marker) => markerWidget(marker)).toList(),
);
}, controller.markers),
],
@@ -93,6 +76,9 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
backgroundColor: AppColor.blueNormal,
icon: vecWidget(Assets.vecFilterSvg, width: 24, height: 24),
onPressed: () {
if (controller.bottomSheetStep.value != BottomSheetStep.filter) {
controller.bottomSheetStep.value = BottomSheetStep.filter;
}
controller.sheetController.value.toggle();
},
),
@@ -102,20 +88,18 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
left: 0,
right: 0,
child: ObxValue((data) {
fLog(data);
return DraggableBottomSheet(
controller: data.value,
child: ObxValue((data) {
if (data.value == BottomSheetStep.filter) {
return filterWidget();
} else if (data.value == BottomSheetStep.markerSelected) {
return const SizedBox(
height: 150,
child: Center(child: Text('Marker Selected')),
);
return selectedLocationWidget();
} else {
return const SizedBox(
height: 150,
child: Center(child: Text('Noting')),
child: Center(child: Text('Marker Selected')),
);
}
}, controller.bottomSheetStep),
@@ -126,6 +110,111 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
);
}
Marker markerWidget(LatLng marker) {
return Marker(
point: marker,
child: IconButton(
onPressed: () {
controller.bottomSheetStep.value = BottomSheetStep.markerSelected;
if (!controller.sheetController.value.isVisible.value) {
controller.sheetController.value.show();
}
},
icon: Icon(Icons.location_on, color: Colors.red, size: 30),
),
);
}
Widget selectedLocationWidget() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
child: Slidable(
key: Key('item'),
endActionPane: ActionPane(
motion: StretchMotion(),
children: [
CustomSlidableAction(
onPressed: (context) {},
backgroundColor: AppColor.blueNormal,
foregroundColor: Colors.white,
padding: EdgeInsets.all(16),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(8),
topRight: Radius.circular(8),
),
child: vecWidget(Assets.vecMapSvg, width: 24, height: 24),
),
CustomSlidableAction(
onPressed: (context) {},
backgroundColor: AppColor.greenNormal,
padding: EdgeInsets.all(16),
child: vecWidget(Assets.vecMessageAddSvg),
),
CustomSlidableAction(
onPressed: (context) {},
backgroundColor: AppColor.warning,
padding: EdgeInsets.all(16),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8),
topLeft: Radius.circular(8),
),
child: vecWidget(Assets.vecSecurityTimeSvg),
),
],
),
child: Container(
height: 58,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(width: 1, color: AppColor.blackLightHover),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Text(
'داود خرم مهری پور',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'گوشت و مرغ',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
Column(
children: [
Text(
'باقی مانده',
style: AppFonts.yekan10.copyWith(
color: AppColor.blueNormal,
),
),
Text(
'0 کیلوگرم',
style: AppFonts.yekan12.copyWith(
color: AppColor.darkGreyDarkHover,
),
),
],
),
vecWidget(Assets.vecScanBarcodeSvg),
],
),
),
),
);
}
Padding filterWidget() {
return Padding(
padding: const EdgeInsets.all(20.0),

View File

@@ -110,6 +110,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.9.0"
flutter_slidable:
dependency: transitive
description:
name: flutter_slidable
sha256: ab7dbb16f783307c9d7762ede2593ce32c220ba2ba0fd540a3db8e9a3acba71a
url: "https://pub.dev"
source: hosted
version: "4.0.0"
flutter_svg:
dependency: transitive
description: