From a4418c8a797ec22d4758a9b6f594b9eae3bbb961 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 24 Oct 2024 22:18:11 +0100 Subject: [PATCH 1/9] fix: app not closing on the exit dialog --- packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart b/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart index 5454f6e3e..c314a658f 100644 --- a/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart +++ b/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:uni/generated/l10n.dart'; /// Manages the app section displayed when the user presses the back button @@ -36,7 +37,7 @@ class BackButtonExitWrapper extends StatelessWidget { ElevatedButton( onPressed: () { userActionCompleter.complete(true); - Navigator.of(context).pop(false); + SystemChannels.platform.invokeMethod('SystemNavigator.pop'); }, child: Text(S.of(context).yes), ), From 2ff5924c7bb7be13a5fe9442ef1dc23c6a41b162 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 24 Oct 2024 22:39:15 +0100 Subject: [PATCH 2/9] formatting --- packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart b/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart index c314a658f..d38878816 100644 --- a/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart +++ b/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart @@ -37,7 +37,8 @@ class BackButtonExitWrapper extends StatelessWidget { ElevatedButton( onPressed: () { userActionCompleter.complete(true); - SystemChannels.platform.invokeMethod('SystemNavigator.pop'); + SystemChannels.platform + .invokeMethod('SystemNavigator.pop'); }, child: Text(S.of(context).yes), ), From c6b1c844b56af7c98b6aefb2aa6e97f86e9bcca9 Mon Sep 17 00:00:00 2001 From: Adriano Machado Date: Sat, 12 Oct 2024 20:00:52 +0100 Subject: [PATCH 3/9] Changed LibraryOccupation to sort floors by number when adding a new floor --- packages/uni_app/lib/model/entities/library_occupation.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/uni_app/lib/model/entities/library_occupation.dart b/packages/uni_app/lib/model/entities/library_occupation.dart index 9931652df..fbfad6b43 100644 --- a/packages/uni_app/lib/model/entities/library_occupation.dart +++ b/packages/uni_app/lib/model/entities/library_occupation.dart @@ -18,7 +18,10 @@ class LibraryOccupation { late List floors; void addFloor(FloorOccupation floor) { - floors.add(floor); + floors + ..add(floor) + ..sort((a, b) => a.number.compareTo(b.number)); + occupation += floor.occupation; capacity += floor.capacity; } From 360472ef31e8ee886a84f5e62e0be8b12e6e6850 Mon Sep 17 00:00:00 2001 From: Adriano Machado Date: Wed, 16 Oct 2024 16:03:55 +0100 Subject: [PATCH 4/9] Switch to SplayTreeSet for automatic floor ordering --- .../model/entities/library_occupation.g.dart | 16 +++++------ .../model/entities/library_occupation.dart | 28 +++++++++++++------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart b/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart index fe8e7e4bb..370277fd6 100644 --- a/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart +++ b/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart @@ -8,24 +8,22 @@ part of '../../../model/entities/library_occupation.dart'; LibraryOccupation _$LibraryOccupationFromJson(Map json) => LibraryOccupation( - json['occupation'] as int, - json['capacity'] as int, - )..floors = (json['floors'] as List) - .map((e) => FloorOccupation.fromJson(e as Map)) - .toList(); + (json['occupation'] as num).toInt(), + (json['capacity'] as num).toInt(), + )..floors = LibraryOccupation._floorsFromJson(json['floors'] as List); Map _$LibraryOccupationToJson(LibraryOccupation instance) => { 'occupation': instance.occupation, 'capacity': instance.capacity, - 'floors': instance.floors, + 'floors': LibraryOccupation._floorsToJson(instance.floors), }; FloorOccupation _$FloorOccupationFromJson(Map json) => FloorOccupation( - json['number'] as int, - json['occupation'] as int, - json['capacity'] as int, + (json['number'] as num).toInt(), + (json['occupation'] as num).toInt(), + (json['capacity'] as num).toInt(), ); Map _$FloorOccupationToJson(FloorOccupation instance) => diff --git a/packages/uni_app/lib/model/entities/library_occupation.dart b/packages/uni_app/lib/model/entities/library_occupation.dart index fbfad6b43..5ad57118e 100644 --- a/packages/uni_app/lib/model/entities/library_occupation.dart +++ b/packages/uni_app/lib/model/entities/library_occupation.dart @@ -1,4 +1,5 @@ import 'dart:math'; +import 'dart:collection'; import 'package:json_annotation/json_annotation.dart'; @@ -8,20 +9,19 @@ part '../../generated/model/entities/library_occupation.g.dart'; @JsonSerializable() class LibraryOccupation { LibraryOccupation(this.occupation, this.capacity) { - floors = []; + floors = SplayTreeSet((a, b) => a.number.compareTo(b.number)); } factory LibraryOccupation.fromJson(Map json) => _$LibraryOccupationFromJson(json); late int occupation; late int capacity; - late List floors; + + @JsonKey(fromJson: _floorsFromJson, toJson: _floorsToJson) + late SplayTreeSet floors; void addFloor(FloorOccupation floor) { - floors - ..add(floor) - ..sort((a, b) => a.number.compareTo(b.number)); - + floors.add(floor); occupation += floor.occupation; capacity += floor.capacity; } @@ -37,10 +37,22 @@ class LibraryOccupation { if (floors.length < number || number < 0) { return FloorOccupation(0, 0, 0); } - return floors[number - 1]; + return floors.elementAt(number - 1); } Map toJson() => _$LibraryOccupationToJson(this); + + static SplayTreeSet _floorsFromJson(List json) { + var set = SplayTreeSet((a, b) => a.number.compareTo(b.number)); + json.forEach((element) { + set.add(FloorOccupation.fromJson(element as Map)); + }); + return set; + } + + static List> _floorsToJson(SplayTreeSet floors) { + return floors.map((floor) => floor.toJson()).toList(); + } } /// Occupation values of a single floor @@ -62,4 +74,4 @@ class FloorOccupation { } Map toJson() => _$FloorOccupationToJson(this); -} +} \ No newline at end of file From 7127f7db15e9a85418c226888859f018b97c7139 Mon Sep 17 00:00:00 2001 From: Adriano Machado Date: Tue, 22 Oct 2024 18:08:20 +0100 Subject: [PATCH 5/9] Revert "Switch to SplayTreeSet for automatic floor ordering" This reverts commit 4d8b270bff391e0bf632196e199e0ebd632e3906. --- .../model/entities/library_occupation.g.dart | 16 ++++++----- .../model/entities/library_occupation.dart | 28 ++++++------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart b/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart index 370277fd6..fe8e7e4bb 100644 --- a/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart +++ b/packages/uni_app/lib/generated/model/entities/library_occupation.g.dart @@ -8,22 +8,24 @@ part of '../../../model/entities/library_occupation.dart'; LibraryOccupation _$LibraryOccupationFromJson(Map json) => LibraryOccupation( - (json['occupation'] as num).toInt(), - (json['capacity'] as num).toInt(), - )..floors = LibraryOccupation._floorsFromJson(json['floors'] as List); + json['occupation'] as int, + json['capacity'] as int, + )..floors = (json['floors'] as List) + .map((e) => FloorOccupation.fromJson(e as Map)) + .toList(); Map _$LibraryOccupationToJson(LibraryOccupation instance) => { 'occupation': instance.occupation, 'capacity': instance.capacity, - 'floors': LibraryOccupation._floorsToJson(instance.floors), + 'floors': instance.floors, }; FloorOccupation _$FloorOccupationFromJson(Map json) => FloorOccupation( - (json['number'] as num).toInt(), - (json['occupation'] as num).toInt(), - (json['capacity'] as num).toInt(), + json['number'] as int, + json['occupation'] as int, + json['capacity'] as int, ); Map _$FloorOccupationToJson(FloorOccupation instance) => diff --git a/packages/uni_app/lib/model/entities/library_occupation.dart b/packages/uni_app/lib/model/entities/library_occupation.dart index 5ad57118e..fbfad6b43 100644 --- a/packages/uni_app/lib/model/entities/library_occupation.dart +++ b/packages/uni_app/lib/model/entities/library_occupation.dart @@ -1,5 +1,4 @@ import 'dart:math'; -import 'dart:collection'; import 'package:json_annotation/json_annotation.dart'; @@ -9,19 +8,20 @@ part '../../generated/model/entities/library_occupation.g.dart'; @JsonSerializable() class LibraryOccupation { LibraryOccupation(this.occupation, this.capacity) { - floors = SplayTreeSet((a, b) => a.number.compareTo(b.number)); + floors = []; } factory LibraryOccupation.fromJson(Map json) => _$LibraryOccupationFromJson(json); late int occupation; late int capacity; - - @JsonKey(fromJson: _floorsFromJson, toJson: _floorsToJson) - late SplayTreeSet floors; + late List floors; void addFloor(FloorOccupation floor) { - floors.add(floor); + floors + ..add(floor) + ..sort((a, b) => a.number.compareTo(b.number)); + occupation += floor.occupation; capacity += floor.capacity; } @@ -37,22 +37,10 @@ class LibraryOccupation { if (floors.length < number || number < 0) { return FloorOccupation(0, 0, 0); } - return floors.elementAt(number - 1); + return floors[number - 1]; } Map toJson() => _$LibraryOccupationToJson(this); - - static SplayTreeSet _floorsFromJson(List json) { - var set = SplayTreeSet((a, b) => a.number.compareTo(b.number)); - json.forEach((element) { - set.add(FloorOccupation.fromJson(element as Map)); - }); - return set; - } - - static List> _floorsToJson(SplayTreeSet floors) { - return floors.map((floor) => floor.toJson()).toList(); - } } /// Occupation values of a single floor @@ -74,4 +62,4 @@ class FloorOccupation { } Map toJson() => _$FloorOccupationToJson(this); -} \ No newline at end of file +} From 2a263f94481b729c3d04f53949ac0aa616004219 Mon Sep 17 00:00:00 2001 From: Adriano Machado Date: Tue, 22 Oct 2024 18:56:45 +0100 Subject: [PATCH 6/9] Moved floor sorting to occur after all floors are added in LibraryOccupation --- .../controller/fetchers/library_occupation_fetcher.dart | 3 ++- .../uni_app/lib/model/entities/library_occupation.dart | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart b/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart index f0616bd13..34798352c 100644 --- a/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart +++ b/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart @@ -38,7 +38,8 @@ class LibraryOccupationFetcher { libraryOccupation.addFloor(floorOccupation); }), ); - + + libraryOccupation.sortFloors(); return libraryOccupation; } diff --git a/packages/uni_app/lib/model/entities/library_occupation.dart b/packages/uni_app/lib/model/entities/library_occupation.dart index fbfad6b43..bf6eb0924 100644 --- a/packages/uni_app/lib/model/entities/library_occupation.dart +++ b/packages/uni_app/lib/model/entities/library_occupation.dart @@ -18,10 +18,7 @@ class LibraryOccupation { late List floors; void addFloor(FloorOccupation floor) { - floors - ..add(floor) - ..sort((a, b) => a.number.compareTo(b.number)); - + floors.add(floor); occupation += floor.occupation; capacity += floor.capacity; } @@ -40,6 +37,10 @@ class LibraryOccupation { return floors[number - 1]; } + void sortFloors(){ + floors.sort((a, b) => a.number.compareTo(b.number)); + } + Map toJson() => _$LibraryOccupationToJson(this); } From 25ea9ef98b1a2cc949e66641c856b2db987732f0 Mon Sep 17 00:00:00 2001 From: Adriano Machado Date: Tue, 22 Oct 2024 19:00:27 +0100 Subject: [PATCH 7/9] Applied Dart formatting --- .../lib/controller/fetchers/library_occupation_fetcher.dart | 2 +- packages/uni_app/lib/model/entities/library_occupation.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart b/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart index 34798352c..be22fb683 100644 --- a/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart +++ b/packages/uni_app/lib/controller/fetchers/library_occupation_fetcher.dart @@ -38,7 +38,7 @@ class LibraryOccupationFetcher { libraryOccupation.addFloor(floorOccupation); }), ); - + libraryOccupation.sortFloors(); return libraryOccupation; } diff --git a/packages/uni_app/lib/model/entities/library_occupation.dart b/packages/uni_app/lib/model/entities/library_occupation.dart index bf6eb0924..cdf692efd 100644 --- a/packages/uni_app/lib/model/entities/library_occupation.dart +++ b/packages/uni_app/lib/model/entities/library_occupation.dart @@ -37,7 +37,7 @@ class LibraryOccupation { return floors[number - 1]; } - void sortFloors(){ + void sortFloors() { floors.sort((a, b) => a.number.compareTo(b.number)); } From d76e43c8ff9661ece35889b2e40522d6b9560793 Mon Sep 17 00:00:00 2001 From: thePeras Date: Fri, 25 Oct 2024 08:18:39 +0000 Subject: [PATCH 8/9] Bump app version [no ci] --- packages/uni_app/app_version.txt | 2 +- packages/uni_app/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/uni_app/app_version.txt b/packages/uni_app/app_version.txt index ee405355c..922a018f5 100644 --- a/packages/uni_app/app_version.txt +++ b/packages/uni_app/app_version.txt @@ -1 +1 @@ -1.10.0-beta.30+333 +1.10.0-beta.31+334 diff --git a/packages/uni_app/pubspec.yaml b/packages/uni_app/pubspec.yaml index 020d47c88..293b3ba9b 100644 --- a/packages/uni_app/pubspec.yaml +++ b/packages/uni_app/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: "none" # We do not publish to pub.dev # To change it manually, override the value in app_version.txt. # The app version code is automatically also bumped by CI. # Do not change it manually. -version: 1.10.0-beta.30+333 +version: 1.10.0-beta.31+334 environment: sdk: ">=3.4.0 <4.0.0" From f92ae0991b160d23aeb06a7cca2a212a24587fb9 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 27 Oct 2024 12:23:30 +0000 Subject: [PATCH 9/9] SystemNavigator.pop() async --- packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart b/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart index d38878816..da241f604 100644 --- a/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart +++ b/packages/uni_app/lib/view/home/widgets/exit_app_dialog.dart @@ -35,10 +35,9 @@ class BackButtonExitWrapper extends StatelessWidget { child: Text(S.of(context).no), ), ElevatedButton( - onPressed: () { + onPressed: () async { userActionCompleter.complete(true); - SystemChannels.platform - .invokeMethod('SystemNavigator.pop'); + await SystemNavigator.pop(); }, child: Text(S.of(context).yes), ),