diff --git a/lib/pages/add_app.dart b/lib/pages/add_app.dart index 43e8121..b019439 100644 --- a/lib/pages/add_app.dart +++ b/lib/pages/add_app.dart @@ -22,6 +22,7 @@ class _AddAppPageState extends State { String userInput = ''; AppSource? pickedSource; List additionalData = []; + String customName = ''; bool validAdditionalData = true; @override @@ -79,6 +80,9 @@ class _AddAppPageState extends State { .doesSourceHaveRequiredAdditionalData( source) : true; + if (source == null) { + customName = ''; + } } }); }, @@ -100,7 +104,8 @@ class _AddAppPageState extends State { }); sourceProvider .getApp(pickedSource!, userInput, - additionalData) + additionalData, + customName: customName) .then((app) { var appsProvider = context.read(); @@ -162,7 +167,30 @@ class _AddAppPageState extends State { }); }, defaultValues: - pickedSource!.additionalDataDefaults) + pickedSource!.additionalDataDefaults), + if (pickedSource != null) + Column( + crossAxisAlignment: + CrossAxisAlignment.stretch, + children: [ + const SizedBox( + height: 8, + ), + GeneratedForm( + items: [ + [ + GeneratedFormItem( + label: 'Custom App Name', + required: false) + ] + ], + onValueChanges: (values, valid) { + setState(() { + customName = values[0]; + }); + }, + defaultValues: [customName]) + ]), ], ) else diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 095b139..856118e 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -176,8 +176,8 @@ class SourceProvider { return false; } - Future getApp( - AppSource source, String url, List additionalData) async { + Future getApp(AppSource source, String url, List additionalData, + {String customName = ''}) async { String standardUrl = source.standardizeURL(makeUrlHttps(url)); AppNames names = source.getAppNames(standardUrl); APKDetails apk = @@ -186,7 +186,9 @@ class SourceProvider { '${names.author.toLowerCase()}_${names.name.toLowerCase()}_${source.host}', standardUrl, names.author[0].toUpperCase() + names.author.substring(1), - names.name[0].toUpperCase() + names.name.substring(1), + customName.trim().isNotEmpty + ? customName + : names.name[0].toUpperCase() + names.name.substring(1), null, apk.version, apk.apkUrls,