mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
Reformat the whole codebase with 100 line width (#3403)
This commit is contained in:
@@ -11,7 +11,6 @@ class AddressFormatter {
|
||||
TextAlign? textAlign,
|
||||
bool shouldTruncate = false,
|
||||
}) {
|
||||
|
||||
final cleanAddress = address.replaceAll('bitcoincash:', '');
|
||||
final isMWEB = address.startsWith('ltcmweb');
|
||||
final chunkSize = walletType != null ? _getChunkSize(walletType) : 4;
|
||||
@@ -27,7 +26,8 @@ class AddressFormatter {
|
||||
isMWEB: isMWEB,
|
||||
chunkSize: chunkSize,
|
||||
evenTextStyle: evenTextStyle,
|
||||
oddTextStyle: oddTextStyle ?? evenTextStyle.copyWith(color: evenTextStyle.color!.withAlpha(150)),
|
||||
oddTextStyle:
|
||||
oddTextStyle ?? evenTextStyle.copyWith(color: evenTextStyle.color!.withAlpha(150)),
|
||||
textAlign: textAlign,
|
||||
);
|
||||
} else {
|
||||
@@ -36,7 +36,8 @@ class AddressFormatter {
|
||||
isMWEB: isMWEB,
|
||||
chunkSize: chunkSize,
|
||||
evenTextStyle: evenTextStyle,
|
||||
oddTextStyle: oddTextStyle ?? evenTextStyle.copyWith(color: evenTextStyle.color!.withAlpha(128)),
|
||||
oddTextStyle:
|
||||
oddTextStyle ?? evenTextStyle.copyWith(color: evenTextStyle.color!.withAlpha(128)),
|
||||
textAlign: textAlign,
|
||||
);
|
||||
}
|
||||
@@ -50,7 +51,6 @@ class AddressFormatter {
|
||||
required TextStyle oddTextStyle,
|
||||
TextAlign? textAlign,
|
||||
}) {
|
||||
|
||||
final chunks = <String>[];
|
||||
|
||||
if (isMWEB) {
|
||||
@@ -95,7 +95,6 @@ class AddressFormatter {
|
||||
required TextStyle oddTextStyle,
|
||||
TextAlign? textAlign,
|
||||
}) {
|
||||
|
||||
if (isMWEB) {
|
||||
const fixedPrefix = 'ltcmweb';
|
||||
final secondChunkStart = fixedPrefix.length;
|
||||
@@ -133,10 +132,8 @@ class AddressFormatter {
|
||||
}
|
||||
|
||||
final String firstPart = address.substring(0, digitCount);
|
||||
final String secondPart =
|
||||
address.substring(digitCount, digitCount * 2);
|
||||
final String lastPart =
|
||||
address.substring(address.length - digitCount);
|
||||
final String secondPart = address.substring(digitCount, digitCount * 2);
|
||||
final String lastPart = address.substring(address.length - digitCount);
|
||||
|
||||
final spans = <TextSpan>[
|
||||
TextSpan(text: '$firstPart ', style: evenTextStyle),
|
||||
|
||||
@@ -17,4 +17,4 @@ class BrightnessUtil {
|
||||
// ignore: unawaited_futures
|
||||
DeviceDisplayBrightness.resetBrightness();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import 'package:flutter/services.dart';
|
||||
import 'package:sensitive_clipboard/sensitive_clipboard.dart';
|
||||
|
||||
class ClipboardUtil {
|
||||
static Future<void> setSensitiveDataToClipboard(ClipboardData data, {bool isSensitive = true}) async {
|
||||
static Future<void> setSensitiveDataToClipboard(ClipboardData data,
|
||||
{bool isSensitive = true}) async {
|
||||
if (isSensitive && DeviceInfo.instance.isMobile) {
|
||||
await SensitiveClipboard.copy(data.text);
|
||||
return;
|
||||
|
||||
@@ -3,12 +3,11 @@ import 'package:cake_wallet/main.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<DateTime?> getDate({
|
||||
required BuildContext context,
|
||||
required DateTime initialDate,
|
||||
required DateTime firstDate,
|
||||
required DateTime lastDate}) {
|
||||
|
||||
Future<DateTime?> getDate(
|
||||
{required BuildContext context,
|
||||
required DateTime initialDate,
|
||||
required DateTime firstDate,
|
||||
required DateTime lastDate}) {
|
||||
if (Platform.isIOS) {
|
||||
return _buildCupertinoDataPicker(context, initialDate, firstDate, lastDate);
|
||||
}
|
||||
@@ -17,10 +16,7 @@ Future<DateTime?> getDate({
|
||||
}
|
||||
|
||||
Future<DateTime?> _buildMaterialDataPicker(
|
||||
BuildContext context,
|
||||
DateTime initialDate,
|
||||
DateTime firstDate,
|
||||
DateTime lastDate) async {
|
||||
BuildContext context, DateTime initialDate, DateTime firstDate, DateTime lastDate) async {
|
||||
return await showDatePicker(
|
||||
context: context,
|
||||
initialDate: initialDate,
|
||||
@@ -30,10 +26,7 @@ Future<DateTime?> _buildMaterialDataPicker(
|
||||
}
|
||||
|
||||
Future<DateTime?> _buildCupertinoDataPicker(
|
||||
BuildContext context,
|
||||
DateTime initialDate,
|
||||
DateTime firstDate,
|
||||
DateTime lastDate) async {
|
||||
BuildContext context, DateTime initialDate, DateTime firstDate, DateTime lastDate) async {
|
||||
DateTime? date;
|
||||
await showModalBottomSheet<void>(
|
||||
context: navigatorKey.currentState!.context,
|
||||
@@ -48,7 +41,6 @@ Future<DateTime?> _buildCupertinoDataPicker(
|
||||
maximumDate: lastDate,
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
class Debounce {
|
||||
Debounce(this.duration);
|
||||
|
||||
|
||||
final Duration duration;
|
||||
Timer? _timer;
|
||||
|
||||
|
||||
void run(VoidCallback action) {
|
||||
_timer?.cancel();
|
||||
_timer = Timer(duration, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ class DeviceInfo {
|
||||
static DeviceInfo get instance => DeviceInfo._();
|
||||
|
||||
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
||||
|
||||
|
||||
bool get isDesktop => Platform.isMacOS || Platform.isWindows || Platform.isLinux;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ class FeatureFlag {
|
||||
static const bool isBackgroundSyncEnabled = true;
|
||||
static bool get isInAppTorEnabled => CakeTor.instance is! CakeTorDisabled;
|
||||
static const int verificationWordsCount = kDebugMode || kProfileMode ? 0 : 2;
|
||||
static const bool hasDevOptions = bool.fromEnvironment('hasDevOptions', defaultValue: kDebugMode || kProfileMode);
|
||||
static const bool hasDevOptions =
|
||||
bool.fromEnvironment('hasDevOptions', defaultValue: kDebugMode || kProfileMode);
|
||||
static const bool hasBitcoinViewOnly = true;
|
||||
static const bool customBackgroundEnabled = false;
|
||||
static const bool duressPinEnabled = true;
|
||||
|
||||
@@ -7,9 +7,7 @@ import 'package:cw_core/keyable.dart';
|
||||
// class NodeListViewModel = NodeListViewModelBase with _$NodeListViewModel;
|
||||
|
||||
class ItemCell<Item> with Keyable {
|
||||
ItemCell(this.value, {
|
||||
required this.isSelectedBuilder,
|
||||
required dynamic key}) {
|
||||
ItemCell(this.value, {required this.isSelectedBuilder, required dynamic key}) {
|
||||
keyIndex = key;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
abstract class ListItem {
|
||||
const ListItem();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ class ListSection<Item> {
|
||||
const ListSection({required this.items});
|
||||
|
||||
final List<Item> items;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -4,15 +4,13 @@ import 'package:mobx/mobx.dart';
|
||||
import 'package:cw_core/keyable.dart';
|
||||
|
||||
void connectMapToListWithTransform<T extends Keyable, Y extends Keyable>(
|
||||
ObservableMap<dynamic, T> source,
|
||||
ObservableList<Y> dest,
|
||||
Y Function(T?) transform,
|
||||
ObservableMap<dynamic, T> source, ObservableList<Y> dest, Y Function(T?) transform,
|
||||
{bool Function(T?)? filter}) {
|
||||
source.observe((MapChange<dynamic, T> change) {
|
||||
if (change.type == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (change.type) {
|
||||
case OperationType.add:
|
||||
if (filter?.call(change.newValue) ?? true) {
|
||||
@@ -21,8 +19,7 @@ void connectMapToListWithTransform<T extends Keyable, Y extends Keyable>(
|
||||
break;
|
||||
case OperationType.remove:
|
||||
// Hive could has equal index and key
|
||||
dest.removeWhere((elem) =>
|
||||
elem.keyIndex == (change.key ?? change.newValue?.keyIndex));
|
||||
dest.removeWhere((elem) => elem.keyIndex == (change.key ?? change.newValue?.keyIndex));
|
||||
break;
|
||||
case OperationType.update:
|
||||
for (var i = 0; i < dest.length; i++) {
|
||||
@@ -88,8 +85,7 @@ extension MobxBindable<T extends Keyable> on Box<T> {
|
||||
return;
|
||||
}
|
||||
|
||||
dest.acceptBoxChange(event,
|
||||
transformed: event.deleted ? null : transform(event.value as T));
|
||||
dest.acceptBoxChange(event, transformed: event.deleted ? null : transform(event.value as T));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+36
-41
@@ -2,53 +2,48 @@ import 'dart:io';
|
||||
import 'package:package_info_plus/package_info_plus.dart' as __package_info__;
|
||||
|
||||
abstract class _EnvKeys {
|
||||
static const kWinAppName = 'CW_WIN_APP_NAME';
|
||||
static const kWinAppPackageName = 'CW_WIN_APP_PACKAGE_NAME';
|
||||
static const kWinAppVersion = 'CW_WIN_APP_VERSION';
|
||||
static const kWinAppBuildNumber = 'CW_WIN_APP_BUILD_NUMBER';
|
||||
static const kWinAppName = 'CW_WIN_APP_NAME';
|
||||
static const kWinAppPackageName = 'CW_WIN_APP_PACKAGE_NAME';
|
||||
static const kWinAppVersion = 'CW_WIN_APP_VERSION';
|
||||
static const kWinAppBuildNumber = 'CW_WIN_APP_BUILD_NUMBER';
|
||||
}
|
||||
|
||||
class PackageInfo {
|
||||
static Future<PackageInfo> fromPlatform() async {
|
||||
if (Platform.isWindows) {
|
||||
return _windowsPackageInfo;
|
||||
}
|
||||
|
||||
final packageInfo = await __package_info__.PackageInfo.fromPlatform();
|
||||
return PackageInfo._(
|
||||
appName: packageInfo.appName,
|
||||
packageName: packageInfo.packageName,
|
||||
version: packageInfo.version,
|
||||
buildNumber: packageInfo.buildNumber);
|
||||
static Future<PackageInfo> fromPlatform() async {
|
||||
if (Platform.isWindows) {
|
||||
return _windowsPackageInfo;
|
||||
}
|
||||
|
||||
static const _defaultCWAppName = 'Cake Wallet';
|
||||
static const _defaultCWAppPackageName = 'com.cakewallet.cake_wallet';
|
||||
static const _defaultCWAppVersion = '1.0.0';
|
||||
static const _defaultCWAppBuildNumber = '1';
|
||||
final packageInfo = await __package_info__.PackageInfo.fromPlatform();
|
||||
return PackageInfo._(
|
||||
appName: packageInfo.appName,
|
||||
packageName: packageInfo.packageName,
|
||||
version: packageInfo.version,
|
||||
buildNumber: packageInfo.buildNumber);
|
||||
}
|
||||
|
||||
static const _windowsPackageInfo = PackageInfo._(
|
||||
appName: const String
|
||||
.fromEnvironment(_EnvKeys.kWinAppName,
|
||||
defaultValue: _defaultCWAppName),
|
||||
packageName: const String
|
||||
.fromEnvironment(_EnvKeys.kWinAppPackageName,
|
||||
defaultValue: _defaultCWAppPackageName),
|
||||
version: const String
|
||||
.fromEnvironment(_EnvKeys.kWinAppVersion,
|
||||
defaultValue: _defaultCWAppVersion),
|
||||
buildNumber: const String
|
||||
.fromEnvironment(_EnvKeys.kWinAppBuildNumber,
|
||||
defaultValue: _defaultCWAppBuildNumber));
|
||||
static const _defaultCWAppName = 'Cake Wallet';
|
||||
static const _defaultCWAppPackageName = 'com.cakewallet.cake_wallet';
|
||||
static const _defaultCWAppVersion = '1.0.0';
|
||||
static const _defaultCWAppBuildNumber = '1';
|
||||
|
||||
final String appName;
|
||||
final String packageName;
|
||||
final String version;
|
||||
final String buildNumber;
|
||||
static const _windowsPackageInfo = PackageInfo._(
|
||||
appName: const String.fromEnvironment(_EnvKeys.kWinAppName, defaultValue: _defaultCWAppName),
|
||||
packageName: const String.fromEnvironment(_EnvKeys.kWinAppPackageName,
|
||||
defaultValue: _defaultCWAppPackageName),
|
||||
version:
|
||||
const String.fromEnvironment(_EnvKeys.kWinAppVersion, defaultValue: _defaultCWAppVersion),
|
||||
buildNumber: const String.fromEnvironment(_EnvKeys.kWinAppBuildNumber,
|
||||
defaultValue: _defaultCWAppBuildNumber));
|
||||
|
||||
const PackageInfo._({
|
||||
required this.appName,
|
||||
required this.packageName,
|
||||
required this.version,
|
||||
required this.buildNumber});
|
||||
final String appName;
|
||||
final String packageName;
|
||||
final String version;
|
||||
final String buildNumber;
|
||||
|
||||
const PackageInfo._(
|
||||
{required this.appName,
|
||||
required this.packageName,
|
||||
required this.version,
|
||||
required this.buildNumber});
|
||||
}
|
||||
|
||||
+8
-8
@@ -59,13 +59,13 @@ Future<BuildContext> showFullscreenDialog(BuildContext context) async {
|
||||
builder: (context) {
|
||||
dialogContext = context;
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
canPop: false,
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -79,4 +79,4 @@ Future<BuildContext> showFullscreenDialog(BuildContext context) async {
|
||||
Future<void> dismissFullscreenDialog(BuildContext context) async {
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ String generateRandomBase32SecretKey(int byteLength) {
|
||||
String generateOTP({required String secretKey, required int input}) {
|
||||
/// base32 decode the secret
|
||||
var hmacKey = base32.decode(secretKey);
|
||||
|
||||
|
||||
/// initial the HMAC-SHA1 object
|
||||
var hmacSha = Hmac(sha512, hmacKey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user