Skip to content

Commit c385e82

Browse files
author
Alberto Aguilar
committed
OSAM-21806-common-module-issues
1 parent 8389c65 commit c385e82

14 files changed

Lines changed: 381 additions & 320 deletions

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
## 8.1.9-dev
1+
## 8.1.10-dev
22

33
* UPDATED NATIVE LIBRARIES
4-
* Updated [modul_comu_osam library](https://github.com/AjuntamentdeBarcelona/modul_comu_osam) to version 3.1.6-dev.
4+
* Updated [modul_comu_osam library](https://github.com/AjuntamentdeBarcelona/modul_comu_osam) to version 3.1.13-dev.
55
* IMPROVED POPUP INTERACTION
66
* Added transparent barriers and PopScope in `AlertWrapper` and `UIHelper` to prevent background interaction while native or custom popups are being shown.
77
* Changed default language fallback to English (`en`).
@@ -19,7 +19,7 @@
1919
* Added UIHelper and OSAMDialog widget in the Flutter part.
2020
* Updated example app with "Custom Flutter Popup" button to test the new UI.
2121

22-
## 8.1.1-dev
22+
## 8.1.2-dev
2323

2424
* BREAKING CHANGES
2525
* Updated [modul_comu_osam library](https://github.com/AjuntamentdeBarcelona/modul_comu_osam) to version 3.0.1-dev accessible popup.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ A partir de la versió 3.0.0 la llibreria es un wrapper de la [desenvolupada en
4141
osam_common_module_flutter:
4242
git:
4343
url: https://github.com/AjuntamentdeBarcelona/modul_comu_osam_flutter.git
44-
ref: '8.1.9-dev'
44+
ref: '8.1.10-dev'
4545
```
4646
4747
En cas que les dependències de Firebase Analytics, Firebase Performance, Firebase Messaging i Firebase Crashlytics fallin, cal afegir aquestes aquesta configuració al pubspec:

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ android {
4949

5050
dependencies {
5151
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0-native-mt")
52-
implementation("com.github.AjuntamentdeBarcelona.modul_comu_osam:common:3.1.6-dev")
52+
implementation("com.github.AjuntamentdeBarcelona.modul_comu_osam:common:3.1.13-dev")
5353
implementation("com.google.code.gson:gson:2.10.1")
5454

5555
implementation(platform("com.google.firebase:firebase-bom:33.6.0"))

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ target 'Runner' do
3232
use_modular_headers!
3333

3434
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
35-
pod 'OSAMCommon', :git => 'https://github.com/AjuntamentdeBarcelona/modul_comu_osam.git', :tag => '3.1.6-dev'
35+
pod 'OSAMCommon', :git => 'https://github.com/AjuntamentdeBarcelona/modul_comu_osam.git', :tag => '3.1.13-dev'
3636
end
3737

3838
post_install do |installer|

example/ios/Runner/Info.plist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,11 @@
4949
</array>
5050
<key>UIViewControllerBasedStatusBarAppearance</key>
5151
<false/>
52+
<key>NSLocalNetworkUsageDescription</key>
53+
<string>Allow Flutter to discover the local network for debugging.</string>
54+
<key>NSBonjourServices</key>
55+
<array>
56+
<string>_dartobservatory._tcp</string>
57+
</array>
5258
</dict>
5359
</plist>

example/lib/actions_screen.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:common_module_flutter_example/data/osam/osam_repository_impl.dart';
12
import 'package:flutter/material.dart';
23
import 'package:osam_common_module_flutter/osam_common_module_flutter.dart';
34

@@ -76,6 +77,10 @@ class ActionsScreenState extends State<ActionsScreen> {
7677
}
7778

7879
void _onVersionControl() async {
80+
if (DI.osamRepository is OsamRepositoryImpl) {
81+
(DI.osamRepository as OsamRepositoryImpl)
82+
.setAlertWrapper(AlertWrapper(context));
83+
}
7984
final result = await DI.osamRepository.checkForUpdates();
8085

8186
if (mounted) {
@@ -97,6 +102,10 @@ class ActionsScreenState extends State<ActionsScreen> {
97102
}
98103

99104
void _onRating() async {
105+
if (DI.osamRepository is OsamRepositoryImpl) {
106+
(DI.osamRepository as OsamRepositoryImpl)
107+
.setAlertWrapper(AlertWrapper(context));
108+
}
100109
final result = await DI.osamRepository.checkRating();
101110

102111
if (mounted) {
Lines changed: 106 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:ui';
2+
import 'package:flutter/foundation.dart';
23
import 'package:osam_common_module_flutter/osam_common_module_flutter.dart';
34
import 'package:common_module_flutter_example/data/interfaces.dart';
45
import 'package:common_module_flutter_example/model/language.dart'
@@ -7,87 +8,144 @@ import 'package:common_module_flutter_example/model/language.dart'
78
class OsamRepositoryImpl extends OsamRepository {
89
final OSAM osamSdk;
910
final Settings settings;
11+
AlertWrapper? alertWrapper;
12+
13+
Future<VersionControlResponse>? _checkForUpdatesFuture;
14+
Future<RatingControlResponse>? _checkRatingFuture;
1015

1116
OsamRepositoryImpl(
1217
this.osamSdk,
1318
this.settings,
1419
);
1520

21+
void setAlertWrapper(AlertWrapper wrapper) {
22+
alertWrapper = wrapper;
23+
}
24+
1625
@override
1726
Future<VersionControlResponse> checkForUpdates() async {
18-
final response = await osamSdk.versionControl(
19-
language: _getLanguage(settings.getLanguage()),
20-
isDarkMode:
21-
PlatformDispatcher.instance.platformBrightness == Brightness.dark,
22-
);
23-
print("checkForUpdates response: $response");
24-
return response;
27+
if (_checkForUpdatesFuture != null) {
28+
debugPrint("OsamRepository: already checking, waiting...");
29+
return _checkForUpdatesFuture!;
30+
}
31+
32+
_checkForUpdatesFuture = _doCheckForUpdates();
33+
try {
34+
return await _checkForUpdatesFuture!;
35+
} finally {
36+
_checkForUpdatesFuture = null;
37+
}
38+
}
39+
40+
Future<VersionControlResponse> _doCheckForUpdates() async {
41+
try {
42+
final language = _getLanguage(settings.getLanguage());
43+
final isDark =
44+
PlatformDispatcher.instance.platformBrightness == Brightness.dark;
45+
46+
debugPrint(
47+
"OsamRepository: Requesting versionControl (lang: ${language.toLanguageCode()}, dark: $isDark)");
48+
49+
if (alertWrapper != null) {
50+
return await alertWrapper!.showVersionControlNative(
51+
osam: osamSdk,
52+
language: language,
53+
isDarkMode: isDark,
54+
);
55+
}
56+
57+
final response = await osamSdk.versionControl(
58+
language: language,
59+
isDarkMode: isDark,
60+
);
61+
62+
debugPrint("OsamRepository: versionControl response = $response");
63+
return response;
64+
} catch (e) {
65+
debugPrint("OsamRepository: versionControl error = $e");
66+
return VersionControlResponse.ERROR;
67+
}
2568
}
2669

2770
@override
2871
Future<RatingControlResponse> checkRating() async {
29-
return osamSdk.rating(
30-
language: _getLanguage(settings.getLanguage()),
31-
isDarkMode:
32-
PlatformDispatcher.instance.platformBrightness == Brightness.dark,
33-
);
72+
if (_checkRatingFuture != null) {
73+
debugPrint("OsamRepository: already checking rating, waiting...");
74+
return _checkRatingFuture!;
75+
}
76+
77+
_checkRatingFuture = _doCheckRating();
78+
try {
79+
return await _checkRatingFuture!;
80+
} finally {
81+
_checkRatingFuture = null;
82+
}
83+
}
84+
85+
Future<RatingControlResponse> _doCheckRating() async {
86+
try {
87+
final language = _getLanguage(settings.getLanguage());
88+
final isDark =
89+
PlatformDispatcher.instance.platformBrightness == Brightness.dark;
90+
91+
debugPrint(
92+
"OsamRepository: Requesting rating (lang: ${language.toLanguageCode()}, dark: $isDark)");
93+
94+
if (alertWrapper != null) {
95+
return await alertWrapper!.showRating(
96+
osam: osamSdk,
97+
language: language,
98+
isDarkMode: isDark,
99+
);
100+
}
101+
102+
final response = await osamSdk.rating(
103+
language: language,
104+
isDarkMode: isDark,
105+
);
106+
107+
debugPrint("OsamRepository: rating response = $response");
108+
return response;
109+
} catch (e) {
110+
debugPrint("OsamRepository: rating error = $e");
111+
return RatingControlResponse.ERROR;
112+
}
34113
}
35114

36115
Language _getLanguage(app_language.AppLanguage appLanguage) {
37-
Language language;
38116
switch (appLanguage) {
39117
case app_language.AppLanguage.ES:
40-
language = Language.ES;
41-
break;
118+
return Language.ES;
42119
case app_language.AppLanguage.CA:
43-
language = Language.CA;
44-
break;
120+
return Language.CA;
45121
case app_language.AppLanguage.EN:
46-
language = Language.EN;
47-
break;
48-
default:
49-
language = Language.EN;
50-
break;
122+
return Language.EN;
51123
}
52-
return language;
53124
}
54125

55126
@override
56-
Future<DeviceInformation> deviceInformation() {
57-
return osamSdk.deviceInformation();
58-
}
127+
Future<DeviceInformation> deviceInformation() => osamSdk.deviceInformation();
59128

60129
@override
61-
Future<AppInformation> appInformation() {
62-
return osamSdk.appInformation();
63-
}
130+
Future<AppInformation> appInformation() => osamSdk.appInformation();
64131

65132
@override
66-
Future<AppLanguageResponse> changeLanguageEvent() {
67-
return osamSdk.changeLanguageEvent(
68-
language: _getLanguage(settings.getLanguage()),
69-
);
70-
}
133+
Future<AppLanguageResponse> changeLanguageEvent() => osamSdk
134+
.changeLanguageEvent(language: _getLanguage(settings.getLanguage()));
71135

72136
@override
73-
Future<AppLanguageResponse> firstTimeOrUpdateEvent() {
74-
return osamSdk.firstTimeOrUpdateAppEvent(
75-
language: _getLanguage(settings.getLanguage()),
76-
);
77-
}
137+
Future<AppLanguageResponse> firstTimeOrUpdateEvent() =>
138+
osamSdk.firstTimeOrUpdateAppEvent(
139+
language: _getLanguage(settings.getLanguage()));
78140

79141
@override
80-
Future<SubscriptionResponse> subscribeToCustomTopic() {
81-
return osamSdk.subscribeToCustomTopic(topic: "TestTopic");
82-
}
142+
Future<SubscriptionResponse> subscribeToCustomTopic() =>
143+
osamSdk.subscribeToCustomTopic(topic: "TestTopic");
83144

84145
@override
85-
Future<SubscriptionResponse> unsubscribeToCustomTopic() {
86-
return osamSdk.unsubscribeToCustomTopic(topic: "TestTopic");
87-
}
146+
Future<SubscriptionResponse> unsubscribeToCustomTopic() =>
147+
osamSdk.unsubscribeToCustomTopic(topic: "TestTopic");
88148

89149
@override
90-
Future<TokenResponse> getFCMToken() {
91-
return osamSdk.getFCMToken();
92-
}
150+
Future<TokenResponse> getFCMToken() => osamSdk.getFCMToken();
93151
}

0 commit comments

Comments
 (0)