Skip to content

Commit 5e7bbda

Browse files
authored
g
Lazy-create acrylic blur only when acrylic is enabled
2 parents 9ba392e + 3a420d1 commit 5e7bbda

3 files changed

Lines changed: 37 additions & 8 deletions

File tree

Src/Components/Notification.luau

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ function Notification:New(Config)
157157
NewNotification.Root,
158158
})
159159

160+
NewNotification.AcrylicPaint.SetVisibility(require(Root).Acrylic == true)
161+
160162
local RootMotor = Flipper.GroupMotor.new({
161163
Scale = 1,
162164
Offset = 60,

Src/Modules/Acrylic/AcrylicPaint.luau

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,40 @@ return function(props)
106106
}),
107107
})
108108

109-
local Blur = AcrylicBlur()
110-
Blur.Frame.Parent = AcrylicPaint.Frame
111-
AcrylicPaint.Model = Blur.Model
112-
AcrylicPaint.AddParent = Blur.AddParent
113-
AcrylicPaint.SetVisibility = Blur.SetVisibility
109+
local Blur
110+
local Parent
111+
112+
local function ensureBlur()
113+
if Blur then
114+
return Blur
115+
end
116+
117+
Blur = AcrylicBlur()
118+
Blur.Frame.Parent = AcrylicPaint.Frame
119+
AcrylicPaint.Model = Blur.Model
120+
121+
if Parent then
122+
Blur.AddParent(Parent)
123+
end
124+
125+
return Blur
126+
end
127+
128+
AcrylicPaint.AddParent = function(Value)
129+
Parent = Value
130+
131+
if Blur then
132+
Blur.AddParent(Value)
133+
end
134+
end
135+
136+
AcrylicPaint.SetVisibility = function(Value)
137+
if Value then
138+
ensureBlur().SetVisibility(Value)
139+
elseif Blur then
140+
Blur.SetVisibility(Value)
141+
end
142+
end
114143

115144
return AcrylicPaint
116145
end

Src/init.luau

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,7 @@ function Library:ToggleAcrylic(Value: boolean)
402402
if Library.CreatedWindow then
403403
Library.UseAcrylic = Value
404404
Library.Acrylic = Value
405-
if Library.CreatedWindow.AcrylicPaint.Model then
406-
Library.CreatedWindow.AcrylicPaint.Model.Transparency = Value and 0.98 or 1
407-
end
405+
Library.CreatedWindow.AcrylicPaint.SetVisibility(Value)
408406
if Library.AcrylicSupported then
409407
if Value then
410408
Acrylic.Enable()

0 commit comments

Comments
 (0)