mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 13:21:38 +00:00
Nicer notification formatting and info
This commit is contained in:
parent
be89259bbd
commit
f3de0c35ef
1 changed files with 15 additions and 3 deletions
|
|
@ -87,6 +87,9 @@ end
|
||||||
|
|
||||||
function Notification:render()
|
function Notification:render()
|
||||||
local time = DateTime.fromUnixTimestampMillis(self.props.timestamp)
|
local time = DateTime.fromUnixTimestampMillis(self.props.timestamp)
|
||||||
|
local infoText =
|
||||||
|
time:FormatLocalTime("LTS", "en-us") ..
|
||||||
|
(if self.props.source then " • From: " .. self.props.source else "")
|
||||||
|
|
||||||
local textBounds = TextService:GetTextSize(
|
local textBounds = TextService:GetTextSize(
|
||||||
self.props.text,
|
self.props.text,
|
||||||
|
|
@ -95,13 +98,22 @@ function Notification:render()
|
||||||
Vector2.new(350, 700)
|
Vector2.new(350, 700)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
local infoTextBounds = TextService:GetTextSize(
|
||||||
|
infoText,
|
||||||
|
12,
|
||||||
|
Enum.Font.Gotham,
|
||||||
|
Vector2.new(350, 14)
|
||||||
|
)
|
||||||
|
|
||||||
|
local textWidth = math.max(infoTextBounds.X, textBounds.X)
|
||||||
|
|
||||||
local transparency = self.binding:map(function(value)
|
local transparency = self.binding:map(function(value)
|
||||||
return 1 - value
|
return 1 - value
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local size = self.binding:map(function(value)
|
local size = self.binding:map(function(value)
|
||||||
return UDim2.fromOffset(
|
return UDim2.fromOffset(
|
||||||
(35+40+textBounds.X)*value,
|
(35+40+textWidth)*value,
|
||||||
math.max(16+20+textBounds.Y, 54)
|
math.max(16+20+textBounds.Y, 54)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
@ -123,7 +135,7 @@ function Notification:render()
|
||||||
size = UDim2.new(1, 0, 1, 0),
|
size = UDim2.new(1, 0, 1, 0),
|
||||||
}, {
|
}, {
|
||||||
TextContainer = e("Frame", {
|
TextContainer = e("Frame", {
|
||||||
Size = UDim2.new(0, 35+textBounds.X, 1, -20),
|
Size = UDim2.new(1, 0, 1, -20),
|
||||||
Position = UDim2.new(0, 0, 0, 10),
|
Position = UDim2.new(0, 0, 0, 10),
|
||||||
BackgroundTransparency = 1
|
BackgroundTransparency = 1
|
||||||
}, {
|
}, {
|
||||||
|
|
@ -151,7 +163,7 @@ function Notification:render()
|
||||||
BackgroundTransparency = 1,
|
BackgroundTransparency = 1,
|
||||||
}),
|
}),
|
||||||
Info = e("TextLabel", {
|
Info = e("TextLabel", {
|
||||||
Text = if self.props.source then "From: " .. self.props.source else time:FormatLocalTime("LTS", "en-us"),
|
Text = infoText,
|
||||||
Font = Enum.Font.Gotham,
|
Font = Enum.Font.Gotham,
|
||||||
TextSize = 12,
|
TextSize = 12,
|
||||||
TextColor3 = theme.Notification.InfoColor,
|
TextColor3 = theme.Notification.InfoColor,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue