Merge pull request #246 from ImranR98/dev

Bugfixes for #242 and #245 + Various UI Improvements
This commit is contained in:
Imran Remtulla
2023-01-29 17:35:18 -05:00
committed by GitHub
6 changed files with 76 additions and 48 deletions

View File

@ -150,6 +150,7 @@ class _GeneratedFormState extends State<GeneratedForm> {
Map<String, dynamic> values = {}; Map<String, dynamic> values = {};
late List<List<Widget>> formInputs; late List<List<Widget>> formInputs;
List<List<Widget>> rows = []; List<List<Widget>> rows = [];
String? initKey;
// If any value changes, call this to update the parent with value and validity // If any value changes, call this to update the parent with value and validity
void someValueChanged({bool isBuilding = false}) { void someValueChanged({bool isBuilding = false}) {
@ -169,13 +170,10 @@ class _GeneratedFormState extends State<GeneratedForm> {
widget.onValueChanges(returnValues, valid, isBuilding); widget.onValueChanges(returnValues, valid, isBuilding);
} }
@override initForm() {
void initState() { initKey = widget.key.toString();
super.initState();
// Initialize form values as all empty // Initialize form values as all empty
values.clear(); values.clear();
int j = 0;
for (var row in widget.items) { for (var row in widget.items) {
for (var e in row) { for (var e in row) {
values[e.key] = e.defaultValue; values[e.key] = e.defaultValue;
@ -245,8 +243,17 @@ class _GeneratedFormState extends State<GeneratedForm> {
someValueChanged(isBuilding: true); someValueChanged(isBuilding: true);
} }
@override
void initState() {
super.initState();
initForm();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (widget.key.toString() != initKey) {
initForm();
}
for (var r = 0; r < formInputs.length; r++) { for (var r = 0; r < formInputs.length; r++) {
for (var e = 0; e < formInputs[r].length; e++) { for (var e = 0; e < formInputs[r].length; e++) {
if (widget.items[r][e] is GeneratedFormSwitch) { if (widget.items[r][e] is GeneratedFormSwitch) {

View File

@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
// ignore: implementation_imports // ignore: implementation_imports
import 'package:easy_localization/src/localization.dart'; import 'package:easy_localization/src/localization.dart';
const String currentVersion = '0.10.5'; const String currentVersion = '0.10.6';
const String currentReleaseTag = const String currentReleaseTag =
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES

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);
@ -327,6 +334,7 @@ class _AddAppPageState extends State<AddAppPage> {
height: 16, height: 16,
), ),
GeneratedForm( GeneratedForm(
key: Key(pickedSource.runtimeType.toString()),
items: pickedSource! items: pickedSource!
.combinedAppSpecificSettingFormItems, .combinedAppSpecificSettingFormItems,
onValueChanges: (values, valid, isBuilding) { onValueChanges: (values, valid, isBuilding) {

View File

@ -564,18 +564,22 @@ class _UrlSelectionModalState extends State<UrlSelectionModal> {
widget.onlyOneSelectionAllowed ? tr('selectURL') : tr('selectURLs')), widget.onlyOneSelectionAllowed ? tr('selectURL') : tr('selectURLs')),
content: Column(children: [ content: Column(children: [
...urlWithDescriptionSelections.keys.map((urlWithD) { ...urlWithDescriptionSelections.keys.map((urlWithD) {
select(bool? value) {
setState(() {
value ??= false;
if (value! && widget.onlyOneSelectionAllowed) {
selectOnlyOne(urlWithD.key);
} else {
urlWithDescriptionSelections[urlWithD] = value!;
}
});
}
return Row(children: [ return Row(children: [
Checkbox( Checkbox(
value: urlWithDescriptionSelections[urlWithD], value: urlWithDescriptionSelections[urlWithD],
onChanged: (value) { onChanged: (value) {
setState(() { select(value);
value ??= false;
if (value! && widget.onlyOneSelectionAllowed) {
selectOnlyOne(urlWithD.key);
} else {
urlWithDescriptionSelections[urlWithD] = value!;
}
});
}), }),
const SizedBox( const SizedBox(
width: 8, width: 8,
@ -599,12 +603,17 @@ class _UrlSelectionModalState extends State<UrlSelectionModal> {
const TextStyle(decoration: TextDecoration.underline), const TextStyle(decoration: TextDecoration.underline),
textAlign: TextAlign.start, textAlign: TextAlign.start,
)), )),
Text( GestureDetector(
urlWithD.value.length > 128 onTap: () {
? '${urlWithD.value.substring(0, 128)}...' select(!(urlWithDescriptionSelections[urlWithD] ?? false));
: urlWithD.value, },
style: const TextStyle( child: Text(
fontStyle: FontStyle.italic, fontSize: 12), urlWithD.value.length > 128
? '${urlWithD.value.substring(0, 128)}...'
: urlWithD.value,
style: const TextStyle(
fontStyle: FontStyle.italic, fontSize: 12),
),
), ),
const SizedBox( const SizedBox(
height: 8, height: 8,

View File

@ -247,7 +247,11 @@ class AppsProvider with ChangeNotifier {
!(await canDowngradeApps())) { !(await canDowngradeApps())) {
throw DowngradeError(); throw DowngradeError();
} }
await InstallPlugin.installApk(file.file.path, 'dev.imranr.obtainium'); await InstallPlugin.installApk(file.file.path, obtainiumId);
if (file.appId == obtainiumId) {
// Obtainium prompt should be lowest
await Future.delayed(const Duration(milliseconds: 500));
}
apps[file.appId]!.app.installedVersion = apps[file.appId]!.app.installedVersion =
apps[file.appId]!.app.latestVersion; apps[file.appId]!.app.latestVersion;
// Don't correct install status as installation may not be done yet // Don't correct install status as installation may not be done yet

View File

@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 0.10.5+111 # When changing this, update the tag in main() accordingly version: 0.10.6+112 # When changing this, update the tag in main() accordingly
environment: environment:
sdk: '>=2.18.2 <3.0.0' sdk: '>=2.18.2 <3.0.0'