diff --git a/system_theme/CHANGELOG.md b/system_theme/CHANGELOG.md
index a8db54c..c76d572 100644
--- a/system_theme/CHANGELOG.md
+++ b/system_theme/CHANGELOG.md
@@ -1,6 +1,9 @@
-## [3.2.0] - [30/12/2025]
+## [3.2.0] - [31/12/2025]
* feat: Reactive theming for macOS ([#45](https://github.com/bdlukaa/system_theme/pull/45))
+* chore: Migrate iOS and macOS to Swift Package Manager. ([#46](https://github.com/bdlukaa/system_theme/pull/46), [#45](https://github.com/bdlukaa/system_theme/pull/45))
+* feat: Automatically adjust lightness if the platform doesn't support it natively. ([#46](https://github.com/bdlukaa/system_theme/pull/46))
+ This is enabled by default. You can disable it by setting `SystemTheme.autoAdjustLightness` to `false`.
## [3.1.2] - [04/10/2024]
diff --git a/system_theme/README.md b/system_theme/README.md
index 56bbf40..dde6b3c 100644
--- a/system_theme/README.md
+++ b/system_theme/README.md
@@ -1,5 +1,5 @@
-
system_theme
+
system_theme
@@ -7,32 +7,22 @@
-
-
-
-
-
-
-
-
- A flutter plugin to get the current system theme information
+ A flutter plugin to retrieve the current system theme information
-- [Supported platforms](#supported-platforms)
-- [Usage](#usage)
- - [Get system accent color](#get-system-accent-color)
-- [Contribution](#contribution)
- - [Acknowlegments](#acknowlegments)
-
### Supported platforms
-| Feature | Android 10+ | iOS | Web | MacOs 10.14+ | Windows 10+ and XBox | Linux GTK 3+ |
-| ----------------- | :---------: | :-: | :-: | :---------: | :------------------: | :----------: |
-| Get accent color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
-| Listen to changes | | | | ✔️ | ✔️ | |
+| Platform | Accent Color | Listen to Changes | Minimum Version |
+| :--- | :---: | :---: | :--- |
+| **Android** | ✔️ | | Android 10+ |
+| **iOS** | ✔️ | | iOS 14+ |
+| **Windows** | ✔️ | ✔️ | Windows 10+ |
+| **macOS** | ✔️ | ✔️ | Mojave 10.14+ |
+| **Linux** | ✔️ | | GTK 3+ |
+| **Web** | ✔️ | | All modern browsers |
## Usage
@@ -94,25 +84,16 @@ SystemTheme.onChange.listen((event) {
Alteratively, you can the `SystemThemeBuilder` widget to listen to changes on the system accent color:
```dart
-SystemThemeBuilder(builder: (context, accent) {
- return ColoredBox(color: accent.accentColor);
-});
-```
-
-### Checking if accent color is supported
-
-The `flutter/foundation` package provides a `defaultTargetPlatform` getter, which can be used to check what platform the current app is running on.
-
-You can check if the current platform supports accent colors using this extension method:
-
-```dart
-import 'package:flutter/foundation.dart' show defaultTargetPlatform;
-
-void main() {
- final supported = defaultTargetPlatform.supportsAccentColor;
-
- print('Accent color is: ${supported ? 'supported' : 'not supported'} on the current platform');
-}
+SystemThemeBuilder(
+ builder: (context, color) {
+ return ColoredBox(
+ color: color.accent, // Automatically updates when system theme changes
+ child: const Center(
+ child: Text('System Accent Color'),
+ ),
+ );
+ },
+);
```
## Contribution
diff --git a/system_theme/android/src/main/kotlin/com/bruno/system_theme/SystemThemePlugin.kt b/system_theme/android/src/main/kotlin/com/bruno/system_theme/SystemThemePlugin.kt
index 0b8f58d..98dd79a 100644
--- a/system_theme/android/src/main/kotlin/com/bruno/system_theme/SystemThemePlugin.kt
+++ b/system_theme/android/src/main/kotlin/com/bruno/system_theme/SystemThemePlugin.kt
@@ -26,16 +26,19 @@ class SystemThemePlugin: FlutterPlugin, ActivityAware, MethodCallHandler {
override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: MethodChannel.Result) {
when (call.method) {
"SystemTheme.accentColor" -> {
- val accentColor = getDeviceAccentColor(activity)
- val hexColor = java.lang.String.format("#%06X", 0xFFFFFF and accentColor)
- val rgb = getRGB(hexColor)
+ val color = getDeviceAccentColor(activity)
+ val r = (color shr 16) and 0xFF
+ val g = (color shr 8) and 0xFF
+ val b = color and 0xFF
+ // val a = (color shr 24) and 0xFF
+
result.success(hashMapOf(
- "accent" to hashMapOf(
- "R" to rgb[0],
- "G" to rgb[1],
- "B" to rgb[2],
- "A" to 1
- )
+ "accent" to hashMapOf(
+ "R" to r,
+ "G" to g,
+ "B" to b,
+ "A" to 255
+ )
))
}
else -> {
@@ -51,15 +54,6 @@ class SystemThemePlugin: FlutterPlugin, ActivityAware, MethodCallHandler {
return value.data
}
- private fun getRGB(rgb: String): IntArray {
- var color = rgb;
- if (rgb.startsWith("#")) color = rgb.replace("#", "");
- val r = color.substring(0, 2).toInt(16) // 16 for hex
- val g = color.substring(2, 4).toInt(16) // 16 for hex
- val b = color.substring(4, 6).toInt(16) // 16 for hex
- return intArrayOf(r, g, b)
- }
-
override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}
diff --git a/system_theme/example/.gitignore b/system_theme/example/.gitignore
index 0fa6b67..a1345d0 100644
--- a/system_theme/example/.gitignore
+++ b/system_theme/example/.gitignore
@@ -32,7 +32,6 @@
/build/
# Web related
-lib/generated_plugin_registrant.dart
# Symbolication related
app.*.symbols
diff --git a/system_theme/example/.metadata b/system_theme/example/.metadata
index 784ce12..7ad3ada 100644
--- a/system_theme/example/.metadata
+++ b/system_theme/example/.metadata
@@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.
version:
- revision: "a14f74ff3a1cbd521163c5f03d68113d50af93d3"
+ revision: "f6ff1529fd6d8af5f706051d9251ac9231c83407"
channel: "stable"
project_type: app
@@ -13,11 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
- create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
- base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
- - platform: web
- create_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
- base_revision: a14f74ff3a1cbd521163c5f03d68113d50af93d3
+ create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
+ base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
+ - platform: android
+ create_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
+ base_revision: f6ff1529fd6d8af5f706051d9251ac9231c83407
# User provided section
diff --git a/system_theme/example/android/.gitignore b/system_theme/example/android/.gitignore
index 6f56801..be3943c 100644
--- a/system_theme/example/android/.gitignore
+++ b/system_theme/example/android/.gitignore
@@ -5,9 +5,10 @@ gradle-wrapper.jar
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
+.cxx/
# Remember to never publicly share your keystore.
-# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
+# See https://flutter.dev/to/reference-keystore
key.properties
**/*.keystore
**/*.jks
diff --git a/system_theme/example/android/app/build.gradle b/system_theme/example/android/app/build.gradle
deleted file mode 100644
index f4f24d0..0000000
--- a/system_theme/example/android/app/build.gradle
+++ /dev/null
@@ -1,71 +0,0 @@
-def localProperties = new Properties()
-def localPropertiesFile = rootProject.file('local.properties')
-if (localPropertiesFile.exists()) {
- localPropertiesFile.withReader('UTF-8') { reader ->
- localProperties.load(reader)
- }
-}
-
-def flutterRoot = localProperties.getProperty('flutter.sdk')
-if (flutterRoot == null) {
- throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
-}
-
-def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
-if (flutterVersionCode == null) {
- flutterVersionCode = '1'
-}
-
-def flutterVersionName = localProperties.getProperty('flutter.versionName')
-if (flutterVersionName == null) {
- flutterVersionName = '1.0'
-}
-
-apply plugin: 'com.android.application'
-apply plugin: 'kotlin-android'
-apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
-
-android {
- compileSdkVersion flutter.compileSdkVersion
- ndkVersion flutter.ndkVersion
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- kotlinOptions {
- jvmTarget = '1.8'
- }
-
- sourceSets {
- main.java.srcDirs += 'src/main/kotlin'
- }
-
- defaultConfig {
- // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId "com.bruno.system_theme_example"
- // You can update the following values to match your application needs.
- // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
- minSdkVersion flutter.minSdkVersion
- targetSdkVersion flutter.targetSdkVersion
- versionCode flutterVersionCode.toInteger()
- versionName flutterVersionName
- }
-
- buildTypes {
- release {
- // TODO: Add your own signing config for the release build.
- // Signing with the debug keys for now, so `flutter run --release` works.
- signingConfig signingConfigs.debug
- }
- }
-}
-
-flutter {
- source '../..'
-}
-
-dependencies {
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
-}
diff --git a/system_theme/example/android/app/build.gradle.kts b/system_theme/example/android/app/build.gradle.kts
new file mode 100644
index 0000000..564b35d
--- /dev/null
+++ b/system_theme/example/android/app/build.gradle.kts
@@ -0,0 +1,44 @@
+plugins {
+ id("com.android.application")
+ id("kotlin-android")
+ // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
+ id("dev.flutter.flutter-gradle-plugin")
+}
+
+android {
+ namespace = "com.bruno.system_theme_example"
+ compileSdk = flutter.compileSdkVersion
+ ndkVersion = flutter.ndkVersion
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_17.toString()
+ }
+
+ defaultConfig {
+ // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
+ applicationId = "com.bruno.system_theme_example"
+ // You can update the following values to match your application needs.
+ // For more information, see: https://flutter.dev/to/review-gradle-config.
+ minSdk = flutter.minSdkVersion
+ targetSdk = flutter.targetSdkVersion
+ versionCode = flutter.versionCode
+ versionName = flutter.versionName
+ }
+
+ buildTypes {
+ release {
+ // TODO: Add your own signing config for the release build.
+ // Signing with the debug keys for now, so `flutter run --release` works.
+ signingConfig = signingConfigs.getByName("debug")
+ }
+ }
+}
+
+flutter {
+ source = "../.."
+}
diff --git a/system_theme/example/android/app/src/debug/AndroidManifest.xml b/system_theme/example/android/app/src/debug/AndroidManifest.xml
index f3e987b..399f698 100644
--- a/system_theme/example/android/app/src/debug/AndroidManifest.xml
+++ b/system_theme/example/android/app/src/debug/AndroidManifest.xml
@@ -1,5 +1,4 @@
-
+
+
+
+
+
+
+
diff --git a/system_theme/example/android/app/src/main/kotlin/com/bruno/system_theme_example/MainActivity.kt b/system_theme/example/android/app/src/main/kotlin/com/bruno/system_theme_example/MainActivity.kt
index 7b943a7..168209f 100644
--- a/system_theme/example/android/app/src/main/kotlin/com/bruno/system_theme_example/MainActivity.kt
+++ b/system_theme/example/android/app/src/main/kotlin/com/bruno/system_theme_example/MainActivity.kt
@@ -2,5 +2,4 @@ package com.bruno.system_theme_example
import io.flutter.embedding.android.FlutterActivity
-class MainActivity: FlutterActivity() {
-}
+class MainActivity : FlutterActivity()
diff --git a/system_theme/example/android/app/src/profile/AndroidManifest.xml b/system_theme/example/android/app/src/profile/AndroidManifest.xml
index f3e987b..399f698 100644
--- a/system_theme/example/android/app/src/profile/AndroidManifest.xml
+++ b/system_theme/example/android/app/src/profile/AndroidManifest.xml
@@ -1,5 +1,4 @@
-
+
-
+
-
+
system_theme_example
+
-