Initial release date support

This commit is contained in:
Imran Remtulla
2023-02-18 20:37:30 -05:00
parent ea81b0e66e
commit 191776d0d5
12 changed files with 209 additions and 66 deletions

View File

@@ -73,6 +73,8 @@ class _AddAppPageState extends State<AddAppPage> {
var userPickedTrackOnly = additionalSettings['trackOnly'] == true;
var userPickedNoVersionDetection =
additionalSettings['noVersionDetection'] == true;
var userPickedReleaseDateAsVersion =
additionalSettings['releaseDateAsVersion'] == true;
var cont = true;
if ((userPickedTrackOnly || pickedSource!.enforceTrackOnly) &&
// ignore: use_build_context_synchronously
@@ -93,7 +95,22 @@ class _AddAppPageState extends State<AddAppPage> {
null) {
cont = false;
}
if (userPickedNoVersionDetection &&
if (userPickedReleaseDateAsVersion && // ignore: use_build_context_synchronously
// ignore: use_build_context_synchronously
await showDialog(
context: context,
builder: (BuildContext ctx) {
return GeneratedFormModal(
title: tr('useReleaseDateAsVersion'),
items: const [],
message: tr('releaseDateAsVersionExplanation'),
);
}) ==
null) {
cont = false;
}
if (!userPickedReleaseDateAsVersion &&
userPickedNoVersionDetection &&
// ignore: use_build_context_synchronously
await showDialog(
context: context,
@@ -113,7 +130,8 @@ class _AddAppPageState extends State<AddAppPage> {
App app = await sourceProvider.getApp(
pickedSource!, userInput, additionalSettings,
trackOnlyOverride: trackOnly,
noVersionDetectionOverride: userPickedNoVersionDetection);
noVersionDetectionOverride: userPickedNoVersionDetection,
releaseDateAsVersionOverride: userPickedReleaseDateAsVersion);
if (!trackOnly) {
await settingsProvider.getInstallPermission();
}

View File

@@ -144,6 +144,13 @@ class _AppPageState extends State<AppPage> {
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.labelSmall,
),
app?.app.releaseDate == null
? const SizedBox.shrink()
: Text(
app!.app.releaseDate.toString(),
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.labelSmall,
),
const SizedBox(
height: 32,
),
@@ -286,6 +293,37 @@ class _AppPageState extends State<AppPage> {
tr('appsFromSourceAreTrackOnly'),
context);
}
if (changedApp.additionalSettings[
'releaseDateAsVersion'] ==
true) {
changedApp.additionalSettings[
'noVersionDetection'] = true;
if (app.app.additionalSettings[
'releaseDateAsVersion'] !=
true) {
if (app.app.releaseDate != null) {
changedApp.latestVersion = app
.app
.releaseDate!
.microsecondsSinceEpoch
.toString();
if (app.app.installedVersion ==
app.app.latestVersion) {
changedApp.installedVersion =
changedApp.latestVersion;
}
}
}
} else if (app.app.additionalSettings[
'releaseDateAsVersion'] ==
true) {
changedApp.additionalSettings[
'noVersionDetection'] = false;
changedApp.installedVersion = app
.installedInfo
?.versionName ??
changedApp.installedVersion;
}
appsProvider.saveApps(
[changedApp]).then((value) {
getUpdate(changedApp.id);

View File

@@ -264,6 +264,7 @@ class AppsPageState extends State<AppsPage> {
sortedApps[index].installedInfo?.name ??
sortedApps[index].app.name,
style: TextStyle(
overflow: TextOverflow.ellipsis,
fontWeight: sortedApps[index].app.pinned
? FontWeight.bold
: FontWeight.normal,
@@ -289,12 +290,35 @@ class AppsPageState extends State<AppsPage> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SizedBox(
width: 100,
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
'${sortedApps[index].app.installedVersion ?? tr('notInstalled')}${sortedApps[index].app.additionalSettings['trackOnly'] == true ? ' ${tr('estimateInBrackets')}' : ''}',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.end,
)
]),
GestureDetector(
onTap: changesUrl == null
? null
: () {
launchUrlString(changesUrl,
mode: LaunchMode
.externalApplication);
},
child: Text(
'${sortedApps[index].app.installedVersion ?? tr('notInstalled')}${sortedApps[index].app.additionalSettings['trackOnly'] == true ? ' ${tr('estimateInBrackets')}' : ''}',
overflow: TextOverflow.fade,
textAlign: TextAlign.end,
sortedApps[index].app.releaseDate ==
null
? tr('changes')
: DateFormat('yyyy-MM-dd').format(
sortedApps[index]
.app
.releaseDate!),
style: const TextStyle(
fontStyle: FontStyle.italic,
decoration:
TextDecoration.underline),
)),
sortedApps[index].app.installedVersion !=
null &&
@@ -304,29 +328,47 @@ class AppsPageState extends State<AppsPage> {
sortedApps[index]
.app
.latestVersion
? GestureDetector(
onTap: changesUrl == null
? null
: () {
launchUrlString(changesUrl,
mode: LaunchMode
.externalApplication);
},
child: appsProvider
.areDownloadsRunning()
? Text(tr('pleaseWait'))
: Text(
'${tr('updateAvailable')}${sortedApps[index].app.additionalSettings['trackOnly'] == true ? ' ${tr('estimateInBracketsShort')}' : ''}',
style: TextStyle(
fontStyle:
FontStyle.italic,
decoration: changesUrl ==
null
? TextDecoration.none
: TextDecoration
.underline),
))
: const SizedBox(),
? appsProvider.areDownloadsRunning()
? Text(tr('pleaseWait'))
: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.end,
children: [
GestureDetector(
onTap: () {
appsProvider
.downloadAndInstallLatestApps(
[
sortedApps[index]
.app
.id
],
globalNavigatorKey
.currentContext).catchError(
(e) {
showError(e, context);
});
},
child: Text(
sortedApps[index]
.app
.additionalSettings[
'trackOnly'] ==
true
? tr('markUpdated')
: tr('update'),
style: TextStyle(
color:
Theme.of(context)
.colorScheme
.primary,
fontWeight:
FontWeight.bold),
)),
],
)
: const SizedBox.shrink(),
],
))),
onTap: () {