Skip to content

Commit

Permalink
Merge pull request #32 from 3Dpass/dev
Browse files Browse the repository at this point in the history
Random rotation bytes
  • Loading branch information
L3odr0id authored Oct 11, 2022
2 parents 47f3f9f + 8f6e28a commit dc1bcbc
Show file tree
Hide file tree
Showing 23 changed files with 282 additions and 353 deletions.
86 changes: 0 additions & 86 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,92 +41,6 @@ linter:
require_trailing_commas: true
eol_at_end_of_file: true

#######
# - prefer_if_elements_to_conditional_expressions # Disabled because this rule decreases productivity by disturbing flow.
# - prefer_foreach # Disabled because this rule decreases productivity by disturbing flow.
# - always_require_non_null_named_parameters # Obsolete because of NNBD.
# - prefer_void_to_null # Obsolete because of NNBD.
# - camel_case_extensions # Disabled because an underscore is useful to represent domains in generated code.
# - omit_local_variable_types # Too pedantic.
# - prefer_adjacent_string_concatenation # No comment.
# - prefer_single_quotes # Too pedantic.
# - always_put_control_body_on_new_line # Too pedantic.
# - always_specify_types # Too pedantic.
# - avoid_as # Too pedantic.
# - unnecessary_this # Too many false positives.
# - prefer_bool_in_asserts # No comment.
# - use_to_and_as_if_applicable # Too pedantic.
# - use_super_parameters # Super parameters make inheritance more convenient, but inheritance should be avoided and composition should be preferred. Even if you need inheritance, you should declare an interface and mixins, and not use super constructors.
# - prefer_function_declarations_over_variables # With variables, the return type can be omitted safely which is useful in FP-style code.
# - always_use_package_imports # Prefer relative imports
# - avoid_annotating_with_dynamic # It is better to always be explicit about dynamic.
# - avoid_bool_literals_in_conditional_expressions # bool literals in conditional expressions make it easier to reason about them. X ? Y : Z is easier for humans than e.g. X || Z
# - avoid_classes_with_only_static_members # Classes with static members don't pollute the global namespace.
# - avoid_escaping_inner_quotes # Too pedantic.
# - avoid_function_literals_in_foreach_calls # Disabled because this rule decreases productivity by disturbing flow.
# - avoid_equals_and_hash_code_on_mutable_classes # @immutable depends on meta.
# - avoid_positional_boolean_parameters # Too pedantic.
# - avoid_print # Too pedantic.
# - avoid_redundant_argument_values # Too pedantic.
# - avoid_renaming_method_parameters # Too pedantic.
# - avoid_setters_without_getters # Too pedantic.
# - avoid_types_on_closure_parameters # Too pedantic.
# - avoid_unnecessary_containers # Disabled because this rule decreases productivity by disturbing flow.
# - camel_case_types # Underscores can be useful in generated code.
# - cascade_invocations # Too pedantic.
# - constant_identifier_names # Too pedantic.
# - deprecated_consistency # Too pedantic.
# - diagnostic_describe_all_properties # Too pedantic.
# - flutter_style_todos # Too pedantic.
# - do_not_use_environment # Too pedantic.
# - leading_newlines_in_multiline_strings # Too pedantic.
# - library_private_types_in_public_api # Too pedantic.
# - lines_longer_than_80_chars # Too pedantic.
# - missing_whitespace_between_adjacent_strings # Too pedantic.
# - non_constant_identifier_names # Too pedantic.
# - no_runtimeType_toString # Too pedantic.
# - one_member_abstracts # Too pedantic.
# - prefer_const_literals_to_create_immutables # Too pedantic.
# - prefer_constructors_over_static_methods # Too pedantic.
# - prefer_double_quotes # Too pedantic.
# - prefer_expression_function_bodies # Too pedantic.
# - prefer_interpolation_to_compose_strings # Too pedantic.
# - prefer_int_literals # Too pedantic.
# - prefer_is_not_operator # Too pedantic.
# - public_member_api_docs # Too pedantic.
# - sort_constructors_first # Too pedantic.
# - super_goes_last # Deprecated
# - unnecessary_brace_in_string_interps # Too pedantic.
# - unnecessary_final # final tells the reader 'This variable won't be mutated.'
# - unnecessary_lambdas # In rare cases it is possible for this to introduce bugs.
# - unnecessary_null_checks # Too pedantic.
# - unnecessary_raw_strings # Too pedantic.
# - unnecessary_string_escapes # Too pedantic.
# - unnecessary_string_interpolations # Too pedantic.
# - use_if_null_to_convert_nulls_to_bools # Too pedantic.
# - use_key_in_widget_constructors # Too pedantic.
# - use_late_for_private_fields_and_variables # Too pedantic.
# - use_named_constants # There could be multiple constants with the same value but different identifiers.
# - use_raw_strings # Too pedantic.
# - use_setters_to_change_properties # Too pedantic.
# - null_check_on_nullable_type_parameter # Too many false positives.
# - require_trailing_commas # Too pedantic.
# - avoid_field_initializers_in_const_classes # Too pedantic.
# - avoid_returning_null # Obsolete because of NNBD.
# - depend_on_referenced_packages # Disabled because this rule decreases productivity by disturbing flow.
# - eol_at_end_of_file # Too pedantic.
# - no_leading_underscores_for_library_prefixes # Too pedantic.
# - no_leading_underscores_for_local_identifiers # Too pedantic.
# - avoid_final_parameters # No comment.
# - sized_box_shrink_expand # Disabled because this rule decreases productivity by disturbing flow.
# - avoid_private_typedef_functions # Too pedantic.
# - avoid_multiple_declarations_per_line # Has false positives.
# - use_decorated_box # Disabled because this rule decreases productivity by disturbing flow.
# - use_test_throws_matchers # Too pedantic.
# - sized_box_for_whitespace # Disabled because this rule decreases productivity by disturbing flow.
# - invariant_booleans # Too many false positives.
# - sort_child_properties_last # Too pedantic.


