mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2026-01-28 21:31:05 +00:00
feat: Add custom patches sources
This commit is contained in:
@@ -1,36 +1,33 @@
|
||||
import 'package:github/github.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/services/github_api.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class ContributorsViewModel extends BaseViewModel {
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
final GithubAPI _githubAPI = GithubAPI();
|
||||
List<Contributor> patcherContributors = [];
|
||||
List<Contributor> patchesContributors = [];
|
||||
List<Contributor> integrationsContributors = [];
|
||||
List<Contributor> patcherContributors = [];
|
||||
List<Contributor> cliContributors = [];
|
||||
List<Contributor> managerContributors = [];
|
||||
|
||||
Future<void> getContributors() async {
|
||||
patcherContributors = await _githubAPI.getContributors(
|
||||
_managerAPI.getPatcherRepo(),
|
||||
);
|
||||
patchesContributors = await _githubAPI.getContributors(
|
||||
ghOrg,
|
||||
patchesRepo,
|
||||
_managerAPI.getPatchesRepo(),
|
||||
);
|
||||
integrationsContributors = await _githubAPI.getContributors(
|
||||
ghOrg,
|
||||
integrationsRepo,
|
||||
);
|
||||
patcherContributors = await _githubAPI.getContributors(
|
||||
ghOrg,
|
||||
patcherRepo,
|
||||
_managerAPI.getIntegrationsRepo(),
|
||||
);
|
||||
cliContributors = await _githubAPI.getContributors(
|
||||
ghOrg,
|
||||
cliRepo,
|
||||
_managerAPI.getCliRepo(),
|
||||
);
|
||||
managerContributors = await _githubAPI.getContributors(
|
||||
ghOrg,
|
||||
managerRepo,
|
||||
_managerAPI.getManagerRepo(),
|
||||
);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class NavigationViewModel extends IndexTrackingViewModel {
|
||||
case 1:
|
||||
return const PatcherView();
|
||||
case 2:
|
||||
return SettingsView();
|
||||
return const SettingsView();
|
||||
default:
|
||||
return const HomeView();
|
||||
}
|
||||
|
||||
@@ -7,17 +7,11 @@ import 'package:revanced_manager/ui/widgets/settingsView/custom_switch_tile.dart
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_tile_dialog.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/social_media_widget.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/sources_widget.dart';
|
||||
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class SettingsView extends StatelessWidget {
|
||||
final TextEditingController organizationController = TextEditingController();
|
||||
final TextEditingController patchesSourceController = TextEditingController();
|
||||
final TextEditingController integrationsSourceController =
|
||||
TextEditingController();
|
||||
|
||||
SettingsView({Key? key}) : super(key: key);
|
||||
const SettingsView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -87,38 +81,18 @@ class SettingsView extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
SettingsTileDialog(
|
||||
title: 'settingsView.languageLabel',
|
||||
subtitle: 'English',
|
||||
children: <Widget>[
|
||||
RadioListTile<String>(
|
||||
title: I18nText('settingsView.englishOption'),
|
||||
value: 'en',
|
||||
groupValue: 'en',
|
||||
onChanged: (value) {
|
||||
model.updateLanguage(context, value);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
RadioListTile<String>(
|
||||
title: I18nText('settingsView.frenchOption'),
|
||||
value: 'fr',
|
||||
groupValue: 'en',
|
||||
onChanged: (value) {
|
||||
model.updateLanguage(context, value);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
]),
|
||||
title: 'settingsView.languageLabel',
|
||||
subtitle: 'English',
|
||||
onTap: () => model.showLanguagesDialog(context),
|
||||
),
|
||||
const Divider(thickness: 1.0),
|
||||
SettingsSection(
|
||||
title: 'settingsView.patcherSectionTitle',
|
||||
children: <Widget>[
|
||||
SourcesWidget(
|
||||
SettingsTileDialog(
|
||||
title: 'settingsView.sourcesLabel',
|
||||
organizationController: organizationController,
|
||||
patchesSourceController: patchesSourceController,
|
||||
integrationsSourceController:
|
||||
integrationsSourceController,
|
||||
subtitle: 'settingsView.sourcesLabelHint',
|
||||
onTap: () => model.showSourcesDialog(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
import 'package:dynamic_themes/dynamic_themes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/app/app.router.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/custom_text_field.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
import 'package:timeago/timeago.dart';
|
||||
@@ -13,6 +16,10 @@ import 'package:timeago/timeago.dart';
|
||||
class SettingsViewModel extends BaseViewModel {
|
||||
final NavigationService _navigationService = locator<NavigationService>();
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
final TextEditingController _orgPatSourceController = TextEditingController();
|
||||
final TextEditingController _patSourceController = TextEditingController();
|
||||
final TextEditingController _orgIntSourceController = TextEditingController();
|
||||
final TextEditingController _intSourceController = TextEditingController();
|
||||
|
||||
void setLanguage(String language) {
|
||||
notifyListeners();
|
||||
@@ -58,4 +65,115 @@ class SettingsViewModel extends BaseViewModel {
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> showLanguagesDialog(BuildContext context) {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => SimpleDialog(
|
||||
title: I18nText('settingsView.languageLabel'),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
children: <Widget>[
|
||||
RadioListTile<String>(
|
||||
title: I18nText('settingsView.englishOption'),
|
||||
value: 'en',
|
||||
groupValue: 'en',
|
||||
onChanged: (value) {
|
||||
updateLanguage(context, value);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> showSourcesDialog(BuildContext context) async {
|
||||
String patchesRepo = _managerAPI.getPatchesRepo();
|
||||
String integrationsRepo = _managerAPI.getIntegrationsRepo();
|
||||
_orgPatSourceController.text = patchesRepo.split('/')[0];
|
||||
_patSourceController.text = patchesRepo.split('/')[1];
|
||||
_orgIntSourceController.text = integrationsRepo.split('/')[0];
|
||||
_intSourceController.text = integrationsRepo.split('/')[1];
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: I18nText('settingsView.sourcesLabel'),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
CustomTextField(
|
||||
leadingIcon: Icon(
|
||||
Icons.extension_outlined,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
inputController: _orgPatSourceController,
|
||||
label: I18nText('settingsView.orgPatchesLabel'),
|
||||
hint: patchesRepo.split('/')[0],
|
||||
onChanged: (value) => notifyListeners(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CustomTextField(
|
||||
leadingIcon: const Icon(
|
||||
Icons.extension_outlined,
|
||||
color: Colors.transparent,
|
||||
),
|
||||
inputController: _patSourceController,
|
||||
label: I18nText('settingsView.sourcesPatchesLabel'),
|
||||
hint: patchesRepo.split('/')[1],
|
||||
onChanged: (value) => notifyListeners(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
CustomTextField(
|
||||
leadingIcon: Icon(
|
||||
Icons.merge_outlined,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
inputController: _orgIntSourceController,
|
||||
label: I18nText('settingsView.orgIntegrationsLabel'),
|
||||
hint: integrationsRepo.split('/')[0],
|
||||
onChanged: (value) => notifyListeners(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
CustomTextField(
|
||||
leadingIcon: const Icon(
|
||||
Icons.merge_outlined,
|
||||
color: Colors.transparent,
|
||||
),
|
||||
inputController: _intSourceController,
|
||||
label: I18nText('settingsView.sourcesIntegrationsLabel'),
|
||||
hint: integrationsRepo.split('/')[1],
|
||||
onChanged: (value) => notifyListeners(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CustomMaterialButton(
|
||||
isFilled: false,
|
||||
label: I18nText('cancelButton'),
|
||||
onPressed: () {
|
||||
_orgPatSourceController.clear();
|
||||
_patSourceController.clear();
|
||||
_orgIntSourceController.clear();
|
||||
_intSourceController.clear();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CustomMaterialButton(
|
||||
label: I18nText('okButton'),
|
||||
onPressed: () {
|
||||
_managerAPI.setPatchesRepo(
|
||||
'${_orgPatSourceController.text}/${_patSourceController.text}',
|
||||
);
|
||||
_managerAPI.setIntegrationsRepo(
|
||||
'${_orgIntSourceController.text}/${_intSourceController.text}',
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
)
|
||||
],
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user