fix layout issues in ipad windowed mode (#3060)

malik1004x committed Mar 13, 2026 at 01:57 UTC 79a0115a7a4eb1e076234f0b8bee11080e6efcb2
2 files changed +52 -40
lib/new-ui/widgets/coins_page/cards/cards_view.dart
+11 -11
@@ -61,8 +61,6 @@ class _CardsViewState extends State<CardsView> {
61 static const Duration animDuration = Duration(milliseconds: 200);
62 static const int compactModeTreshold = 4;
63 static const int maxCards = 5;
64 - late final double cardWidth = MediaQuery.of(context).size.width * 0.878;
65 - late final double effectiveCardWidth = min(cardWidth, 768);
64
65 Widget _buildCard(int visualIndex, int realIndex, int numCards, double parentWidth,
66 Map<int, int> order, bool compactMode, double overlapAmount) {
@@ -74,6 +72,9 @@ class _CardsViewState extends State<CardsView> {
72
73 final top = baseTop - (howFarBehind * overlapAmount);
74
75 + final double cardWidth = MediaQuery.of(context).size.width * 0.878;
76 + final double effectiveCardWidth = min(cardWidth, 768);
77 +
78 final left = (parentWidth - effectiveCardWidth) / 2.0;
79
80 return AnimatedPositioned(
@@ -220,6 +221,8 @@ class _CardsViewState extends State<CardsView> {
221 }
222
223 double _getBoxHeight(int numCards, double overlapAmount) {
224 + final double cardWidth = MediaQuery.of(context).size.width * 0.878;
225 + final double effectiveCardWidth = min(cardWidth, 768);
226 return
227 /* height of initial card */
228 (2 / 3.2) * (effectiveCardWidth) +
@@ -267,6 +270,7 @@ class _CardsViewState extends State<CardsView> {
270
271 if (visualIndex == _selectedIndex &&
272 widget.accountListViewModel != null &&
273 + realIndex < widget.accountListViewModel!.accounts.length &&
274 widget.accountListViewModel?.selected.label !=
275 widget.accountListViewModel?.accounts[realIndex].label) {
276 widget.accountListViewModel!
@@ -282,15 +286,11 @@ class _CardsViewState extends State<CardsView> {
286 curve: Curves.easeOut,
287 width: double.infinity,
288 height: _getBoxHeight(numCards, overlapAmount),
285 - child: AnimatedSwitcher(
286 - duration: Duration(milliseconds: 200),
287 - transitionBuilder: (child, animation) => FadeTransition(opacity: animation, child: child),
288 - child: SizedBox(
289 - key: ValueKey(_getBoxHeight(numCards, overlapAmount)),
290 - width: double.infinity,
291 - height: _getBoxHeight(numCards, overlapAmount),
292 - child: Stack(alignment: Alignment.center, children: children),
293 - ),
289 + child: SizedBox(
290 + key: ValueKey(_getBoxHeight(numCards, overlapAmount)),
291 + width: double.infinity,
292 + height: _getBoxHeight(numCards, overlapAmount),
293 + child: Stack(alignment: Alignment.center, children: children),
294 ),
295 );
296 });
lib/new-ui/widgets/coins_page/top_bar_widget/top_bar.dart
+41 -29
@@ -1,3 +1,5 @@
1 +import 'dart:io';
2 +
3 import 'package:cake_wallet/new-ui/widgets/coins_page/top_bar_widget/chain_icon.dart';
4 import 'package:cake_wallet/new-ui/widgets/coins_page/top_bar_widget/lightning_switcher.dart';
5 import 'package:cake_wallet/new-ui/widgets/coins_page/top_bar_widget/sync_bar.dart';
@@ -23,37 +25,47 @@ class TopBar extends StatelessWidget {
25
26 @override
27 Widget build(BuildContext context) {
26 - return Padding(
27 - padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 10),
28 - child: Observer(
29 - builder: (_) => Row(
30 - spacing: 12,
31 - children: [
32 - (dashboardViewModel.hasLightning)
33 - ? LightningSwitcher(
34 - lightningMode: lightningMode,
35 - onLightningSwitchPress: onLightningSwitchPress,
36 - )
37 - : ChainIcon(
38 - iconPath: dashboardViewModel.wallet.currency.flatIconPath ?? "",
39 - dashboardViewModel: dashboardViewModel,
40 - isSyncHeavy: dashboardViewModel.isSyncHeavy),
41 - SyncBar(
42 - dashboardViewModel: dashboardViewModel,
43 - isSyncHeavy: dashboardViewModel.isSyncHeavy,
44 - ),
45 - ModernButton.svg(
46 - iconColor: Theme.of(context).colorScheme.primary,
47 - size: 36,
48 - onPressed: () {
49 - HapticFeedback.mediumImpact();
50 - onSettingsButtonPress();
51 - },
52 - svgPath: "assets/new-ui/top-settings.svg",
53 - ),
54 - ],
28 + return SafeArea(
29 + child: Padding(
30 + padding: EdgeInsets.only(bottom: 10, left: 18, right:18, top: 10+_additionalTopPadding(context)),
31 + child: Observer(
32 + builder: (_) => Row(
33 + spacing: 12,
34 + children: [
35 + (dashboardViewModel.hasLightning)
36 + ? LightningSwitcher(
37 + lightningMode: lightningMode,
38 + onLightningSwitchPress: onLightningSwitchPress,
39 + )
40 + : ChainIcon(
41 + iconPath: dashboardViewModel.wallet.currency.flatIconPath ?? "",
42 + dashboardViewModel: dashboardViewModel,
43 + isSyncHeavy: dashboardViewModel.isSyncHeavy),
44 + SyncBar(
45 + dashboardViewModel: dashboardViewModel,
46 + isSyncHeavy: dashboardViewModel.isSyncHeavy,
47 + ),
48 + ModernButton.svg(
49 + iconColor: Theme.of(context).colorScheme.primary,
50 + size: 36,
51 + onPressed: () {
52 + HapticFeedback.mediumImpact();
53 + onSettingsButtonPress();
54 + },
55 + svgPath: "assets/new-ui/top-settings.svg",
56 + ),
57 + ],
58 + ),
59 ),
60 ),
61 );
62 }
63 +
64 +
65 + //FIXME remove after this gets fixed flutter-side
66 + double _additionalTopPadding(BuildContext context) {
67 + if(Platform.isIOS && MediaQuery.of(context).viewPadding.top < 12) return 24;
68 +
69 + return 0;
70 + }
71 }