mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 13:21:38 +00:00
Include creator info in notifs
This commit is contained in:
parent
742c2a34dc
commit
92a3044f4e
3 changed files with 58 additions and 14 deletions
|
|
@ -113,24 +113,37 @@ function Notification:render()
|
||||||
buttonsX += (count - 1) * 5
|
buttonsX += (count - 1) * 5
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local thirdPartyName = ""
|
||||||
|
if self.props.thirdParty and self.props.callerInfo then
|
||||||
|
thirdPartyName = self.props.callerInfo.Name .. " by " .. self.props.callerInfo.Creator.Name
|
||||||
|
end
|
||||||
|
|
||||||
local paddingY, logoSize = 20, 32
|
local paddingY, logoSize = 20, 32
|
||||||
local actionsY = if self.props.actions then 35 else 0
|
local actionsY = if self.props.actions then 35 else 0
|
||||||
local textXSpace = math.max(250, buttonsX) + 35
|
local thirdPartyBounds = if self.props.thirdParty
|
||||||
|
then getTextBoundsAsync(thirdPartyName, theme.Font.Main, theme.TextSize.Body, math.huge)
|
||||||
|
+ (
|
||||||
|
if self.props.callerInfo.Creator.HasVerifiedBadge
|
||||||
|
then Vector2.new(theme.TextSize.Body + 5, 0)
|
||||||
|
else Vector2.zero
|
||||||
|
)
|
||||||
|
else Vector2.zero
|
||||||
|
local textXSpace = math.max(250, thirdPartyBounds.X, buttonsX) + 35
|
||||||
local textBounds = Vector2.new(
|
local textBounds = Vector2.new(
|
||||||
textXSpace,
|
textXSpace,
|
||||||
getTextBoundsAsync(self.props.text, theme.Font.Main, theme.TextSize.Body, textXSpace).Y
|
getTextBoundsAsync(self.props.text, theme.Font.Main, theme.TextSize.Body, textXSpace).Y
|
||||||
)
|
)
|
||||||
local contentX = math.max(textBounds.X, buttonsX)
|
local contentX = math.max(textBounds.X, buttonsX, thirdPartyBounds.X)
|
||||||
|
|
||||||
local size = self.binding:map(function(value)
|
local size = self.binding:map(function(value)
|
||||||
return UDim2.fromOffset(
|
return UDim2.fromOffset(
|
||||||
(35 + 40 + contentX) * value,
|
(35 + 40 + contentX) * value,
|
||||||
5 + actionsY + paddingY + math.max(logoSize, textBounds.Y)
|
5 + actionsY + thirdPartyBounds.Y + paddingY + math.max(logoSize, textBounds.Y)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local logoAssetId = if self.props.thirdParty
|
local logoAssetId = if self.props.thirdParty
|
||||||
then getThirdPartyIcon(self.props.source)
|
then getThirdPartyIcon(self.props.callerInfo.Source)
|
||||||
else Assets.Images.PluginButton
|
else Assets.Images.PluginButton
|
||||||
|
|
||||||
return e("TextButton", {
|
return e("TextButton", {
|
||||||
|
|
@ -160,6 +173,36 @@ function Notification:render()
|
||||||
Position = UDim2.new(0, 0, 0, 0),
|
Position = UDim2.new(0, 0, 0, 0),
|
||||||
AnchorPoint = Vector2.new(0, 0),
|
AnchorPoint = Vector2.new(0, 0),
|
||||||
}),
|
}),
|
||||||
|
ThirdPartyName = if self.props.thirdParty
|
||||||
|
then e(
|
||||||
|
"TextLabel",
|
||||||
|
{
|
||||||
|
Text = thirdPartyName,
|
||||||
|
FontFace = theme.Font.Main,
|
||||||
|
TextSize = theme.TextSize.Body,
|
||||||
|
TextColor3 = theme.SubTextColor,
|
||||||
|
TextTransparency = transparency,
|
||||||
|
TextXAlignment = Enum.TextXAlignment.Left,
|
||||||
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
|
Size = UDim2.new(0, 0, 0, thirdPartyBounds.Y),
|
||||||
|
AutomaticSize = Enum.AutomaticSize.X,
|
||||||
|
Position = UDim2.fromOffset(35, 0),
|
||||||
|
|
||||||
|
LayoutOrder = 1,
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
},
|
||||||
|
if self.props.callerInfo and self.props.callerInfo.Creator.HasVerifiedBadge
|
||||||
|
then e("ImageLabel", {
|
||||||
|
Image = Assets.Images.Icons.Verified,
|
||||||
|
BackgroundTransparency = 1,
|
||||||
|
SizeConstraint = Enum.SizeConstraint.RelativeYY,
|
||||||
|
AnchorPoint = Vector2.new(0, 0.5),
|
||||||
|
Position = UDim2.new(1, 3, 0.5, 0),
|
||||||
|
Size = UDim2.fromScale(0.8, 0.8),
|
||||||
|
})
|
||||||
|
else nil
|
||||||
|
)
|
||||||
|
else nil,
|
||||||
Info = e("TextLabel", {
|
Info = e("TextLabel", {
|
||||||
Text = self.props.text,
|
Text = self.props.text,
|
||||||
FontFace = theme.Font.Main,
|
FontFace = theme.Font.Main,
|
||||||
|
|
@ -170,8 +213,8 @@ function Notification:render()
|
||||||
TextYAlignment = Enum.TextYAlignment.Top,
|
TextYAlignment = Enum.TextYAlignment.Top,
|
||||||
TextWrapped = true,
|
TextWrapped = true,
|
||||||
|
|
||||||
Size = UDim2.new(1, -35, 1, -actionsY),
|
Size = UDim2.new(1, -35, 1, -actionsY - thirdPartyBounds.Y),
|
||||||
Position = UDim2.fromOffset(35, 0),
|
Position = UDim2.fromOffset(35, thirdPartyBounds.Y),
|
||||||
|
|
||||||
LayoutOrder = 1,
|
LayoutOrder = 1,
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
|
|
@ -237,8 +280,7 @@ function Notifications:render()
|
||||||
actions = notif.actions,
|
actions = notif.actions,
|
||||||
soundPlayer = self.props.soundPlayer,
|
soundPlayer = self.props.soundPlayer,
|
||||||
thirdParty = notif.thirdParty,
|
thirdParty = notif.thirdParty,
|
||||||
name = notif.name,
|
callerInfo = notif.callerInfo,
|
||||||
source = notif.source,
|
|
||||||
onClose = function()
|
onClose = function()
|
||||||
self.props.onClose(id)
|
self.props.onClose(id)
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
|
|
@ -294,8 +294,7 @@ function App:addNotification(
|
||||||
end
|
end
|
||||||
|
|
||||||
function App:addThirdPartyNotification(
|
function App:addThirdPartyNotification(
|
||||||
name: string,
|
callerInfo: HeadlessAPI.CallerInfo,
|
||||||
source: string,
|
|
||||||
text: string,
|
text: string,
|
||||||
timeout: number?,
|
timeout: number?,
|
||||||
actions: {
|
actions: {
|
||||||
|
|
@ -316,8 +315,7 @@ function App:addThirdPartyNotification(
|
||||||
timeout = timeout or 3,
|
timeout = timeout or 3,
|
||||||
actions = actions,
|
actions = actions,
|
||||||
thirdParty = true,
|
thirdParty = true,
|
||||||
name = name,
|
callerInfo = callerInfo,
|
||||||
source = source,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self:setState({
|
self:setState({
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ local apiPermissionAllowlist = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CallerInfo = {
|
export type CallerInfo = {
|
||||||
|
Source: string,
|
||||||
Type: "Local" | "Cloud" | "Studio",
|
Type: "Local" | "Cloud" | "Studio",
|
||||||
Name: string,
|
Name: string,
|
||||||
Description: string,
|
Description: string,
|
||||||
|
|
@ -139,6 +140,7 @@ function API.new(app)
|
||||||
local localPlugin = string.match(source, "user_(.+)")
|
local localPlugin = string.match(source, "user_(.+)")
|
||||||
if localPlugin then
|
if localPlugin then
|
||||||
return {
|
return {
|
||||||
|
Source = source,
|
||||||
Type = "Local",
|
Type = "Local",
|
||||||
Name = localPlugin,
|
Name = localPlugin,
|
||||||
Description = "Locally installed plugin.",
|
Description = "Locally installed plugin.",
|
||||||
|
|
@ -164,6 +166,7 @@ function API.new(app)
|
||||||
|
|
||||||
if info then
|
if info then
|
||||||
return {
|
return {
|
||||||
|
Source = source,
|
||||||
Type = "Cloud",
|
Type = "Cloud",
|
||||||
Name = info.Name,
|
Name = info.Name,
|
||||||
Description = info.Description,
|
Description = info.Description,
|
||||||
|
|
@ -175,6 +178,7 @@ function API.new(app)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return {
|
return {
|
||||||
|
Source = source,
|
||||||
Type = "Cloud",
|
Type = "Cloud",
|
||||||
Name = source,
|
Name = source,
|
||||||
Description = "Could not retrieve plugin asset info.",
|
Description = "Could not retrieve plugin asset info.",
|
||||||
|
|
@ -188,6 +192,7 @@ function API.new(app)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Source = source,
|
||||||
Type = "Studio",
|
Type = "Studio",
|
||||||
Name = "Command Bar",
|
Name = "Command Bar",
|
||||||
Description = "Command bar in Roblox Studio.",
|
Description = "Command bar in Roblox Studio.",
|
||||||
|
|
@ -461,8 +466,7 @@ function API.new(app)
|
||||||
end
|
end
|
||||||
|
|
||||||
return app:addThirdPartyNotification(
|
return app:addThirdPartyNotification(
|
||||||
Rojo:_getCallerName(),
|
Rojo:_getCallerInfoFromSource(Rojo:_getCallerSource()),
|
||||||
Rojo:_getCallerSource(),
|
|
||||||
msg,
|
msg,
|
||||||
timeout,
|
timeout,
|
||||||
sanitizedActions
|
sanitizedActions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue