-
Notifications
You must be signed in to change notification settings - Fork 12
feat(tokenized community): onboarding dialog #3108
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
Open
ice-orion
wants to merge
9
commits into
master
Choose a base branch
from
feature/tc-onboarding
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4f9178b
feat: add stub tc onboarding provider and UI
ice-orion 61cfa65
feat: make ui queue async, distinct
ice-orion 7023569
feat: tc onboarding UI
ice-orion 6d2189f
feat: add animation
ice-orion 1aa115a
chore: optimize images
ice-orion 7cdcaaa
fix: remove monetization-live-dialog listener
ice-orion cd7ebc8
chore: remove debug data
ice-orion 088a258
feat: rework both ct monetization and onboarding dialogs conditions
ice-orion eeeffa6
chore: add guard to the context usage
ice-orion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file modified
BIN
-38.1 KB
(19%)
assets/images/tokenized_communities/1.5x/creator_monetization_live.png
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.
Binary file modified
BIN
-62.5 KB
(18%)
assets/images/tokenized_communities/2.0x/creator_monetization_live.png
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.
Binary file modified
BIN
-128 KB
(17%)
assets/images/tokenized_communities/3.0x/creator_monetization_live.png
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.
Binary file modified
BIN
-215 KB
(16%)
assets/images/tokenized_communities/4.0x/creator_monetization_live.png
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.
Binary file modified
BIN
-17.6 KB
(24%)
assets/images/tokenized_communities/creator_monetization_live.png
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
...p/features/tokenized_communities/providers/tokenized_community_onboarding_provider.r.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
ice-orion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.