mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
fix: Desktop resize bug (#1461)
* fix: Desktop resize bug * Change default spl tokens * Minor enhancements [skip ci] * minor enhancements [skip ci] --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
dfba5be2cd
commit
461fe1c859
3 changed files with 114 additions and 77 deletions
|
@ -19,30 +19,6 @@ class DefaultSPLTokens {
|
||||||
mint: 'usdcsol',
|
mint: 'usdcsol',
|
||||||
enabled: true,
|
enabled: true,
|
||||||
),
|
),
|
||||||
SPLToken(
|
|
||||||
name: 'Wrapped Ethereum (Sollet)',
|
|
||||||
symbol: 'soETH',
|
|
||||||
mintAddress: '2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk',
|
|
||||||
decimal: 6,
|
|
||||||
mint: 'soEth',
|
|
||||||
iconPath: 'assets/images/eth_icon.png',
|
|
||||||
),
|
|
||||||
SPLToken(
|
|
||||||
name: 'Wrapped SOL',
|
|
||||||
symbol: 'WSOL',
|
|
||||||
mintAddress: 'So11111111111111111111111111111111111111112',
|
|
||||||
decimal: 9,
|
|
||||||
mint: 'WSOL',
|
|
||||||
iconPath: 'assets/images/sol_icon.png',
|
|
||||||
),
|
|
||||||
SPLToken(
|
|
||||||
name: 'Wrapped Bitcoin (Sollet)',
|
|
||||||
symbol: 'BTC',
|
|
||||||
mintAddress: '9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E',
|
|
||||||
decimal: 6,
|
|
||||||
mint: 'btcsol',
|
|
||||||
iconPath: 'assets/images/btc.png',
|
|
||||||
),
|
|
||||||
SPLToken(
|
SPLToken(
|
||||||
name: 'Bonk',
|
name: 'Bonk',
|
||||||
symbol: 'Bonk',
|
symbol: 'Bonk',
|
||||||
|
@ -50,21 +26,7 @@ class DefaultSPLTokens {
|
||||||
decimal: 5,
|
decimal: 5,
|
||||||
mint: 'Bonk',
|
mint: 'Bonk',
|
||||||
iconPath: 'assets/images/bonk_icon.png',
|
iconPath: 'assets/images/bonk_icon.png',
|
||||||
),
|
enabled: true,
|
||||||
SPLToken(
|
|
||||||
name: 'Helium Network Token',
|
|
||||||
symbol: 'HNT',
|
|
||||||
mintAddress: 'hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux',
|
|
||||||
decimal: 8,
|
|
||||||
mint: 'hnt',
|
|
||||||
iconPath: 'assets/images/hnt_icon.png',
|
|
||||||
),
|
|
||||||
SPLToken(
|
|
||||||
name: 'Pyth Network',
|
|
||||||
symbol: 'PYTH',
|
|
||||||
mintAddress: 'HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3',
|
|
||||||
decimal: 6,
|
|
||||||
mint: 'pyth',
|
|
||||||
),
|
),
|
||||||
SPLToken(
|
SPLToken(
|
||||||
name: 'Raydium',
|
name: 'Raydium',
|
||||||
|
@ -73,6 +35,51 @@ class DefaultSPLTokens {
|
||||||
decimal: 6,
|
decimal: 6,
|
||||||
mint: 'ray',
|
mint: 'ray',
|
||||||
iconPath: 'assets/images/ray_icon.png',
|
iconPath: 'assets/images/ray_icon.png',
|
||||||
|
enabled: true,
|
||||||
|
),
|
||||||
|
SPLToken(
|
||||||
|
name: 'Wrapped Ethereum (Sollet)',
|
||||||
|
symbol: 'soETH',
|
||||||
|
mintAddress: '2FPyTwcZLUg1MDrwsyoP4D6s1tM7hAkHYRjkNb5w6Pxk',
|
||||||
|
decimal: 6,
|
||||||
|
mint: 'soEth',
|
||||||
|
iconPath: 'assets/images/eth_icon.png',
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
SPLToken(
|
||||||
|
name: 'Wrapped SOL',
|
||||||
|
symbol: 'WSOL',
|
||||||
|
mintAddress: 'So11111111111111111111111111111111111111112',
|
||||||
|
decimal: 9,
|
||||||
|
mint: 'WSOL',
|
||||||
|
iconPath: 'assets/images/sol_icon.png',
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
SPLToken(
|
||||||
|
name: 'Wrapped Bitcoin (Sollet)',
|
||||||
|
symbol: 'BTC',
|
||||||
|
mintAddress: '9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E',
|
||||||
|
decimal: 6,
|
||||||
|
mint: 'btcsol',
|
||||||
|
iconPath: 'assets/images/btc.png',
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
SPLToken(
|
||||||
|
name: 'Helium Network Token',
|
||||||
|
symbol: 'HNT',
|
||||||
|
mintAddress: 'hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux',
|
||||||
|
decimal: 8,
|
||||||
|
mint: 'hnt',
|
||||||
|
iconPath: 'assets/images/hnt_icon.png',
|
||||||
|
enabled: false,
|
||||||
|
),
|
||||||
|
SPLToken(
|
||||||
|
name: 'Pyth Network',
|
||||||
|
symbol: 'PYTH',
|
||||||
|
mintAddress: 'HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3',
|
||||||
|
decimal: 6,
|
||||||
|
mint: 'pyth',
|
||||||
|
enabled: false,
|
||||||
),
|
),
|
||||||
SPLToken(
|
SPLToken(
|
||||||
name: 'GMT',
|
name: 'GMT',
|
||||||
|
@ -81,6 +88,7 @@ class DefaultSPLTokens {
|
||||||
decimal: 6,
|
decimal: 6,
|
||||||
mint: 'ray',
|
mint: 'ray',
|
||||||
iconPath: 'assets/images/gmt_icon.png',
|
iconPath: 'assets/images/gmt_icon.png',
|
||||||
|
enabled: false,
|
||||||
),
|
),
|
||||||
SPLToken(
|
SPLToken(
|
||||||
name: 'AvocadoCoin',
|
name: 'AvocadoCoin',
|
||||||
|
@ -89,6 +97,7 @@ class DefaultSPLTokens {
|
||||||
decimal: 8,
|
decimal: 8,
|
||||||
mint: 'avdo',
|
mint: 'avdo',
|
||||||
iconPath: 'assets/images/avdo_icon.png',
|
iconPath: 'assets/images/avdo_icon.png',
|
||||||
|
enabled: false,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import 'package:cake_wallet/src/screens/release_notes/release_notes_screen.dart'
|
||||||
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
|
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
|
||||||
import 'package:cake_wallet/themes/extensions/balance_page_theme.dart';
|
import 'package:cake_wallet/themes/extensions/balance_page_theme.dart';
|
||||||
|
|
||||||
class DashboardPage extends StatelessWidget {
|
class DashboardPage extends StatefulWidget {
|
||||||
DashboardPage({
|
DashboardPage({
|
||||||
required this.bottomSheetService,
|
required this.bottomSheetService,
|
||||||
required this.balancePage,
|
required this.balancePage,
|
||||||
|
@ -50,43 +50,71 @@ class DashboardPage extends StatelessWidget {
|
||||||
final WalletAddressListViewModel addressListViewModel;
|
final WalletAddressListViewModel addressListViewModel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
State<DashboardPage> createState() => _DashboardPageState();
|
||||||
final screenHeight = MediaQuery.of(context).size.height;
|
}
|
||||||
return Scaffold(
|
|
||||||
body: Builder(
|
|
||||||
builder: (_) {
|
|
||||||
final dashboardPageView = RefreshIndicator(
|
|
||||||
displacement: screenHeight * 0.1,
|
|
||||||
onRefresh: () async => await dashboardViewModel.refreshDashboard(),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
|
||||||
child: Container(
|
|
||||||
height: screenHeight,
|
|
||||||
child: _DashboardPageView(
|
|
||||||
balancePage: balancePage,
|
|
||||||
bottomSheetService: bottomSheetService,
|
|
||||||
dashboardViewModel: dashboardViewModel,
|
|
||||||
addressListViewModel: addressListViewModel,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DeviceInfo.instance.isDesktop) {
|
class _DashboardPageState extends State<DashboardPage> {
|
||||||
if (responsiveLayoutUtil.screenWidth >
|
@override
|
||||||
ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
void initState() {
|
||||||
return getIt.get<DesktopSidebarWrapper>();
|
super.initState();
|
||||||
} else {
|
|
||||||
return dashboardPageView;
|
bool isMobileLayout =
|
||||||
}
|
responsiveLayoutUtil.screenWidth < ResponsiveLayoutUtilBase.kMobileThreshold;
|
||||||
} else if (responsiveLayoutUtil.shouldRenderMobileUI) {
|
|
||||||
return dashboardPageView;
|
reaction((_) => responsiveLayoutUtil.screenWidth, (screenWidth) {
|
||||||
} else {
|
// Check if it was previously in mobile layout, and now changing to desktop
|
||||||
return getIt.get<DesktopSidebarWrapper>();
|
if (isMobileLayout &&
|
||||||
}
|
screenWidth > ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||||
},
|
setState(() {
|
||||||
|
isMobileLayout = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it was previously in desktop layout, and now changing to mobile
|
||||||
|
if (!isMobileLayout &&
|
||||||
|
screenWidth <= ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||||
|
setState(() {
|
||||||
|
isMobileLayout = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Widget dashboardChild;
|
||||||
|
|
||||||
|
final dashboardPageView = RefreshIndicator(
|
||||||
|
displacement: responsiveLayoutUtil.screenHeight * 0.1,
|
||||||
|
onRefresh: () async => await widget.dashboardViewModel.refreshDashboard(),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
physics: AlwaysScrollableScrollPhysics(),
|
||||||
|
child: Container(
|
||||||
|
height: responsiveLayoutUtil.screenHeight,
|
||||||
|
child: _DashboardPageView(
|
||||||
|
balancePage: widget.balancePage,
|
||||||
|
bottomSheetService: widget.bottomSheetService,
|
||||||
|
dashboardViewModel: widget.dashboardViewModel,
|
||||||
|
addressListViewModel: widget.addressListViewModel,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (DeviceInfo.instance.isDesktop) {
|
||||||
|
if (responsiveLayoutUtil.screenWidth >
|
||||||
|
ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||||
|
dashboardChild = getIt.get<DesktopSidebarWrapper>();
|
||||||
|
} else {
|
||||||
|
dashboardChild = dashboardPageView;
|
||||||
|
}
|
||||||
|
} else if (responsiveLayoutUtil.shouldRenderMobileUI) {
|
||||||
|
dashboardChild = dashboardPageView;
|
||||||
|
} else {
|
||||||
|
dashboardChild = getIt.get<DesktopSidebarWrapper>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(body: dashboardChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ part 'responsive_layout_util.g.dart';
|
||||||
class _ResponsiveLayoutUtil = ResponsiveLayoutUtilBase with _$_ResponsiveLayoutUtil;
|
class _ResponsiveLayoutUtil = ResponsiveLayoutUtilBase with _$_ResponsiveLayoutUtil;
|
||||||
|
|
||||||
abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
||||||
static const double _kMobileThreshold = 550;
|
static const double kMobileThreshold = 550;
|
||||||
static const double kDesktopMaxWidthConstraint = 400;
|
static const double kDesktopMaxWidthConstraint = 400;
|
||||||
static const double kDesktopMaxDashBoardWidthConstraint = 900;
|
static const double kDesktopMaxDashBoardWidthConstraint = 900;
|
||||||
static const double kPopupWidth = 400;
|
static const double kPopupWidth = 400;
|
||||||
|
@ -42,13 +42,13 @@ abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get shouldRenderMobileUI {
|
bool get shouldRenderMobileUI {
|
||||||
return (screenWidth <= _kMobileThreshold) ||
|
return (screenWidth <= kMobileThreshold) ||
|
||||||
(orientation == Orientation.portrait && screenWidth < screenHeight) ||
|
(orientation == Orientation.portrait && screenWidth < screenHeight) ||
|
||||||
(orientation == Orientation.landscape && screenWidth < screenHeight);
|
(orientation == Orientation.landscape && screenWidth < screenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get shouldRenderTabletUI {
|
bool get shouldRenderTabletUI {
|
||||||
return screenWidth > _kMobileThreshold && screenWidth < kDesktopMaxDashBoardWidthConstraint;
|
return screenWidth > kMobileThreshold && screenWidth < kDesktopMaxDashBoardWidthConstraint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue