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.
258 lines
11 KiB
Dart
258 lines
11 KiB
Dart
import 'package:hash_wallet/core/auth_service.dart';
|
|
import 'package:hash_wallet/di.dart';
|
|
import 'package:hash_wallet/generated/i18n.dart';
|
|
import 'package:hash_wallet/new-ui/modal_navigator.dart';
|
|
import 'package:hash_wallet/new-ui/pages/account_customizer.dart';
|
|
import 'package:hash_wallet/new-ui/pages/card_customizer.dart';
|
|
import 'package:hash_wallet/new-ui/pages/settings_page.dart';
|
|
import 'package:hash_wallet/new-ui/viewmodels/card_customizer/card_customizer_bloc.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coins_page/action_row/coin_action_row.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coins_page/assets_history/assets_history_section.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coins_page/cards/cards_view.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coins_page/mweb_ad.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coins_page/top_bar_widget/top_bar.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coins_page/unconfirmed_balance_widget.dart';
|
|
import 'package:hash_wallet/new-ui/widgets/coins_page/wallet_info.dart';
|
|
import 'package:hash_wallet/view_model/dashboard/dashboard_view_model.dart';
|
|
import 'package:hash_wallet/view_model/dashboard/nft_view_model.dart';
|
|
import 'package:hash_wallet/view_model/monero_account_list/monero_account_edit_or_create_view_model.dart';
|
|
import 'package:hash_wallet/view_model/monero_account_list/monero_account_list_view_model.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
|
|
|
class NewHomePage extends StatefulWidget {
|
|
NewHomePage({super.key, required this.dashboardViewModel, required this.nftViewModel});
|
|
|
|
final DashboardViewModel dashboardViewModel;
|
|
final NFTViewModel nftViewModel;
|
|
|
|
@override
|
|
State<NewHomePage> createState() => _NewHomePageState();
|
|
}
|
|
|
|
class _NewHomePageState extends State<NewHomePage> {
|
|
MoneroAccountListViewModel? accountListViewModel;
|
|
bool _lightningMode = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_setAccountViewModel();
|
|
reaction((_)=>widget.dashboardViewModel.wallet, (_) {
|
|
_setAccountViewModel();
|
|
setState(() {
|
|
_lightningMode = false;
|
|
});
|
|
});
|
|
}
|
|
|
|
void _setAccountViewModel() {
|
|
accountListViewModel = widget.dashboardViewModel.balanceViewModel.hasAccounts
|
|
? getIt.get<MoneroAccountListViewModel>()
|
|
: null;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: MediaQuery.of(context).size.height,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Theme.of(context).colorScheme.surface,
|
|
Theme.of(context).colorScheme.surfaceDim,
|
|
],
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
CustomScrollView(
|
|
physics: BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
|
|
slivers:[
|
|
SliverPadding(
|
|
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
|
sliver: CupertinoSliverRefreshControl(
|
|
refreshTriggerPullDistance: 160,
|
|
refreshIndicatorExtent: 90,
|
|
onRefresh: () => widget.dashboardViewModel.refreshDashboard(),
|
|
),
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
spacing: 24.0,
|
|
children: [
|
|
TopBar(
|
|
dashboardViewModel: widget.dashboardViewModel,
|
|
lightningMode: _lightningMode,
|
|
onLightningSwitchPress: () {
|
|
setState(() {
|
|
_lightningMode = !_lightningMode;
|
|
});
|
|
},
|
|
onSettingsButtonPress: () {
|
|
CupertinoScaffold.showCupertinoModalBottomSheet(
|
|
context: context,
|
|
barrierColor: Colors.black.withAlpha(85),
|
|
builder: (context) => FractionallySizedBox(
|
|
child: Material(
|
|
child: NewSettingsPage(
|
|
dashboardViewModel: widget.dashboardViewModel,
|
|
authService: getIt.get<AuthService>(),
|
|
))),
|
|
);
|
|
},
|
|
),
|
|
Observer(
|
|
builder: (_)=>WalletInfoBar(
|
|
lightningMode: _lightningMode,
|
|
hardwareWalletType: widget.dashboardViewModel.wallet.hardwareWalletType,
|
|
name: widget.dashboardViewModel.wallet.name,
|
|
hasCustomize: accountListViewModel != null,
|
|
onCustomizeButtonTap: openAccountCustomizer),
|
|
),
|
|
Column(
|
|
children: [
|
|
Observer(
|
|
builder: (_) => CardsView(
|
|
key: ValueKey(widget.dashboardViewModel.wallet.name),
|
|
onCustomizeTapped: openCardCustomizer,
|
|
dashboardViewModel: widget.dashboardViewModel,
|
|
accountListViewModel: accountListViewModel,
|
|
onCompactModeBackgroundCardsTapped: openAccountCustomizer,
|
|
lightningMode: _lightningMode,
|
|
),
|
|
),
|
|
Observer(builder: (_) {
|
|
return AnimatedSize(
|
|
duration: Duration(milliseconds: 150),
|
|
curve: Curves.easeInOutCubic,
|
|
child: (widget.dashboardViewModel.shouldShowBalanceHiddenMessage)
|
|
? Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 12,
|
|
width: double.infinity,
|
|
),
|
|
Text(
|
|
S.of(context).long_press_show_balance,
|
|
style: TextStyle(
|
|
color:
|
|
Theme.of(context).colorScheme.onSurfaceVariant),
|
|
)
|
|
],
|
|
)
|
|
: SizedBox(width: double.infinity),
|
|
);
|
|
}),
|
|
UnconfirmedBalanceWidget(dashboardViewModel: widget.dashboardViewModel,),
|
|
],
|
|
),
|
|
Observer(
|
|
builder: (_) {
|
|
return Column(
|
|
children: [
|
|
CoinActionRow(
|
|
lightningMode: _lightningMode,
|
|
showSwap: widget.dashboardViewModel.isEnabledSwapAction,
|
|
walletType: widget.dashboardViewModel.wallet.type,
|
|
),
|
|
MwebAd(
|
|
dashboardViewModel: widget.dashboardViewModel,
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
|
|
],
|
|
),
|
|
),
|
|
Observer(
|
|
builder: (_) => AssetsHistorySection(
|
|
nftViewModel: widget.nftViewModel,
|
|
dashboardViewModel: widget.dashboardViewModel,
|
|
),
|
|
),
|
|
SliverToBoxAdapter(
|
|
child: SizedBox(height: 80.0),
|
|
)
|
|
]),
|
|
Container(
|
|
height: (MediaQuery.of(context).padding.top),
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.bottomCenter,
|
|
end: Alignment.topCenter,
|
|
colors: <Color>[
|
|
Theme.of(context).colorScheme.surface.withAlpha(5),
|
|
Theme.of(context).colorScheme.surface.withAlpha(25),
|
|
Theme.of(context).colorScheme.surface.withAlpha(50),
|
|
Theme.of(context).colorScheme.surface.withAlpha(100),
|
|
Theme.of(context).colorScheme.surface.withAlpha(150),
|
|
Theme.of(context).colorScheme.surface.withAlpha(175),
|
|
Theme.of(context).colorScheme.surface.withAlpha(200),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
void openAccountCustomizer() async {
|
|
await CupertinoScaffold.showCupertinoModalBottomSheet(
|
|
barrierColor: Colors.black.withAlpha(60),
|
|
context: context,
|
|
builder: (context) {
|
|
return ModalNavigator(
|
|
parentContext: context,
|
|
heightMode: ModalHeightModes.fullScreen,
|
|
rootPage: Material(
|
|
child: AccountCustomizer(
|
|
accountListViewModel: accountListViewModel!,
|
|
accountEditOrCreateViewModel: getIt.get<MoneroAccountEditOrCreateViewModel>(),
|
|
dashboardViewModel: widget.dashboardViewModel,
|
|
)),
|
|
);
|
|
},
|
|
);
|
|
widget.dashboardViewModel.loadCardDesigns();
|
|
}
|
|
|
|
void openCardCustomizer() async {
|
|
final bloc = getIt.get<CardCustomizerBloc>(
|
|
param1: _lightningMode,
|
|
param2: widget.dashboardViewModel.settingsStore.displayAmountsInSatoshi);
|
|
await CupertinoScaffold.showCupertinoModalBottomSheet(
|
|
barrierColor: Colors.black.withAlpha(60),
|
|
context: context,
|
|
builder: (context) {
|
|
return ModalNavigator(
|
|
parentContext: context,
|
|
heightMode: ModalHeightModes.fullScreen,
|
|
rootPage: BlocProvider(
|
|
create: (context) => bloc,
|
|
child: Material(
|
|
child: CardCustomizer(
|
|
cryptoTitle: widget.dashboardViewModel.wallet.currency.fullName ??
|
|
widget.dashboardViewModel.wallet.currency.name,
|
|
cryptoName: widget.dashboardViewModel.wallet.currency.name,
|
|
)),
|
|
));
|
|
},
|
|
);
|
|
bloc.add(DesignSaved());
|
|
await bloc.stream.firstWhere((s) => s is CardCustomizerSaved);
|
|
widget.dashboardViewModel.loadCardDesigns();
|
|
}
|
|
}
|