Updated version, standardized quotes, deleted test_page

This commit is contained in:
Imran Remtulla
2022-09-25 00:21:41 -04:00
parent f58d26524c
commit 9a4b0301be
10 changed files with 41 additions and 97 deletions

View File

@@ -21,9 +21,9 @@ class GitHub implements AppSource {
Future<APKDetails> getLatestAPKDetails( Future<APKDetails> getLatestAPKDetails(
String standardUrl, List<String> additionalData) async { String standardUrl, List<String> additionalData) async {
var includePrereleases = var includePrereleases =
additionalData.isNotEmpty && additionalData[0] == "true"; additionalData.isNotEmpty && additionalData[0] == 'true';
var fallbackToOlderReleases = var fallbackToOlderReleases =
additionalData.length >= 2 && additionalData[1] == "true"; additionalData.length >= 2 && additionalData[1] == 'true';
var regexFilter = additionalData.length >= 3 && additionalData[2].isNotEmpty var regexFilter = additionalData.length >= 3 && additionalData[2].isNotEmpty
? additionalData[2] ? additionalData[2]
: null; : null;
@@ -92,14 +92,14 @@ class GitHub implements AppSource {
@override @override
List<List<GeneratedFormItem>> additionalDataFormItems = [ List<List<GeneratedFormItem>> additionalDataFormItems = [
[GeneratedFormItem(label: "Include prereleases", type: FormItemType.bool)], [GeneratedFormItem(label: 'Include prereleases', type: FormItemType.bool)],
[ [
GeneratedFormItem( GeneratedFormItem(
label: "Fallback to older releases", type: FormItemType.bool) label: 'Fallback to older releases', type: FormItemType.bool)
], ],
[ [
GeneratedFormItem( GeneratedFormItem(
label: "Filter Release Titles by Regular Expression", label: 'Filter Release Titles by Regular Expression',
type: FormItemType.string, type: FormItemType.string,
required: false, required: false,
additionalValidators: [ additionalValidators: [
@@ -110,7 +110,7 @@ class GitHub implements AppSource {
try { try {
RegExp(value); RegExp(value);
} catch (e) { } catch (e) {
return "Invalid regular expression"; return 'Invalid regular expression';
} }
return null; return null;
} }
@@ -119,5 +119,5 @@ class GitHub implements AppSource {
]; ];
@override @override
List<String> additionalDataDefaults = ["true", "true", ""]; List<String> additionalDataDefaults = ['true', 'true', ''];
} }

View File

@@ -12,7 +12,7 @@ class GeneratedFormItem {
late List<String? Function(String? value)> additionalValidators; late List<String? Function(String? value)> additionalValidators;
GeneratedFormItem( GeneratedFormItem(
{this.label = "Input", {this.label = 'Input',
this.type = FormItemType.string, this.type = FormItemType.string,
this.required = true, this.required = true,
this.max = 1, this.max = 1,
@@ -69,7 +69,7 @@ class _GeneratedFormState extends State<GeneratedForm> {
.map((row) => row.map((e) { .map((row) => row.map((e) {
return j < widget.defaultValues.length return j < widget.defaultValues.length
? widget.defaultValues[j++] ? widget.defaultValues[j++]
: ""; : '';
}).toList()) }).toList())
.toList(); .toList();
@@ -89,7 +89,7 @@ class _GeneratedFormState extends State<GeneratedForm> {
}); });
}, },
decoration: InputDecoration( decoration: InputDecoration(
helperText: e.value.label + (e.value.required ? " *" : "")), helperText: e.value.label + (e.value.required ? ' *' : '')),
minLines: e.value.max <= 1 ? null : e.value.max, minLines: e.value.max <= 1 ? null : e.value.max,
maxLines: e.value.max <= 1 ? 1 : e.value.max, maxLines: e.value.max <= 1 ? 1 : e.value.max,
validator: (value) { validator: (value) {
@@ -122,10 +122,10 @@ class _GeneratedFormState extends State<GeneratedForm> {
children: [ children: [
Text(widget.items[r][e].label), Text(widget.items[r][e].label),
Switch( Switch(
value: values[r][e] == "true", value: values[r][e] == 'true',
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
values[r][e] = value ? "true" : ""; values[r][e] = value ? 'true' : '';
someValueChanged(); someValueChanged();
}); });
}) })

View File

@@ -9,7 +9,7 @@ class GeneratedFormModal extends StatefulWidget {
required this.items, required this.items,
required this.defaultValues, required this.defaultValues,
this.initValid = false, this.initValid = false,
this.message = ""}); this.message = ''});
final String title; final String title;
final String message; final String message;
@@ -40,7 +40,7 @@ class _GeneratedFormModalState extends State<GeneratedFormModal> {
Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
if (widget.message.isNotEmpty) Text(widget.message), if (widget.message.isNotEmpty) Text(widget.message),
if (widget.message.isNotEmpty) if (widget.message.isNotEmpty)
SizedBox( const SizedBox(
height: 16, height: 16,
), ),
GeneratedForm( GeneratedForm(

View File

@@ -13,7 +13,7 @@ import 'package:dynamic_color/dynamic_color.dart';
import 'package:device_info_plus/device_info_plus.dart'; import 'package:device_info_plus/device_info_plus.dart';
const String currentReleaseTag = const String currentReleaseTag =
'v0.3.2-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES 'v0.4.0-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
@pragma('vm:entry-point') @pragma('vm:entry-point')
void bgTaskCallback() { void bgTaskCallback() {
@@ -118,7 +118,7 @@ class MyApp extends StatelessWidget {
currentReleaseTag, currentReleaseTag,
[], [],
0, 0,
["true"])); ['true']));
} }
} }

View File

@@ -19,7 +19,7 @@ class AddAppPage extends StatefulWidget {
class _AddAppPageState extends State<AddAppPage> { class _AddAppPageState extends State<AddAppPage> {
bool gettingAppInfo = false; bool gettingAppInfo = false;
String userInput = ""; String userInput = '';
AppSource? pickedSource; AppSource? pickedSource;
List<String> additionalData = []; List<String> additionalData = [];
bool validAdditionalData = true; bool validAdditionalData = true;
@@ -44,19 +44,19 @@ class _AddAppPageState extends State<AddAppPage> {
items: [ items: [
[ [
GeneratedFormItem( GeneratedFormItem(
label: "App Source Url", label: 'App Source Url',
additionalValidators: [ additionalValidators: [
(value) { (value) {
try { try {
sourceProvider sourceProvider
.getSource(value ?? "") .getSource(value ?? '')
.standardizeURL( .standardizeURL(
makeUrlHttps( makeUrlHttps(
value ?? "")); value ?? ''));
} catch (e) { } catch (e) {
return e is String return e is String
? e ? e
: "Error"; : 'Error';
} }
return null; return null;
} }

View File

@@ -247,13 +247,13 @@ class AppsPageState extends State<AppsPage> {
formInputs.add([ formInputs.add([
GeneratedFormItem( GeneratedFormItem(
label: label:
"Update ${existingUpdateIdsSelected.length} Apps?", 'Update ${existingUpdateIdsSelected.length} Apps?',
type: FormItemType.bool) type: FormItemType.bool)
]); ]);
formInputs.add([ formInputs.add([
GeneratedFormItem( GeneratedFormItem(
label: label:
"Install ${newInstallIdsSelected.length} new Apps?", 'Install ${newInstallIdsSelected.length} new Apps?',
type: FormItemType.bool) type: FormItemType.bool)
]); ]);
} }
@@ -261,13 +261,13 @@ class AppsPageState extends State<AppsPage> {
context: context, context: context,
builder: (BuildContext ctx) { builder: (BuildContext ctx) {
return GeneratedFormModal( return GeneratedFormModal(
title: "Install Selected Apps?", title: 'Install Selected Apps?',
message: message:
"${existingUpdateIdsSelected.length} update${existingUpdateIdsSelected.length == 1 ? '' : 's'} and ${newInstallIdsSelected.length} new install${newInstallIdsSelected.length == 1 ? '' : 's'}.", '${existingUpdateIdsSelected.length} update${existingUpdateIdsSelected.length == 1 ? '' : 's'} and ${newInstallIdsSelected.length} new install${newInstallIdsSelected.length == 1 ? '' : 's'}.',
items: formInputs, items: formInputs,
defaultValues: const [ defaultValues: const [
"true", 'true',
"true" 'true'
], ],
initValid: true, initValid: true,
); );
@@ -275,10 +275,10 @@ class AppsPageState extends State<AppsPage> {
if (values != null) { if (values != null) {
bool shouldInstallUpdates = bool shouldInstallUpdates =
values.length < 2 || values.length < 2 ||
values[0] == "true"; values[0] == 'true';
bool shouldInstallNew = bool shouldInstallNew =
values.length < 2 || values.length < 2 ||
values[1] == "true"; values[1] == 'true';
settingsProvider settingsProvider
.getInstallPermission() .getInstallPermission()
.then((_) { .then((_) {
@@ -323,18 +323,18 @@ class AppsPageState extends State<AppsPage> {
items: [ items: [
[ [
GeneratedFormItem( GeneratedFormItem(
label: "App Name", required: false), label: 'App Name', required: false),
GeneratedFormItem( GeneratedFormItem(
label: "Author", required: false) label: 'Author', required: false)
], ],
[ [
GeneratedFormItem( GeneratedFormItem(
label: "Up to Date Apps", label: 'Up to Date Apps',
type: FormItemType.bool) type: FormItemType.bool)
], ],
[ [
GeneratedFormItem( GeneratedFormItem(
label: "Non-Installed Apps", label: 'Non-Installed Apps',
type: FormItemType.bool) type: FormItemType.bool)
] ]
], ],
@@ -371,8 +371,8 @@ class AppsFilter {
late bool includeNonInstalled; late bool includeNonInstalled;
AppsFilter( AppsFilter(
{this.nameFilter = "", {this.nameFilter = '',
this.authorFilter = "", this.authorFilter = '',
this.includeUptodate = true, this.includeUptodate = true,
this.includeNonInstalled = true}); this.includeNonInstalled = true});
@@ -380,16 +380,16 @@ class AppsFilter {
return [ return [
nameFilter, nameFilter,
authorFilter, authorFilter,
includeUptodate ? "true" : "", includeUptodate ? 'true' : '',
includeNonInstalled ? "true" : "" includeNonInstalled ? 'true' : ''
]; ];
} }
AppsFilter.fromValuesArray(List<String> values) { AppsFilter.fromValuesArray(List<String> values) {
nameFilter = values[0]; nameFilter = values[0];
authorFilter = values[1]; authorFilter = values[1];
includeUptodate = values[2] == "true"; includeUptodate = values[2] == 'true';
includeNonInstalled = values[3] == "true"; includeNonInstalled = values[3] == 'true';
} }
bool isIdenticalTo(AppsFilter other) => bool isIdenticalTo(AppsFilter other) =>

View File

@@ -1,53 +0,0 @@
import 'package:flutter/material.dart';
import 'package:obtainium/components/generated_form.dart';
class TestPage extends StatefulWidget {
const TestPage({super.key});
@override
State<TestPage> createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
List<String?>? sourceSpecificData;
bool valid = false;
List<List<GeneratedFormItem>> sourceSpecificInputs = [
[GeneratedFormItem(label: 'Test Item 1')],
[
GeneratedFormItem(label: 'Test Item 2', required: false),
GeneratedFormItem(label: 'Test Item 3')
],
[GeneratedFormItem(label: 'Test Item 4', type: FormItemType.bool)]
];
List<String> defaultInputValues = ["ABC"];
void onSourceSpecificDataChanges(
List<String?> valuesFromForm, bool formValid) {
setState(() {
sourceSpecificData = valuesFromForm;
valid = formValid;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Test Page')),
backgroundColor: Theme.of(context).colorScheme.surface,
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(children: [
GeneratedForm(
items: sourceSpecificInputs,
onValueChanges: onSourceSpecificDataChanges,
defaultValues: defaultInputValues,
),
...(sourceSpecificData != null
? (sourceSpecificData as List<String?>)
.map((e) => Text(e ?? ""))
: [Container()])
])));
}
}

View File

@@ -113,9 +113,6 @@ class AppsProvider with ChangeNotifier {
cancelExisting: true); cancelExisting: true);
await FGBGEvents.stream.first == FGBGType.foreground; await FGBGEvents.stream.first == FGBGType.foreground;
await notificationsProvider.cancel(completeInstallationNotification.id); await notificationsProvider.cancel(completeInstallationNotification.id);
// We need to wait for the App to come to the foreground to install it
// Can't try to call install plugin in a background isolate (may not have worked anyways) because of:
// https://github.com/flutter/flutter/issues/13937
} }
} }

View File

@@ -85,7 +85,7 @@ class App {
escapeRegEx(String s) { escapeRegEx(String s) {
return s.replaceAllMapped(RegExp(r'[.*+?^${}()|[\]\\]'), (x) { return s.replaceAllMapped(RegExp(r'[.*+?^${}()|[\]\\]'), (x) {
return "\\${x[0]}"; return '\\${x[0]}';
}); });
} }

View File

@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 0.3.2+18 # When changing this, update the tag in main() accordingly version: 0.4.0+19 # When changing this, update the tag in main() accordingly
environment: environment:
sdk: '>=2.19.0-79.0.dev <3.0.0' sdk: '>=2.19.0-79.0.dev <3.0.0'