-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement dropbox sign in * Implement dropbox sign in * Implement dropbox-sign-in * Fix dropbox-sign-in * Fix dropbox-sign-in * Fix dropbox-sign-in * Added feature flags * Added feature flags
- Loading branch information
1 parent
1b136d7
commit 939b07f
Showing
52 changed files
with
2,291 additions
and
331 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
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 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 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 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 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 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 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 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,56 @@ | ||
import 'dart:developer'; | ||
|
||
import 'package:app_links/app_links.dart'; | ||
import 'package:data/apis/network/urls.dart'; | ||
import 'package:data/services/auth_service.dart'; | ||
import 'package:data/services/dropbox_services.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
final appLinksProvider = Provider<AppLinks>((ref) { | ||
return AppLinks(); | ||
}); | ||
|
||
class DeepLinkHandler { | ||
static Future<void> observeDeepLinks({ | ||
required ProviderContainer container, | ||
}) async { | ||
final appLinks = container.read(appLinksProvider); | ||
|
||
Future<void> handleDeepLink(Uri link) async { | ||
if (link.toString().contains(RedirectURL.auth) && | ||
link.queryParameters['code'] != null) { | ||
// Set the dropbox token from the code | ||
final authService = container.read(authServiceProvider); | ||
await authService.setDropboxTokenFromCode( | ||
code: link.queryParameters['code']!, | ||
); | ||
|
||
final dropboxService = container.read(dropboxServiceProvider); | ||
await dropboxService.setCurrentUserAccount(); | ||
} | ||
} | ||
|
||
try { | ||
final initialLink = await appLinks.getInitialLink(); | ||
if (initialLink != null && !kDebugMode) handleDeepLink(initialLink); | ||
} catch (error) { | ||
log( | ||
"Failed to handle initial deep link", | ||
error: error, | ||
name: "DeepLinkHandler", | ||
); | ||
} | ||
|
||
appLinks.uriLinkStream.listen( | ||
(link) => handleDeepLink(link), | ||
onError: (error) { | ||
log( | ||
"Failed to listen to deep links", | ||
error: error, | ||
name: "DeepLinkHandler", | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.