Add headless API

This commit is contained in:
boatbomber 2022-09-25 16:43:02 -04:00
parent 003abe86bb
commit 4832035a18
6 changed files with 149 additions and 25 deletions

View file

@ -91,7 +91,7 @@ function Notification:render()
local textBounds = TextService:GetTextSize(
self.props.text,
15,
Enum.Font.GothamSemibold,
Enum.Font.GothamMedium,
Vector2.new(350, 700)
)
@ -102,7 +102,7 @@ function Notification:render()
local size = self.binding:map(function(value)
return UDim2.fromOffset(
(35+40+textBounds.X)*value,
math.max(14+20+textBounds.Y, 32+20)
math.max(16+20+textBounds.Y, 54)
)
end)
@ -129,15 +129,15 @@ function Notification:render()
}, {
Logo = e("ImageLabel", {
ImageTransparency = transparency,
Image = Assets.Images.PluginButton,
Image = if self.props.thirdParty then Assets.Images.ThirdPartyPlugin else Assets.Images.PluginButton,
BackgroundTransparency = 1,
Size = UDim2.new(0, 32, 0, 32),
Position = UDim2.new(0, 0, 0.5, 0),
AnchorPoint = Vector2.new(0, 0.5),
}),
Info = e("TextLabel", {
Message = e("TextLabel", {
Text = self.props.text,
Font = Enum.Font.GothamSemibold,
Font = Enum.Font.GothamMedium,
TextSize = 15,
TextColor3 = theme.Notification.InfoColor,
TextTransparency = transparency,
@ -145,21 +145,21 @@ function Notification:render()
TextWrapped = true,
Size = UDim2.new(0, textBounds.X, 0, textBounds.Y),
Position = UDim2.fromOffset(35, 0),
Position = UDim2.fromOffset(38, 0),
LayoutOrder = 1,
BackgroundTransparency = 1,
}),
Time = e("TextLabel", {
Text = time:FormatLocalTime("LTS", "en-us"),
Font = Enum.Font.Code,
Info = e("TextLabel", {
Text = if self.props.source then "From: " .. self.props.source else time:FormatLocalTime("LTS", "en-us"),
Font = Enum.Font.Gotham,
TextSize = 12,
TextColor3 = theme.Notification.InfoColor,
TextTransparency = transparency,
TextXAlignment = Enum.TextXAlignment.Left,
Size = UDim2.new(1, -35, 0, 14),
Position = UDim2.new(0, 35, 1, -14),
Size = UDim2.new(1, -38, 0, 14),
Position = UDim2.new(0, 38, 1, -14),
LayoutOrder = 1,
BackgroundTransparency = 1,
@ -167,8 +167,8 @@ function Notification:render()
}),
Padding = e("UIPadding", {
PaddingLeft = UDim.new(0, 17),
PaddingRight = UDim.new(0, 15),
PaddingLeft = UDim.new(0, 12),
PaddingRight = UDim.new(0, 12),
}),
})
})
@ -181,16 +181,18 @@ function Notifications:render()
local notifs = {}
for index, notif in ipairs(self.props.notifications) do
notifs[notif] = e(Notification, {
local props = {
soundPlayer = self.props.soundPlayer,
text = notif.text,
timestamp = notif.timestamp,
timeout = notif.timeout,
layoutOrder = (notif.timestamp - baseClock),
onClose = function()
self.props.onClose(index)
end,
})
}
for key, value in notif do
props[key] = value
end
notifs[notif] = e(Notification, props)
end
return Roact.createFragment(notifs)