Skip to content

Commit

Permalink
Remove unused imports and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
takenagain committed Jan 29, 2024
1 parent 5ecfa04 commit a885aff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 52 deletions.
19 changes: 8 additions & 11 deletions lib/screens/portfolio/activate/select_coins_page.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:komodo_dex/model/coin_type.dart';
import 'package:komodo_dex/packages/z_coin_activation/bloc/z_coin_activation_bloc.dart';
import 'package:komodo_dex/packages/z_coin_activation/bloc/z_coin_activation_event.dart';
import 'package:komodo_dex/packages/z_coin_activation/models/z_coin_activation_prefs.dart';
import 'package:komodo_dex/packages/z_coin_activation/widgets/z_coin_status_list_tile.dart';

import '../../../app_config/app_config.dart';
import '../../../blocs/coins_bloc.dart';
import '../../../blocs/dialog_bloc.dart';
import '../../../blocs/settings_bloc.dart';
import '../../../localizations.dart';
import '../../../app_config/app_config.dart';
import '../../../model/coin.dart';
import '../../../widgets/custom_simple_dialog.dart';
import '../../../widgets/primary_button.dart';
import '../../authentification/lock_screen.dart';
import '../../portfolio/activate/build_item_coin.dart';
import '../../portfolio/activate/build_type_header.dart';
import '../../portfolio/activate/search_filter.dart';
import '../../portfolio/loading_coin.dart';
import 'build_filter_coin.dart';
import '../../../widgets/custom_simple_dialog.dart';
import '../../../widgets/primary_button.dart';
import 'build_selected_coins.dart';

import 'build_filter_coin.dart';

class SelectCoinsPage extends StatefulWidget {
const SelectCoinsPage({this.autoSubmit, this.coinsToAutoSubmit});

Expand Down Expand Up @@ -164,11 +164,8 @@ class _SelectCoinsPageState extends State<SelectCoinsPage> {
_listViewItems = _buildListView();
});

// This is used to pre-select coins when the auto-submitting a ZHTLC coin
// activation request. This is because the ZHTLC activation process
// requires tSync piratedex mobilehe user to keep the app open for a long time, so we want to
// present the user with the ZHTLC activation request dialog as soon as
// the app opens.
// Auto-submitting through this page allows for the ZHTLC activation
// flow to be triggered.
if (widget.autoSubmit && widget.coinsToAutoSubmit != null) {
for (final Coin coin in widget.coinsToAutoSubmit) {
coinsBloc.setCoinBeforeActivation(coin, true);
Expand Down
45 changes: 4 additions & 41 deletions lib/screens/portfolio/coins_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:komodo_dex/packages/rebranding/rebranding_dialog.dart';
import 'package:komodo_dex/packages/rebranding/rebranding_provider.dart';
import 'package:komodo_dex/packages/z_coin_activation/bloc/z_coin_activation_bloc.dart';
import 'package:komodo_dex/packages/z_coin_activation/bloc/z_coin_activation_state.dart';
import 'package:komodo_dex/packages/z_coin_activation/models/z_coin_activation_prefs.dart';
import 'package:komodo_dex/packages/z_coin_activation/widgets/z_coin_status_list_tile.dart';
import 'package:komodo_dex/screens/portfolio/animated_asset_proportions_graph.dart';
import 'package:komodo_dex/services/db/database.dart';
Expand Down Expand Up @@ -86,10 +85,11 @@ class _CoinsPageState extends State<CoinsPage> {
super.initState();
}

// This is a hack to show the add coin dialog on first launch
// This function should not be awaited or used in any other place
// ignore: avoid_void_async
/// This is a hack to auto-submit ZHTLC coins via AddCoinPage on first launch
/// to start the ZHTLC activation flow.
void _showAddCoinsOnFirstLaunch() async {
// Known coins are not available immediately after app launch, so wait for
// them before mapping the ZHTLC coin abbreviation to the Coin.
while (coinsBloc.knownCoins == null && mounted) {
await Future<void>.delayed(const Duration(milliseconds: 100));
}
Expand All @@ -101,7 +101,6 @@ class _CoinsPageState extends State<CoinsPage> {
}

final Set<String> coinsToActivate = appConfig.defaultZHTLCCoins.toSet();

final Set<String> activeCoins = coinsBloc.coinBalance
.map((CoinBalance coinBalance) => coinBalance.coin.abbr)
.toSet();
Expand All @@ -114,7 +113,6 @@ class _CoinsPageState extends State<CoinsPage> {

showAddCoinPage(context, true,
autoSubmitCoins: coinsToActivate, autoSubmit: true);

await Db.setDefaultZHLTCCoinActivated(true);
}

Expand Down Expand Up @@ -300,41 +298,6 @@ class _CoinsPageState extends State<CoinsPage> {
colors: colors,
);
}

/// Shows a confirmation dialog for each coin which requires special
/// activation.
///
/// Currently this is only for ZHTLC coins because their activation can take
/// a long time and the user must keep the app open.
Future<bool> _confirmSpecialActivations() async {
final isDeviceSupported = await _devicePermitsIntensiveWork(context);
if (!isDeviceSupported) return false;

final zhtlcActivationPrefs =
await ZCoinStatusWidget.showConfirmationDialog(context);
if (zhtlcActivationPrefs == null) return false;

// enum SyncType { newTransactions, fullSync, specifiedDate } is in z_coin_status_list_tile.dart
// Use zhtlcActivationPrefs as { 'zhtlcSyncType': SyncType, 'zhtlcSyncStartDate': DateTime }
await saveZhtlcActivationPrefs(zhtlcActivationPrefs);

return true;
}

/// *NOT IMPLEMENTED*
///
/// Checks if the device is capable of performing intensive work required
/// for certain coin activations. Shows a dialog if the device is not
/// capable.
///
/// Returns true if the device is capable of performing intensive work.
/// Returns false after showing a dialog if the device is not capable.
Future<bool> _devicePermitsIntensiveWork(BuildContext context) async {
// TODO: Ensure user has sufficient battery life, storage space, and
// has battery saver disabled.

return true;
}
}

class LoadAsset extends StatefulWidget {
Expand Down

0 comments on commit a885aff

Please sign in to comment.