Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #175 from MXCzkEVM/notificaitons
Browse files Browse the repository at this point in the history
Privacy pdf & miner hooks text change
  • Loading branch information
reasje authored Mar 18, 2024
2 parents 8a23f00 + 3306822 commit 1dc3ef8
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 13 deletions.
8 changes: 5 additions & 3 deletions assets/flutter_i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@
"experiencing_issues": "Experiencing issues?",
"background_service_solution": "Try re-enabling the app or check the battery optimization settings.",
"dapp_hooks": "DApp hooks",
"wifi_hooks": "Wi-Fi hooks",
"wifi_hexagon_location_hooks": "Wi-Fi hexagon location hooks",
"miner_hooks": "Miner hooks",
"location_permission_required_title": "Location permission required.",
"location_permission_required_text": "Oops, location permission is denied, It's essential for us to have location permission in order for Wi-Fi hooks to perform actively, Please grant location permission by going to settings.",
"location_permission_required_text": "Oops, location permission is denied, It's essential for us to have location permission in order for Wi-Fi hexagon location hooks to perform actively, Please grant location permission by going to settings.",
"open_settings": "Open settings",
"service_launched_successfully": "{0} service launched successfully.",
"unable_to_launch_service": "Unable to launch {0} service.",
Expand All @@ -347,5 +347,7 @@
"auto_claim_execution_dialog_title": "Time Already Passed!",
"auto_claim_execution_dialog_text": "The time for auto claim has elapsed. Would you like to execute auto claim now?",
"execute": "Execute",
"auto_claim_scheduling_text": "Auto-claim will execute at {0} tomorrow"
"auto_claim_scheduling_text": "Auto-claim will execute at {0} tomorrow",
"mxc_top_up_notification_text": "Hey {0}! You added {1} MXC to your wallet today. Keep it growing!",
"mxc_top_up_notification_title": "Congrats on new Top-Up"
}
Binary file added assets/pdf/privacy.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions lib/common/components/components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export 'balance_panel/balance.dart';
export 'snack_bar.dart';
export 'list/list.dart';
export 'property_item.dart';
export 'notification.dart';
9 changes: 9 additions & 0 deletions lib/common/components/notification.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:datadashwallet/core/core.dart';

showNotification(String title, String? text) {
AXSNotification().showNotification(title, text);
}

showLowPriorityNotification(String title, String? text) {
AXSNotification().showLowPriorityNotification(title, text);
}
16 changes: 16 additions & 0 deletions lib/features/common/app/launcher_use_case.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import 'dart:async';
import 'dart:io';

import 'package:datadashwallet/common/common.dart';
import 'package:datadashwallet/core/core.dart';
import 'package:datadashwallet/features/common/common.dart';
import 'package:datadashwallet/features/settings/subfeatures/chain_configuration/domain/chain_configuration_use_case.dart';
import 'package:mxc_logic/mxc_logic.dart';
import 'package:open_file/open_file.dart';
import 'package:path_provider/path_provider.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/services.dart' show ByteData, rootBundle;
import 'package:web3dart/web3dart.dart';

