mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-22 06:28:39 +02:00
* Add theme base v2 * Initial new theme base files * Typos * Fixes * Update theme files * feat: Migrate to Material 3 Theming Foundation, Theme Data Refactor, and First Extension Cleanup Batch. This commit completes the first major phase of migrating to Material 3 theming by setting up the foundations for material 3 integration and begins the initial migration, removing custom theme extensions, updating theme data, and refactoring all relevant widget and page theming to use Material 3’s built-in color and typography tokens. These changes: - Lays the groundwork for Material 3 theming by restructuring the app’s theme configuration to use Material 3’s ColorScheme and TextTheme as the primary sources of color and typography throughout the app. - Refactors the core theme config files by removing legacy custom color roles ensuring all color definitions now map directly to Material 3’s role. - Begins the first batch migration of custom theme extensions (InfoTheme, PlaceholderTheme, KeyboardTheme, PinCodeTheme) and updates all affected widgets and pages to use Material 3 color and typography tokens instead of the custom properties. - Cleans up the codebase by deleting the files of the initial set of migrated extensions and eliminating all related imports and usages. * feat: Migrate to Material 3 Theming. This change: - Updates the themes README.md file to reflect the current structure and give more information based on the first major phase that was completed. * feat: Migrate to Material 3 Theming Deleting previous theme extensions * feat: Migrate to Material 3 Theming Another batch of migrations from existing extensions * feat: Migration to Material 3 Theming Third Migration batch for theme extensions * fwat: Migration to Material 3 Theming Final Migration batch for previous theme extensions * Update onboarding hero * Update button radius * Add surfaceContainer to light theme * feat(themes): Migrate to Material 3 Theming This change: - Adds new set of hero images - Modifies the core structure for the themes - Add missing color tokens to the theme classes - Adds a CustomThemeColor class for custom color tokens - Modifies the themelist to have a fall back for previous theme implementation - Adds localization for some texts - Modifies the flow for loading the theme on app start - Add a WidgetsBindingObserver that listens for changes in the device theme and updates the app theme when there is a change - Registers the themeStore as a Singleton for codebase wide use * feat(themes): Migrate to Material 3 theming This change: - Migrates UI flows across the app to the new themes - Confirms styling and typography of components across the app uses the new themes - Remove instances of Palette use - Switch TextStyles across the app to use theme text styles * feat(themes): Migrate to Material 3 Theming. This change: - Adjusts bottomsheets styling and removes duplicate close button - Removes more themedata extensions from the previous implementation * - Remove outlines from cards and dock - Update menu colors - Update padding/divider size for cards * - Update PIN screen - Fix navigation dock shadow - Update wallet screen colors * Update border radius --skip-ci * feat(themes): Migrate to Material 3 Theming. This change: - Adds gradient backgrounds to the dashbaord and balance cards. - Migrates the input fields across the app to BaseTextFormFields. - Removes dependence of input fields on individual styling, focusing instead on using theme defined InputDecoration styling with adjustments on individual components where needed. - Applies new theme styling to BaseTextFormField, AddressTextField and CurrencyAmountTextField. * - Switch some hero images to PNG - Fix nagivation_dock shadow - Minor fixes * feat: Add fallback to previous underline styling in central widgets This change: - Adds a fallback to CurrencyAmountTextField, AddressTextField, and BaseTextFormField, allowing them use the previous theme styling. - Adds localization for new texts * feat(themes): Update warning box colors for dark and light themes * feat(themes): Relaod themes when user restores from backup, ensuring the user previous theme preference is used. * feat(themes): Handle themes logic during restore from backup This change: - Refactors theme loading logic to handle backup restore edgecase - Refreshes the theme based on the user saved preference during restore from backup flow * Fix card gradients and spacing * Fix even more radiuses Test new icons for navigation_dock.dart * Update onboarding flow backgrounds Fix swap icon clipping Fix some text colors Add more hero images * Fix incorrect color for light theme * Fix more hero images and cleanup * Update text field icons Fix info box CTA colors Fix sync indicator colors * Update toggle colors Update dark theme colors (minor) Update crypto_balance_widget.dart icon * Update page transitions in router.dart Fix some colors * feat(themes): Display label by default for filled textfields * feat(themes): Refactor theme handling across various components This change: - Fixes issue with themeMode resetting to system mode when app is restarted causing a UI glitch - Updates theme checks from `currentTheme.type == ThemeType.dark` to `currentTheme.isDark` for consistency - Adjusts UI components to use the theme directly from the themeStore * feat(themes): Add animating tagline to the create pin welcome screen * Revert text fields label temporarily, fix a couple colors, and cleanup some images --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com> Co-authored-by: Blazebrain <davidadegoke16@gmail.com>
214 lines
7.2 KiB
Dart
214 lines
7.2 KiB
Dart
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:cake_wallet/src/widgets/standard_switch.dart';
|
|
import 'package:cake_wallet/utils/date_picker.dart';
|
|
import 'package:cake_wallet/wownero/wownero.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:cake_wallet/monero/monero.dart';
|
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
|
import 'package:cake_wallet/decred/decred.dart';
|
|
|
|
class BlockchainHeightWidget extends StatefulWidget {
|
|
BlockchainHeightWidget({
|
|
GlobalKey? key,
|
|
this.onHeightChange,
|
|
this.focusNode,
|
|
this.onHeightOrDateEntered,
|
|
this.hasDatePicker = true,
|
|
this.isSilentPaymentsScan = false,
|
|
this.isMwebScan = false,
|
|
this.toggleSingleScan,
|
|
this.doSingleScan = false,
|
|
this.bitcoinMempoolAPIEnabled,
|
|
required this.walletType,
|
|
this.blockHeightTextFieldKey,
|
|
}) : super(key: key);
|
|
|
|
final Function(int)? onHeightChange;
|
|
final Function(bool)? onHeightOrDateEntered;
|
|
final FocusNode? focusNode;
|
|
final bool hasDatePicker;
|
|
final bool isSilentPaymentsScan;
|
|
final bool isMwebScan;
|
|
final bool doSingleScan;
|
|
final Future<bool>? bitcoinMempoolAPIEnabled;
|
|
final Function()? toggleSingleScan;
|
|
final WalletType walletType;
|
|
final Key? blockHeightTextFieldKey;
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => BlockchainHeightState();
|
|
}
|
|
|
|
class BlockchainHeightState extends State<BlockchainHeightWidget> {
|
|
final dateController = TextEditingController();
|
|
final restoreHeightController = TextEditingController();
|
|
|
|
int get height => _height;
|
|
int _height = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
restoreHeightController.addListener(() {
|
|
if (restoreHeightController.text.isNotEmpty) {
|
|
widget.onHeightOrDateEntered?.call(true);
|
|
} else {
|
|
widget.onHeightOrDateEntered?.call(false);
|
|
dateController.text = '';
|
|
}
|
|
try {
|
|
_changeHeight(
|
|
restoreHeightController.text.isNotEmpty ? int.parse(restoreHeightController.text) : 0);
|
|
} catch (_) {
|
|
_changeHeight(0);
|
|
}
|
|
});
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () => FocusScope.of(context).unfocus(),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Row(
|
|
children: <Widget>[
|
|
Flexible(
|
|
child: Container(
|
|
padding: EdgeInsets.only(top: 20.0, bottom: 10.0),
|
|
child: BaseTextFormField(
|
|
key: widget.blockHeightTextFieldKey,
|
|
focusNode: widget.focusNode,
|
|
controller: restoreHeightController,
|
|
keyboardType: TextInputType.numberWithOptions(
|
|
signed: false,
|
|
decimal: false,
|
|
),
|
|
hintText: widget.isSilentPaymentsScan
|
|
? S.of(context).silent_payments_scan_from_height
|
|
: S.of(context).widgets_restore_from_blockheight,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
if (widget.hasDatePicker) ...[
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 15, bottom: 15),
|
|
child: Text(
|
|
S.of(context).widgets_or,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
children: <Widget>[
|
|
Flexible(
|
|
child: Container(
|
|
child: InkWell(
|
|
onTap: () => _selectDate(context),
|
|
child: IgnorePointer(
|
|
child: BaseTextFormField(
|
|
controller: dateController,
|
|
hintText: widget.isSilentPaymentsScan
|
|
? S.of(context).silent_payments_scan_from_date
|
|
: S.of(context).widgets_restore_from_date,
|
|
),
|
|
),
|
|
),
|
|
))
|
|
],
|
|
),
|
|
if (widget.isSilentPaymentsScan)
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 24),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
S.of(context).scan_one_block,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 8),
|
|
child: StandardSwitch(
|
|
value: widget.doSingleScan,
|
|
onTaped: () => widget.toggleSingleScan?.call(),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 40, right: 40, top: 24),
|
|
child: Text(
|
|
widget.isSilentPaymentsScan
|
|
? S.of(context).silent_payments_scan_from_date_or_blockheight
|
|
: S.of(context).restore_from_date_or_blockheight,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
)
|
|
]
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _selectDate(BuildContext context) async {
|
|
final now = DateTime.now();
|
|
final date = await getDate(
|
|
context: context,
|
|
initialDate: now.subtract(Duration(days: 1)),
|
|
firstDate: DateTime(2014, DateTime.may),
|
|
lastDate: now);
|
|
|
|
if (date != null) {
|
|
int height;
|
|
if (widget.isMwebScan) {
|
|
height = bitcoin!.getLitecoinHeightByDate(date: date);
|
|
} else if (widget.isSilentPaymentsScan) {
|
|
height = await bitcoin!.getHeightByDate(
|
|
date: date,
|
|
bitcoinMempoolAPIEnabled: await widget.bitcoinMempoolAPIEnabled,
|
|
);
|
|
} else {
|
|
if (widget.walletType == WalletType.decred) {
|
|
height = decred!.heightByDate(date);
|
|
} else if (widget.walletType == WalletType.monero) {
|
|
height = monero!.getHeightByDate(date: date);
|
|
} else {
|
|
assert(widget.walletType == WalletType.wownero,
|
|
"unknown currency in BlockchainHeightWidget");
|
|
height = wownero!.getHeightByDate(date: date);
|
|
}
|
|
}
|
|
if (mounted) {
|
|
setState(() {
|
|
dateController.text = DateFormat('yyyy-MM-dd').format(date);
|
|
restoreHeightController.text = '$height';
|
|
_changeHeight(height);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
void _changeHeight(int height) {
|
|
_height = height;
|
|
widget.onHeightChange?.call(height);
|
|
}
|
|
}
|