mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-02 12:14:09 +01:00
The big one. Touches 760+ files. Locks in the user's decision to break import-line compatibility with upstream cake-tech/cake_wallet in exchange for a binary named hash_wallet on every platform. Changes: - pubspec_description.yaml: project name cake_wallet -> hash_wallet - 762 Dart files: every 'package:cake_wallet/...' import rewritten to 'package:hash_wallet/...' (lib/, cw_*/lib/, tool/, test/, integration_test/) - linux/CMakeLists.txt: BINARY_NAME cake_wallet -> hash_wallet - windows/CMakeLists.txt: project + BINARY_NAME (CakeWallet -> HashWallet) - windows/runner/Runner.rc: company / file / product strings to Hash Wallet + Such Software LLC copyright - macos/Runner.xcodeproj/project_base.pbxproj: cake_wallet_new.app refs -> hash_wallet.app (macOS output bundle name) - com.suchsoftware.HashWallet.yml (Flatpak): all binary path refs cake_wallet -> hash_wallet (e.g. /app/hash_wallet/hash_wallet) - linux/com.suchsoftware.HashWallet.desktop: Exec=hash_wallet - scripts/android/copy_monero_deps.sh: CW_DIR target path - configure_hash_wallet.sh: error message typo (old filename) INTENTIONALLY UNCHANGED: - cw_* subpackage names (cw_core, cw_bitcoin, cw_wownero, etc.) — they remain as the historical 'cake wallet' naming; renaming them would cascade through every sub-package's internal structure - Method channel name 'com.cake_wallet/native_utils' in iOS/macOS/Android AppDelegates and MainActivity — it's a string identifier that has to match the Dart side exactly. Renaming requires both-sides change; it's internal-only and not user-visible. - ghcr.io/cake-tech/cake_wallet:debian13-... docker image references in build scripts — that's Cake Labs' published image we use as the build environment, not ours. User data directory now follows the new binary name: ~/.local/share/hash_wallet/ (was ~/.local/share/cake_wallet/) ~/.config/hash_wallet/ (was ~/.config/cake_wallet/) Existing users on the old name will need migration if any exist.
281 lines
9.8 KiB
Dart
281 lines
9.8 KiB
Dart
import 'package:hash_wallet/generated/i18n.dart';
|
|
import 'package:hash_wallet/src/widgets/setting_action_button.dart';
|
|
import 'package:hash_wallet/src/widgets/setting_actions.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hash_wallet/view_model/dashboard/dashboard_view_model.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
class MenuWidget extends StatefulWidget {
|
|
MenuWidget(this.dashboardViewModel, Key? key);
|
|
|
|
final DashboardViewModel dashboardViewModel;
|
|
|
|
@override
|
|
MenuWidgetState createState() => MenuWidgetState();
|
|
}
|
|
|
|
class MenuWidgetState extends State<MenuWidget> {
|
|
MenuWidgetState()
|
|
: this.menuWidth = 0,
|
|
this.screenWidth = 0,
|
|
this.screenHeight = 0,
|
|
this.headerHeight = 120,
|
|
this.tileHeight = 60,
|
|
this.fromTopEdge = 50,
|
|
this.fromBottomEdge = 25,
|
|
this.moneroIcon = Image.asset('assets/images/crypto/monero.webp'),
|
|
this.bitcoinIcon = Image.asset('assets/images/crypto/bitcoin.webp'),
|
|
this.litecoinIcon = Image.asset('assets/images/crypto/litecoin.webp'),
|
|
this.havenIcon = Image.asset('assets/images/haven_menu.webp'),
|
|
this.ethereumIcon = Image.asset('assets/images/crypto/ethereum.webp'),
|
|
this.nanoIcon = Image.asset('assets/images/crypto/nano.webp'),
|
|
this.bananoIcon = Image.asset('assets/images/crypto/nano.webp'),
|
|
this.bitcoinCashIcon = Image.asset('assets/images/crypto/bitcoin-cash.webp'),
|
|
this.polygonIcon = Image.asset('assets/images/crypto/polygon.webp'),
|
|
this.baseIcon = Image.asset('assets/images/crypto/base_icon.webp'),
|
|
this.arbitrumIcon = Image.asset('assets/images/crypto/arbitrum.webp'),
|
|
this.bscIcon = Image.asset('assets/images/crypto/BNB.webp'),
|
|
this.solanaIcon = Image.asset('assets/images/crypto/solana.webp'),
|
|
this.tronIcon = Image.asset('assets/images/crypto/tron.webp'),
|
|
this.wowneroIcon = Image.asset('assets/images/crypto/wownero.webp'),
|
|
this.zanoIcon = Image.asset('assets/images/crypto/zano.webp'),
|
|
this.decredIcon = Image.asset('assets/images/crypto/decred.webp'),
|
|
this.dogecoinIcon = Image.asset('assets/images/crypto/dogecoin.webp'),
|
|
this.zcashIcon = Image.asset('assets/images/crypto/zcash.webp');
|
|
|
|
final largeScreen = 731;
|
|
|
|
double menuWidth;
|
|
double screenWidth;
|
|
double screenHeight;
|
|
|
|
double headerHeight;
|
|
double tileHeight;
|
|
double fromTopEdge;
|
|
double fromBottomEdge;
|
|
|
|
Image moneroIcon;
|
|
Image bitcoinIcon;
|
|
Image litecoinIcon;
|
|
Image havenIcon;
|
|
Image ethereumIcon;
|
|
Image bitcoinCashIcon;
|
|
Image nanoIcon;
|
|
Image bananoIcon;
|
|
Image polygonIcon;
|
|
Image baseIcon;
|
|
Image arbitrumIcon;
|
|
Image bscIcon;
|
|
Image solanaIcon;
|
|
Image tronIcon;
|
|
Image wowneroIcon;
|
|
Image zanoIcon;
|
|
Image decredIcon;
|
|
Image dogecoinIcon;
|
|
Image zcashIcon;
|
|
|
|
@override
|
|
void initState() {
|
|
menuWidth = 0;
|
|
screenWidth = 0;
|
|
screenHeight = 0;
|
|
|
|
headerHeight = 120;
|
|
tileHeight = 60;
|
|
fromTopEdge = 50;
|
|
fromBottomEdge = 25;
|
|
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback(afterLayout);
|
|
}
|
|
|
|
void afterLayout(dynamic _) {
|
|
screenWidth = MediaQuery.of(context).size.width;
|
|
screenHeight = MediaQuery.of(context).size.height;
|
|
|
|
setState(() {
|
|
menuWidth = screenWidth;
|
|
|
|
if (screenHeight > largeScreen) {
|
|
final scale = screenHeight / largeScreen;
|
|
tileHeight *= scale;
|
|
headerHeight *= scale;
|
|
fromTopEdge *= scale;
|
|
fromBottomEdge *= scale;
|
|
}
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
List<SettingActions> items = List.of(SettingActions.all);
|
|
if (!widget.dashboardViewModel.hasSilentPayments) {
|
|
items.removeWhere(
|
|
(element) => element.name(context) == S.of(context).silent_payments_settings);
|
|
}
|
|
if (!widget.dashboardViewModel.isMoneroViewOnly) {
|
|
items.removeWhere((element) => element.name(context) == S.of(context).export_outputs);
|
|
}
|
|
if (!widget.dashboardViewModel.hasMweb) {
|
|
items.removeWhere((element) => element.name(context) == S.of(context).litecoin_mweb_settings);
|
|
}
|
|
int itemCount = items.length;
|
|
|
|
moneroIcon = Image.asset('assets/images/crypto/monero.webp');
|
|
bitcoinIcon = Image.asset('assets/images/crypto/bitcoin.webp');
|
|
|
|
return Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 24),
|
|
child: Container(
|
|
height: 60,
|
|
width: 4,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(2)),
|
|
color: Theme.of(context).colorScheme.outline,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(width: 12),
|
|
Expanded(
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(24),
|
|
bottomLeft: Radius.circular(24),
|
|
),
|
|
child: Container(
|
|
color: Theme.of(context).colorScheme.surface,
|
|
child: ListView.separated(
|
|
padding: EdgeInsets.only(top: 0),
|
|
itemBuilder: (_, index) {
|
|
if (index == 0) {
|
|
return Container(
|
|
height: headerHeight,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(24)),
|
|
color: Theme.of(context).colorScheme.surface,
|
|
),
|
|
padding: EdgeInsets.only(
|
|
left: 24,
|
|
top: fromTopEdge,
|
|
right: 24,
|
|
bottom: fromBottomEdge,
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: <Widget>[
|
|
_iconFor(type: widget.dashboardViewModel.type),
|
|
SizedBox(width: 12),
|
|
SingleChildScrollView(
|
|
child: Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: widget.dashboardViewModel.subname.isNotEmpty
|
|
? MainAxisAlignment.spaceBetween
|
|
: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Text(
|
|
widget.dashboardViewModel.name,
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
if (widget.dashboardViewModel.subname.isNotEmpty)
|
|
Observer(
|
|
builder: (_) => Text(
|
|
widget.dashboardViewModel.subname,
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
index--;
|
|
|
|
final item = items[index];
|
|
final isLastTile = index == itemCount - 1;
|
|
|
|
return SettingActionButton(
|
|
key: item.key,
|
|
isLastTile: isLastTile,
|
|
tileHeight: tileHeight,
|
|
selectionActive: false,
|
|
fromBottomEdge: fromBottomEdge,
|
|
fromTopEdge: fromTopEdge,
|
|
onTap: () => item.onTap.call(context),
|
|
image: item.image,
|
|
title: item.name.call(context),
|
|
);
|
|
},
|
|
separatorBuilder: (_, index) => Container(
|
|
height: 0,
|
|
color: Theme.of(context).colorScheme.outline,
|
|
),
|
|
itemCount: itemCount + 1,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _iconFor({required WalletType type}) {
|
|
switch (type) {
|
|
case WalletType.monero:
|
|
return moneroIcon;
|
|
case WalletType.bitcoin:
|
|
return bitcoinIcon;
|
|
case WalletType.litecoin:
|
|
return litecoinIcon;
|
|
case WalletType.haven:
|
|
return havenIcon;
|
|
case WalletType.ethereum:
|
|
return ethereumIcon;
|
|
case WalletType.bitcoinCash:
|
|
return bitcoinCashIcon;
|
|
case WalletType.nano:
|
|
return nanoIcon;
|
|
case WalletType.banano:
|
|
return bananoIcon;
|
|
case WalletType.polygon:
|
|
return polygonIcon;
|
|
case WalletType.solana:
|
|
return solanaIcon;
|
|
case WalletType.base:
|
|
return baseIcon;
|
|
case WalletType.arbitrum:
|
|
return arbitrumIcon;
|
|
case WalletType.bsc:
|
|
return bscIcon;
|
|
case WalletType.tron:
|
|
return tronIcon;
|
|
case WalletType.wownero:
|
|
return wowneroIcon;
|
|
case WalletType.zano:
|
|
return zanoIcon;
|
|
case WalletType.decred:
|
|
return decredIcon;
|
|
case WalletType.dogecoin:
|
|
return dogecoinIcon;
|
|
case WalletType.zcash:
|
|
return zcashIcon;
|
|
default:
|
|
throw Exception('No icon for ${type.toString()}');
|
|
}
|
|
}
|
|
}
|