mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 04:37:37 +02:00
feat: Add a toggle for alternative sources (#1686)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
@ -14,9 +14,9 @@ class ContributorsViewModel extends BaseViewModel {
|
||||
final Map<String, List<dynamic>> contributors =
|
||||
await _managerAPI.getContributors();
|
||||
patcherContributors = contributors[_managerAPI.defaultPatcherRepo] ?? [];
|
||||
patchesContributors = contributors[_managerAPI.getPatchesRepo().toLowerCase()] ?? [];
|
||||
patchesContributors = contributors[_managerAPI.defaultPatchesRepo] ?? [];
|
||||
integrationsContributors =
|
||||
contributors[_managerAPI.getIntegrationsRepo().toLowerCase()] ?? [];
|
||||
contributors[_managerAPI.defaultIntegrationsRepo] ?? [];
|
||||
cliContributors = contributors[_managerAPI.defaultCliRepo] ?? [];
|
||||
managerContributors = contributors[_managerAPI.defaultManagerRepo] ?? [];
|
||||
notifyListeners();
|
||||
|
@ -12,17 +12,14 @@ class SManageSources extends BaseViewModel {
|
||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||
final Toast _toast = locator<Toast>();
|
||||
|
||||
final TextEditingController _hostSourceController = TextEditingController();
|
||||
final TextEditingController _orgPatSourceController = TextEditingController();
|
||||
final TextEditingController _patSourceController = TextEditingController();
|
||||
final TextEditingController _orgIntSourceController = TextEditingController();
|
||||
final TextEditingController _intSourceController = TextEditingController();
|
||||
|
||||
Future<void> showSourcesDialog(BuildContext context) async {
|
||||
final String hostRepository = _managerAPI.getRepoUrl();
|
||||
final String patchesRepo = _managerAPI.getPatchesRepo();
|
||||
final String integrationsRepo = _managerAPI.getIntegrationsRepo();
|
||||
_hostSourceController.text = hostRepository;
|
||||
_orgPatSourceController.text = patchesRepo.split('/')[0];
|
||||
_patSourceController.text = patchesRepo.split('/')[1];
|
||||
_orgIntSourceController.text = integrationsRepo.split('/')[0];
|
||||
@ -44,26 +41,6 @@ class SManageSources extends BaseViewModel {
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
/*
|
||||
API for accessing the specified repositories
|
||||
If default is used, will use the ReVanced API
|
||||
*/
|
||||
TextField(
|
||||
controller: _hostSourceController,
|
||||
autocorrect: false,
|
||||
onChanged: (value) => notifyListeners(),
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
Icons.rocket_launch_outlined,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: t.settingsView.hostRepositoryLabel,
|
||||
hintText: hostRepository,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Patches owner's name
|
||||
TextField(
|
||||
controller: _orgPatSourceController,
|
||||
autocorrect: false,
|
||||
@ -144,7 +121,6 @@ class SManageSources extends BaseViewModel {
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
_managerAPI.setRepoUrl(_hostSourceController.text.trim());
|
||||
_managerAPI.setPatchesRepo(
|
||||
'${_orgPatSourceController.text.trim()}/${_patSourceController.text.trim()}',
|
||||
);
|
||||
@ -176,7 +152,6 @@ class SManageSources extends BaseViewModel {
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
_managerAPI.setRepoUrl('');
|
||||
_managerAPI.setPatchesRepo('');
|
||||
_managerAPI.setIntegrationsRepo('');
|
||||
_managerAPI.setCurrentPatchesVersion('0.0.0');
|
||||
|
@ -7,6 +7,7 @@ import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_upd
|
||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_theme.dart';
|
||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_advanced_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_data_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_debug_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_export_section.dart';
|
||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_team_section.dart';
|
||||
@ -49,6 +50,8 @@ class SettingsView extends StatelessWidget {
|
||||
_settingsDivider,
|
||||
SAdvancedSection(),
|
||||
_settingsDivider,
|
||||
SDataSection(),
|
||||
_settingsDivider,
|
||||
SExportSection(),
|
||||
_settingsDivider,
|
||||
STeamSection(),
|
||||
|
@ -53,6 +53,17 @@ class SettingsViewModel extends BaseViewModel {
|
||||
return _managerAPI.isPatchesChangeEnabled();
|
||||
}
|
||||
|
||||
void useAlternativeSources(bool value) {
|
||||
_managerAPI.useAlternativeSources(value);
|
||||
_managerAPI.setCurrentPatchesVersion('0.0.0');
|
||||
_managerAPI.setCurrentIntegrationsVersion('0.0.0');
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isUsingAlternativeSources() {
|
||||
return _managerAPI.isUsingAlternativeSources();
|
||||
}
|
||||
|
||||
Future<void> showPatchesChangeEnableDialog(
|
||||
bool value,
|
||||
BuildContext context,
|
||||
|
Reference in New Issue
Block a user