Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: disable trading features #166

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/coin-icons/bczero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/coin-icons/guru.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/coin-icons/mdx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/coin-icons/raph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
370 changes: 192 additions & 178 deletions assets/coins.json

Large diffs are not rendered by default.

4,722 changes: 2,096 additions & 2,626 deletions assets/coins_config_tcp.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion coins_ci.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"coins_repo_commit": "642abea7172b81db24b16bffc13783b9a0e400f5"
"coins_repo_commit": "8a37a6cdb8f4f334f305899006b31415e3a49bf1"
}
3 changes: 3 additions & 0 deletions lib/app_config/app_config.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../model/feed_provider.dart';
Expand Down Expand Up @@ -48,6 +49,8 @@ class AppConfig {
String get appCompanyLong => 'Komodo Platform';
String get appCompanyShort => 'Komodo';

final bool kIsWalletOnly = !kDebugMode;

List<String> get defaultCoins => ['KMD', 'BTC-segwit'];
List<String> get coinsFiat => ['BTC-segwit', 'KMD'];
List<String> get walletOnlyCoins => [
Expand Down
11 changes: 7 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart' as real_bloc;
Expand Down Expand Up @@ -308,7 +309,7 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {

final List<Widget> _children = <Widget>[
CoinsPage(),
DexPage(),
if (!appConfig.kIsWalletOnly) DexPage(),
MarketsPage(),
if (appConfig.isFeedEnabled) FeedPage()
];
Expand Down Expand Up @@ -544,9 +545,11 @@ class _MyHomePageState extends State<MyHomePage> with WidgetsBindingObserver {
key: Key('main-nav-portfolio'),
),
label: AppLocalizations.of(context).portfolio),
BottomNavigationBarItem(
icon: const Icon(Icons.swap_vert, key: Key('main-nav-dex')),
label: AppLocalizations.of(context).dex),
if (!appConfig.kIsWalletOnly)
BottomNavigationBarItem(
icon:
const Icon(Icons.swap_vert, key: Key('main-nav-dex')),
label: AppLocalizations.of(context).dex),
BottomNavigationBarItem(
icon: const Icon(
Icons.show_chart,
Expand Down
46 changes: 46 additions & 0 deletions lib/screens/portfolio/coins_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
Expand All @@ -14,6 +15,7 @@ import 'package:komodo_dex/packages/z_coin_activation/widgets/z_coin_status_list
import 'package:komodo_dex/screens/portfolio/animated_asset_proportions_graph.dart';
import 'package:komodo_dex/widgets/animated_collapse.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../../../../blocs/coins_bloc.dart';
import '../../../../blocs/settings_bloc.dart';
Expand Down Expand Up @@ -75,6 +77,12 @@ class _CoinsPageState extends State<CoinsPage> {
if (rebrandingNotifier.shouldShowRebrandingDialog) {
showRebrandingDialog(context).ignore();
}

WidgetsBinding.instance.addPostFrameCallback((_) async {
if (kDebugMode && !await _hasAgreedNoTrading()) {
_showDebugModeDialog().ignore();
}
});
}
});

Expand Down Expand Up @@ -263,6 +271,44 @@ class _CoinsPageState extends State<CoinsPage> {
colors: colors,
);
}

// Method to show an alert dialog with an option to agree if the app is in
// debug mode stating that trading features may not be used for actual trading
// and that only test assets/networks may be used.
Future<void> _showDebugModeDialog() async {
await showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return AlertDialog(
title: const Text('Debug mode'),
content: const Text(
'This app is in debug mode. Trading features may not be used for '
'actual trading. Only test assets/networks may be used.',
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
_saveAgreedState().ignore();
},
child: const Text('I agree'),
),
],
);
},
);
}

Future<void> _saveAgreedState() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setBool('wallet_only_agreed', true);
}

Future<bool> _hasAgreedNoTrading() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getBool('wallet_only_agreed') ?? false;
}
}

class LoadAsset extends StatefulWidget {
Expand Down