mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-18 05:51:34 +02: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.
247 lines
11 KiB
Dart
247 lines
11 KiB
Dart
import 'package:hash_wallet/generated/i18n.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coin_control_page/coin_control_list_item.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/modal_header.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/receive_page/receive_top_bar.dart';
|
|
import 'package:hash_wallet/routes.dart';
|
|
import 'package:hash_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
import "package:hash_wallet/view_model/unspent_coins/unspent_coins_item.dart";
|
|
|
|
class NewCoinControlPage extends StatefulWidget {
|
|
const NewCoinControlPage({super.key, required this.unspentCoinsListViewModel});
|
|
|
|
final UnspentCoinsListViewModel unspentCoinsListViewModel;
|
|
|
|
@override
|
|
State<NewCoinControlPage> createState() => _NewCoinControlPageState();
|
|
}
|
|
|
|
class _NewCoinControlPageState extends State<NewCoinControlPage> {
|
|
late Future<void> _initialization;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_initialization = widget.unspentCoinsListViewModel.initialSetup();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return PopScope(
|
|
canPop: !widget.unspentCoinsListViewModel.isSavingItems,
|
|
onPopInvokedWithResult: (didPop, result) async{
|
|
await widget.unspentCoinsListViewModel.dispose();
|
|
if(!didPop && mounted) Navigator.of(context).pop();
|
|
},
|
|
child: Material(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
|
color: Colors.transparent,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.surface,
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16))),
|
|
child: Column(
|
|
children: [
|
|
ModalTopBar(
|
|
title: "",
|
|
trailingWidget: GestureDetector(
|
|
onTap: Navigator.of(context).pop,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
|
borderRadius: BorderRadius.circular(99999)),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
|
child: Text(
|
|
S.of(context).done,
|
|
style: TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
fontWeight: FontWeight.w600),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
FutureBuilder(
|
|
future: _initialization,
|
|
builder: (context, asyncSnapshot) {
|
|
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
|
return Expanded(
|
|
child: Center(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
spacing: 12,
|
|
children: [
|
|
CupertinoActivityIndicator(),
|
|
Text("${S.of(context).loading}...")
|
|
],
|
|
)),
|
|
);
|
|
}
|
|
|
|
if (asyncSnapshot.hasError)
|
|
return Center(child: Text(S.of(context).coin_control_load_failed));
|
|
|
|
return Expanded(
|
|
child: SingleChildScrollView(
|
|
child: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 18.0),
|
|
child: ModalHeader(
|
|
iconPath: "assets/new-ui/settings_row_icons/coin-control.svg",
|
|
title: "Coin Control",
|
|
message: S.of(context).coin_control_desc),
|
|
),
|
|
if (widget.unspentCoinsListViewModel.items.isNotEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: Row(
|
|
spacing: 20,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
widget.unspentCoinsListViewModel.toggleSelectAll(true);
|
|
},
|
|
child: Text(S.of(context).select_all,
|
|
style: TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400)),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
widget.unspentCoinsListViewModel.toggleSelectAll(false);
|
|
},
|
|
child: Text(S.of(context).unselect_all,
|
|
style: TextStyle(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400)),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
if (widget.unspentCoinsListViewModel.nonFrozenItems.isEmpty &&
|
|
widget.unspentCoinsListViewModel.frozenItems.isEmpty) ...[
|
|
SizedBox(height: 12),
|
|
Center(
|
|
child: Text(
|
|
S.of(context).no_unspent_coins,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
)),
|
|
],
|
|
Observer(
|
|
builder: (_) => widget
|
|
.unspentCoinsListViewModel.nonFrozenItems.isEmpty
|
|
? SizedBox.shrink()
|
|
: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 18.0),
|
|
child: CoinControlListSection(
|
|
items: widget.unspentCoinsListViewModel.nonFrozenItems,
|
|
unspentCoinsListViewModel:
|
|
widget.unspentCoinsListViewModel),
|
|
),
|
|
),
|
|
Observer(
|
|
builder: (context) =>
|
|
widget.unspentCoinsListViewModel.frozenItems.isEmpty
|
|
? SizedBox.shrink()
|
|
: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 18.0),
|
|
child: Column(
|
|
spacing: 10,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
SizedBox(height: 12),
|
|
Text(
|
|
S.of(context).frozen,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
color: Theme.of(context)
|
|
.colorScheme
|
|
.onSurfaceVariant),
|
|
),
|
|
CoinControlListSection(
|
|
items: widget
|
|
.unspentCoinsListViewModel.frozenItems,
|
|
unspentCoinsListViewModel:
|
|
widget.unspentCoinsListViewModel),
|
|
]),
|
|
),
|
|
),
|
|
SizedBox(height: 12)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
})
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class CoinControlListSection extends StatelessWidget {
|
|
const CoinControlListSection(
|
|
{super.key, required this.items, required this.unspentCoinsListViewModel});
|
|
|
|
final List<UnspentCoinsItem> items;
|
|
final UnspentCoinsListViewModel unspentCoinsListViewModel;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView.separated(
|
|
shrinkWrap: true,
|
|
padding: EdgeInsets.zero,
|
|
physics: NeverScrollableScrollPhysics(),
|
|
itemCount: items.length,
|
|
separatorBuilder: (_, __) => Container(
|
|
height: 1,
|
|
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
|
),
|
|
itemBuilder: (_, int index) {
|
|
return Observer(builder: (_) {
|
|
final item = items[index];
|
|
final fiatAmount = unspentCoinsListViewModel.fiatAmounts[item.amount] ?? '';
|
|
return GestureDetector(
|
|
onTap: () => Navigator.of(context).pushNamed(
|
|
Routes.unspentCoinsDetails,
|
|
arguments: [item, unspentCoinsListViewModel],
|
|
),
|
|
child: CoinControlListItem(
|
|
note: item.note,
|
|
amount: item.amount,
|
|
fiatAmount: fiatAmount,
|
|
address: item.address,
|
|
isSending: item.isSending,
|
|
isFrozen: item.isFrozen,
|
|
isChange: item.isChange,
|
|
isSilentPayment: item.isSilentPayment,
|
|
isLoading: item.isBeingSaved,
|
|
isFirst: index == 0,
|
|
isLast: index == items.length - 1,
|
|
onCheckBoxTap: item.isFrozen
|
|
? null
|
|
: () async {
|
|
item.isSending = !item.isSending;
|
|
await unspentCoinsListViewModel.saveUnspentCoinInfo(item);
|
|
},
|
|
),
|
|
);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
}
|