Skip to content

Commit

Permalink
Basic custom App name support (only when adding)
Browse files Browse the repository at this point in the history
  • Loading branch information
Imran Remtulla committed Sep 25, 2022
1 parent 1285537 commit 420cf48
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
32 changes: 30 additions & 2 deletions lib/pages/add_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class _AddAppPageState extends State<AddAppPage> {
String userInput = '';
AppSource? pickedSource;
List<String> additionalData = [];
String customName = '';
bool validAdditionalData = true;

@override
Expand Down Expand Up @@ -79,6 +80,9 @@ class _AddAppPageState extends State<AddAppPage> {
.doesSourceHaveRequiredAdditionalData(
source)
: true;
if (source == null) {
customName = '';
}
}
});
},
Expand All @@ -100,7 +104,8 @@ class _AddAppPageState extends State<AddAppPage> {
});
sourceProvider
.getApp(pickedSource!, userInput,
additionalData)
additionalData,
customName: customName)
.then((app) {
var appsProvider =
context.read<AppsProvider>();
Expand Down Expand Up @@ -162,7 +167,30 @@ class _AddAppPageState extends State<AddAppPage> {
});
},
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
Expand Down
8 changes: 5 additions & 3 deletions lib/providers/source_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ class SourceProvider {
return false;
}

Future<App> getApp(
AppSource source, String url, List<String> additionalData) async {
Future<App> getApp(AppSource source, String url, List<String> additionalData,
{String customName = ''}) async {
String standardUrl = source.standardizeURL(makeUrlHttps(url));
AppNames names = source.getAppNames(standardUrl);
APKDetails apk =
Expand All @@ -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,
Expand Down

0 comments on commit 420cf48

Please sign in to comment.