fix:
1-bottom sheet 2- on tap location 3- swipe widget
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rasadyar_core/data/utils.dart';
|
||||
import 'package:rasadyar_core/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';
|
||||
|
||||
class DraggableBottomSheet extends StatelessWidget {
|
||||
@@ -23,12 +24,11 @@ class DraggableBottomSheet extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// If no controller is passed, create one locally
|
||||
final DraggableBottomSheetController bottomSheetController =
|
||||
controller ??
|
||||
Get.put(
|
||||
DraggableBottomSheetController(
|
||||
initialVisibility: false, // always start hidden
|
||||
initialVisibility: false,
|
||||
initialHeight: initialHeight,
|
||||
minHeight: minHeight,
|
||||
maxHeight: maxHeight,
|
||||
@@ -52,7 +52,7 @@ class DraggableBottomSheet extends StatelessWidget {
|
||||
right: 0,
|
||||
child: GestureDetector(
|
||||
onVerticalDragUpdate: (DragUpdateDetails details) {
|
||||
bottomSheetController.updateHeight(details.delta.dy);
|
||||
bottomSheetController.updateHeight(details.primaryDelta);
|
||||
},
|
||||
child: Container(
|
||||
height: data.value,
|
||||
@@ -63,18 +63,9 @@ class DraggableBottomSheet extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10),
|
||||
|
||||
/* Container(
|
||||
width: 40,
|
||||
height: 5,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[400],
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
),*/
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
bottomSheetController.hide();
|
||||
bottomSheetController.toggle();
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Row(
|
||||
@@ -83,7 +74,7 @@ class DraggableBottomSheet extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Expanded(child: child ?? SizedBox.shrink()),
|
||||
child ?? SizedBox.shrink(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
|
||||
class DraggableBottomSheetController extends GetxController {
|
||||
// Observable variables
|
||||
final RxBool isVisible = false.obs;
|
||||
@@ -19,7 +17,7 @@ class DraggableBottomSheetController extends GetxController {
|
||||
this.maxHeight = 700,
|
||||
}) {
|
||||
isVisible.value = initialVisibility;
|
||||
currentHeight.value = initialHeight;
|
||||
currentHeight.value = 0;
|
||||
}
|
||||
|
||||
// Show the bottom sheet
|
||||
@@ -53,14 +51,15 @@ class DraggableBottomSheetController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// Update height (usually called during drag)
|
||||
void updateHeight(double delta) {
|
||||
final newHeight = currentHeight.value - delta;
|
||||
if(newHeight < minHeight) {
|
||||
hide();
|
||||
return;
|
||||
void updateHeight(double? delta) {
|
||||
if (delta == null) return;
|
||||
final newHeight = (currentHeight.value - delta).clamp(minHeight, maxHeight);
|
||||
|
||||
if (newHeight <= minHeight) {
|
||||
toggle();
|
||||
} else {
|
||||
currentHeight.value = newHeight;
|
||||
}
|
||||
currentHeight.value = newHeight.clamp(minHeight, maxHeight);
|
||||
}
|
||||
|
||||
// Expand to maximum height
|
||||
@@ -73,4 +72,4 @@ class DraggableBottomSheetController extends GetxController {
|
||||
void collapse() {
|
||||
currentHeight.value = minHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user