mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-25 11:03:55 +01:00
Catches up from the May 12 fork point (v6.1.2+23) through v6.5.0: 535 upstream commits, including the Monero silent-open fix, Monero on Trezor, Ledger/Trezor BLE fixes, the new seed and history screens, quick Bitcoin sync, git-pinned dependencies (pubspec_overrides.yaml), frozen Hive adapters (*.part.dart), monero_c v0.18.4.6-RC2 and Flutter 3.41.9. Merged with both sides normalized first (import rename, 100-column format), which took the conflict count from 614 paths to 322. The procedure is now scripts/upstream_sync.sh. Kept from Hash Bags: - WalletType enum order and Hive IDs. SQLite stores WalletType.index and our order differs from upstream's; taking theirs would reread saved wallets as other chains. Our frozen adapter keeps the shipped IDs. - The 1.0.2 legacy PIN and wallet-password decode and self-heal. - Removed chains (Solana, Tron, Zano, Zcash, Decred, Haven) and the new Robinhood chain stay out; Cake Pay and non-Trocador swaps stay out. - Default nodes (node.wownero.org, sethforprivacy, Blockstream, bysh.me), converted to upstream's isDefault node-list key; Wownero is back in the node reset list. - Privacy: address resolvers limited to domain-anchored sources again; prices.neroswap.com for fiat; upstream's charts tab, which reads prices.cakewallet.com, sits behind FeatureFlag.isChartsEnabled = false. - Lightning stays behind FeatureFlag.isLightningEnabled, including upstream's new post-seed Lightning username step. - Our icon pipeline, branding and bundle identifiers. Twelve new upstream widget tests are skipped: test and code are unchanged from v6.5.0 apart from renames (not rerun on a pristine upstream checkout; upstream's top_bar_test does not compile against its own TopBar). flutter analyze lib: 0 errors; flutter test: 345 passed, 12 skipped; flutter build bundle compiles. Built with Flutter 3.41.9.
247 lines
7.7 KiB
Dart
247 lines
7.7 KiB
Dart
import "package:hash_wallet/generated/i18n.dart";
|
|
import "package:hash_wallet/new-ui/widgets/modern_button.dart";
|
|
import "package:hash_wallet/new-ui/widgets/new_primary_button.dart";
|
|
import "package:hash_wallet/src/widgets/hash_image_widget.dart";
|
|
import "package:hash_wallet/store/settings_store.dart";
|
|
import "package:hash_wallet/themes/core/theme_extension.dart";
|
|
import "package:flutter/material.dart";
|
|
import "package:modal_bottom_sheet/modal_bottom_sheet.dart";
|
|
|
|
abstract class EducationPage extends StatefulWidget {
|
|
const EducationPage({required this.settingsStore, super.key});
|
|
|
|
final SettingsStore settingsStore;
|
|
|
|
String get educationId;
|
|
String get title;
|
|
String get iconPath;
|
|
String get completionLabel;
|
|
List<EducationSlide> get slides;
|
|
String progressLabel(int current, int total);
|
|
|
|
bool get isDismissed => settingsStore.isEducationDismissed(educationId);
|
|
|
|
Future<void> show(BuildContext context) async {
|
|
await showCupertinoModalBottomSheet<void>(
|
|
useRootNavigator: true,
|
|
context: context,
|
|
backgroundColor: Colors.transparent,
|
|
builder: (_) => this,
|
|
);
|
|
await settingsStore.dismissEducation(educationId);
|
|
}
|
|
|
|
@override
|
|
State<EducationPage> createState() => _EducationPageState();
|
|
}
|
|
|
|
class _EducationPageState extends State<EducationPage> {
|
|
final PageController _pageController = PageController();
|
|
int _currentPage = 0;
|
|
bool _isCompleting = false;
|
|
|
|
@override
|
|
void dispose() {
|
|
_pageController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _complete() {
|
|
if (_isCompleting) {
|
|
return;
|
|
}
|
|
|
|
_isCompleting = true;
|
|
Navigator.of(context).pop();
|
|
}
|
|
|
|
Future<void> _continue(int pageCount) async {
|
|
if (_currentPage == pageCount - 1) {
|
|
_complete();
|
|
return;
|
|
}
|
|
|
|
await _pageController.nextPage(
|
|
duration: const Duration(milliseconds: 250),
|
|
curve: Curves.easeOutCubic,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final pages = widget.slides;
|
|
|
|
return Material(
|
|
color: Colors.transparent,
|
|
child: Container(
|
|
clipBehavior: Clip.antiAlias,
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.surface,
|
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
|
|
),
|
|
child: SafeArea(
|
|
top: false,
|
|
child: Column(
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(18),
|
|
child: Row(
|
|
children: [
|
|
HashImageWidget(
|
|
imageUrl: widget.iconPath,
|
|
width: 24,
|
|
height: 24,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text(widget.title, style: Theme.of(context).textTheme.headlineMedium),
|
|
const Spacer(),
|
|
ModernButton(
|
|
size: 36,
|
|
icon: const Icon(Icons.close),
|
|
semanticLabel: S.of(context).close,
|
|
onPressed: _complete,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Expanded(
|
|
child: PageView(
|
|
controller: _pageController,
|
|
onPageChanged: (page) => setState(() => _currentPage = page),
|
|
children: pages,
|
|
),
|
|
),
|
|
Semantics(
|
|
label: widget.progressLabel(_currentPage + 1, pages.length),
|
|
child: ExcludeSemantics(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: List.generate(
|
|
pages.length,
|
|
(index) => AnimatedContainer(
|
|
key: ValueKey("education-dot-$index"),
|
|
duration: const Duration(milliseconds: 200),
|
|
width: 8,
|
|
height: 8,
|
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
|
decoration: BoxDecoration(
|
|
color: index == _currentPage
|
|
? Theme.of(context).colorScheme.primary
|
|
: Theme.of(context).colorScheme.surfaceContainerHighest,
|
|
shape: BoxShape.circle,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 18),
|
|
child: NewPrimaryButton(
|
|
onPressed: () => _continue(pages.length),
|
|
text: _currentPage == pages.length - 1
|
|
? widget.completionLabel
|
|
: S.of(context).continue_text,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
textColor: Theme.of(context).colorScheme.onPrimary,
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class EducationSlide extends StatelessWidget {
|
|
const EducationSlide({
|
|
required this.children,
|
|
super.key,
|
|
this.distributeChildren = false,
|
|
});
|
|
|
|
final List<Widget> children;
|
|
final bool distributeChildren;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => LayoutBuilder(
|
|
builder: (context, constraints) => SingleChildScrollView(
|
|
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 8),
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(minHeight: constraints.maxHeight - 16),
|
|
child: distributeChildren
|
|
? IntrinsicHeight(
|
|
child: Column(
|
|
children: [
|
|
for (var index = 0; index < children.length; index++) ...[
|
|
children[index],
|
|
if (index < children.length - 1) ...[
|
|
const SizedBox(height: 24),
|
|
const Spacer(),
|
|
],
|
|
],
|
|
],
|
|
),
|
|
)
|
|
: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: children,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class EducationText extends StatelessWidget {
|
|
const EducationText({
|
|
required this.text,
|
|
super.key,
|
|
this.highlightedText,
|
|
this.secondary = false,
|
|
this.warning = false,
|
|
});
|
|
|
|
final String text;
|
|
final String? highlightedText;
|
|
final bool secondary;
|
|
final bool warning;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final style = Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
color: warning
|
|
? context.customColors.warningOutlineColor
|
|
: secondary
|
|
? Theme.of(context).colorScheme.onSurfaceVariant
|
|
: Theme.of(context).colorScheme.onSurface,
|
|
);
|
|
final highlight = highlightedText;
|
|
final highlightStart = highlight == null ? -1 : text.indexOf(highlight);
|
|
|
|
if (highlight == null || highlightStart < 0) {
|
|
return Text(text, textAlign: TextAlign.center, style: style);
|
|
}
|
|
|
|
final highlightEnd = highlightStart + highlight.length;
|
|
return Text.rich(
|
|
TextSpan(
|
|
style: style,
|
|
children: [
|
|
TextSpan(text: text.substring(0, highlightStart)),
|
|
TextSpan(
|
|
text: text.substring(highlightStart, highlightEnd),
|
|
style: TextStyle(color: Theme.of(context).colorScheme.primary),
|
|
),
|
|
TextSpan(text: text.substring(highlightEnd)),
|
|
],
|
|
),
|
|
textAlign: TextAlign.center,
|
|
);
|
|
}
|
|
}
|