Skip to content

fix: optimize blur animation handling for full and no blur states#110

Open
sbaiahmed1 wants to merge 3 commits into
mainfrom
fix/animator-issues-iOS
Open

fix: optimize blur animation handling for full and no blur states#110
sbaiahmed1 wants to merge 3 commits into
mainfrom
fix/animator-issues-iOS

Conversation

@sbaiahmed1
Copy link
Copy Markdown
Owner

@sbaiahmed1 sbaiahmed1 commented May 28, 2026

Summary by CodeRabbit

  • New Features

    • Added new material blur variants (Ultra Thin, Thin, Material, Thick, Chrome) for expanded customization.
  • Bug Fixes

    • Removed dark-mode dependent blur selection for consistent blur types.
    • More reliable blur initialization/teardown and rendering behavior.
    • iOS: honor configured light/dark intent for blur styles to prevent unintended system adaptation.
  • Chores

    • Updated example iOS script to run on a physical device.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

This PR removes Configuration-driven dark-mode branching from Android blur resolution and initialization, moves Android blur init to onAttachedToWindow and tightens cleanup, and adds iOS helpers and view updates to apply explicit overrideUserInterfaceStyle based on blur type strings; several iOS view simplifications and blur-intensity optimizations were also made.

Changes

Android Configuration-Independent Blur

Layer / File(s) Summary
BlurType contract refactoring
android/src/main/java/com/sbaiahmed1/reactnativeblur/BlurType.kt
BlurType.fromString() now accepts only the type string; Configuration parameter removed and dark-mode branching eliminated; enum entries reorganized to non-conditional base variants and explicit system material variants.
ReactNativeBlurView lifecycle and type resolution
android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt
Removes Configuration import and onConfigurationChanged; onAttachedToWindow() swaps blur root via reflection and initializes blur (guarded by isBlurInitialized); reflection swap removal/reattach is wrapped in error handling; onDetachedFromWindow() always calls cleanup(); setBlurType() now calls BlurType.fromString(type); glass overlay setters and updateViewType() centralized.
ReactNativeProgressiveBlurView configuration removal
android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeProgressiveBlurView.kt
Removes Configuration import and onConfigurationChanged override; setBlurType() updated to call BlurType.fromString(type) without resources.configuration.

iOS Explicit Interface Style Overrides

Layer / File(s) Summary
BlurStyleHelpers interface style mapping
ios/Helpers/BlurStyleHelpers.swift
Adds interfaceStyleForBlurType() to map blur-style strings to UIUserInterfaceStyle (.light/.dark) or nil for ambiguous styles.
AdvancedBlurView & ProgressiveBlurView interface style
ios/Views/AdvancedBlurView.swift, ios/Views/ProgressiveBlurView.swift
Both views compute interfaceStyle from blurTypeString and apply it to overrideUserInterfaceStyle on the view and hosted/embedded controllers during setup and updates.
Vibrancy/Variable/BlurEffect adjustments
ios/Views/VibrancyEffectView.swift, ios/Views/VariableBlurView.swift, ios/Views/BlurEffectView.swift
VibrancyEffectView sets overrideUserInterfaceStyle from blur type before rebuilding effects; VariableBlurView removes traitCollectionDidChange refresh; BlurEffectView tracks currentEffectStyle and adds intensity-based fast paths and animator reuse logic.
BasicColoredView & LiquidGlass formatting
ios/Views/BasicColoredView.swift, ios/Views/LiquidGlassContainerView.swift
BasicColoredView drops reduced-transparency fallback and always renders the regular blur; LiquidGlassContainerView has minor formatting/whitespace changes in fallback handling.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

bug, android, ios

Suggested reviewers

  • DanielAraldi

Poem

🐰 I hopped through code where blurs used to bend,
Removed the night-mask branch and lashed the end.
Android wakes on attach, iOS dons a style,
Cleaner views, fewer tricks — I pause and smile. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title focuses on iOS blur animation optimization but the PR also includes significant Android refactoring removing Configuration dependency, iOS view simplifications, and npm script changes. Revise the title to reflect the broader scope: 'refactor: remove configuration-dependent blur handling and optimize animation logic' or similar to capture both Android and iOS changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/animator-issues-iOS

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt (2)

