This commit is contained in:
2026-06-28 16:16:19 +03:00
parent 5891440a0c
commit 3adac05cdf
2 changed files with 73 additions and 28 deletions
@@ -95,7 +95,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
Positioned( Positioned(
left: 8, left: 8,
right: 8, right: 8,
bottom: -20, bottom: 0,
child: _HeightResizeHandle( child: _HeightResizeHandle(
cardHeight: cardHeight, cardHeight: cardHeight,
onHeightChanged: (newHeight) { onHeightChanged: (newHeight) {
@@ -828,38 +828,82 @@ class _HeightResizeHandle extends StatefulWidget {
class _HeightResizeHandleState extends State<_HeightResizeHandle> { class _HeightResizeHandleState extends State<_HeightResizeHandle> {
bool _dragging = false; bool _dragging = false;
double _lastHeight = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final canShrink = widget.cardHeight > CardHeightNotifier.minHeight;
final canGrow = widget.cardHeight < CardHeightNotifier.maxHeight;
return GestureDetector( return GestureDetector(
onVerticalDragStart: (_) => setState(() => _dragging = true), onVerticalDragStart: (_) {
setState(() => _dragging = true);
_lastHeight = widget.cardHeight;
},
onVerticalDragUpdate: (details) { onVerticalDragUpdate: (details) {
final newHeight = widget.cardHeight + details.delta.dy * 2; final newHeight = widget.cardHeight + details.delta.dy * 2;
widget.onHeightChanged(newHeight); if ((newHeight - _lastHeight).abs() > 0.5) {
widget.onHeightChanged(newHeight);
_lastHeight = newHeight;
}
}, },
onVerticalDragEnd: (_) => setState(() => _dragging = false), onVerticalDragEnd: (_) => setState(() => _dragging = false),
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: Container( child: SizedBox(
height: 32, height: 44,
padding: const EdgeInsets.symmetric(horizontal: 20), child: Stack(
child: Column( clipBehavior: Clip.none,
mainAxisAlignment: MainAxisAlignment.center, alignment: Alignment.center,
children: [ children: [
CustomPaint( Positioned(
size: const Size(double.infinity, 1), left: 0,
painter: _DashedLinePainter( right: 0,
color: theme.colorScheme.onSurface.withOpacity(_dragging ? 0.4 : 0.2), top: 0,
child: CustomPaint(
size: const Size(double.infinity, 0),
painter: _DashedLinePainter(
color: theme.colorScheme.onSurface.withOpacity(0.5),
),
), ),
), ),
const SizedBox(height: 8), Positioned(
AnimatedContainer( top: 6,
duration: const Duration(milliseconds: 150), child: Container(
width: _dragging ? 48 : 36, width: 44,
height: _dragging ? 5 : 4, height: 44,
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.colorScheme.onSurface.withOpacity(_dragging ? 0.5 : 0.25), color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(3), shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (canGrow)
Icon(
Icons.keyboard_arrow_up_rounded,
size: 16,
color: theme.colorScheme.onSurface.withOpacity(_dragging ? 0.9 : 0.5),
)
else
const SizedBox(height: 6),
if (canShrink)
Icon(
Icons.keyboard_arrow_down_rounded,
size: 16,
color: theme.colorScheme.onSurface.withOpacity(_dragging ? 0.9 : 0.5),
)
else
const SizedBox(height: 6),
],
),
), ),
), ),
], ],
@@ -878,11 +922,12 @@ class _DashedLinePainter extends CustomPainter {
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
final paint = Paint() final paint = Paint()
..color = color ..color = color
..strokeWidth = 1 ..strokeWidth = 2
..style = PaintingStyle.stroke; ..style = PaintingStyle.stroke
..strokeCap = StrokeCap.round;
const dashWidth = 6.0; const dashWidth = 10.0;
const dashSpace = 4.0; const dashSpace = 6.0;
double x = 0; double x = 0;
while (x < size.width) { while (x < size.width) {
canvas.drawLine( canvas.drawLine(
+4 -4
View File
@@ -109,8 +109,8 @@ final cardHeightProvider = NotifierProvider<CardHeightNotifier, double>(
class CardHeightNotifier extends Notifier<double> { class CardHeightNotifier extends Notifier<double> {
static const _key = 'card_height'; static const _key = 'card_height';
static const _minHeight = 140.0; static const minHeight = 140.0;
static const _maxHeight = 200.0; static const maxHeight = 200.0;
static const _defaultHeight = 200.0; static const _defaultHeight = 200.0;
@override @override
@@ -118,11 +118,11 @@ class CardHeightNotifier extends Notifier<double> {
final prefs = ref.watch(sharedPreferencesProvider); final prefs = ref.watch(sharedPreferencesProvider);
final saved = prefs.getDouble(_key); final saved = prefs.getDouble(_key);
if (saved == null) return _defaultHeight; if (saved == null) return _defaultHeight;
return saved.clamp(_minHeight, _maxHeight); return saved.clamp(minHeight, maxHeight);
} }
void set(double height) { void set(double height) {
final clamped = height.clamp(_minHeight, _maxHeight); final clamped = height.clamp(minHeight, maxHeight);
state = clamped; state = clamped;
ref.read(sharedPreferencesProvider).setDouble(_key, clamped); ref.read(sharedPreferencesProvider).setDouble(_key, clamped);
} }