feat: Use ReVanced API v4

This commit is contained in:
oSumAtrIX
2024-11-09 01:39:31 +01:00
parent 44b8d4ceee
commit 7b7d91d661
6 changed files with 58 additions and 58 deletions

View File

@ -30,25 +30,13 @@ class ContributorsView extends StatelessWidget {
sliver: SliverList(
delegate: SliverChildListDelegate.fixed(
<Widget>[
ContributorsCard(
title: 'ReVanced Patcher',
contributors: model.patcherContributors,
),
const SizedBox(height: 20),
ContributorsCard(
title: 'ReVanced Patches',
contributors: model.patchesContributors,
),
const SizedBox(height: 20),
ContributorsCard(
title: 'ReVanced CLI',
contributors: model.cliContributors,
),
const SizedBox(height: 20),
ContributorsCard(
title: 'ReVanced Manager',
contributors: model.managerContributors,
),
for (final String tool in model.contributors.keys) ...[
ContributorsCard(
title: tool,
contributors: model.contributors[tool]!,
),
const SizedBox(height: 20),
],
SizedBox(height: MediaQuery.viewPaddingOf(context).bottom),
],
),

View File

@ -4,20 +4,10 @@ import 'package:stacked/stacked.dart';
class ContributorsViewModel extends BaseViewModel {
final ManagerAPI _managerAPI = locator<ManagerAPI>();
List<dynamic> patcherContributors = [];
List<dynamic> patchesContributors = [];
List<dynamic> cliContributors = [];
List<dynamic> managerContributors = [];
String repoName(String repo) => repo.split('/').last;
Map<String, List<dynamic>> contributors = {};
Future<void> getContributors() async {
final Map<String, List<dynamic>> contributors =
await _managerAPI.getContributors();
patcherContributors = contributors[repoName(_managerAPI.defaultPatcherRepo)] ?? [];
patchesContributors = contributors[repoName(_managerAPI.defaultPatchesRepo)] ?? [];
cliContributors = contributors[repoName(_managerAPI.defaultCliRepo)] ?? [];
managerContributors = contributors[repoName(_managerAPI.defaultManagerRepo)] ?? [];
contributors = await _managerAPI.getContributors();
notifyListeners();
}
}

View File

@ -13,8 +13,9 @@ class SManageApiUrl extends BaseViewModel {
final TextEditingController _apiUrlController = TextEditingController();
Future<void> showApiUrlDialog(BuildContext context) async {
final String apiUrl = _managerAPI.getApiUrl();
_apiUrlController.text = apiUrl.replaceAll('https://', '');
final apiUrl = _managerAPI.getApiUrl();
_apiUrlController.text = apiUrl;
return showDialog(
context: context,
builder: (context) => AlertDialog(
@ -60,11 +61,7 @@ class SManageApiUrl extends BaseViewModel {
),
FilledButton(
onPressed: () {
String apiUrl = _apiUrlController.text;
if (!apiUrl.startsWith('https')) {
apiUrl = 'https://$apiUrl';
}
_managerAPI.setApiUrl(apiUrl);
_managerAPI.setApiUrl(_apiUrlController.text);
Navigator.of(context).pop();
},
child: Text(t.okButton),
@ -87,7 +84,7 @@ class SManageApiUrl extends BaseViewModel {
),
FilledButton(
onPressed: () {
_managerAPI.setApiUrl('');
_managerAPI.resetApiUrl();
Navigator.of(context)
..pop()
..pop();

View File

@ -49,7 +49,7 @@ class _ContributorsCardState extends State<ContributorsCard> {
child: GestureDetector(
onTap: () => launchUrl(
Uri.parse(
widget.contributors[index]['html_url'],
widget.contributors[index]['url'],
),
mode: LaunchMode.externalApplication,
),