Search allows option changes (no direct add)

This commit is contained in:
Imran Remtulla
2023-01-29 17:23:35 -05:00
parent ee4d0f259f
commit 60e3b68ebd

View File

@@ -32,6 +32,7 @@ class _AddAppPageState extends State<AddAppPage> {
Map<String, dynamic> additionalSettings = {}; Map<String, dynamic> additionalSettings = {};
bool additionalSettingsValid = true; bool additionalSettingsValid = true;
List<String> pickedCategories = []; List<String> pickedCategories = [];
int searchnum = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -40,10 +41,14 @@ class _AddAppPageState extends State<AddAppPage> {
bool doingSomething = gettingAppInfo || searching; bool doingSomething = gettingAppInfo || searching;
changeUserInput(String input, bool valid, bool isBuilding) { changeUserInput(String input, bool valid, bool isBuilding,
{bool isSearch = false}) {
userInput = input; userInput = input;
if (!isBuilding) { if (!isBuilding) {
setState(() { setState(() {
if (isSearch) {
searchnum++;
}
var source = valid ? sourceProvider.getSource(userInput) : null; var source = valid ? sourceProvider.getSource(userInput) : null;
if (pickedSource.runtimeType != source.runtimeType) { if (pickedSource.runtimeType != source.runtimeType) {
pickedSource = source; pickedSource = source;
@@ -169,30 +174,32 @@ class _AddAppPageState extends State<AddAppPage> {
children: [ children: [
Expanded( Expanded(
child: GeneratedForm( child: GeneratedForm(
key: Key(searchnum.toString()),
items: [ items: [
[ [
GeneratedFormTextField('appSourceURL', GeneratedFormTextField('appSourceURL',
label: tr('appSourceURL'), label: tr('appSourceURL'),
additionalValidators: [ defaultValue: userInput,
(value) { additionalValidators: [
try { (value) {
sourceProvider try {
.getSource(value ?? '') sourceProvider
.standardizeURL( .getSource(value ?? '')
preStandardizeUrl( .standardizeURL(
value ?? '')); preStandardizeUrl(
} catch (e) { value ?? ''));
return e is String } catch (e) {
? e return e is String
: e is ObtainiumError ? e
? e.toString() : e is ObtainiumError
: tr('error'); ? e.toString()
} : tr('error');
return null; }
} return null;
]) }
] ])
], ]
],
onValueChanges: (values, valid, isBuilding) { onValueChanges: (values, valid, isBuilding) {
changeUserInput(values['appSourceURL']!, changeUserInput(values['appSourceURL']!,
valid, isBuilding); valid, isBuilding);
@@ -296,8 +303,8 @@ class _AddAppPageState extends State<AddAppPage> {
if (selectedUrls != null && if (selectedUrls != null &&
selectedUrls.isNotEmpty) { selectedUrls.isNotEmpty) {
changeUserInput( changeUserInput(
selectedUrls[0], true, false); selectedUrls[0], true, false,
addApp(resetUserInputAfter: true); isSearch: true);
} }
}).catchError((e) { }).catchError((e) {
showError(e, context); showError(e, context);