mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 09:41:13 +03:00
step
This commit is contained in:
@@ -95,7 +95,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
|
||||
Positioned(
|
||||
left: 8,
|
||||
right: 8,
|
||||
bottom: -20,
|
||||
bottom: 0,
|
||||
child: _HeightResizeHandle(
|
||||
cardHeight: cardHeight,
|
||||
onHeightChanged: (newHeight) {
|
||||
@@ -828,39 +828,83 @@ class _HeightResizeHandle extends StatefulWidget {
|
||||
|
||||
class _HeightResizeHandleState extends State<_HeightResizeHandle> {
|
||||
bool _dragging = false;
|
||||
double _lastHeight = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final canShrink = widget.cardHeight > CardHeightNotifier.minHeight;
|
||||
final canGrow = widget.cardHeight < CardHeightNotifier.maxHeight;
|
||||
|
||||
return GestureDetector(
|
||||
onVerticalDragStart: (_) => setState(() => _dragging = true),
|
||||
onVerticalDragStart: (_) {
|
||||
setState(() => _dragging = true);
|
||||
_lastHeight = widget.cardHeight;
|
||||
},
|
||||
onVerticalDragUpdate: (details) {
|
||||
final newHeight = widget.cardHeight + details.delta.dy * 2;
|
||||
if ((newHeight - _lastHeight).abs() > 0.5) {
|
||||
widget.onHeightChanged(newHeight);
|
||||
_lastHeight = newHeight;
|
||||
}
|
||||
},
|
||||
onVerticalDragEnd: (_) => setState(() => _dragging = false),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: SizedBox(
|
||||
height: 44,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
top: 0,
|
||||
child: CustomPaint(
|
||||
size: const Size(double.infinity, 0),
|
||||
painter: _DashedLinePainter(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 6,
|
||||
child: Container(
|
||||
height: 32,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surface,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CustomPaint(
|
||||
size: const Size(double.infinity, 1),
|
||||
painter: _DashedLinePainter(
|
||||
color: theme.colorScheme.onSurface.withOpacity(_dragging ? 0.4 : 0.2),
|
||||
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),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
width: _dragging ? 48 : 36,
|
||||
height: _dragging ? 5 : 4,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onSurface.withOpacity(_dragging ? 0.5 : 0.25),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -878,11 +922,12 @@ class _DashedLinePainter extends CustomPainter {
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final paint = Paint()
|
||||
..color = color
|
||||
..strokeWidth = 1
|
||||
..style = PaintingStyle.stroke;
|
||||
..strokeWidth = 2
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeCap = StrokeCap.round;
|
||||
|
||||
const dashWidth = 6.0;
|
||||
const dashSpace = 4.0;
|
||||
const dashWidth = 10.0;
|
||||
const dashSpace = 6.0;
|
||||
double x = 0;
|
||||
while (x < size.width) {
|
||||
canvas.drawLine(
|
||||
|
||||
@@ -109,8 +109,8 @@ final cardHeightProvider = NotifierProvider<CardHeightNotifier, double>(
|
||||
|
||||
class CardHeightNotifier extends Notifier<double> {
|
||||
static const _key = 'card_height';
|
||||
static const _minHeight = 140.0;
|
||||
static const _maxHeight = 200.0;
|
||||
static const minHeight = 140.0;
|
||||
static const maxHeight = 200.0;
|
||||
static const _defaultHeight = 200.0;
|
||||
|
||||
@override
|
||||
@@ -118,11 +118,11 @@ class CardHeightNotifier extends Notifier<double> {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
final saved = prefs.getDouble(_key);
|
||||
if (saved == null) return _defaultHeight;
|
||||
return saved.clamp(_minHeight, _maxHeight);
|
||||
return saved.clamp(minHeight, maxHeight);
|
||||
}
|
||||
|
||||
void set(double height) {
|
||||
final clamped = height.clamp(_minHeight, _maxHeight);
|
||||
final clamped = height.clamp(minHeight, maxHeight);
|
||||
state = clamped;
|
||||
ref.read(sharedPreferencesProvider).setDouble(_key, clamped);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user