Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
AppUpdater:
+ sistemato il controllo delle nuove versioni (prima controllava solo minor e major, ora controlla anche la patch version).
  • Loading branch information
mikyll committed Jan 17, 2024
1 parent 8f7dc89 commit 242b9b2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
30 changes: 22 additions & 8 deletions app-mobile/flutter_application/lib/model/AppUpdater.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ class AppUpdater {
try {
Map<String, dynamic> json = jsonDecode(response.body);
String tagName = json['tag_name'];
List<String> repoVersion = tagName.replaceAll("v", "").split(".");
List<String> segmentsRepoV = tagName.replaceAll("v", "").split(".");

int repoMajor = int.parse(repoVersion[0]);
int repoMinor = int.parse(repoVersion[1]);
List<String> segmentsCurrV = currentVersion.split(".");

List<String> splittedCurrentVersion = currentVersion.split(".");
int currentMajor = int.parse(splittedCurrentVersion[0]);
int currentMinor = int.parse(splittedCurrentVersion[1]);
for (int i = 0;
i < segmentsRepoV.length && i < segmentsCurrV.length;
i++) {
if (int.parse(segmentsRepoV[i]) > int.parse(segmentsCurrV[i])) {
newVersionPresent = true;
break;
}
}

newVersionPresent = currentMajor < repoMajor ||
(currentMajor == repoMajor && currentMinor < repoMinor);
// test
print(newVersionPresent);
return (newVersionPresent, newVersion, newVersionDownloadURL);

if (newVersionPresent) {
newVersion = tagName;
Expand Down Expand Up @@ -60,3 +65,12 @@ class AppUpdater {
return (newVersionPresent, newVersion, newVersionDownloadURL);
}
}

void main() {
AppUpdater.checkNewVersion("1.09.1");
AppUpdater.checkNewVersion("1.09.1");
AppUpdater.checkNewVersion("1.10.1");
AppUpdater.checkNewVersion("1.10.0");
AppUpdater.checkNewVersion("1.11.0");
AppUpdater.checkNewVersion("2.9.0");
}
6 changes: 3 additions & 3 deletions app-mobile/flutter_application/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ packages:
source: sdk
version: "0.0.0"
http:
dependency: transitive
dependency: "direct main"
description:
name: http
sha256: d4872660c46d929f6b8a9ef4e7a7eff7e49bbf0c4ec3f385ee32df5119175139
sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba
url: "https://pub.dev"
source: hosted
version: "1.1.2"
version: "1.2.0"
http_parser:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion app-mobile/flutter_application/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
# 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.
version: 1.11.0
version: 1.10.1

environment:
sdk: '>=3.0.6 <4.0.0'
Expand All @@ -43,6 +43,7 @@ dependencies:
file_picker: ^5.3.3
desktop_window: ^0.4.0
flutter_svg: ^2.0.9
http: ^1.2.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 242b9b2

Please sign in to comment.