Skip to content

Commit 24d1ac7

Browse files
author
dawid
committed
stylua
1 parent d5d88ef commit 24d1ac7

File tree

3 files changed

+181
-178
lines changed

3 files changed

+181
-178
lines changed

src/Components/Notification.lua

Lines changed: 138 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -10,190 +10,193 @@ local New = Creator.New
1010
local Notification = {}
1111

1212
function Notification:Init(GUI)
13-
Notification.Holder = New("Frame", {
14-
Position = UDim2.new(1, -30, 1, -30),
15-
Size = UDim2.new(0, 300, 1, -30),
16-
AnchorPoint = Vector2.new(1, 1),
17-
BackgroundTransparency = 1,
18-
Parent = GUI
19-
}, {
20-
New("UIListLayout", {
21-
HorizontalAlignment = Enum.HorizontalAlignment.Center,
22-
SortOrder = Enum.SortOrder.LayoutOrder,
23-
VerticalAlignment = Enum.VerticalAlignment.Bottom,
24-
Padding = UDim.new(0, 20)
25-
})
26-
})
13+
Notification.Holder = New("Frame", {
14+
Position = UDim2.new(1, -30, 1, -30),
15+
Size = UDim2.new(0, 310, 1, -30),
16+
AnchorPoint = Vector2.new(1, 1),
17+
BackgroundTransparency = 1,
18+
Parent = GUI,
19+
}, {
20+
New("UIListLayout", {
21+
HorizontalAlignment = Enum.HorizontalAlignment.Center,
22+
SortOrder = Enum.SortOrder.LayoutOrder,
23+
VerticalAlignment = Enum.VerticalAlignment.Bottom,
24+
Padding = UDim.new(0, 20),
25+
}),
26+
})
2727
end
2828

