This commit is contained in:
2026-06-28 15:10:17 +03:00
parent 2b89545248
commit f2d444cb16
5 changed files with 114 additions and 15 deletions
@@ -87,15 +87,15 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
final mq = MediaQuery.of(widget.context);
final layout = CardOverlayLayout.fromMediaQuery(mq);
final cardTop = layout.cardTop;
final cardHeight = layout.cardHeight;
final editorPanelHeight = layout.editorPanelHeight;
final editorPanelTop = cardTop + cardHeight + layout.sectionGap;
final colorPanelTop = editorPanelTop + editorPanelHeight + layout.sectionGap;
final colorPanelHeight = layout.colorPanelHeight(mq, colorPanelTop);
return Consumer(
builder: (context, ref, _) {
final exchangeService = ref.watch(exchangeRateServiceProvider);
final cardHeight = ref.watch(cardHeightProvider);
final editorPanelTop = cardTop + cardHeight + layout.sectionGap;
final colorPanelTop = editorPanelTop + editorPanelHeight + layout.sectionGap;
final colorPanelHeight = layout.colorPanelHeight(mq, colorPanelTop);
double previewBalance = 0.0;
if (!dash.isAddingAccount) {
@@ -220,11 +220,38 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
Brightness.dark
? dash.tempDarkGradientType
: dash.tempLightGradientType,
cardHeight: cardHeight,
),
),
),
),
),
Positioned(
top: cardTop - 28,
left: 0,
right: 0,
child: Center(
child: _HeightHandle(
onDrag: (delta) {
final newHeight = cardHeight - delta * 2;
ref.read(cardHeightProvider.notifier).set(newHeight);
},
),
),
),
Positioned(
top: cardTop + cardHeight + 6,
left: 0,
right: 0,
child: Center(
child: _HeightHandle(
onDrag: (delta) {
final newHeight = cardHeight + delta * 2;
ref.read(cardHeightProvider.notifier).set(newHeight);
},
),
),
),
Positioned(
top: editorPanelTop,
left: 20,
@@ -468,3 +495,36 @@ class _AccountEditorOverlayState extends State<AccountEditorOverlay> {
);
}
}
class _HeightHandle extends StatefulWidget {
final ValueChanged<double> onDrag;
const _HeightHandle({required this.onDrag});
@override
State<_HeightHandle> createState() => _HeightHandleState();
}
class _HeightHandleState extends State<_HeightHandle> {
bool _active = false;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return GestureDetector(
onVerticalDragStart: (_) => setState(() => _active = true),
onVerticalDragUpdate: (details) => widget.onDrag(details.delta.dy),
onVerticalDragEnd: (_) => setState(() => _active = false),
behavior: HitTestBehavior.opaque,
child: AnimatedContainer(
duration: const Duration(milliseconds: 150),
width: _active ? 56 : 44,
height: _active ? 6 : 4,
decoration: BoxDecoration(
color: theme.colorScheme.onSurface.withOpacity(_active ? 0.5 : 0.25),
borderRadius: BorderRadius.circular(3),
),
),
);
}
}
@@ -37,6 +37,7 @@ class BalanceCard extends ConsumerStatefulWidget {
final GradientType? previewGradientType;
final String? accountName;
final CardColors? accountColors;
final double? cardHeight;
const BalanceCard({
super.key,
@@ -48,6 +49,7 @@ class BalanceCard extends ConsumerStatefulWidget {
this.previewGradientType,
this.accountName,
this.accountColors,
this.cardHeight,
});
@override
@@ -132,7 +134,7 @@ class BalanceCardState extends ConsumerState<BalanceCard>
..rotateY(_tiltY * 0.42),
child: Container(
width: double.infinity,
height: kBalanceCardHeight,
height: widget.cardHeight ?? kBalanceCardHeight,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
gradient: buildCardGradient(primary, secondary, gradientType),
@@ -59,6 +59,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
Widget build(BuildContext context) {
final accountsAsync = ref.watch(accountsProvider);
final activeIndex = ref.watch(activeAccountIndexProvider);
final cardHeight = ref.watch(cardHeightProvider);
return accountsAsync.when(
data: (accounts) {
@@ -67,7 +68,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
return Column(
children: [
SizedBox(
height: kBalanceCardCarouselHeight,
height: cardHeight + 10,
child: OverflowBox(
maxWidth: MediaQuery.of(context).size.width,
child: PageView.builder(
@@ -96,6 +97,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
previewPrimary: widget.previewPrimary,
previewSecondary: widget.previewSecondary,
previewGradientType: widget.previewGradientType,
cardHeight: cardHeight,
);
} else if (index <= accounts.length) {
final account = accounts[index - 1];
@@ -134,10 +136,12 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
widget.onAccountLongPress?.call(account),
accountName: account.name,
accountColors: accountColors,
cardHeight: cardHeight,
);
} else {
cardWidget = AddAccountCard(
onTap: widget.onAddAccountTap,
cardHeight: cardHeight,
);
}
@@ -154,15 +158,15 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
],
);
},
loading: () => const SizedBox(
height: kBalanceCardCarouselHeight,
child: Center(child: CircularProgressIndicator()),
loading: () => SizedBox(
height: cardHeight + 10,
child: const Center(child: CircularProgressIndicator()),
),
error: (error, stack) {
return Column(
children: [
SizedBox(
height: kBalanceCardCarouselHeight,
height: cardHeight + 10,
child: BalanceCard(
balance: widget.balance,
currencyInfo: widget.currencyInfo,
@@ -170,6 +174,7 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
previewPrimary: widget.previewPrimary,
previewSecondary: widget.previewSecondary,
previewGradientType: widget.previewGradientType,
cardHeight: cardHeight,
),
),
const SizedBox(height: 12),
@@ -183,8 +188,9 @@ class _BalanceCardCarouselState extends ConsumerState<BalanceCardCarousel> {
class AddAccountCard extends StatelessWidget {
final VoidCallback? onTap;
final double? cardHeight;
const AddAccountCard({super.key, this.onTap});
const AddAccountCard({super.key, this.onTap, this.cardHeight});
@override
Widget build(BuildContext context) {
@@ -199,7 +205,7 @@ class AddAccountCard extends StatelessWidget {
painter: _DashedBorderPainter(),
child: Container(
width: double.infinity,
height: kAddAccountCardHeight,
height: cardHeight ?? kAddAccountCardHeight,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface.withOpacity(0.4),
borderRadius: BorderRadius.circular(20),
@@ -37,9 +37,12 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
final mq = MediaQuery.of(widget.context);
final layout = CardOverlayLayout.fromMediaQuery(mq);
final cardTop = layout.cardTop;
final cardHeight = layout.cardHeight;
final panelTop = cardTop + cardHeight + layout.cardPreviewGap;
final panelHeight = layout.colorPanelHeight(mq, panelTop);
return Consumer(
builder: (context, ref, _) {
final cardHeight = ref.watch(cardHeightProvider);
final panelTop = cardTop + cardHeight + layout.cardPreviewGap;
final panelHeight = layout.colorPanelHeight(mq, panelTop);
return Material(
color: Colors.transparent,
@@ -80,6 +83,7 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
Theme.of(widget.context).brightness == Brightness.dark
? dash.tempDarkGradientType
: dash.tempLightGradientType,
cardHeight: cardHeight,
),
),
),
@@ -132,6 +136,8 @@ class _FullScreenBlurOverlayState extends State<FullScreenBlurOverlay> {
],
),
);
},
);
}
Widget _buildPanel(double panelHeight, CardOverlayLayout layout) {