@@ -32,6 +32,7 @@ local Setting = Roact.Component:extend("Setting")
32
32
function Setting :init ()
33
33
self .contentSize , self .setContentSize = Roact .createBinding (Vector2 .new (0 , 0 ))
34
34
self .containerSize , self .setContainerSize = Roact .createBinding (Vector2 .new (0 , 0 ))
35
+ self .inputSize , self .setInputSize = Roact .createBinding (Vector2 .new (0 , 0 ))
35
36
36
37
self :setState ({
37
38
setting = Settings :get (self .props .id ),
@@ -65,43 +66,56 @@ function Setting:render()
65
66
self .setContainerSize (object .AbsoluteSize )
66
67
end ,
67
68
}, {
68
- Input = if self .props .options ~= nil then
69
- e (Dropdown , {
70
- locked = self .props .locked ,
71
- options = self .props .options ,
72
- active = self .state .setting ,
73
- transparency = self .props .transparency ,
74
- position = UDim2 .new (1 , 0 , 0.5 , 0 ),
75
- anchorPoint = Vector2 .new (1 , 0.5 ),
76
- onClick = function (option )
77
- Settings :set (self .props .id , option )
78
- end ,
79
- })
80
- else
81
- e (Checkbox , {
82
- locked = self .props .locked ,
83
- active = self .state .setting ,
84
- transparency = self .props .transparency ,
85
- position = UDim2 .new (1 , 0 , 0.5 , 0 ),
86
- anchorPoint = Vector2 .new (1 , 0.5 ),
87
- onClick = function ()
88
- local currentValue = Settings :get (self .props .id )
89
- Settings :set (self .props .id , not currentValue )
69
+ RightAligned = Roact .createElement (" Frame" , {
70
+ BackgroundTransparency = 1 ,
71
+ Size = UDim2 .new (1 , 0 , 1 , 0 ),
72
+ }, {
73
+ Layout = e (" UIListLayout" , {
74
+ VerticalAlignment = Enum .VerticalAlignment .Center ,
75
+ HorizontalAlignment = Enum .HorizontalAlignment .Right ,
76
+ FillDirection = Enum .FillDirection .Horizontal ,
77
+ SortOrder = Enum .SortOrder .LayoutOrder ,
78
+ Padding = UDim .new (0 , 2 ),
79
+ [Roact .Change .AbsoluteContentSize ] = function (rbx )
80
+ self .setInputSize (rbx .AbsoluteContentSize )
90
81
end ,
91
82
}),
92
83
93
- Reset = if self .props .onReset then e (IconButton , {
94
- icon = Assets .Images .Icons .Reset ,
95
- iconSize = 24 ,
96
- color = theme .BackButtonColor ,
97
- transparency = self .props .transparency ,
98
- visible = self .props .showReset ,
99
-
100
- position = UDim2 .new (1 , - 32 - (self .props .options ~= nil and 120 or 40 ), 0.5 , 0 ),
101
- anchorPoint = Vector2 .new (0 , 0.5 ),
84
+ Input =
85
+ if self .props .input ~= nil then
86
+ self .props .input
87
+ elseif self .props .options ~= nil then
88
+ e (Dropdown , {
89
+ locked = self .props .locked ,
90
+ options = self .props .options ,
91
+ active = self .state .setting ,
92
+ transparency = self .props .transparency ,
93
+ onClick = function (option )
94
+ Settings :set (self .props .id , option )
95
+ end ,
96
+ })
97
+ else
98
+ e (Checkbox , {
99
+ locked = self .props .locked ,
100
+ active = self .state .setting ,
101
+ transparency = self .props .transparency ,
102
+ onClick = function ()
103
+ local currentValue = Settings :get (self .props .id )
104
+ Settings :set (self .props .id , not currentValue )
105
+ end ,
106
+ }),
107
+
108
+ Reset = if self .props .onReset then e (IconButton , {
109
+ icon = Assets .Images .Icons .Reset ,
110
+ iconSize = 24 ,
111
+ color = theme .BackButtonColor ,
112
+ transparency = self .props .transparency ,
113
+ visible = self .props .showReset ,
114
+ layoutOrder = - 1 ,
102
115
103
- onClick = self .props .onReset ,
104
- }) else nil ,
116
+ onClick = self .props .onReset ,
117
+ }) else nil ,
118
+ }),
105
119
106
120
Text = e (" Frame" , {
107
121
Size = UDim2 .new (1 , 0 , 1 , 0 ),
@@ -133,12 +147,15 @@ function Setting:render()
133
147
TextWrapped = true ,
134
148
RichText = true ,
135
149
136
- Size = self .containerSize :map (function (value )
150
+ Size = Roact .joinBindings ({
151
+ containerSize = self .containerSize ,
152
+ inputSize = self .inputSize ,
153
+ }):map (function (values )
137
154
local desc = (if self .props .experimental then " [Experimental] " else " " ) .. self .props .description
138
- local offset = ( self . props . onReset and 34 or 0 ) + ( self . props . options ~= nil and 120 or 40 )
155
+ local offset = values . inputSize . X + 5
139
156
local textBounds = getTextBounds (
140
157
desc , 14 , Enum .Font .Gotham , 1.2 ,
141
- Vector2 .new (value .X - offset , math.huge )
158
+ Vector2 .new (values . containerSize .X - offset , math.huge )
142
159
)
143
160
return UDim2 .new (1 , - offset , 0 , textBounds .Y )
144
161
end ),
0 commit comments