199-209: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unregister the swapped OnPreDrawListener in ReactNativeBlurView.cleanup()

swapBlurRootToScreenAncestor() removes the listener from the old root and re-registers it on the new screen/root ancestor, but ReactNativeBlurView.cleanup() only resets flags/callbacks and never calls removeOnPreDrawListener. Since ReactNativeBlurViewManager.onDropViewInstance() also calls view.cleanup(), dropped/detached views can leave the listener registered on the ancestor ViewTreeObserver, keeping callbacks alive past teardown. Mirror the listener-unregister logic used in ReactNativeProgressiveBlurView.cleanup().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt`
around lines 199 - 209, ReactNativeBlurView.cleanup() currently only clears
flags/callbacks but does not unregister the OnPreDrawListener, which can leave
the listener attached to the ancestor ViewTreeObserver after teardown; update
cleanup() to mirror ReactNativeProgressiveBlurView.cleanup() by checking the
stored blur root/screen ancestor and calling its
viewTreeObserver.removeOnPreDrawListener(blurPreDrawListener) (or the actual
listener field name used), then nulling any root/ancestor references, before
resetting isBlurInitialized and initRunnable; ensure
swapBlurRootToScreenAncestor()'s listener registration and the listener field
(e.g., blurPreDrawListener) are used consistently.

252-268: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix missing setGlassTintColor KDoc/function block (breaks Kotlin parsing)

In ReactNativeBlurView.kt, the KDoc opened at line 252 is never closed until the */ at line 440, so the color?.let { ... } block (lines 254-268) and the following methods are effectively commented out; setGlassTintColor(...) also doesn’t exist elsewhere in the file.

Suggested fix
  /**
   * Set the glass tint color for liquid glass effect.
+  */
+  fun setGlassTintColor(color: String?) {
    color?.let {
      try {
        glassTintColor = it.toColorInt()
        logDebug("setGlassTintColor: $color -> $glassTintColor")
        updateGlassEffect()
      } catch (e: Exception) {
        logWarning("Invalid color format for glass tint: $color")
        glassTintColor = Color.TRANSPARENT
      }
    } ?: run {
      glassTintColor = Color.TRANSPARENT
      logDebug("Cleared glass tint color")
      updateGlassEffect()
    }
+  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt`
around lines 252 - 268, Close the stray KDoc block before the method and
restore/implement the missing setGlassTintColor function using the existing
color handling logic: add a proper function signature named
setGlassTintColor(...) containing the color?.let { try { glassTintColor =
it.toColorInt(); logDebug("setGlassTintColor: $color -> $glassTintColor");
updateGlassEffect() } catch (e: Exception) { logWarning("Invalid color format
for glass tint: $color"); glassTintColor = Color.TRANSPARENT } } ?: run {
glassTintColor = Color.TRANSPARENT; logDebug("Cleared glass tint color");
updateGlassEffect() }, ensuring glassTintColor, updateGlassEffect(), logDebug(),
and logWarning() are referenced exactly as in the diff and any required imports
(e.g., Color, toColorInt) are present.
🧹 Nitpick comments (2)
ios/Views/VibrancyEffectView.swift (1)

98-122: ⚡ Quick win

Remove duplicate style mapping logic.

The styleFromString method duplicates the blurStyleFromString function in BlurStyleHelpers.swift. Prefer reusing the existing helper to maintain a single source of truth for blur style mappings.

♻️ Proposed refactor to use shared helper

Remove the local styleFromString method and update line 68 to use the shared helper:

-    let style = styleFromString(blurType)
+    let style = blurStyleFromString(blurType)
     let blurEffect = UIBlurEffect(style: style)

Then delete the duplicate method:

-    // Helper to parse string to UIBlurEffect.Style
-    private func styleFromString(_ style: String) -> UIBlurEffect.Style {
-        switch style {
-        case "xlight": return .extraLight
-        case "light": return .light
-        case "dark": return .dark
-        case "regular": return .regular
-        case "prominent": return .prominent
-        case "systemUltraThinMaterial": return .systemUltraThinMaterial
-        case "systemThinMaterial": return .systemThinMaterial
-        case "systemMaterial": return .systemMaterial
-        case "systemThickMaterial": return .systemThickMaterial
-        case "systemChromeMaterial": return .systemChromeMaterial
-        case "systemUltraThinMaterialLight": return .systemUltraThinMaterialLight
-        case "systemThinMaterialLight": return .systemThinMaterialLight
-        case "systemMaterialLight": return .systemMaterialLight
-        case "systemThickMaterialLight": return .systemThickMaterialLight
-        case "systemChromeMaterialLight": return .systemChromeMaterialLight
-        case "systemUltraThinMaterialDark": return .systemUltraThinMaterialDark
-        case "systemThinMaterialDark": return .systemThinMaterialDark
-        case "systemMaterialDark": return .systemMaterialDark
-        case "systemThickMaterialDark": return .systemThickMaterialDark
-        case "systemChromeMaterialDark": return .systemChromeMaterialDark
-        default: return .regular
-        }
-    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ios/Views/VibrancyEffectView.swift` around lines 98 - 122, Replace the local
duplicate mapping by removing the private method styleFromString in
VibrancyEffectView and instead call the shared helper blurStyleFromString (from
BlurStyleHelpers.swift) wherever styleFromString was used (e.g., in
VibrancyEffectView's initializer/configuration code); ensure you import or
reference the helper function and adjust any parameter types if needed so the
view uses the single source of truth for blur style mappings.
ios/Views/BasicColoredView.swift (1)

23-23: ⚡ Quick win

reducedTransparencyFallbackColor is now a no-op for this rendering path.

Line 23 always uses regularBlurView, so the initializer parameter reducedTransparencyFallbackColor no longer affects behavior. This leaves a misleading API contract for callers still passing that value.

♻️ Suggested cleanup
 init(blurAmount: Double,
      blurStyle: UIBlurEffect.Style,
-     ignoreSafeArea: Bool,
-     reducedTransparencyFallbackColor: UIColor) {
+     ignoreSafeArea: Bool) {
   self.blurAmount = blurAmount
   self.blurStyle = blurStyle
   self.ignoreSafeArea = ignoreSafeArea
   self.blurIntensity = mapBlurAmountToIntensity(blurAmount)
 }

Also update BasicColoredView(...) call sites to remove reducedTransparencyFallbackColor.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ios/Views/BasicColoredView.swift` at line 23, The initializer parameter
reducedTransparencyFallbackColor of BasicColoredView is unused because the code
always uses regularBlurView; remove the unused parameter from the
BasicColoredView init signature and any stored property or parameter handling
tied to reducedTransparencyFallbackColor, update the implementation so it relies
solely on regularBlurView, and update all BasicColoredView(...) call sites to
stop passing reducedTransparencyFallbackColor; also remove related docs/comments
and any dead branches that reference reducedTransparencyFallbackColor to keep
the API and implementation consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@example/package.json`:
- Line 10: Restore the default iOS script to run the simulator and add a
separate device-targeted script: change the "ios" npm script to "expo run:ios"
(remove the --device flag) and add a new "ios:device" script with "expo run:ios
--device"; ensure consistency with the existing "build:ios" script and update
any documentation or README references to use "ios:device" when physical-device
testing is required.

In `@ios/Views/BlurEffectView.swift`:
- Around line 39-45: In updateBlur(style:intensity:) ensure the
UIViewPropertyAnimator is recreated when the requested UIBlurEffect(style:)
differs from the currently applied style even for 0–1 intensity updates: detect
if animator exists but its effect style doesn't match the new style (compare the
new style to a stored currentStyle or to the animator's effect), and call
setupBlur() to recreate the animator and effect instead of simply setting
existing.fractionComplete; update stored currentStyle when creating the animator
so future calls can correctly decide whether to reuse or recreate.

---

Outside diff comments:
In `@android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt`:
- Around line 199-209: ReactNativeBlurView.cleanup() currently only clears
flags/callbacks but does not unregister the OnPreDrawListener, which can leave
the listener attached to the ancestor ViewTreeObserver after teardown; update
cleanup() to mirror ReactNativeProgressiveBlurView.cleanup() by checking the
stored blur root/screen ancestor and calling its
viewTreeObserver.removeOnPreDrawListener(blurPreDrawListener) (or the actual
listener field name used), then nulling any root/ancestor references, before
resetting isBlurInitialized and initRunnable; ensure
swapBlurRootToScreenAncestor()'s listener registration and the listener field
(e.g., blurPreDrawListener) are used consistently.
- Around line 252-268: Close the stray KDoc block before the method and
restore/implement the missing setGlassTintColor function using the existing
color handling logic: add a proper function signature named
setGlassTintColor(...) containing the color?.let { try { glassTintColor =
it.toColorInt(); logDebug("setGlassTintColor: $color -> $glassTintColor");
updateGlassEffect() } catch (e: Exception) { logWarning("Invalid color format
for glass tint: $color"); glassTintColor = Color.TRANSPARENT } } ?: run {
glassTintColor = Color.TRANSPARENT; logDebug("Cleared glass tint color");
updateGlassEffect() }, ensuring glassTintColor, updateGlassEffect(), logDebug(),
and logWarning() are referenced exactly as in the diff and any required imports
(e.g., Color, toColorInt) are present.

---

Nitpick comments:
In `@ios/Views/BasicColoredView.swift`:
- Line 23: The initializer parameter reducedTransparencyFallbackColor of
BasicColoredView is unused because the code always uses regularBlurView; remove
the unused parameter from the BasicColoredView init signature and any stored
property or parameter handling tied to reducedTransparencyFallbackColor, update
the implementation so it relies solely on regularBlurView, and update all
BasicColoredView(...) call sites to stop passing
reducedTransparencyFallbackColor; also remove related docs/comments and any dead
branches that reference reducedTransparencyFallbackColor to keep the API and
implementation consistent.

In `@ios/Views/VibrancyEffectView.swift`:
- Around line 98-122: Replace the local duplicate mapping by removing the
private method styleFromString in VibrancyEffectView and instead call the shared
helper blurStyleFromString (from BlurStyleHelpers.swift) wherever
styleFromString was used (e.g., in VibrancyEffectView's
initializer/configuration code); ensure you import or reference the helper
function and adjust any parameter types if needed so the view uses the single
source of truth for blur style mappings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a03319d2-b613-4b6d-a677-2d3e7e5d1476

📥 Commits

Reviewing files that changed from the base of the PR and between f9f1149 and 261c6ec.

📒 Files selected for processing (12)
  • android/src/main/java/com/sbaiahmed1/reactnativeblur/BlurType.kt
  • android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt
  • android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeProgressiveBlurView.kt
  • example/package.json
  • ios/Helpers/BlurStyleHelpers.swift
  • ios/Views/AdvancedBlurView.swift
  • ios/Views/BasicColoredView.swift
  • ios/Views/BlurEffectView.swift
  • ios/Views/LiquidGlassContainerView.swift
  • ios/Views/ProgressiveBlurView.swift
  • ios/Views/VariableBlurView.swift
  • ios/Views/VibrancyEffectView.swift
💤 Files with no reviewable changes (1)
  • ios/Views/VariableBlurView.swift

Comment thread example/package.json
"android": "expo run:android",
"prebuild:ios": "expo prebuild --platform ios --clean",
"ios": "expo run:ios",
"ios": "expo run:ios --device",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Reconsider forcing physical device as the default iOS target.

Changing the ios script to require --device breaks the standard development workflow for contributors who rely on simulators. Simulators are faster, more convenient for iterative testing, and don't require physical hardware.

Additionally, this is inconsistent with the build:ios script on line 14, which explicitly targets the simulator (-sdk iphonesimulator).

If device testing is necessary for validating blur effects on real hardware, consider adding a separate script instead of replacing the default:

"ios": "expo run:ios",
"ios:device": "expo run:ios --device",
📱 Proposed fix to restore simulator default and add device option
-    "ios": "expo run:ios --device",
+    "ios": "expo run:ios",
+    "ios:device": "expo run:ios --device",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@example/package.json` at line 10, Restore the default iOS script to run the
simulator and add a separate device-targeted script: change the "ios" npm script
to "expo run:ios" (remove the --device flag) and add a new "ios:device" script
with "expo run:ios --device"; ensure consistency with the existing "build:ios"
script and update any documentation or README references to use "ios:device"
when physical-device testing is required.

Comment thread ios/Views/BlurEffectView.swift Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt (1)

256-271: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing updateGlassEffect() call in catch block causes visual inconsistency.

When color parsing fails at line 262-264, glassTintColor is set to Color.TRANSPARENT but updateGlassEffect() is not called. In contrast, the null branch at lines 266-270 correctly calls updateGlassEffect() after setting the same value. This leaves the UI showing the previous tint color despite the internal state being TRANSPARENT.

🐛 Proposed fix to ensure consistent UI update on parse failure
     } catch (e: Exception) {
       logWarning("Invalid color format for glass tint: $color")
       glassTintColor = Color.TRANSPARENT
+      updateGlassEffect()
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt`
around lines 256 - 271, In setGlassTintColor, the catch block sets
glassTintColor = Color.TRANSPARENT but does not call updateGlassEffect(),
leaving the UI stale; modify the catch handler in the setGlassTintColor method
(where the Exception is caught) to call updateGlassEffect() after setting
glassTintColor and logging the warning so the visual state is updated
consistently (same behavior as the null branch).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt`:
- Around line 256-271: In setGlassTintColor, the catch block sets glassTintColor
= Color.TRANSPARENT but does not call updateGlassEffect(), leaving the UI stale;
modify the catch handler in the setGlassTintColor method (where the Exception is
caught) to call updateGlassEffect() after setting glassTintColor and logging the
warning so the visual state is updated consistently (same behavior as the null
branch).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 09f08aa2-cf8e-494b-b25b-f19dba84fa1a

📥 Commits

Reviewing files that changed from the base of the PR and between 261c6ec and e151f8d.

📒 Files selected for processing (2)
  • android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt
  • ios/Views/BlurEffectView.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • ios/Views/BlurEffectView.swift

Comment on lines +10 to +52
REGULAR(Color.argb(35, 255, 255, 255)),
PROMINENT(Color.argb(140, 240, 240, 240)),
SYSTEM_ULTRA_THIN_MATERIAL(Color.argb(75, 240, 240, 240)),
SYSTEM_ULTRA_THIN_MATERIAL_LIGHT(Color.argb(75, 240, 240, 240)),
SYSTEM_ULTRA_THIN_MATERIAL_DARK(Color.argb(65, 40, 40, 40)),
SYSTEM_THIN_MATERIAL(Color.argb(102, 240, 240, 240)),
SYSTEM_THIN_MATERIAL_LIGHT(Color.argb(102, 240, 240, 240)),
SYSTEM_THIN_MATERIAL_DARK(Color.argb(102, 35, 35, 35)),
SYSTEM_MATERIAL(Color.argb(140, 245, 245, 245)),
SYSTEM_MATERIAL_LIGHT(Color.argb(140, 245, 245, 245)),
SYSTEM_MATERIAL_DARK(Color.argb(215, 65, 60, 60)),
SYSTEM_THICK_MATERIAL(Color.argb(210, 248, 248, 248)),
SYSTEM_THICK_MATERIAL_LIGHT(Color.argb(210, 248, 248, 248)),
SYSTEM_THICK_MATERIAL_DARK(Color.argb(160, 35, 35, 35)),
SYSTEM_CHROME_MATERIAL(Color.argb(165, 248, 248, 248)),
SYSTEM_CHROME_MATERIAL_LIGHT(Color.argb(165, 248, 248, 248)),
SYSTEM_CHROME_MATERIAL_DARK(Color.argb(100, 32, 32, 32));

companion object {
/**
* Get BlurType from string, with fallback to LIGHT for unknown types.
* Uses the provided configuration to determine if dark mode is active for
* appropriate defaults.
*/
fun fromString(type: String, configuration: Configuration): BlurType {
val isDarkMode = (configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES

fun fromString(type: String): BlurType {
return when (type.lowercase()) {
"xlight" -> XLIGHT
"light" -> LIGHT
"dark" -> DARK
"extradark" -> EXTRA_DARK
"regular" -> if (isDarkMode) REGULAR_DARK else REGULAR_LIGHT
"prominent" -> if (isDarkMode) PROMINENT_DARK else PROMINENT_LIGHT
"systemultrathinmaterial" -> if (isDarkMode) SYSTEM_ULTRA_THIN_MATERIAL_DARK else SYSTEM_ULTRA_THIN_MATERIAL_LIGHT
"regular" -> REGULAR
"prominent" -> PROMINENT
"systemultrathinmaterial" -> SYSTEM_ULTRA_THIN_MATERIAL
"systemultrathinmateriallight" -> SYSTEM_ULTRA_THIN_MATERIAL_LIGHT
"systemultrathinmaterialdark" -> SYSTEM_ULTRA_THIN_MATERIAL_DARK
"systemthinmaterial" -> if (isDarkMode) SYSTEM_THIN_MATERIAL_DARK else SYSTEM_THIN_MATERIAL_LIGHT
"systemthinmaterial" -> SYSTEM_THIN_MATERIAL
"systemthinmateriallight" -> SYSTEM_THIN_MATERIAL_LIGHT
"systemthinmaterialdark" -> SYSTEM_THIN_MATERIAL_DARK
"systemmaterial" -> if (isDarkMode) SYSTEM_MATERIAL_DARK else SYSTEM_MATERIAL_LIGHT
"systemmaterial" -> SYSTEM_MATERIAL
"systemmateriallight" -> SYSTEM_MATERIAL_LIGHT
"systemmaterialdark" -> SYSTEM_MATERIAL_DARK
"systemthickmaterial" -> if (isDarkMode) SYSTEM_THICK_MATERIAL_DARK else SYSTEM_THICK_MATERIAL_LIGHT
"systemthickmaterial" -> SYSTEM_THICK_MATERIAL
"systemthickmateriallight" -> SYSTEM_THICK_MATERIAL_LIGHT
"systemthickmaterialdark" -> SYSTEM_THICK_MATERIAL_DARK
"systemchromematerial" -> if (isDarkMode) SYSTEM_CHROME_MATERIAL_DARK else SYSTEM_CHROME_MATERIAL_LIGHT
"systemchromematerial" -> SYSTEM_CHROME_MATERIAL
"systemchromemateriallight" -> SYSTEM_CHROME_MATERIAL_LIGHT
"systemchromematerialdark" -> SYSTEM_CHROME_MATERIAL_DARK
else -> XLIGHT // default fallback
else -> XLIGHT
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I didn't quite understand when we talked about the X. But why the option to adapt the color from the device's UI settings?

Could you explain to me exactly what the problem is?

Comment on lines +58 to +74
/// Determines the fixed interface style for a blur type to prevent system adaptation.
/// Returns nil for ambiguous styles that should inherit from the system.
func interfaceStyleForBlurType(_ styleString: String) -> UIUserInterfaceStyle? {
switch styleString {
case "xlight", "light",
"systemUltraThinMaterialLight", "systemThinMaterialLight",
"systemMaterialLight", "systemThickMaterialLight", "systemChromeMaterialLight":
return .light
case "dark", "extraDark",
"systemUltraThinMaterialDark", "systemThinMaterialDark",
"systemMaterialDark", "systemThickMaterialDark", "systemChromeMaterialDark":
return .dark
default:
return nil
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that at some point someone might request this adjustment to the blurring function through the system?

Perhaps we should consider doing this for both iOS and Android, adding a boolean property called adaptiveBlur. What do you think about this?

@DanielAraldi DanielAraldi added the bug Something isn't working label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants