-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat:get anilist data change android manifeast for web auth SettingKey.tmdbKay -> SettingKey.tmdbKey add svg and web auth library add in app webview update anilist api * initial desktop support * feat(mobile):add anilist * feat: anilist fully support on desktop * feat: show snakbar also change the position of tracking button * fix: anilist ui for android -add unbind button that only delete inapp instead of deleting anilist too - redesign ui for android list editor * anilist tracking page * fix anilist tracking page * anilist more page * AniList binding page * getMediaList by using id * fix: edit list error add auto update progress in anime * Revert "fix: edit list error" This reverts commit ca3f819. * feat: desktop tracking dialog * feat: android tracking dialog * fix * fix * Refactor AnilistType usage in detail_tracking_button.dart * Refactor Anilist tracking dialog and horizontal list widget * Add auto-tracking feature and Anilist integration * Fix Anilist token saving and cookie handling * Fix error handling in AniListProvider and AnilistMorePage * add i18n * Update localization and UI text --------- Co-authored-by: MiaoMint <miaomint@0u0.ren>
- Loading branch information
1 parent
4c40645
commit f663535
Showing
39 changed files
with
2,667 additions
and
96 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter_windows_webview/flutter_windows_webview.dart'; | ||
import 'package:get/get.dart'; | ||
import 'package:miru_app/data/providers/anilist_provider.dart'; | ||
import 'package:miru_app/utils/miru_storage.dart'; | ||
import 'package:miru_app/views/pages/tracking/anilist_webview.dart'; | ||
|
||
class TrackingPageController extends GetxController { | ||
final anilistIsLogin = false.obs; | ||
final anilistOauthUrl = "".obs; | ||
final anilistUserData = {}.obs; | ||
|
||
Future<Map<String, dynamic>> initAnilistData() async { | ||
final Map<String, dynamic> result = {}; | ||
result["userData"] = await AniListProvider.getuserData(); | ||
result["animeData"] = | ||
await AniListProvider.getCollection(AnilistType.anime); | ||
result["mangaData"] = | ||
await AniListProvider.getCollection(AnilistType.manga); | ||
return result; | ||
} | ||
|
||
_saveAnilistToken(String result) { | ||
RegExp tokenRegex = RegExp(r'(?<=access_token=).+(?=&token_type)'); | ||
Match? re = tokenRegex.firstMatch(result); | ||
if (re != null) { | ||
String token = re.group(0)!; | ||
updateAniListToken(token); | ||
} | ||
} | ||
|
||
updateAniListToken(String accessToken) { | ||
MiruStorage.setSetting(SettingKey.aniListToken, accessToken); | ||
anilistIsLogin.value = true; | ||
initAnilistData(); | ||
} | ||
|
||
logoutAniList() { | ||
MiruStorage.setSetting(SettingKey.aniListToken, ""); | ||
anilistIsLogin.value = false; | ||
} | ||
|
||
loginAniList() async { | ||
const loginUrl = | ||
"https://anilist.co/api/v2/oauth/authorize?client_id=16214&response_type=token"; | ||
if (Platform.isAndroid) { | ||
final result = await Get.to( | ||
() => const AnilistWebViewPage(url: loginUrl), | ||
); | ||
_saveAnilistToken(result); | ||
return; | ||
} | ||
final webview = FlutterWindowsWebview(); | ||
webview.launchWebview(loginUrl, WebviewOptions( | ||
onNavigation: (url) { | ||
if (url.contains("miru-app")) { | ||
_saveAnilistToken(url); | ||
webview.getCookies("https://anilist.co").then((cookies) async { | ||
for (final cookie in cookies.entries) { | ||
await webview.setCookie( | ||
name: cookie.key, | ||
value: "", | ||
domain: "anilist.co", | ||
); | ||
} | ||
webview.close(); | ||
}); | ||
} | ||
return false; | ||
}, | ||
)); | ||
} | ||
|
||
@override | ||
void onInit() { | ||
final token = MiruStorage.getSetting(SettingKey.aniListToken); | ||
if (token != "") { | ||
anilistIsLogin.value = true; | ||
} | ||
super.onInit(); | ||
} | ||
} |
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
Oops, something went wrong.