Skip to content

Commit

Permalink
Clearer GitHub PAT instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Imran Remtulla committed Sep 30, 2022
1 parent 3958425 commit aebc8ae
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
21 changes: 20 additions & 1 deletion lib/app_sources/github.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:obtainium/components/generated_form.dart';
import 'package:obtainium/custom_errors.dart';
import 'package:obtainium/providers/settings_provider.dart';
import 'package:obtainium/providers/source_provider.dart';
import 'package:url_launcher/url_launcher_string.dart';

class GitHub implements AppSource {
@override
Expand Down Expand Up @@ -137,7 +139,7 @@ class GitHub implements AppSource {
@override
List<GeneratedFormItem> moreSourceSettingsFormItems = [
GeneratedFormItem(
label: 'GitHub Credentials (Increases Rate Limit)',
label: 'GitHub Personal Access Token (Increases Rate Limit)',
id: 'github-creds',
required: false,
additionalValidators: [
Expand All @@ -153,6 +155,23 @@ class GitHub implements AppSource {
}
return null;
}
],
hint: 'username:token',
belowWidgets: [
const SizedBox(
height: 8,
),
GestureDetector(
onTap: () {
launchUrlString(
'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token',
mode: LaunchMode.externalApplication);
},
child: const Text(
'About GitHub PATs',
style: TextStyle(
decoration: TextDecoration.underline, fontSize: 12),
))
])
];
}
17 changes: 14 additions & 3 deletions lib/components/generated_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ class GeneratedFormItem {
late int max;
late List<String? Function(String? value)> additionalValidators;
late String id;
late List<Widget> belowWidgets;
late String? hint;

GeneratedFormItem(
{this.label = 'Input',
this.type = FormItemType.string,
this.required = true,
this.max = 1,
this.additionalValidators = const [],
this.id = 'input'});
this.id = 'input',
this.belowWidgets = const [],
this.hint});
}

class GeneratedForm extends StatefulWidget {
Expand Down Expand Up @@ -91,7 +95,8 @@ class _GeneratedFormState extends State<GeneratedForm> {
});
},
decoration: InputDecoration(
helperText: e.value.label + (e.value.required ? ' *' : '')),
helperText: e.value.label + (e.value.required ? ' *' : ''),
hintText: e.value.hint),
minLines: e.value.max <= 1 ? null : e.value.max,
maxLines: e.value.max <= 1 ? 1 : e.value.max,
validator: (value) {
Expand Down Expand Up @@ -157,7 +162,13 @@ class _GeneratedFormState extends State<GeneratedForm> {
width: 20,
));
}
rowItems.add(Expanded(child: rowInput.value));
rowItems.add(Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
rowInput.value,
...widget.items[rowInputs.key][rowInput.key].belowWidgets
])));
});
rows.add(rowItems);
});
Expand Down

0 comments on commit aebc8ae

Please sign in to comment.