Skip to content

Commit 6be819d

Browse files
author
Alberto Aguilar Garcia WORDLINE
committed
Merge branch 'develop' into 'master'
Update to version 3.2.0 See merge request osam/common_module_flutter!26
1 parent b64720e commit 6be819d

28 files changed

Lines changed: 1004 additions & 303 deletions

CHANGELOG.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
## 8.2.0
2+
3+
* UPDATED NATIVE LIBRARIES
4+
* Updated [modul_comu_osam library](https://github.com/AjuntamentdeBarcelona/modul_comu_osam) to version 3.2.0-dev.
5+
* IMPROVED POPUP INTERACTION
6+
* Added transparent barriers and PopScope in `AlertWrapper` and `UIHelper` to prevent background interaction while native or custom popups are being shown.
7+
* Changed default language fallback to English (`en`).
8+
* Refined `VersionControlResponse` handling, ensuring `DISMISSED` is returned consistently.
9+
10+
## 8.1.8-dev
11+
12+
* IMPLEMENTED STYLES FLEXIBILITY FOR CUSTOM POPUPS
13+
* Added a parameter when building the version control popup for adding foreign styles or keeping their own.
14+
15+
## 8.1.2-dev
16+
17+
* IMPLEMENTED CUSTOM POPUPS
18+
* Added custom Flutter popups implementation to support dark/light mode colors (#1C1C1C and #B0B0B0) as requested.
19+
* Added UIHelper and OSAMDialog widget in the Flutter part.
20+
* Updated example app with "Custom Flutter Popup" button to test the new UI.
21+
22+
## 8.1.2-dev
23+
24+
* BREAKING CHANGES
25+
* Updated [modul_comu_osam library](https://github.com/AjuntamentdeBarcelona/modul_comu_osam) to version 3.0.1-dev accessible popup.
26+
127
## 8.1.0
228

329
* BREAKING CHANGES
@@ -105,4 +131,4 @@
105131

106132
## 1.0.0
107133

108-
* First version of common module flutter (not null safety)
134+
* First version of common module flutter (not null safety)

README.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
---
77

8-
## Migrate from 6.0.0 to 8.1.0
8+
## Migrate from 6.0.0 to 8.2.0
99

10+
- Default language fallback changed from Catalan (`ca`) to English (`en`).
1011
- Need to use minimal Dart SDK version ^3.5.0
1112
- Need to use minimal Flutter version 3.24.3
1213

@@ -40,7 +41,7 @@ A partir de la versió 3.0.0 la llibreria es un wrapper de la [desenvolupada en
4041
osam_common_module_flutter:
4142
git:
4243
url: https://github.com/AjuntamentdeBarcelona/modul_comu_osam_flutter.git
43-
ref: '8.1.0'
44+
ref: '8.2.0'
4445
```
4546
4647
En cas que les dependències de Firebase Analytics, Firebase Performance, Firebase Messaging i Firebase Crashlytics fallin, cal afegir aquestes aquesta configuració al pubspec:
@@ -110,7 +111,7 @@ En el Podfile del projecte d'iOS creat por Flutter haurem d'incloure el pod del
110111
Kotlin Multiplatform Mobile. Això es fa incloent la següent linea:
111112

112113
```plist
113-
pod 'OSAMCommon', :git => 'https://github.com/AjuntamentdeBarcelona/modul_comu_osam.git', :tag => '2.2.3'
114+
pod 'OSAMCommon', :git => 'https://github.com/AjuntamentdeBarcelona/modul_comu_osam.git', :tag => '3.2.0-dev'
114115
```
115116

116117
El Podfile quedaria de [la següent manera](https://github.com/AjuntamentdeBarcelona/modul_comu_osam_flutter/blob/main/example/ios/Podfile)
@@ -231,12 +232,12 @@ void _onChangeLanguageEvent(BuildContext context) async {
231232
if (context.mounted) {
232233
switch (result) {
233234
case AppLanguageResponse.SUCCESS:
234-
_showToast(context, AppLanguageResponse.SENT.name);
235+
_showToast(context, AppLanguageResponse.SUCCESS.name);
235236
break;
236-
case LanguageInformationResponse.UNCHANGED:
237-
_showToast(context, AppLanguageResponse.NOT_SENT.name);
237+
case AppLanguageResponse.UNCHANGED:
238+
_showToast(context, AppLanguageResponse.UNCHANGED.name);
238239
break;
239-
case LanguageInformationResponse.ERROR:
240+
case AppLanguageResponse.ERROR:
240241
_showToast(context, AppLanguageResponse.ERROR.name);
241242
break;
242243
}
@@ -261,10 +262,10 @@ void _onFirstTimeOrUpdateEvent(BuildContext context) async {
261262
case AppLanguageResponse.SUCCESS:
262263
_showToast(context, AppLanguageResponse.SUCCESS.name);
263264
break;
264-
case LanguageInformationResponse.UNCHANGED:
265+
case AppLanguageResponse.UNCHANGED:
265266
_showToast(context, AppLanguageResponse.UNCHANGED.name);
266267
break;
267-
case LanguageInformationResponse.ERROR:
268+
case AppLanguageResponse.ERROR:
268269
_showToast(context, AppLanguageResponse.ERROR.name);
269270
break;
270271
}
@@ -287,11 +288,11 @@ void _onSubscribeToCustomTopic(BuildContext context, String topic) async {
287288
final result = await DI.osamRepository.subscribeToCustomTopic(topic: topic);
288289
if (context.mounted) {
289290
switch (result) {
290-
case AppLanguageResponse.ACCEPTED:
291-
_showToast(context, AppLanguageResponse.ACCEPTED.name);
291+
case SubscriptionResponse.accepted:
292+
_showToast(context, SubscriptionResponse.accepted.name);
292293
break;
293-
case LanguageInformationResponse.ERROR:
294-
_showToast(context, AppLanguageResponse.ERROR.name);
294+
case SubscriptionResponse.error:
295+
_showToast(context, SubscriptionResponse.error.name);
295296
break;
296297
}
297298
}
@@ -313,11 +314,11 @@ void _onUnsubscribeToCustomTopic(BuildContext context, String topic) async {
313314
final result = await DI.osamRepository.unsubscribeToCustomTopic(topic: topic);
314315
if (context.mounted) {
315316
switch (result) {
316-
case AppLanguageResponse.ACCEPTED:
317-
_showToast(context, AppLanguageResponse.ACCEPTED.name);
317+
case SubscriptionResponse.accepted:
318+
_showToast(context, SubscriptionResponse.accepted.name);
318319
break;
319-
case LanguageInformationResponse.ERROR:
320-
_showToast(context, AppLanguageResponse.ERROR.name);
320+
case SubscriptionResponse.error:
321+
_showToast(context, SubscriptionResponse.error.name);
321322
break;
322323
}
323324
}
@@ -368,7 +369,10 @@ static _onMessagingEvent(String topic, String action) async {
368369
static Future<void> cacheTokenForNative() async {
369370
String? token = await FirebaseMessaging.instance.getToken();
370371
if (token != null) {
371-
await _prefs.setString('fcm_token', token);
372+
// Save token where native side can access it, e.g. SharedPreferences
373+
final prefs = await SharedPreferences.getInstance();
374+
await prefs.setString('fcm_token', token);
375+
}
372376
}
373377
```
374378
## Flutter app demo

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.0")
52+
implementation("com.github.AjuntamentdeBarcelona.modul_comu_osam:common:3.2.0-dev")
5353
implementation("com.google.code.gson:gson:2.10.1")
5454

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

android/src/main/kotlin/cat/bcn/commonmodule/flutter/osam_common_module_flutter/CommonModuleFlutterPlugin.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class CommonModuleFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
8080
val osamCommons = this.osamCommons
8181
if (osamCommons != null) {
8282
val language = getLanguageFromString(call.argument("language") ?: "")
83-
osamCommons.versionControl(language) {
83+
val isDarkMode = call.argument<Boolean>("isDarkMode") ?: false
84+
osamCommons.versionControl(language, isDarkMode) {
8485
result.success(it.toStringResponse())
8586
}
8687
} else {
@@ -91,7 +92,8 @@ class CommonModuleFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
9192
val osamCommons = this.osamCommons
9293
if (osamCommons != null) {
9394
val language = getLanguageFromString(call.argument("language") ?: "")
94-
osamCommons.rating(language) {
95+
val isDarkMode = call.argument<Boolean>("isDarkMode") ?: false
96+
osamCommons.rating(language, isDarkMode) {
9597
result.success(it.toStringResponse())
9698
}
9799
} else {

android/src/main/kotlin/cat/bcn/commonmodule/flutter/osam_common_module_flutter/extension/Extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fun getLanguageFromString(languageCode: String): Language = when (languageCode)
2020
catalanLanguageCode -> Language.CA
2121
spanishLanguageCode -> Language.ES
2222
englishLanguageCode -> Language.EN
23-
else -> Language.CA
23+
else -> Language.EN
2424
}
2525

2626
fun VersionControlResponse.toStringResponse(): String = when (this) {

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.0'
35+
pod 'OSAMCommon', :git => 'https://github.com/AjuntamentdeBarcelona/modul_comu_osam.git', :tag => '3.2.0-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>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict/>
5+
</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) {

0 commit comments

Comments
 (0)