diff --git a/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet.dart b/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet.dart index 90e8b3d..ed56eba 100644 --- a/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet.dart +++ b/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet.dart @@ -2,6 +2,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/common/app_color.dart'; import 'package:rasadyar_core/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet_controller.dart'; class DraggableBottomSheet extends StatelessWidget { @@ -17,7 +18,7 @@ class DraggableBottomSheet extends StatelessWidget { super.key, this.controller, this.isVisible = false, - this.backgroundColor = Colors.white, + this.backgroundColor = AppColor.lightGreyNormal, this.initialHeight = 200, this.minHeight = 0, this.maxHeight = 700, diff --git a/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet_controller.dart b/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet_controller.dart index e42138e..8c57cdf 100644 --- a/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet_controller.dart +++ b/packages/core/lib/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet_controller.dart @@ -1,6 +1,12 @@ +import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:rasadyar_core/core.dart'; +import 'draggable_bottom_sheet.dart'; class DraggableBottomSheetController extends GetxController { + final RxList bottomSheets = + [].obs; + // Observable variables final RxBool isVisible = false.obs; final RxDouble currentHeight = 200.0.obs; @@ -17,7 +23,7 @@ class DraggableBottomSheetController extends GetxController { this.maxHeight = 700, }) { isVisible.value = initialVisibility; - currentHeight.value = 0; + currentHeight.value = initialHeight; } // Show the bottom sheet @@ -72,4 +78,50 @@ class DraggableBottomSheetController extends GetxController { void collapse() { currentHeight.value = minHeight; } + + void addBottomSheet({ + required Widget child, + required double initHeight, + required double maxHeight, + required double minHeight, + }) { + final controller = DraggableBottomSheetController( + initialVisibility: true, + initialHeight: initHeight, + minHeight: minHeight, + maxHeight: maxHeight, + ); + + final bottomSheet = DraggableBottomSheet( + controller: controller, + backgroundColor: AppColor.lightGreyLightActive, + child: child, + ); + if (bottomSheets.isNotEmpty) { + bottomSheets.removeLast(); + } + + bottomSheets.add(bottomSheet); + } + + void removeLastBottomSheet() { + if (bottomSheets.isNotEmpty) { + bottomSheets.last.controller?.hide(); + Future.delayed(Duration(milliseconds: 200), () { + bottomSheets.removeLast(); + if(bottomSheets.isNotEmpty){ + bottomSheets.last.controller?.show(); + } + + }); + } + } + + bool handleBack() { + if (bottomSheets.isNotEmpty) { + removeLastBottomSheet(); + return true; + } + return false; + } }