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

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

View File

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