analyzer:
### extra_pedantic ###
Expand Down
2 changes: 1 addition & 1 deletion lib/core/polkawallet/app_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppService {
balance = ValueNotifier<BalanceData>(BalanceData());

final ValueNotifier<BalanceData> balance;
final ValueNotifier<String> bestNumber = ValueNotifier<String>('');
// final ValueNotifier<String> bestNumber = ValueNotifier<String>('');
final Keyring keyring;
final NetworkStateData networkStateData;
final PolkawalletPlugin plugin;
Expand Down
16 changes: 6 additions & 10 deletions lib/core/polkawallet/bloc/app_service_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:threedpass/core/polkawallet/plugins/d3p_core_plugin.dart';
import 'package:threedpass/core/polkawallet/plugins/d3p_live_net_plugin.dart';
import 'package:threedpass/core/polkawallet/plugins/d3p_test_net_plugin.dart';
import 'package:threedpass/features/accounts/domain/account_info.dart';
import 'package:threedpass/features/scan_page/bloc/object_from_file_cubit.dart';
import 'package:threedpass/features/settings_page/bloc/settings_page_cubit.dart';
import 'package:threedpass/features/settings_page/domain/entities/global_settings.dart';
import 'package:threedpass/features/settings_page/domain/entities/wallet_settings.dart';
Expand All @@ -26,7 +25,6 @@ import 'package:threedpass/features/settings_page/domain/entities/wallet_setting
class AppServiceLoaderCubit extends Cubit<AppService> {
AppServiceLoaderCubit({
required this.settingsConfigCubit,
required this.bestNumberAvaliableCubit,
}) : super(
AppService(
plugin: D3pLiveNetPlugin(),
Expand All @@ -38,7 +36,6 @@ class AppServiceLoaderCubit extends Cubit<AppService> {
}

final SettingsConfigCubit settingsConfigCubit;
final BestNumberAvaliableCubit bestNumberAvaliableCubit;

Future<Map<dynamic, dynamic>> importAccount({
required final AccountInfo account,
Expand Down Expand Up @@ -164,13 +161,12 @@ class AppServiceLoaderCubit extends Cubit<AppService> {

final newAppService = await _buildNewAppServiceWithProperties(service);

unawaited(
newAppService.plugin.sdk.api.setting
.subscribeBestNumber((final String value) {
newAppService.bestNumber.value = value;
bestNumberAvaliableCubit.setValue(true);
}),
);
// unawaited(
// newAppService.plugin.sdk.api.setting
// .subscribeBestNumber((final String value) {
// newAppService.bestNumber.value = value;
// }),
// );

unawaited(subscribeToBalance(newAppService));

Expand Down
15 changes: 15 additions & 0 deletions lib/core/utils/random_hex.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'dart:math';

class RandomHex {
static const _chars = '1234567890abcdef';
static final Random _rnd = Random();

static String generate(final int length) => String.fromCharCodes(
Iterable.generate(
length,
(final _) => _chars.codeUnitAt(
_rnd.nextInt(_chars.length),
),
),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import 'package:threedpass/core/widgets/buttons/elevated_button.dart';
import 'package:threedpass/core/widgets/paddings.dart';
import 'package:threedpass/features/accounts/bloc/account_store_bloc/account_store_bloc.dart';
import 'package:threedpass/features/accounts/presentation/pages/account_page_template.dart';
import 'package:threedpass/features/accounts/presentation/pages/create_account/create_account_info_page.dart';
import 'package:threedpass/features/accounts/presentation/widgets/header_info.dart';
import 'package:threedpass/features/accounts/presentation/widgets/text_info.dart';
import 'package:threedpass/features/hashes_list/bloc/hashes_list_bloc.dart';
import 'package:threedpass/features/hashes_list/domain/entities/hash_object.dart';
import 'package:threedpass/router/router.gr.dart';

part './widgets/create_account_stateful.dart';
part './widgets/submit_button.dart';
part './widgets/object_account_info.dart';
part './widgets/choose_hash_title.dart';
part './widgets/choose_hash_dropdown.dart';
part './widgets/choose_object_title.dart';
part './widgets/choose_object_dropdown.dart';

class CreateAccountFromObject extends StatelessWidget {
const CreateAccountFromObject({final Key? key}) : super(key: key);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
part of '../create_account_from_object.dart';

class _ChooseHashDropdown extends StatelessWidget {
const _ChooseHashDropdown({
required this.objectValueNotifier,
required this.chosenHash,
});

final ValueNotifier<HashObject> objectValueNotifier;
final ValueNotifier<String> chosenHash;

void onHashChoose(final String? value) {
if (value != null) {
chosenHash.value = value;
}
}

@override
Widget build(final BuildContext context) {
return ValueListenableBuilder(
valueListenable: objectValueNotifier,
builder: (final ___, final _, final __) => ValueListenableBuilder(
valueListenable: chosenHash,
builder: (final context, final _, final __) => DropdownButton<String>(
isExpanded: true,
style: Theme.of(context).textTheme.bodyText1,
value: chosenHash.value,
items: objectValueNotifier.value.stableHashes
.map(
(final e) => DropdownMenuItem<String>(
value: e,
child: Text(
e,
maxLines: 3,
style: Theme.of(context).textTheme.bodyText1,
),
),
)
.toList(),
onChanged: (final String? modelChosen) => onHashChoose(modelChosen),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
part of '../create_account_from_object.dart';

class _ChooseHashTitle extends StatelessWidget {
const _ChooseHashTitle();

@override
Widget build(final BuildContext context) => Text.rich(
TextSpan(
text: 'create_from_object_text2'.tr(),
style: Theme.of(context).textTheme.headline6,
children: [
TextSpan(
text: '\n' + 'create_from_object_text2_hint'.tr(),
style: Theme.of(context).textTheme.bodyText1,
),
],
),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
part of '../create_account_from_object.dart';

class _ChooseObjectDropdown extends StatelessWidget {
const _ChooseObjectDropdown({
required this.objectValueNotifier,
required this.objectsToUse,
required this.chosenHash,
});

final ValueNotifier<HashObject> objectValueNotifier;
final List<HashObject> objectsToUse;
final ValueNotifier<String> chosenHash;

void onObjectChoose(final HashObject? hashObject) {
if (hashObject != null) {
objectValueNotifier.value = hashObject;
chosenHash.value = hashObject.stableHashes.first;
}
}

@override
Widget build(final BuildContext context) {
return ValueListenableBuilder(
valueListenable: objectValueNotifier,
builder: (final context, final _, final __) => DropdownButton<HashObject>(
style: Theme.of(context).textTheme.bodyText1,
value: objectValueNotifier.value,
items: objectsToUse
.map(
(final e) => DropdownMenuItem<HashObject>(
value: e,
child: Text(
e.name.cutWithEllipsis(20),
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyText1,
),
),
)
.toList(),
onChanged: (final modelChosen) => onObjectChoose(modelChosen),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
part of '../create_account_from_object.dart';

class _ChooseObjectTitle extends StatelessWidget {
const _ChooseObjectTitle();

@override
Widget build(final BuildContext context) => Text(
'create_from_object_text1'.tr(),
style: Theme.of(context).textTheme.headline6,
);
}
Loading

0 comments on commit dc1bcbc

Please sign in to comment.