1-bottom sheet
2-details filter
3- animated to current location
4-
This commit is contained in:
2025-04-13 12:00:13 +03:30
parent 503dcd91b8
commit 28d43aa027
13 changed files with 529 additions and 99 deletions

View File

@@ -9,6 +9,7 @@ class Assets {
static const String iconsDownload = 'assets/icons/download.svg';
static const String iconsEdit = 'assets/icons/edit.svg';
static const String iconsFilter = 'assets/icons/filter.svg';
static const String iconsGps = 'assets/icons/gps.svg';
static const String iconsKey = 'assets/icons/key.svg';
static const String iconsMap = 'assets/icons/map.svg';
static const String iconsMapMarker = 'assets/icons/map_marker.svg';
@@ -25,6 +26,7 @@ class Assets {
static const String vecDownloadSvg = 'assets/vec/download.svg.vec';
static const String vecEditSvg = 'assets/vec/edit.svg.vec';
static const String vecFilterSvg = 'assets/vec/filter.svg.vec';
static const String vecGpsSvg = 'assets/vec/gps.svg.vec';
static const String vecKeySvg = 'assets/vec/key.svg.vec';
static const String vecMapMarkerSvg = 'assets/vec/map_marker.svg.vec';
static const String vecMapSvg = 'assets/vec/map.svg.vec';

View File

@@ -5,16 +5,15 @@ import 'package:rasadyar_core/presentation/utils/color_utils.dart';
import 'package:rasadyar_core/presentation/widget/vec_widget.dart';
class RFab extends StatefulWidget {
final VoidCallback? onPressed;
Color? foregroundColor;
Color? backgroundColor;
Color? disabledForegroundColor;
Color? disabledBackgroundColor;
double? radius;
double radius;
ShapeBorder? shapeBorder;
Widget? icon;
bool isLoading;
@override
State<RFab> createState() => _RFabState();
@@ -177,6 +176,7 @@ class RFab extends StatefulWidget {
required this.icon,
required this.backgroundColor,
super.key,
this.isLoading = false,
}) : radius = 40.0,
foregroundColor = Colors.white;
@@ -184,6 +184,7 @@ class RFab extends StatefulWidget {
required this.onPressed,
required this.icon,
required this.backgroundColor,
this.isLoading = false,
super.key,
}) : radius = 56.0,
foregroundColor = Colors.white;
@@ -195,7 +196,7 @@ class _RFabState extends State<RFab> {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: widget.onPressed,
onPressed: widget.isLoading == false ? widget.onPressed : null,
style: ButtonStyle(
side: WidgetStateProperty.all(BorderSide.none),
backgroundColor: WidgetStateProperty.resolveWith<Color?>((states) {
@@ -226,7 +227,19 @@ class _RFabState extends State<RFab> {
),
padding: WidgetStatePropertyAll(EdgeInsets.zero),
),
child: widget.icon,
child:
widget.isLoading
? SizedBox(
height: widget.radius / 2,
width: widget.radius / 2,
child: CircularProgressIndicator(
strokeWidth: 2.5,
valueColor: AlwaysStoppedAnimation<Color>(
widget.foregroundColor ?? Colors.white,
),
),
)
: widget.icon,
);
}
}

View File

@@ -0,0 +1,95 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rasadyar_core/presentation/widget/draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';
class DraggableBottomSheet extends StatelessWidget {
final DraggableBottomSheetController? controller;
final bool isVisible;
final double initialHeight;
final double minHeight;
final double maxHeight;
final Widget? child;
const DraggableBottomSheet({
super.key,
this.controller,
this.isVisible = false,
this.initialHeight = 200,
this.minHeight = 0,
this.maxHeight = 700,
this.child,
});
@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
initialHeight: initialHeight,
minHeight: minHeight,
maxHeight: maxHeight,
),
tag: 'local_$hashCode',
);
// Optionally show after first frame if isVisible is true
WidgetsBinding.instance.addPostFrameCallback((_) {
if (isVisible && !bottomSheetController.isVisible.value) {
bottomSheetController.show();
}
});
return ObxValue(
(data) => AnimatedPositioned(
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
bottom: bottomSheetController.isVisible.value ? 0 : -maxHeight,
left: 0,
right: 0,
child: GestureDetector(
onVerticalDragUpdate: (DragUpdateDetails details) {
bottomSheetController.updateHeight(details.delta.dy);
},
child: Container(
height: data.value,
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(50)),
),
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();
},
behavior: HitTestBehavior.opaque,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [const Icon(CupertinoIcons.chevron_down)],
),
),
const SizedBox(height: 10),
Expanded(child: child ?? SizedBox.shrink()),
],
),
),
),
),
bottomSheetController.currentHeight,
);
}
}

View File

@@ -0,0 +1,76 @@
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
class DraggableBottomSheetController extends GetxController {
// Observable variables
final RxBool isVisible = false.obs;
final RxDouble currentHeight = 200.0.obs;
// Configuration values
final double initialHeight;
final double minHeight;
final double maxHeight;
DraggableBottomSheetController({
bool initialVisibility = false,
this.initialHeight = 200,
this.minHeight = 0,
this.maxHeight = 700,
}) {
isVisible.value = initialVisibility;
currentHeight.value = initialHeight;
}
// Show the bottom sheet
void show() {
if (!isVisible.value) {
isVisible.value = true;
currentHeight.value = initialHeight;
}
}
// Hide the bottom sheet
void hide() {
if (isVisible.value) {
isVisible.value = false;
}
}
// Toggle visibility
void toggle() {
isVisible.value = !isVisible.value;
if (isVisible.value) {
currentHeight.value = initialHeight;
}
}
// Set a specific height for the bottom sheet
void setHeight(double height) {
final clampedHeight = height.clamp(minHeight, maxHeight);
if (currentHeight.value != clampedHeight) {
currentHeight.value = clampedHeight;
}
}
// Update height (usually called during drag)
void updateHeight(double delta) {
final newHeight = currentHeight.value - delta;
if(newHeight < minHeight) {
hide();
return;
}
currentHeight.value = newHeight.clamp(minHeight, maxHeight);
}
// Expand to maximum height
void expandFully() {
currentHeight.value = maxHeight;
isVisible.value = true;
}
// Collapse to minimum height
void collapse() {
currentHeight.value = minHeight;
}
}

View File

@@ -1,2 +1,4 @@
export 'vec_widget.dart';
export 'bottom_navigation/bottom_navigation_1.dart';
export 'draggable_bottom_sheet/draggable_bottom_sheet.dart';
export 'draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';