mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 21:30:16 +02:00
Merge pull request #1240 from ImranR98/dev
- Remove reference to old plugin to avoid crashes (#1221) - Confirmation box for link-based imports (#1232) - Construct extracted versions from match groups (#1235) - Fix the WebView 'cleartext' error caused by HTTP sites (#1235) - Make GitHub's (and Codeberg's) "fallback" work with the APK filter (#1236) - Make version extraction universal (#1237) - HTML Bugfix (#1238)
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:app_links/app_links.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:obtainium/components/generated_form_modal.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/pages/add_app.dart';
|
||||
import 'package:obtainium/pages/apps.dart';
|
||||
@@ -76,14 +77,39 @@ class _HomePageState extends State<HomePage> {
|
||||
try {
|
||||
if (action == 'add') {
|
||||
await goToAddApp(data);
|
||||
} else if (action == 'app') {
|
||||
await context
|
||||
.read<AppsProvider>()
|
||||
.import('{ "apps": [${Uri.decodeComponent(data)}] }');
|
||||
} else if (action == 'apps') {
|
||||
await context
|
||||
.read<AppsProvider>()
|
||||
.import('{ "apps": ${Uri.decodeComponent(data)} }');
|
||||
} else if (action == 'app' || action == 'apps') {
|
||||
var dataStr = Uri.decodeComponent(data);
|
||||
if (await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: tr('importX', args: [
|
||||
action == 'app' ? tr('app') : tr('appsString')
|
||||
]),
|
||||
items: const [],
|
||||
additionalWidgets: [
|
||||
ExpansionTile(
|
||||
title: const Text('Raw JSON'),
|
||||
children: [
|
||||
Text(
|
||||
dataStr,
|
||||
style: const TextStyle(fontFamily: 'monospace'),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}) !=
|
||||
null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
var result = await context.read<AppsProvider>().import(
|
||||
action == 'app'
|
||||
? '{ "apps": [$dataStr] }'
|
||||
: '{ "apps": $dataStr }');
|
||||
// ignore: use_build_context_synchronously
|
||||
showMessage(
|
||||
tr('importedX', args: [plural('apps', result.key)]), context);
|
||||
}
|
||||
} else {
|
||||
throw ObtainiumError(tr('unknown'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user