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',
|
||||
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(
|
||||
name: 'Bonk',
|
||||
symbol: 'Bonk',
|
||||
|
@ -50,21 +26,7 @@ class DefaultSPLTokens {
|
|||
decimal: 5,
|
||||
mint: 'Bonk',
|
||||
iconPath: 'assets/images/bonk_icon.png',
|
||||
),
|
||||
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',
|
||||
enabled: true,
|
||||
),
|
||||
SPLToken(
|
||||
name: 'Raydium',
|
||||
|
@ -73,6 +35,51 @@ class DefaultSPLTokens {
|
|||
decimal: 6,
|
||||
mint: 'ray',
|
||||
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(
|
||||
name: 'GMT',
|
||||
|
@ -81,6 +88,7 @@ class DefaultSPLTokens {
|
|||
decimal: 6,
|
||||
mint: 'ray',
|
||||
iconPath: 'assets/images/gmt_icon.png',
|
||||
enabled: false,
|
||||
),
|
||||
SPLToken(
|
||||
name: 'AvocadoCoin',
|
||||
|
@ -89,6 +97,7 @@ class DefaultSPLTokens {
|
|||
decimal: 8,
|
||||
mint: 'avdo',
|
||||
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/balance_page_theme.dart';
|
||||
|
||||
class DashboardPage extends StatelessWidget {
|
||||
class DashboardPage extends StatefulWidget {
|
||||
DashboardPage({
|
||||
required this.bottomSheetService,
|
||||
required this.balancePage,
|
||||
|
@ -49,24 +49,53 @@ class DashboardPage extends StatelessWidget {
|
|||
final DashboardViewModel dashboardViewModel;
|
||||
final WalletAddressListViewModel addressListViewModel;
|
||||
|
||||
@override
|
||||
State<DashboardPage> createState() => _DashboardPageState();
|
||||
}
|
||||
|
||||
class _DashboardPageState extends State<DashboardPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
bool isMobileLayout =
|
||||
responsiveLayoutUtil.screenWidth < ResponsiveLayoutUtilBase.kMobileThreshold;
|
||||
|
||||
reaction((_) => responsiveLayoutUtil.screenWidth, (screenWidth) {
|
||||
// Check if it was previously in mobile layout, and now changing to desktop
|
||||
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) {
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
return Scaffold(
|
||||
body: Builder(
|
||||
builder: (_) {
|
||||
Widget dashboardChild;
|
||||
|
||||
final dashboardPageView = RefreshIndicator(
|
||||
displacement: screenHeight * 0.1,
|
||||
onRefresh: () async => await dashboardViewModel.refreshDashboard(),
|
||||
displacement: responsiveLayoutUtil.screenHeight * 0.1,
|
||||
onRefresh: () async => await widget.dashboardViewModel.refreshDashboard(),
|
||||
child: SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: Container(
|
||||
height: screenHeight,
|
||||
height: responsiveLayoutUtil.screenHeight,
|
||||
child: _DashboardPageView(
|
||||
balancePage: balancePage,
|
||||
bottomSheetService: bottomSheetService,
|
||||
dashboardViewModel: dashboardViewModel,
|
||||
addressListViewModel: addressListViewModel,
|
||||
balancePage: widget.balancePage,
|
||||
bottomSheetService: widget.bottomSheetService,
|
||||
dashboardViewModel: widget.dashboardViewModel,
|
||||
addressListViewModel: widget.addressListViewModel,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -75,18 +104,17 @@ class DashboardPage extends StatelessWidget {
|
|||
if (DeviceInfo.instance.isDesktop) {
|
||||
if (responsiveLayoutUtil.screenWidth >
|
||||
ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||
return getIt.get<DesktopSidebarWrapper>();
|
||||
dashboardChild = getIt.get<DesktopSidebarWrapper>();
|
||||
} else {
|
||||
return dashboardPageView;
|
||||
dashboardChild = dashboardPageView;
|
||||
}
|
||||
} else if (responsiveLayoutUtil.shouldRenderMobileUI) {
|
||||
return dashboardPageView;
|
||||
dashboardChild = dashboardPageView;
|
||||
} else {
|
||||
return getIt.get<DesktopSidebarWrapper>();
|
||||
dashboardChild = getIt.get<DesktopSidebarWrapper>();
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return Scaffold(body: dashboardChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ part 'responsive_layout_util.g.dart';
|
|||
class _ResponsiveLayoutUtil = ResponsiveLayoutUtilBase with _$_ResponsiveLayoutUtil;
|
||||
|
||||
abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
||||
static const double _kMobileThreshold = 550;
|
||||
static const double kMobileThreshold = 550;
|
||||
static const double kDesktopMaxWidthConstraint = 400;
|
||||
static const double kDesktopMaxDashBoardWidthConstraint = 900;
|
||||
static const double kPopupWidth = 400;
|
||||
|
@ -42,13 +42,13 @@ abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
|||
|
||||
@computed
|
||||
bool get shouldRenderMobileUI {
|
||||
return (screenWidth <= _kMobileThreshold) ||
|
||||
return (screenWidth <= kMobileThreshold) ||
|
||||
(orientation == Orientation.portrait && screenWidth < screenHeight) ||
|
||||
(orientation == Orientation.landscape && screenWidth < screenHeight);
|
||||
}
|
||||
|
||||
bool get shouldRenderTabletUI {
|
||||
return screenWidth > _kMobileThreshold && screenWidth < kDesktopMaxDashBoardWidthConstraint;
|
||||
return screenWidth > kMobileThreshold && screenWidth < kDesktopMaxDashBoardWidthConstraint;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue