fix ui edge cases (#3109)

* wrap navbar in observer to account for disabling pages

* always display fiat amount with 2 decimals on confirm sheet

* don't show limit popup if max limit is 0 (this signifies the providers didn't load yet)

* fix deposit amount getting set to "ALL" in race condition

* disable showing hardware wallets on l2 wallet selector

* fix reset in account customizer if designs weren't loaded properly

* add withDecimals string extension

* add fallback on failed display amount parse
This commit is contained in:
malik1004x
2026-03-18 22:34:02 +01:00
committed by GitHub
parent 410c496bfc
commit 24cceb5795
8 changed files with 151 additions and 109 deletions
@@ -2,6 +2,7 @@ import 'dart:io';
import 'dart:ui';
import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:cake_wallet/entities/new_main_actions.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
@@ -123,124 +124,126 @@ class _NEWNewMainNavBarState extends State<NewMainNavBar> {
final activeColor = theme.colorScheme.onSurface;
final inactiveColor = theme.colorScheme.primary;
final visibleActions = NewMainActions.all
.where(
(action) => action.canShow?.call(widget.dashboardViewModel) ?? true)
.toList();
return Observer(
builder: (_) {
final visibleActions = NewMainActions.all
.where((action) => action.canShow?.call(widget.dashboardViewModel) ?? true)
.toList();
final pillWidth = _estimatePillWidthForAction(
context, visibleActions[widget.selectedIndex],
color: activeColor);
final pillWidth = _estimatePillWidthForAction(context, visibleActions[widget.selectedIndex],
color: activeColor);
final barWidth = calcBarWidth(pillWidth, visibleActions.length);
final barWidth = calcBarWidth(pillWidth, visibleActions.length);
final currentAction = visibleActions[widget.selectedIndex];
final currentAction = visibleActions[widget.selectedIndex];
return Align(
alignment: Alignment.bottomCenter,
child: SafeArea(
bottom: !(Platform.isIOS),
top: false,
child: Padding(
// tux PLEASE consult me (malik) before removing this padding.
padding: EdgeInsets.only(bottom: NewMainNavBar.barBottomPadding),
child: AnimatedContainer(
duration: barResizeDuration,
curve: Curves.easeOutCubic,
width: barWidth,
child: ClipRSuperellipse(
borderRadius: BorderRadius.circular(barBorderRadius),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
child: Container(
height: NewMainNavBar.barHeight,
decoration: ShapeDecoration(
color: backgroundColor,
shape: RoundedSuperellipseBorder(borderRadius: BorderRadius.circular(barBorderRadius),
side: const BorderSide(color: Color(0x14FFFFFF), width: 1),
return Align(
alignment: Alignment.bottomCenter,
child: SafeArea(
bottom: !(Platform.isIOS),
top: false,
child: Padding(
// tux PLEASE consult me (malik) before removing this padding.
padding: EdgeInsets.only(bottom: NewMainNavBar.barBottomPadding),
child: AnimatedContainer(
duration: barResizeDuration,
curve: Curves.easeOutCubic,
width: barWidth,
child: ClipRSuperellipse(
borderRadius: BorderRadius.circular(barBorderRadius),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 3, sigmaY: 3),
child: Container(
height: NewMainNavBar.barHeight,
decoration: ShapeDecoration(
color: backgroundColor,
shape: RoundedSuperellipseBorder(borderRadius: BorderRadius.circular(barBorderRadius),
side: const BorderSide(color: Color(0x14FFFFFF), width: 1),
),
),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: barHorizontalPadding),
child: Stack(
alignment: Alignment.center,
children: [
AnimatedPill(
left: calcLeft(widget.selectedIndex, pillWidth),
pillColor: pillColor,
currentAction: currentAction,
pillIconHeight: pillIconHeight,
pillIconWidth: pillIconWidth,
pillIconSpacing: pillIconSpacing,
pillBorderRadius: pillBorderRadius,
contentColor: activeColor,
estimateWidthForAction: pillWidth,
pillTextStyle: pillTextStyle,
pillMoveDuration: pillMoveDuration,
pillResizeDuration: pillResizeDuration,
),
for (int i = 0; i < visibleActions.length; i++)
AnimatedPositioned(
duration: pillResizeDuration,
width: iconBoxWidth,
left: calcLeft(i, pillWidth)+((i == widget.selectedIndex) ? iconHorizontalPadding/100 : 0),
curve: Curves.easeOutCubic,
child: InkWell(
splashFactory: NoSplash.splashFactory,
splashColor: Colors.transparent,
borderRadius: BorderRadius.circular(pillBorderRadius),
onTap: () => _onItemTap(i),
child: AnimatedContainer(
duration: _firstFrame
? Duration.zero
: inactiveIconMoveDuration,
curve: Curves.easeOutCubic,
width:
i == widget.selectedIndex ? pillWidth : iconBoxWidth,
alignment: Alignment.center,
child: AnimatedAlign(
duration: inactiveIconFadeDuration,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: barHorizontalPadding),
child: Stack(
alignment: Alignment.center,
children: [
AnimatedPill(
left: calcLeft(widget.selectedIndex, pillWidth),
pillColor: pillColor,
currentAction: currentAction,
pillIconHeight: pillIconHeight,
pillIconWidth: pillIconWidth,
pillIconSpacing: pillIconSpacing,
pillBorderRadius: pillBorderRadius,
contentColor: activeColor,
estimateWidthForAction: pillWidth,
pillTextStyle: pillTextStyle,
pillMoveDuration: pillMoveDuration,
pillResizeDuration: pillResizeDuration,
),
for (int i = 0; i < visibleActions.length; i++)
AnimatedPositioned(
duration: pillResizeDuration,
width: iconBoxWidth,
left: calcLeft(i, pillWidth)+((i == widget.selectedIndex) ? iconHorizontalPadding/100 : 0),
curve: Curves.easeOutCubic,
child: InkWell(
splashFactory: NoSplash.splashFactory,
splashColor: Colors.transparent,
borderRadius: BorderRadius.circular(pillBorderRadius),
onTap: () => _onItemTap(i),
child: AnimatedContainer(
duration: _firstFrame
? Duration.zero
: inactiveIconMoveDuration,
curve: Curves.easeOutCubic,
width:
i == widget.selectedIndex ? pillWidth : iconBoxWidth,
alignment: Alignment.center,
child: AnimatedScale(
duration: inactiveIconAppearDuration,
child: AnimatedAlign(
duration: inactiveIconFadeDuration,
curve: Curves.easeOutCubic,
scale: (i == widget.selectedIndex) ? 0.857 : 1.0,
child: TweenAnimationBuilder<Color?>(
tween: ColorTween(
begin: (i == widget.selectedIndex) ? inactiveColor : activeColor,
end: (i==widget.selectedIndex) ? activeColor : inactiveColor,
),
duration: iconColorChangeDuration,
builder: (context, value, child) {
return Container(
height: NewMainNavBar.barHeight,
child: CakeImageWidget(imageUrl:
visibleActions[i].image,
width: iconWidth,
height: iconHeight,
//fit: BoxFit.scaleDown,
colorFilter: ColorFilter.mode(
value ?? inactiveColor,
BlendMode.srcIn,
alignment: Alignment.center,
child: AnimatedScale(
duration: inactiveIconAppearDuration,
curve: Curves.easeOutCubic,
scale: (i == widget.selectedIndex) ? 0.857 : 1.0,
child: TweenAnimationBuilder<Color?>(
tween: ColorTween(
begin: (i == widget.selectedIndex) ? inactiveColor : activeColor,
end: (i==widget.selectedIndex) ? activeColor : inactiveColor,
),
duration: iconColorChangeDuration,
builder: (context, value, child) {
return Container(
height: NewMainNavBar.barHeight,
child: CakeImageWidget(imageUrl:
visibleActions[i].image,
width: iconWidth,
height: iconHeight,
//fit: BoxFit.scaleDown,
colorFilter: ColorFilter.mode(
value ?? inactiveColor,
BlendMode.srcIn,
),
),
),
);
}
);
}
),
),
),
),
),
),
),
],
),
)),
],
),
)),
),
),
),
),
),
),
);
},
);
}
}