feat : new logic

This commit is contained in:
2025-04-16 15:17:17 +03:30
parent 9188bf871f
commit 8f93a5c893
6 changed files with 191 additions and 158 deletions

View File

@@ -6,7 +6,6 @@ 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 }
@@ -21,8 +20,10 @@ class SupervisionFilterLogic extends GetxController
RxInt filterIndex = 0.obs;
RxInt showIndex = 0.obs;
bool showSlideHint = true;
Rx<BottomSheetStep> bottomSheetStep = BottomSheetStep.filter.obs;
late Rx<SlidableController> slidController;
Rx<MapController> mapController = MapController().obs;
late final AnimatedMapController animatedMapController;
@@ -113,8 +114,10 @@ class SupervisionFilterLogic extends GetxController
maxHeight: 600,
).obs;
bottomSheetStep.listen((data) {
tLog('1 bottomSheetStep -> ${data.name}');
slidController = SlidableController(this).obs;
/*bottomSheetStep.listen((data) {
tLog('1 bottomSheetStep -> ${data.nme}');
if (data == BottomSheetStep.filter) {
sheetController.value = DraggableBottomSheetController(
initialVisibility: true,
@@ -143,9 +146,7 @@ class SupervisionFilterLogic extends GetxController
sheetController.refresh();
sheetController.value.toggle();
});
});*/
}
@override
@@ -153,8 +154,19 @@ class SupervisionFilterLogic extends GetxController
super.onReady();
determineCurrentPosition();
generatedMarkers();
}
Future<void> triggerSlidableAnimation() async {
await Future.delayed(Duration(milliseconds: 200));
await slidController.value.openEndActionPane();
await Future.delayed(Duration(milliseconds: 200));
await slidController.value.close();
showSlideHint = !showSlideHint;
}
@override
void onClose() {
// TODO: implement onClose

View File

@@ -4,6 +4,7 @@ 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 'package:supervision/presentation/location_details/view.dart';
import 'package:supervision/presentation/routes/app_routes.dart';
import 'logic.dart';
@@ -23,88 +24,110 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
@override
Widget build(BuildContext context) {
return Stack(
children: [
ObxValue((currentLocation) {
return FlutterMap(
mapController: controller.animatedMapController.mapController,
options: MapOptions(
initialCenter: currentLocation.value,
initialZoom: 18,
onPositionChanged: (camera, hasGesture) {
controller.debouncedUpdateVisibleMarkers(center: camera.center);
return PopScope(
canPop: controller.sheetController.value.handleBack(),
onPopInvokedWithResult: (didPop, result) {
if (!didPop &&
controller.sheetController.value.bottomSheets.isNotEmpty) {
controller.sheetController.value.removeLastBottomSheet();
}
},
child: Stack(
children: [
ObxValue((currentLocation) {
return FlutterMap(
mapController: controller.animatedMapController.mapController,
options: MapOptions(
initialCenter: currentLocation.value,
initialZoom: 18,
onPositionChanged: (camera, hasGesture) {
controller.debouncedUpdateVisibleMarkers(
center: camera.center,
);
},
),
children: [
TileLayer(
urlTemplate:
"https://map.ir/shiveh/xyz/1.0.0/Shiveh:Shiveh@EPSG:3857@png/{z}/{x}/{y}.png"
"?x-api-key=$token",
),
ObxValue((markers) {
return MarkerLayer(
markers:
markers.map((marker) => markerWidget(marker)).toList(),
);
}, controller.markers),
],
);
}, controller.currentLocation),
Positioned(
right: 10,
bottom: 150,
child: ObxValue((data) {
return RFab.small(
backgroundColor: AppColor.greenNormal,
isLoading: data.value,
icon: vecWidget(Assets.vecGpsSvg),
onPressed: () {
controller.isLoading.value = true;
controller.determineCurrentPosition().then(
(value) =>
controller.isLoading.value =
!controller.isLoading.value,
);
},
);
}, controller.isLoading),
),
Positioned(
right: 10,
bottom: 100,
child: RFab.small(
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();
},
),
children: [
TileLayer(
urlTemplate:
"https://map.ir/shiveh/xyz/1.0.0/Shiveh:Shiveh@EPSG:3857@png/{z}/{x}/{y}.png"
"?x-api-key=$token",
),
ObxValue((markers) {
return MarkerLayer(
markers:
markers.map((marker) => markerWidget(marker)).toList(),
);
}, controller.markers),
],
);
}, controller.currentLocation),
Positioned(
right: 10,
bottom: 150,
child: ObxValue((data) {
return RFab.small(
backgroundColor: AppColor.greenNormal,
isLoading: data.value,
icon: vecWidget(Assets.vecGpsSvg),
onPressed: () {
controller.isLoading.value = true;
controller.determineCurrentPosition().then(
(value) =>
controller.isLoading.value = !controller.isLoading.value,
);
},
);
}, controller.isLoading),
),
Positioned(
right: 10,
bottom: 100,
child: RFab.small(
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();
},
),
),
ObxValue((data) {
return DraggableBottomSheet(
controller: data.value,
backgroundColor:
controller.bottomSheetStep.value == BottomSheetStep.filter
? Colors.white
: AppColor.lightGreyLight,
child: ObxValue((data) {
if (data.value == BottomSheetStep.filter) {
return filterWidget();
} else if (data.value == BottomSheetStep.markerSelected) {
return selectedLocationWidget();
} else if (data.value == BottomSheetStep.markerDetails) {
return markerDetailsWidget();
} else {
return Container(height: 300, color: AppColor.blueNormal);
}
}, controller.bottomSheetStep),
);
}, controller.sheetController),
],
Obx(
() => Stack(
children:
controller.sheetController.value.bottomSheets
.map((sheet) => sheet)
.toList(),
),
),
/* ObxValue((data) {
return DraggableBottomSheet(
controller: data.value,
backgroundColor:
controller.bottomSheetStep.value == BottomSheetStep.filter
? Colors.white
: AppColor.lightGreyLight,
child: ObxValue((data) {
if (data.value == BottomSheetStep.filter) {
return filterWidget();
} else if (data.value == BottomSheetStep.markerSelected) {
return selectedLocationWidget();
} else if (data.value == BottomSheetStep.markerDetails) {
return markerDetailsWidget();
} else {
return Container(height: 300, color: AppColor.blueNormal);
}
}, controller.bottomSheetStep),
);
}, controller.sheetController),*/
],
),
);
}
@@ -114,10 +137,12 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
child: GestureDetector(
onTap: () {
controller.bottomSheetStep.value = BottomSheetStep.markerSelected;
if (!controller.sheetController.value.isVisible.value) {
controller.sheetController.value.show();
}
controller.sheetController.value.addBottomSheet(
child: selectedLocationWidget(),
minHeight: 0,
maxHeight: 250,
initHeight: 250,
);
},
behavior: HitTestBehavior.opaque,
child: SizedBox(
@@ -130,10 +155,15 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
}
Widget selectedLocationWidget() {
if (controller.showSlideHint) {
controller.triggerSlidableAnimation();
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
child: Slidable(
key: Key('item'),
key: Key('selectedLocationWidget'),
controller: controller.slidController.value,
endActionPane: ActionPane(
motion: StretchMotion(),
children: [
@@ -151,7 +181,14 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
child: vecWidget(Assets.vecMapSvg, width: 24, height: 24),
),
CustomSlidableAction(
onPressed: (context) {},
onPressed: (context) {
controller.sheetController.value.addBottomSheet(
child: LocationDetailsPage(),
initHeight: 500,
maxHeight: Get.height * 2,
minHeight: 0,
);
},
backgroundColor: AppColor.greenNormal,
padding: EdgeInsets.all(16),
child: vecWidget(Assets.vecMessageAddSvg),
@@ -170,10 +207,12 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
),
child: GestureDetector(
onTap: () {
controller.bottomSheetStep.value = BottomSheetStep.markerDetails;
if (!controller.sheetController.value.isVisible.value) {
controller.sheetController.value.show();
}
controller.sheetController.value.addBottomSheet(
child: markerDetailsWidget(),
minHeight: 0,
maxHeight: Get.height * 0.65,
initHeight: Get.height * 0.6,
);
},
child: Container(
height: 58,
@@ -581,37 +620,37 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
),
);
}
}
Widget customChip({
bool isSelected = false,
required String title,
required int index,
required Function(int) onTap,
}) {
return GestureDetector(
onTap: () {
onTap.call(index);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: isSelected ? AppColor.blueNormal : AppColor.whiteGreyNormal,
borderRadius: BorderRadius.circular(8),
border:
isSelected
? Border.fromBorderSide(BorderSide.none)
: Border.all(width: 0.25, color: const Color(0xFFB0B0B0)),
Widget customChip({
bool isSelected = false,
required String title,
required int index,
required Function(int) onTap,
}) {
return GestureDetector(
onTap: () {
onTap.call(index);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: isSelected ? AppColor.blueNormal : AppColor.whiteGreyNormal,
borderRadius: BorderRadius.circular(8),
border:
isSelected
? Border.fromBorderSide(BorderSide.none)
: Border.all(width: 0.25, color: const Color(0xFFB0B0B0)),
),
child: Text(
title,
textAlign: TextAlign.center,
style:
isSelected
? AppFonts.yekan10.copyWith(color: AppColor.whiteLight)
: AppFonts.yekan10,
),
),
child: Text(
title,
textAlign: TextAlign.center,
style:
isSelected
? AppFonts.yekan10.copyWith(color: AppColor.whiteLight)
: AppFonts.yekan10,
),
),
);
);
}
}

View File

@@ -1,9 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/utils/color_utils.dart';
import 'package:rasadyar_core/presentation/widget/tabs/new_tab.dart';
import 'logic.dart';
class LocationDetailsPage extends GetView<LocationDetailsLogic> {
@@ -12,21 +10,8 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
actions: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: IconButton(
onPressed: () {
Get.back();
},
icon: Icon(CupertinoIcons.chevron_back),
color: AppColor.blueNormal,
),
),
],
),
backgroundColor: AppColor.lightGreyLight,
appBar: RAppBar(title: 'جزئیات محل'),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -84,7 +69,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
children: [
Expanded(
child: ROutlinedElevatedIcon(
icon: Icon(Icons.calendar_month),
icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () {},
text: 'از تاریخ',
textStyle: AppFonts.yekan16.copyWith(
@@ -94,7 +79,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
),
Expanded(
child: ROutlinedElevatedIcon(
icon: Icon(Icons.calendar_month),
icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () {},
text: 'تا تاریخ',
textStyle: AppFonts.yekan16.copyWith(
@@ -131,7 +116,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
Expanded(
child: GridView.builder(
itemCount: 50,
itemCount: 51,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.fromLTRB(20, 14, 20, 50),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

View File

@@ -13,18 +13,11 @@ sealed class SupervisionPages {
GetPage(
name: SupervisionRoutes.supervision,
page: () => RootPage(),
bindings: [
BindingsBuilder.put(() => RootLogic()),
BindingsBuilder.put(() => SupervisionFilterLogic()),
],
),
GetPage(
name: SupervisionRoutes.supervision,
page: () => RootPage(),
bindings: [
BindingsBuilder.put(() => RootLogic()),
BindingsBuilder.put(() => SupervisionFilterLogic()),
],
binding: BindingsBuilder(() {
Get.put(RootLogic());
Get.put(SupervisionFilterLogic());
Get.lazyPut(() => LocationDetailsLogic(), fenix: true);
}),
),
GetPage(

View File

@@ -4,6 +4,9 @@ export 'package:get/get.dart';
export 'package:rasadyar_core/presentation/common/common.dart';
export 'package:rasadyar_core/presentation/utils/utils.dart';
export 'package:rasadyar_core/presentation/widget/widget.dart';
//other packages
export 'package:flutter_slidable/flutter_slidable.dart';
export 'package:font_awesome_flutter/font_awesome_flutter.dart';

View File

@@ -4,4 +4,5 @@ export 'draggable_bottom_sheet/draggable_bottom_sheet.dart';
export 'draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';
export 'buttons/outline_elevated_icon.dart';
export 'buttons/outline_elevated.dart';
export 'app_bar/r_app_bar.dart';