Files
hash-wallet/lib/src/screens/base_page.dart
T
jwinterm 04203654f1 Rename Flutter project + binary: cake_wallet -> hash_wallet
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.
2026-05-16 11:33:25 -04:00

224 lines
7.0 KiB
Dart

import 'dart:io';
import 'package:hash_wallet/new-ui/widgets/modern_button.dart';
import 'package:hash_wallet/store/settings_store.dart';
import 'package:hash_wallet/themes/core/material_base_theme.dart';
import 'package:hash_wallet/themes/core/theme_store.dart';
import 'package:hash_wallet/utils/route_aware.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hash_wallet/di.dart';
import 'package:hash_wallet/src/widgets/nav_bar.dart';
import 'package:hash_wallet/generated/i18n.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
enum AppBarStyle { regular, withShadow, transparent, completelyTransparent }
abstract class BasePage extends StatelessWidget {
BasePage() : _scaffoldKey = GlobalKey<ScaffoldState>();
final GlobalKey<ScaffoldState> _scaffoldKey;
final Image closeButtonImage = Image.asset('assets/images/close_button.png');
final Image closeButtonImageDarkTheme = Image.asset('assets/images/close_button_dark_theme.png');
String? get title => null;
Color? get backgroundLightColor => null;
Color? get backgroundDarkColor => null;
bool get gradientBackground => false;
bool get gradientAll => false;
bool get resizeToAvoidBottomInset => true;
bool get extendBodyBehindAppBar => false;
Widget? get endDrawer => null;
Function(BuildContext context)? get pushToWidget => null;
Function(BuildContext context)? get pushToNextWidget => null;
Function(BuildContext context)? get popWidget => null;
Function(BuildContext context)? get popNextWidget => null;
AppBarStyle get appBarStyle => AppBarStyle.regular;
bool get hideAppBar => false;
Widget Function(BuildContext, Widget)? get rootWrapper => null;
MaterialThemeBase get currentTheme => getIt.get<ThemeStore>().currentTheme;
void onOpenEndDrawer() => _scaffoldKey.currentState!.openEndDrawer();
void onClose(BuildContext context) => Navigator.of(context).pop();
Color pageBackgroundColor(BuildContext context) =>
(currentTheme.isDark ? backgroundDarkColor : backgroundLightColor) ??
(gradientBackground ? Colors.transparent : Theme.of(context).colorScheme.surface);
Color titleColor(BuildContext context) => Theme.of(context).colorScheme.onSurface;
Color? pageIconColor(BuildContext context) => titleColor(context);
Widget closeButton(BuildContext context) => Image.asset(
currentTheme.isDark
? 'assets/images/close_button_dark_theme.png'
: 'assets/images/close_button.png',
color: pageIconColor(context),
height: 16,
);
Widget backButton(BuildContext context) => Icon(
Icons.arrow_back_ios,
color: Theme.of(context).colorScheme.primary,
size: 16,
);
Widget? leading(BuildContext context) {
if (ModalRoute.of(context)?.isFirst ?? true) {
return null;
}
return MergeSemantics(
child: Padding(
padding: const EdgeInsets.only(top: 4.0),
child: ButtonTheme(
minWidth: double.minPositive,
child: Semantics(
label: S.of(context).seed_alert_back,
child: ModernButton(
size: 37,
icon: Icon(CupertinoIcons.back),
iconColor: Theme.of(context).colorScheme.onSurfaceVariant,
onPressed: () => onClose(context),
),
),
),
),
);
}
Widget? middle(BuildContext context) {
return title == null
? null
: Text(
title!,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontSize: 18.0,
fontWeight: FontWeight.w600,
color: titleColor(context),
),
);
}
Widget? trailing(BuildContext context) => null;
Widget? floatingActionButton(BuildContext context) => null;
PreferredSizeWidget appBar(BuildContext context) {
final appBarColor = pageBackgroundColor(context);
switch (appBarStyle) {
case AppBarStyle.regular:
// FIX-ME: NavBar no context
return NavBar(
// context: context,
leading: leading(context),
middle: middle(context),
trailing: trailing(context),
backgroundColor: appBarColor);
case AppBarStyle.withShadow:
// FIX-ME: NavBar no context
return NavBar.withShadow(
// context: context,
leading: leading(context),
middle: middle(context),
trailing: trailing(context),
backgroundColor: appBarColor);
case AppBarStyle.transparent:
return CupertinoNavigationBar(
leading: leading(context),
middle: middle(context),
trailing: trailing(context),
backgroundColor: Colors.transparent,
border: null,
);
case AppBarStyle.completelyTransparent:
return AppBar(
leading: leading(context),
title: middle(context),
actions: <Widget>[if (trailing(context) != null) trailing(context)!],
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
);
default:
// FIX-ME: NavBar no context
return NavBar(
// context: context,
leading: leading(context),
middle: middle(context),
trailing: trailing(context),
backgroundColor: appBarColor);
}
}
Widget body(BuildContext context);
@override
Widget build(BuildContext context) {
final root = RouteAwareWidget(
child: Observer(
builder: (context) {
final backgroundImage = getIt.get<SettingsStore>().backgroundImage;
return Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
image: backgroundImage.isNotEmpty
? DecorationImage(
image: FileImage(File(backgroundImage)),
fit: BoxFit.cover,
)
: null,
// color: Colors.grey[200],
),
child: Scaffold(
key: _scaffoldKey,
backgroundColor: pageBackgroundColor(context),
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
extendBodyBehindAppBar: extendBodyBehindAppBar,
endDrawer: endDrawer,
appBar: hideAppBar ? null : appBar(context),
body: SafeArea(
left: false,
right: false,
top: false,
bottom: Platform.isAndroid,
child: body(context),
),
floatingActionButton: floatingActionButton(context),
),
);
},
),
pushToWidget: (context) => pushToWidget?.call(context),
pushToNextWidget: (context) => pushToNextWidget?.call(context),
popWidget: (context) => popWidget?.call(context),
popNextWidget: (context) => popNextWidget?.call(context),
);
return rootWrapper?.call(context, root) ?? root;
}
}