class LauncherUseCase extends ReactiveUseCase {
Expand Down Expand Up @@ -118,4 +122,16 @@ class LauncherUseCase extends ReactiveUseCase {
void openTelegram() => launchUrlInPlatformDefaultWithString(Urls.telegram);

void openWeChat() => launchUrlInPlatformDefaultWithString(Urls.weChat);

void openAXSPrivacy(String path) async {
ByteData data = await rootBundle.load(path);
List<int> bytes = data.buffer.asUint8List();
String tempDir = (await getTemporaryDirectory()).path;
String tempFilePath = '$tempDir/${path.split('/').last}';
File tempFile = File(tempFilePath);
await tempFile.writeAsBytes(bytes, flush: true);
openFile(tempFilePath);
}

void openFile(String path) => OpenFile.open(path);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AboutPage extends HookConsumerWidget {
const AppTerm(
name: 'privacy_policy',
externalLink: Urls.axsPrivacy,
isFile: true,
),
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:mxc_ui/mxc_ui.dart';

class AppTerm extends HookConsumerWidget {
const AppTerm({
super.key,
required this.name,
required this.externalLink,
});
const AppTerm(
{super.key,
required this.name,
required this.externalLink,
this.isFile = false});

final String name;
final String externalLink;
final bool isFile;

@override
Widget build(BuildContext context, WidgetRef ref) {
late final launcherUseCase = ref.read(launcherUseCaseProvider);

return InkWell(
onTap: () =>
launcherUseCase.launchUrlInExternalAppWithString(externalLink),
onTap: () => isFile
? launcherUseCase.openAXSPrivacy(externalLink)
: launcherUseCase.launchUrlInExternalAppWithString(externalLink),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: Sizes.spaceSmall),
child: Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DAppHooksPage extends HookConsumerWidget {
children: [
MXCSwitchRowItem(
key: const Key('wifiHookSwitch'),
title: translate('wifi_hooks'),
title: translate('wifi_hexagon_location_hooks'),
value: dappHooksState.dAppHooksData!.wifiHooks.enabled,
onChanged: dappHooksPresenter.changeWifiHooksEnabled,
enabled: isSettingsChangeEnabled,
Expand Down Expand Up @@ -120,6 +120,7 @@ class DAppHooksPage extends HookConsumerWidget {
value: dappHooksState.dAppHooksData!.minerHooks.enabled,
onChanged: dappHooksPresenter.changeMinerHooksEnabled,
enabled: isMXCChains,
titleStyle: FontTheme.of(context).h6(),
),
const SizedBox(height: Sizes.spaceNormal),
MXCDropDown(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class BackgroundFetchConfigUseCase extends ReactiveUseCase {
if (expectedEpochOccurrence <= epochQuantity) {
periodicalCallData = periodicalCallData.copyWith(lasEpoch: epochNumber);
AXSNotification().showNotification("Epoch Achievement Alert!",
"Congratulations! The anticipated epoch you've been waiting for has just occurred. It's a significant milestone. Let's take the next steps forward.,");
"Congratulations! The anticipated epoch you've been waiting for has just occurred. It's a significant milestone. Let's take the next steps forward.");
}

return periodicalCallData;
Expand Down
22 changes: 22 additions & 0 deletions lib/features/wallet/presentation/wallet_page_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,28 @@ class WalletPresenter extends CompletePresenter<WalletState> {
break;
// coin transfer done
case 'transaction':
// final newMXCTx = WannseeTransactionModel.fromJson(
// json.encode(event.payload['transactions'][0]));

// final newTx = TransactionModel.fromMXCTransaction(
// newMXCTx, state.account!.address);

// if (newTx.token.symbol == Config.mxcName &&
// newTx.type == TransactionType.received) {
// final decimal = newTx.token.decimals ?? Config.ethDecimals;
// final formattedValue =
// MXCFormatter.convertWeiToEth(newTx.value ?? '0', decimal);
// showNotification(
// translate('mxc_top_up_notification_title')!,
// translate('mxc_top_up_notification_text')!
// .replaceFirst(
// '{0}',
// state.account!.mns ??
// MXCFormatter.formatWalletAddress(
// state.account!.address),
// )
// .replaceFirst('{1}', formattedValue));
// }
// Sometimes getting the tx list from remote right away, results in having the pending tx in the list too (Which shouldn't be)
Future.delayed(const Duration(seconds: 3), () {
getMXCTransactions();
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.2"
open_file:
dependency: "direct main"
description:
name: open_file
sha256: a5a32d44acb7c899987d0999e1e3cbb0a0f1adebbf41ac813ec6d2d8faa0af20
url: "https://pub.dev"
source: hosted
version: "3.3.2"
open_mail_app:
dependency: "direct main"
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ dependencies:
mxc_ui:
path: packages/shared/ui
network_info_plus: ^4.1.0
open_file: ^3.3.2
open_mail_app: ^0.4.5
package_info_plus: ^4.2.0
path_provider: ^2.0.12
Expand Down Expand Up @@ -120,6 +121,7 @@ flutter:
- assets/svg/settings/
- assets/lottie/
- assets/lottie/gestures/
- assets/pdf/

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
Expand Down

0 comments on commit 1dc3ef8

Please sign in to comment.