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:geolocator/geolocator.dart';
import 'package:latlong2/latlong.dart'; import 'package:latlong2/latlong.dart';
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/data/utils.dart';
import 'package:supervision/data/utils/marker_generator.dart'; import 'package:supervision/data/utils/marker_generator.dart';
enum BottomSheetStep { filter, markerSelected, markerDetails } enum BottomSheetStep { filter, markerSelected, markerDetails }
@@ -21,8 +20,10 @@ class SupervisionFilterLogic extends GetxController
RxInt filterIndex = 0.obs; RxInt filterIndex = 0.obs;
RxInt showIndex = 0.obs; RxInt showIndex = 0.obs;
bool showSlideHint = true;
Rx<BottomSheetStep> bottomSheetStep = BottomSheetStep.filter.obs; Rx<BottomSheetStep> bottomSheetStep = BottomSheetStep.filter.obs;
late Rx<SlidableController> slidController;
Rx<MapController> mapController = MapController().obs; Rx<MapController> mapController = MapController().obs;
late final AnimatedMapController animatedMapController; late final AnimatedMapController animatedMapController;
@@ -113,8 +114,10 @@ class SupervisionFilterLogic extends GetxController
maxHeight: 600, maxHeight: 600,
).obs; ).obs;
bottomSheetStep.listen((data) { slidController = SlidableController(this).obs;
tLog('1 bottomSheetStep -> ${data.name}');
/*bottomSheetStep.listen((data) {
tLog('1 bottomSheetStep -> ${data.nme}');
if (data == BottomSheetStep.filter) { if (data == BottomSheetStep.filter) {
sheetController.value = DraggableBottomSheetController( sheetController.value = DraggableBottomSheetController(
initialVisibility: true, initialVisibility: true,
@@ -143,9 +146,7 @@ class SupervisionFilterLogic extends GetxController
sheetController.refresh(); sheetController.refresh();
sheetController.value.toggle(); sheetController.value.toggle();
}); });*/
} }
@override @override
@@ -153,8 +154,19 @@ class SupervisionFilterLogic extends GetxController
super.onReady(); super.onReady();
determineCurrentPosition(); determineCurrentPosition();
generatedMarkers(); 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 @override
void onClose() { void onClose() {
// TODO: implement 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/core.dart';
import 'package:rasadyar_core/data/utils.dart'; import 'package:rasadyar_core/data/utils.dart';
import 'package:rasadyar_core/presentation/widget/buttons/fab.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 'package:supervision/presentation/routes/app_routes.dart';
import 'logic.dart'; import 'logic.dart';
@@ -23,88 +24,110 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Stack( return PopScope(
children: [ canPop: controller.sheetController.value.handleBack(),
ObxValue((currentLocation) { onPopInvokedWithResult: (didPop, result) {
return FlutterMap( if (!didPop &&
mapController: controller.animatedMapController.mapController, controller.sheetController.value.bottomSheets.isNotEmpty) {
options: MapOptions( controller.sheetController.value.removeLastBottomSheet();
initialCenter: currentLocation.value, }
initialZoom: 18, },
onPositionChanged: (camera, hasGesture) { child: Stack(
controller.debouncedUpdateVisibleMarkers(center: camera.center); 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();
},
), ),
), Obx(
ObxValue((data) { () => Stack(
return DraggableBottomSheet( children:
controller: data.value, controller.sheetController.value.bottomSheets
backgroundColor: .map((sheet) => sheet)
controller.bottomSheetStep.value == BottomSheetStep.filter .toList(),
? Colors.white ),
: AppColor.lightGreyLight, ),
child: ObxValue((data) {
if (data.value == BottomSheetStep.filter) { /* ObxValue((data) {
return filterWidget(); return DraggableBottomSheet(
} else if (data.value == BottomSheetStep.markerSelected) { controller: data.value,
return selectedLocationWidget(); backgroundColor:
} else if (data.value == BottomSheetStep.markerDetails) { controller.bottomSheetStep.value == BottomSheetStep.filter
return markerDetailsWidget(); ? Colors.white
} else { : AppColor.lightGreyLight,
return Container(height: 300, color: AppColor.blueNormal); child: ObxValue((data) {
} if (data.value == BottomSheetStep.filter) {
}, controller.bottomSheetStep), return filterWidget();
); } else if (data.value == BottomSheetStep.markerSelected) {
}, controller.sheetController), 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( child: GestureDetector(
onTap: () { onTap: () {
controller.bottomSheetStep.value = BottomSheetStep.markerSelected; controller.sheetController.value.addBottomSheet(
if (!controller.sheetController.value.isVisible.value) { child: selectedLocationWidget(),
controller.sheetController.value.show(); minHeight: 0,
} maxHeight: 250,
initHeight: 250,
);
}, },
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: SizedBox( child: SizedBox(
@@ -130,10 +155,15 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
} }
Widget selectedLocationWidget() { Widget selectedLocationWidget() {
if (controller.showSlideHint) {
controller.triggerSlidableAnimation();
}
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20), padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
child: Slidable( child: Slidable(
key: Key('item'), key: Key('selectedLocationWidget'),
controller: controller.slidController.value,
endActionPane: ActionPane( endActionPane: ActionPane(
motion: StretchMotion(), motion: StretchMotion(),
children: [ children: [
@@ -151,7 +181,14 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
child: vecWidget(Assets.vecMapSvg, width: 24, height: 24), child: vecWidget(Assets.vecMapSvg, width: 24, height: 24),
), ),
CustomSlidableAction( CustomSlidableAction(
onPressed: (context) {}, onPressed: (context) {
controller.sheetController.value.addBottomSheet(
child: LocationDetailsPage(),
initHeight: 500,
maxHeight: Get.height * 2,
minHeight: 0,
);
},
backgroundColor: AppColor.greenNormal, backgroundColor: AppColor.greenNormal,
padding: EdgeInsets.all(16), padding: EdgeInsets.all(16),
child: vecWidget(Assets.vecMessageAddSvg), child: vecWidget(Assets.vecMessageAddSvg),
@@ -170,10 +207,12 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
), ),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
controller.bottomSheetStep.value = BottomSheetStep.markerDetails; controller.sheetController.value.addBottomSheet(
if (!controller.sheetController.value.isVisible.value) { child: markerDetailsWidget(),
controller.sheetController.value.show(); minHeight: 0,
} maxHeight: Get.height * 0.65,
initHeight: Get.height * 0.6,
);
}, },
child: Container( child: Container(
height: 58, height: 58,
@@ -581,37 +620,37 @@ class SupervisionFilterPage extends GetView<SupervisionFilterLogic> {
), ),
); );
} }
}
Widget customChip({ Widget customChip({
bool isSelected = false, bool isSelected = false,
required String title, required String title,
required int index, required int index,
required Function(int) onTap, required Function(int) onTap,
}) { }) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
onTap.call(index); onTap.call(index);
}, },
child: Container( child: Container(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? AppColor.blueNormal : AppColor.whiteGreyNormal, color: isSelected ? AppColor.blueNormal : AppColor.whiteGreyNormal,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: border:
isSelected isSelected
? Border.fromBorderSide(BorderSide.none) ? Border.fromBorderSide(BorderSide.none)
: Border.all(width: 0.25, color: const Color(0xFFB0B0B0)), : 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:flutter/material.dart';
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/presentation/utils/color_utils.dart'; import 'package:rasadyar_core/presentation/utils/color_utils.dart';
import 'package:rasadyar_core/presentation/widget/tabs/new_tab.dart'; import 'package:rasadyar_core/presentation/widget/tabs/new_tab.dart';
import 'logic.dart'; import 'logic.dart';
class LocationDetailsPage extends GetView<LocationDetailsLogic> { class LocationDetailsPage extends GetView<LocationDetailsLogic> {
@@ -12,21 +10,8 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( backgroundColor: AppColor.lightGreyLight,
automaticallyImplyLeading: false, appBar: RAppBar(title: 'جزئیات محل'),
actions: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: IconButton(
onPressed: () {
Get.back();
},
icon: Icon(CupertinoIcons.chevron_back),
color: AppColor.blueNormal,
),
),
],
),
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -84,7 +69,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
children: [ children: [
Expanded( Expanded(
child: ROutlinedElevatedIcon( child: ROutlinedElevatedIcon(
icon: Icon(Icons.calendar_month), icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () {}, onPressed: () {},
text: 'از تاریخ', text: 'از تاریخ',
textStyle: AppFonts.yekan16.copyWith( textStyle: AppFonts.yekan16.copyWith(
@@ -94,7 +79,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
), ),
Expanded( Expanded(
child: ROutlinedElevatedIcon( child: ROutlinedElevatedIcon(
icon: Icon(Icons.calendar_month), icon: FaIcon(FontAwesomeIcons.calendar),
onPressed: () {}, onPressed: () {},
text: 'تا تاریخ', text: 'تا تاریخ',
textStyle: AppFonts.yekan16.copyWith( textStyle: AppFonts.yekan16.copyWith(
@@ -131,7 +116,7 @@ class LocationDetailsPage extends GetView<LocationDetailsLogic> {
Expanded( Expanded(
child: GridView.builder( child: GridView.builder(
itemCount: 50, itemCount: 51,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
padding: EdgeInsets.fromLTRB(20, 14, 20, 50), padding: EdgeInsets.fromLTRB(20, 14, 20, 50),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

View File

@@ -13,18 +13,11 @@ sealed class SupervisionPages {
GetPage( GetPage(
name: SupervisionRoutes.supervision, name: SupervisionRoutes.supervision,
page: () => RootPage(), page: () => RootPage(),
bindings: [ binding: BindingsBuilder(() {
BindingsBuilder.put(() => RootLogic()), Get.put(RootLogic());
BindingsBuilder.put(() => SupervisionFilterLogic()), Get.put(SupervisionFilterLogic());
], Get.lazyPut(() => LocationDetailsLogic(), fenix: true);
), }),
GetPage(
name: SupervisionRoutes.supervision,
page: () => RootPage(),
bindings: [
BindingsBuilder.put(() => RootLogic()),
BindingsBuilder.put(() => SupervisionFilterLogic()),
],
), ),
GetPage( 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/common/common.dart';
export 'package:rasadyar_core/presentation/utils/utils.dart'; export 'package:rasadyar_core/presentation/utils/utils.dart';
export 'package:rasadyar_core/presentation/widget/widget.dart'; export 'package:rasadyar_core/presentation/widget/widget.dart';
//other packages
export 'package:flutter_slidable/flutter_slidable.dart'; 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 'draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';
export 'buttons/outline_elevated_icon.dart'; export 'buttons/outline_elevated_icon.dart';
export 'buttons/outline_elevated.dart'; export 'buttons/outline_elevated.dart';
export 'app_bar/r_app_bar.dart';