@rbxts/uiblox 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import { ComponentType } from "@rbxts/react";
|
|
1
2
|
import { CustomizedProps } from "../../../../theme/index";
|
|
2
3
|
export interface PreloaderAssets {
|
|
3
4
|
[key: string]: string | PreloaderAssets;
|
|
4
5
|
}
|
|
6
|
+
export interface CustomAdornmentProps {
|
|
7
|
+
progress: number;
|
|
8
|
+
}
|
|
5
9
|
export interface PreloaderProps {
|
|
6
10
|
preloaderAssets: Map<string, PreloaderAssets>;
|
|
7
11
|
icon?: string;
|
|
8
12
|
showPercentage?: boolean;
|
|
9
13
|
loaderPrecision?: number;
|
|
14
|
+
hideProgressBar?: boolean;
|
|
10
15
|
showAssetName?: boolean;
|
|
16
|
+
adornment?: ComponentType<CustomAdornmentProps>;
|
|
11
17
|
}
|
|
12
18
|
declare function Preloader(props: CustomizedProps<Frame, PreloaderProps>): JSX.Element;
|
|
13
19
|
export default Preloader;
|
|
@@ -13,6 +13,7 @@ local usePreloaderStyles = TS.import(script, script.Parent, "Preloader.styles").
|
|
|
13
13
|
local function Preloader(props)
|
|
14
14
|
local _binding = props
|
|
15
15
|
local preloaderAssets = _binding.preloaderAssets
|
|
16
|
+
local icon = _binding.icon
|
|
16
17
|
local showPercentage = _binding.showPercentage
|
|
17
18
|
if showPercentage == nil then
|
|
18
19
|
showPercentage = false
|
|
@@ -21,10 +22,16 @@ local function Preloader(props)
|
|
|
21
22
|
if loaderPrecision == nil then
|
|
22
23
|
loaderPrecision = 0
|
|
23
24
|
end
|
|
25
|
+
local hideProgressBar = _binding.hideProgressBar
|
|
26
|
+
if hideProgressBar == nil then
|
|
27
|
+
hideProgressBar = false
|
|
28
|
+
end
|
|
24
29
|
local showAssetName = _binding.showAssetName
|
|
25
30
|
if showAssetName == nil then
|
|
26
31
|
showAssetName = false
|
|
27
32
|
end
|
|
33
|
+
local Adornment = _binding.adornment
|
|
34
|
+
local className = _binding.className
|
|
28
35
|
local children = _binding.children
|
|
29
36
|
local percentage, setPercentage = useState(0)
|
|
30
37
|
local loaded, setLoaded = useState(false)
|
|
@@ -79,6 +86,12 @@ local function Preloader(props)
|
|
|
79
86
|
end)
|
|
80
87
|
setCurrentAsset(nil)
|
|
81
88
|
end), {})
|
|
89
|
+
local percentageStr = useMemo(function()
|
|
90
|
+
if not showPercentage then
|
|
91
|
+
return nil
|
|
92
|
+
end
|
|
93
|
+
return `{string.format(`%.{loaderPrecision}f`, percentage)}%`
|
|
94
|
+
end, { showPercentage, loaderPrecision, percentage })
|
|
82
95
|
local _result
|
|
83
96
|
if loaded then
|
|
84
97
|
_result = ({
|
|
@@ -91,16 +104,31 @@ local function Preloader(props)
|
|
|
91
104
|
for _k, _v in container do
|
|
92
105
|
_attributes[_k] = _v
|
|
93
106
|
end
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
_result = (React.createElement("frame", _attributes, _exp, React.createElement("textlabel", _attributes_2), React.createElement(ProgressBar, {
|
|
101
|
-
className = progressBar,
|
|
107
|
+
if className then
|
|
108
|
+
for _k, _v in className do
|
|
109
|
+
_attributes[_k] = _v
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
local _exp = Adornment ~= nil and React.createElement(Adornment, {
|
|
102
113
|
progress = percentage,
|
|
103
|
-
})
|
|
114
|
+
})
|
|
115
|
+
local _condition = icon ~= nil
|
|
116
|
+
if _condition then
|
|
117
|
+
local _attributes_1 = table.clone(logo)
|
|
118
|
+
setmetatable(_attributes_1, nil)
|
|
119
|
+
_condition = React.createElement("imagelabel", _attributes_1)
|
|
120
|
+
end
|
|
121
|
+
local _condition_1 = not hideProgressBar
|
|
122
|
+
if _condition_1 then
|
|
123
|
+
local _attributes_1 = table.clone(label)
|
|
124
|
+
setmetatable(_attributes_1, nil)
|
|
125
|
+
_attributes_1.Text = `Loading {if currentAsset ~= nil then currentAsset else "resources"}... {percentageStr}`
|
|
126
|
+
_condition_1 = (React.createElement(React.Fragment, nil, React.createElement("textlabel", _attributes_1), React.createElement(ProgressBar, {
|
|
127
|
+
className = progressBar,
|
|
128
|
+
progress = percentage,
|
|
129
|
+
})))
|
|
130
|
+
end
|
|
131
|
+
_result = (React.createElement("frame", _attributes, _exp, _condition, _condition_1))
|
|
104
132
|
end
|
|
105
133
|
return React.createElement(React.Fragment, nil, _result)
|
|
106
134
|
end
|