2929
function Notification:New(Config)
30-
Config.Title = Config.Title or "Title"
31-
Config.Content = Config.Content or "Content"
32-
Config.SubContent = Config.SubContent or ""
33-
Config.Duration = Config.Duration or nil
34-
local NewNotification = {
35-
Closed = false
36-
}
37-
38-
NewNotification.AcrylicPaint = Acrylic.AcrylicPaint()
39-
40-
NewNotification.Title = New("TextLabel", {
41-
Position = UDim2.new(0, 13, 0, 15),
42-
Text = Config.Title,
43-
RichText = true,
44-
TextColor3 = Color3.fromRGB(255, 255, 255),
45-
TextTransparency = 0,
46-
FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json"),
47-
TextSize = 12,
48-
TextXAlignment = "Left",
49-
TextYAlignment = "Center",
50-
Size = UDim2.new(1, -12, 0, 12),
51-
TextWrapped = true,
52-
BackgroundTransparency = 1,
53-
ThemeTag = {
54-
TextColor3 = "Text"
55-
}
56-
})
57-
58-
NewNotification.ContentLabel = New("TextLabel", {
30+
Config.Title = Config.Title or "Title"
31+
Config.Content = Config.Content or "Content"
32+
Config.SubContent = Config.SubContent or ""
33+
Config.Duration = Config.Duration or nil
34+
Config.Buttons = Config.Buttons or {}
35+
local NewNotification = {
36+
Closed = false,
37+
}
38+
39+
NewNotification.AcrylicPaint = Acrylic.AcrylicPaint()
40+
41+
NewNotification.Title = New("TextLabel", {
42+
Position = UDim2.new(0, 14, 0, 17),
43+
Text = Config.Title,
44+
RichText = true,
45+
TextColor3 = Color3.fromRGB(255, 255, 255),
46+
TextTransparency = 0,
47+
FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json"),
48+
TextSize = 13,
49+
TextXAlignment = "Left",
50+
TextYAlignment = "Center",
51+
Size = UDim2.new(1, -12, 0, 12),
52+
TextWrapped = true,
53+
BackgroundTransparency = 1,
54+
ThemeTag = {
55+
TextColor3 = "Text",
56+
},
57+
})
58+
59+
NewNotification.ContentLabel = New("TextLabel", {
5960
FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json"),
6061
Text = Config.Content,
6162
TextColor3 = Color3.fromRGB(240, 240, 240),
62-
TextSize = 13,
63+
TextSize = 14,
6364
TextXAlignment = Enum.TextXAlignment.Left,
64-
AutomaticSize = Enum.AutomaticSize.Y,
65+
AutomaticSize = Enum.AutomaticSize.Y,
6566
Size = UDim2.new(1, 0, 0, 14),
6667
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
6768
BackgroundTransparency = 1,
68-
TextWrapped = true,
69+
TextWrapped = true,
6970
ThemeTag = {
7071
TextColor3 = "Text",
7172
},
7273
})
7374

74-
NewNotification.SubContentLabel = New("TextLabel", {
75+
NewNotification.SubContentLabel = New("TextLabel", {
7576
FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json"),
7677
Text = Config.SubContent,
7778
TextColor3 = Color3.fromRGB(240, 240, 240),
78-
TextSize = 13,
79+
TextSize = 14,
7980
TextXAlignment = Enum.TextXAlignment.Left,
80-
AutomaticSize = Enum.AutomaticSize.Y,
81+
AutomaticSize = Enum.AutomaticSize.Y,
8182
Size = UDim2.new(1, 0, 0, 14),
8283
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
8384
BackgroundTransparency = 1,
84-
TextWrapped = true,
85+
TextWrapped = true,
8586
ThemeTag = {
8687
TextColor3 = "SubText",
8788
},
8889
})
8990

90-
NewNotification.LabelHolder = New("Frame", {
91+
NewNotification.LabelHolder = New("Frame", {
9192
AutomaticSize = Enum.AutomaticSize.Y,
9293
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
9394
BackgroundTransparency = 1,
94-
Position = UDim2.fromOffset(13, 38),
95-
Size = UDim2.new(1, -26, 0, 0),
95+
Position = UDim2.fromOffset(14, 40),
96+
Size = UDim2.new(1, -28, 0, 0),
9697
}, {
9798
New("UIListLayout", {
9899
SortOrder = Enum.SortOrder.LayoutOrder,
99100
VerticalAlignment = Enum.VerticalAlignment.Center,
100-
Padding = UDim.new(0, 2)
101+
Padding = UDim.new(0, 3),
101102
}),
102103
NewNotification.ContentLabel,
103104
NewNotification.SubContentLabel,
104105
})
105106

106-
NewNotification.CloseButton = New("TextButton", {
107-
Text = "",
108-
Position = UDim2.new(1, -12, 0, 11),
109-
Size = UDim2.fromOffset(20, 20),
110-
AnchorPoint = Vector2.new(1, 0),
111-
BackgroundTransparency = 1
112-
}, {
113-
New("ImageLabel", {
114-
Image = require(script.Parent.Assets).Close,
115-
Size = UDim2.fromOffset(16, 16),
116-
Position = UDim2.fromScale(0.5, 0.5),
117-
AnchorPoint = Vector2.new(0.5, 0.5),
118-
BackgroundTransparency = 1,
119-
ThemeTag = {
120-
ImageColor3 = "Text",
121-
},
122-
}),
123-
})
124-
125-
NewNotification.Root = New("Frame", {
126-
BackgroundTransparency = 1,
107+
NewNotification.CloseButton = New("TextButton", {
108+
Text = "",
109+
Position = UDim2.new(1, -14, 0, 13),
110+
Size = UDim2.fromOffset(20, 20),
111+
AnchorPoint = Vector2.new(1, 0),
112+
BackgroundTransparency = 1,
113+
}, {
114+
New("ImageLabel", {
115+
Image = require(script.Parent.Assets).Close,
116+
Size = UDim2.fromOffset(16, 16),
117+
Position = UDim2.fromScale(0.5, 0.5),
118+
AnchorPoint = Vector2.new(0.5, 0.5),
119+
BackgroundTransparency = 1,
120+
ThemeTag = {
121+
ImageColor3 = "Text",
122+
},
123+
}),
124+
})
125+
126+
NewNotification.Root = New("Frame", {
127+
BackgroundTransparency = 1,
127128
Size = UDim2.new(1, 0, 1, 0),
128-
Position = UDim2.fromScale(1, 0)
129-
}, {
130-
NewNotification.AcrylicPaint.Frame,
131-
NewNotification.Title,
132-
NewNotification.CloseButton,
133-
NewNotification.LabelHolder
134-
})
135-
136-
if Config.Content == "" then
137-
NewNotification.ContentLabel.Visible = false
138-
end
139-
140-
if Config.SubContent == "" then
141-
NewNotification.SubContentLabel.Visible = false
142-
end
143-
144-
NewNotification.Holder = New("Frame", {
129+
Position = UDim2.fromScale(1, 0),
130+
}, {
131+
NewNotification.AcrylicPaint.Frame,
132+
NewNotification.Title,
133+
NewNotification.CloseButton,
134+
NewNotification.LabelHolder,
135+
})
136+
137+
if Config.Content == "" then
138+
NewNotification.ContentLabel.Visible = false
139+
end
140+
141+
if Config.SubContent == "" then
142+
NewNotification.SubContentLabel.Visible = false
143+
end
144+
145+
NewNotification.Holder = New("Frame", {
145146
BackgroundTransparency = 1,
146147
Size = UDim2.new(1, 0, 0, 200),
147-
Parent = Notification.Holder
148+
Parent = Notification.Holder,
148149
}, {
149-
NewNotification.Root
150+
NewNotification.Root,
150151
})
151152

152-
local RootMotor = Flipper.GroupMotor.new({
153-
Scale = 1,
154-
Offset = 60
155-
})
153+
local RootMotor = Flipper.GroupMotor.new({
154+
Scale = 1,
155+
Offset = 60,
156+
})
156157

157158
RootMotor:onStep(function(Values)
158159
NewNotification.Root.Position = UDim2.new(Values.Scale, Values.Offset, 0, 0)
159160
end)
160161

161-
Creator.AddSignal(NewNotification.CloseButton.MouseButton1Click, function()
162-
NewNotification:Close()
163-
end)
164-
165-
function NewNotification:Open()
166-
local ContentSize = NewNotification.LabelHolder.AbsoluteSize.Y
167-
NewNotification.Holder.Size = UDim2.new(1, 0, 0, 55 + ContentSize)
168-
169-
RootMotor:setGoal({
170-
Scale = Spring(0, { frequency = 5 }),
171-
Offset = Spring(0, { frequency = 5 })
172-
})
173-
end
174-
175-
function NewNotification:Close()
176-
if not NewNotification.Closed then
177-
NewNotification.Closed = true
178-
task.spawn(function()
179-
RootMotor:setGoal({
180-
Scale = Spring(1, { frequency = 5 }),
181-
Offset = Spring(60, { frequency = 5 })
182-
})
183-
task.wait(0.45)
184-
NewNotification.AcrylicPaint.Model:Destroy()
185-
NewNotification.Holder:Destroy()
186-
end)
187-
end
188-
end
189-
190-
NewNotification:Open()
191-
if Config.Duration then
192-
task.delay(Config.Duration, function()
193-
NewNotification:Close()
194-
end)
195-
end
196-
return NewNotification
162+
Creator.AddSignal(NewNotification.CloseButton.MouseButton1Click, function()
163+
NewNotification:Close()
164+
end)
165+
166+
function NewNotification:Open()
167+
local ContentSize = NewNotification.LabelHolder.AbsoluteSize.Y
168+
NewNotification.Holder.Size = UDim2.new(1, 0, 0, 58 + ContentSize)
169+
170+
RootMotor:setGoal({
171+
Scale = Spring(0, { frequency = 5 }),
172+
Offset = Spring(0, { frequency = 5 }),
173+
})
174+
end
175+
176+
function NewNotification:Close()
177+
if not NewNotification.Closed then
178+
NewNotification.Closed = true
179+
task.spawn(function()
180+
RootMotor:setGoal({
181+
Scale = Spring(1, { frequency = 5 }),
182+
Offset = Spring(60, { frequency = 5 }),
183+
})
184+
task.wait(0.4)
185+
if require(Root).UseAcrylic then
186+
NewNotification.AcrylicPaint.Model:Destroy()
187+
end
188+
NewNotification.Holder:Destroy()
189+
end)
190+
end
191+
end
192+
193+
NewNotification:Open()
194+
if Config.Duration then
195+
task.delay(Config.Duration, function()
196+
NewNotification:Close()
197+
end)
198+
end
199+
return NewNotification
197200
end
198201

199-
return Notification
202+
return Notification

0 commit comments

Comments
 (0)