Skip to content
Open
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import 'package:ion/generated/assets.gen.dart';
import 'package:ion_identity_client/ion_identity.dart';

class ShowLinkNewDeviceDialogEvent extends UiEvent {
const ShowLinkNewDeviceDialogEvent();
const ShowLinkNewDeviceDialogEvent() : super(id: 'link_new_device_dialog');

@override
void performAction(BuildContext context) {
showSimpleBottomSheet<void>(
Future<void> performAction(BuildContext context) async {
await showSimpleBottomSheet<void>(
context: context,
isDismissible: false,
child: const LinkNewDeviceDialog(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import 'package:ion/generated/assets.gen.dart';
import 'package:ion_identity_client/ion_identity.dart';

class CreatorMonetizationIsLiveDialogEvent extends UiEvent {
const CreatorMonetizationIsLiveDialogEvent();
const CreatorMonetizationIsLiveDialogEvent() : super(id: 'creator_monetization_is_live_dialog');

static bool shown = false;

@override
void performAction(BuildContext context) {
Future<void> performAction(BuildContext context) async {
if (!shown) {
shown = true;
showSimpleBottomSheet<void>(
await showSimpleBottomSheet<void>(
context: context,
isDismissible: false,
backgroundColor: context.theme.appColors.forest,
Expand Down Expand Up @@ -59,14 +59,6 @@ class _ContentState extends ConsumerWidget {
final textStyles = context.theme.appTextThemes;
final colors = context.theme.appColors;

ref.listen(bscWalletCheckProvider, (prev, next) {
next.whenData((result) {
if (result.hasBscWallet && context.mounted) {
Navigator.of(context).pop();
}
});
});

final isCreatingWallet = ref.watch(
walletAddressNotifierProvider.select((state) => state.isLoading),
);
Expand Down Expand Up @@ -132,7 +124,6 @@ class _ContentState extends ConsumerWidget {
final address = await _createBscWallet(context, ref, network: bscNetwork);
if (!context.mounted || address == null) return;

ref.invalidate(bscWalletCheckProvider);
await ref
.read(userMetadataInvalidatorNotifierProvider.notifier)
.invalidateCurrentUserMetadataProviders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import 'package:ion/app/router/components/sheet_content/sheet_content.dart';
import 'package:ion/app/services/ui_event_queue/ui_event_queue_notifier.r.dart';

class ShowTurnOnNotificationsEvent extends UiEvent {
const ShowTurnOnNotificationsEvent();
const ShowTurnOnNotificationsEvent() : super(id: 'turn_on_notifications');

@override
void performAction(BuildContext context) {
context.go(NotificationsRoute().location);
Future<void> performAction(BuildContext context) async {
await context.push<void>(NotificationsRoute().location);
}
}

Expand Down
8 changes: 5 additions & 3 deletions lib/app/features/core/providers/init_provider.r.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import 'package:ion/app/features/force_update/providers/force_update_provider.r.
import 'package:ion/app/features/ion_connect/providers/global_subscription.r.dart';
import 'package:ion/app/features/push_notifications/background/firebase_messaging_background_service.dart';
import 'package:ion/app/features/push_notifications/providers/pushes_init_provider.r.dart';
import 'package:ion/app/features/tokenized_communities/providers/tokenized_community_onboarding_provider.r.dart';
import 'package:ion/app/features/user/providers/account_notifications_sync_provider.r.dart';
import 'package:ion/app/features/user/providers/force_account_security_notifier.r.dart';
import 'package:ion/app/features/user/providers/relays/user_chat_relays_sync_provider.r.dart';
import 'package:ion/app/features/user/providers/relays/user_file_storage_relays_sync_provider.r.dart';
import 'package:ion/app/features/user/providers/relays/user_relays_sync_provider.r.dart';
import 'package:ion/app/features/user/providers/user_awards_sync_provider.r.dart';
import 'package:ion/app/features/wallets/providers/bsc_wallet_check_service.r.dart';
import 'package:ion/app/features/wallets/providers/coins_sync_provider.r.dart';
import 'package:ion/app/features/wallets/providers/creator_monetization_dialog_provider.r.dart';
import 'package:ion/app/features/wallets/providers/user_public_wallets_sync_provider.r.dart';
import 'package:ion/app/features/wallets/providers/wallets_initializer_provider.r.dart';
import 'package:ion/app/services/conversion_tracking/facebook_conversion_tracking_service.r.dart';
Expand Down Expand Up @@ -76,15 +77,16 @@ Future<void> initApp(Ref ref) async {
..listen(userRelaysSyncProvider, noop)
..listen(userAwardsSyncProvider, noop)
..listen(forceAccountSecurityServiceProvider, noop)
..listen(bscWalletCheckServiceProvider, noop)
..listen(creatorMonetizationDialogServiceProvider, noop)
..listen(userChatRelaysSyncProvider, noop)
..listen(userFileStorageRelaysSyncProvider, noop)
..listen(feedBookmarksSyncProvider, noop)
..listen(feedBookmarkCollectionsNotifierProvider, noop)
..listen(pushesInitProvider, noop)
..listen(globalSubscriptionProvider, (_, subscription) => subscription?.init())
..listen(accountNotificationsSyncProvider, noop)
..listen(deepLinkHandlerProvider, noop);
..listen(deepLinkHandlerProvider, noop)
..listen(tokenizedCommunityOnboardingServiceProvider, noop);

initFirebaseMessagingBackgroundHandler();

Expand Down
12 changes: 6 additions & 6 deletions lib/app/features/force_update/view/pages/app_update_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import 'package:ion/app/services/ui_event_queue/ui_event_queue_notifier.r.dart';
import 'package:ion/generated/assets.gen.dart';

class ShowAppUpdateModalEvent extends UiEvent {
const ShowAppUpdateModalEvent();
const ShowAppUpdateModalEvent() : super(id: 'app_update_modal');

static bool shown = false;

@override
void performAction(BuildContext context) {
Future<void> performAction(BuildContext context) async {
if (!shown) {
shown = true;
showSimpleBottomSheet<void>(
await showSimpleBottomSheet<void>(
context: context,
isDismissible: false,
child: const AppUpdateModal(
Expand All @@ -41,17 +41,17 @@ class ShowAppUpdateModalEvent extends UiEvent {
}

class ShowInAppUpdateModalEvent extends UiEvent {
const ShowInAppUpdateModalEvent();
const ShowInAppUpdateModalEvent() : super(id: 'in_app_update_modal');

static bool shown = false;

@override
void performAction(BuildContext context) {
Future<void> performAction(BuildContext context) async {
final ref = ProviderScope.containerOf(context);

if (!shown) {
shown = true;
showSimpleBottomSheet<void>(
await showSimpleBottomSheet<void>(
context: context,
child: AppUpdateModal(
appUpdateType: AppUpdateType.androidSoftUpdate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import 'package:ion/app/services/ui_event_queue/ui_event_queue_notifier.r.dart';
import 'package:ion/generated/assets.gen.dart';

class SecureAccountDialogEvent extends UiEvent {
const SecureAccountDialogEvent();
const SecureAccountDialogEvent() : super(id: 'secure_account_dialog');

static bool shown = false;

@override
void performAction(BuildContext context) {
Future<void> performAction(BuildContext context) async {
if (!shown) {
shown = true;
showSimpleBottomSheet<void>(
await showSimpleBottomSheet<void>(
context: context,
isDismissible: false,
child: const SecureAccountModal(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// SPDX-License-Identifier: ice License 1.0

import 'dart:async';

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:ion/app/features/auth/providers/auth_provider.m.dart';
import 'package:ion/app/features/auth/providers/delegation_complete_provider.r.dart';
import 'package:ion/app/features/tokenized_communities/views/pages/tokenized_community_onboarding_dialog/tokenized_community_onboarding_dialog.dart';
import 'package:ion/app/features/wallets/providers/bsc_wallet_check_provider.m.dart';
import 'package:ion/app/router/app_routes.gr.dart';
import 'package:ion/app/router/providers/route_location_provider.r.dart';
import 'package:ion/app/services/storage/user_preferences_service.r.dart';
import 'package:ion/app/services/ui_event_queue/ui_event_queue_notifier.r.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'tokenized_community_onboarding_provider.r.g.dart';

class TokenizedCommunityOnboardingService {
TokenizedCommunityOnboardingService({
required void Function() emitDialog,
required Future<void> Function() setShown,
}) : _emitDialog = emitDialog,
_setShown = setShown;

bool? _authenticated;
bool? _delegationCompleted;
bool? _userHasBscWallet;
bool? _alreadyShown;
String? _route;

final void Function() _emitDialog;
final Future<void> Function() _setShown;

void onAuthenticated({required bool? authenticated}) {
_authenticated = authenticated;
_maybeTrigger();
}

void onDelegationCompleted({required bool? delegationCompleted}) {
_delegationCompleted = delegationCompleted;
_maybeTrigger();
}

void onUserHasBscWalletChanged({required bool hasBscWallet}) {
_userHasBscWallet = hasBscWallet;
_maybeTrigger();
}

void onRouteChanged(String value) {
_route = value;
_maybeTrigger();
}

void onShownChanged({required bool? shown}) {
_alreadyShown = shown;
_maybeTrigger();
}

Future<void> _maybeTrigger() async {
if (_authenticated != true) return;
if (_delegationCompleted != true) return;
if (_userHasBscWallet != true) return;
if (_alreadyShown ?? true) return;
if (_route != FeedRoute().location) return;

_emitDialog();
await _setShown();
}
}

@riverpod
TokenizedCommunityOnboardingService? tokenizedCommunityOnboardingService(Ref ref) {
final userPreferencesService = ref.watch(currentUserPreferencesServiceProvider);

if (userPreferencesService == null) return null;

final service = TokenizedCommunityOnboardingService(
emitDialog: () {
ref
.read(uiEventQueueNotifierProvider.notifier)
.emit(const TokenizedCommunityOnboardingDialogEvent());
},
setShown: () async {
await ref.read(tokenizedCommunityOnboardingShownProvider.notifier).setShown();
},
);

ref
..listen<AsyncValue<AuthState>>(
authProvider,
fireImmediately: true,
(_, next) {
service.onAuthenticated(authenticated: next.valueOrNull?.isAuthenticated);
},
)
..listen<AsyncValue<bool?>>(
delegationCompleteProvider,
fireImmediately: true,
(_, next) {
service.onDelegationCompleted(delegationCompleted: next.valueOrNull);
},
)
..listen<String>(
routeLocationProvider,
fireImmediately: true,
(_, next) {
service.onRouteChanged(next);
},
)
..listen<AsyncValue<BscWalletCheckResult>>(
bscWalletCheckProvider,
fireImmediately: true,
(_, next) {
if (!next.isLoading && next.hasValue) {
service.onUserHasBscWalletChanged(hasBscWallet: next.value!.hasBscWallet);
}
},
)
..listen<bool?>(
tokenizedCommunityOnboardingShownProvider,
fireImmediately: true,
(_, next) {
service.onShownChanged(shown: next);
},
);

return service;
}

@riverpod
class TokenizedCommunityOnboardingShown extends _$TokenizedCommunityOnboardingShown {
static const String _key = 'tokenized_community_onboarding_shown';

@override
bool? build() {
final userPreferencesService = ref.watch(currentUserPreferencesServiceProvider);
if (userPreferencesService == null) {
return null;
}
return userPreferencesService.getValue<bool>(_key) ?? false;
}

Future<void> setShown() async {
final userPreferencesService = ref.read(currentUserPreferencesServiceProvider);
if (userPreferencesService == null) {
return;
}
await userPreferencesService.setValue(_key, true);
state = true;
}
}
Loading
Loading