Skip to content

Commit bb8b7c8

Browse files
author
Alberto Aguilar Garcia WORDLINE
committed
Merge branch 'OSAM-21605-dark-mode-control-version-popup' into 'feat/OSAM_april_2026'
OSAM-21605-dark-mode-control-version-popup See merge request osam/common_module_flutter!16
1 parent 04685c7 commit bb8b7c8

13 files changed

Lines changed: 326 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 8.1.2-dev
2+
3+
* IMPLEMENTED CUSTOM POPUPS
4+
* Added custom Flutter popups implementation to support dark/light mode colors (#1C1C1C and #B0B0B0) as requested.
5+
* Added UIHelper and OSAMDialog widget in the Flutter part.
6+
* Updated example app with "Custom Flutter Popup" button to test the new UI.
7+
18
## 8.1.1-dev
29

310
* BREAKING CHANGES

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.2-dev")
52+
implementation("com.github.AjuntamentdeBarcelona.modul_comu_osam:common:3.1.3-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 {

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.2-dev'
35+
pod 'OSAMCommon', :git => 'https://github.com/AjuntamentdeBarcelona/modul_comu_osam.git', :tag => '3.1.3-dev'
3636
end
3737

3838
post_install do |installer|

example/lib/data/osam/osam_repository_impl.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'dart:ui';
12
import 'package:osam_common_module_flutter/osam_common_module_flutter.dart';
23
import 'package:common_module_flutter_example/data/interfaces.dart';
34
import 'package:common_module_flutter_example/model/language.dart'
@@ -16,12 +17,18 @@ class OsamRepositoryImpl extends OsamRepository {
1617
Future<VersionControlResponse> checkForUpdates() async {
1718
return osamSdk.versionControl(
1819
language: _getLanguage(settings.getLanguage()),
20+
isDarkMode:
21+
PlatformDispatcher.instance.platformBrightness == Brightness.dark,
1922
);
2023
}
2124

2225
@override
2326
Future<RatingControlResponse> checkRating() async {
24-
return osamSdk.rating(language: _getLanguage(settings.getLanguage()));
27+
return osamSdk.rating(
28+
language: _getLanguage(settings.getLanguage()),
29+
isDarkMode:
30+
PlatformDispatcher.instance.platformBrightness == Brightness.dark,
31+
);
2532
}
2633

2734
Language _getLanguage(app_language.AppLanguage appLanguage) {

example/lib/main.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ class MyApp extends StatelessWidget {
1717
return MaterialApp(
1818
debugShowCheckedModeBanner: false,
1919
title: 'Common Module Flutter Demo',
20-
theme: ThemeData(primarySwatch: Colors.blue),
20+
theme: ThemeData(
21+
primarySwatch: Colors.blue,
22+
brightness: Brightness.light,
23+
),
24+
darkTheme: ThemeData(
25+
primarySwatch: Colors.blue,
26+
brightness: Brightness.dark,
27+
),
28+
themeMode: ThemeMode.system,
2129
home: const SplashScreen(),
2230
);
2331
}

ios/Classes/SwiftCommonModuleFlutterPlugin.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ public class SwiftCommonModuleFlutterPlugin: NSObject, FlutterPlugin {
4646
if call.method == "versionControl" {
4747
if let osamCommons = self.osamCommons {
4848
let language : String = ((call.arguments as? Dictionary<String, Any>)?["language"] as? String) ?? ""
49+
let isDarkMode : Bool = ((call.arguments as? Dictionary<String, Any>)?["isDarkMode"] as? Bool) ?? false
4950
osamCommons.versionControl(
5051
language: getLanguageFromString(langugageCode: language),
52+
isDarkMode: isDarkMode,
5153
f: { versionControlResponse in
5254
result(versionControlResponse.toStringResponse())
5355
}
@@ -58,8 +60,10 @@ public class SwiftCommonModuleFlutterPlugin: NSObject, FlutterPlugin {
5860
} else if call.method == "rating" {
5961
if let osamCommons = self.osamCommons {
6062
let language : String = ((call.arguments as? Dictionary<String, Any>)?["language"] as? String) ?? ""
63+
let isDarkMode : Bool = ((call.arguments as? Dictionary<String, Any>)?["isDarkMode"] as? Bool) ?? false
6164
osamCommons.rating(
6265
language: getLanguageFromString(langugageCode: language),
66+
isDarkMode: isDarkMode,
6367
f: { versionControlResponse in
6468
result(versionControlResponse.toStringResponse())
6569
}

ios/osam_common_module_flutter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A new flutter plugin project.
1515
s.source = { :path => '.' }
1616
s.source_files = 'Classes/**/*'
1717
s.dependency 'Flutter'
18-
s.dependency 'OSAMCommon', '~> 3.1.2-dev'
18+
s.dependency 'OSAMCommon', '~> 3.1.3-dev'
1919
s.platform = :ios, '8.0'
2020

2121
# Flutter.framework does not contain a i386 slice.

lib/osam_common_module_flutter.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ export 'src/model/language.dart';
88
export 'src/model/rating_control_response.dart';
99
export 'src/model/subscription_response.dart';
1010
export 'src/model/token_response.dart';
11+
export 'src/model/version.dart';
1112
export 'src/model/version_control_response.dart';
1213
export 'src/osam.dart';
14+
export 'src/ui/ui_helper.dart';

lib/src/model/version.dart

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import 'package:osam_common_module_flutter/src/model/language.dart';
2+
3+
class Version {
4+
final LocalizedText title;
5+
final LocalizedText message;
6+
final LocalizedText ok;
7+
final LocalizedText cancel;
8+
final CheckBoxDontShowAgain checkBoxDontShowAgain;
9+
10+
Version({
11+
required this.title,
12+
required this.message,
13+
required this.ok,
14+
required this.cancel,
15+
required this.checkBoxDontShowAgain,
16+
});
17+
}
18+
19+
class LocalizedText {
20+
final String ca;
21+
final String es;
22+
final String en;
23+
24+
LocalizedText({
25+
required this.ca,
26+
required this.es,
27+
required this.en,
28+
});
29+
30+
String localize(Language language) {
31+
switch (language) {
32+
case Language.CA:
33+
return ca;
34+
case Language.ES:
35+
return es;
36+
case Language.EN:
37+
return en;
38+
default:
39+
return ca;
40+
}
41+
}
42+
}
43+
44+
class CheckBoxDontShowAgain {
45+
final bool isCheckBoxVisible;
46+
final LocalizedText text;
47+
48+
CheckBoxDontShowAgain({
49+
required this.isCheckBoxVisible,
50+
required this.text,
51+
});
52+
}

0 commit comments

Comments
 (0)