From ff2be27244ec3eb2c6bda3f3cc219d12d7d9a769 Mon Sep 17 00:00:00 2001 From: Marin Minnerly Date: Wed, 8 May 2024 19:17:30 -0700 Subject: [PATCH] Move sample Modal to SettingsView --- src/Plugin/PluginApp.luau | 16 ---------------- src/UserSettings/SettingsView.luau | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Plugin/PluginApp.luau b/src/Plugin/PluginApp.luau index 6b44224c..0c64177c 100644 --- a/src/Plugin/PluginApp.luau +++ b/src/Plugin/PluginApp.luau @@ -1,5 +1,3 @@ -local Modal = require("@root/Modal/Modal") -local ModalPortal = require("@root/Modal/ModalPortal") local ModalRoot = require("@root/Modal/ModalRoot") local NavigationContext = require("@root/Navigation/NavigationContext") local React = require("@pkg/React") @@ -38,26 +36,12 @@ local function App(props: Props) setSidebarWidth(newSize.X) end, {}) - local isModalShown, setIsModalShown = React.useState(true) - local onCloseModal = React.useCallback(function() - setIsModalShown(false) - end, {}) - return React.createElement("Frame", { BackgroundTransparency = 1, Size = UDim2.fromScale(1, 1), }, { ModalRoot = React.createElement(ModalRoot), - Sample = if isModalShown - then React.createElement(ModalPortal, {}, { - Modal = React.createElement(Modal, { - title = "Example", - onClose = onCloseModal, - }, {}), - }) - else nil, - App = React.createElement("Frame", { BackgroundColor3 = theme.background, Size = UDim2.fromScale(1, 1), diff --git a/src/UserSettings/SettingsView.luau b/src/UserSettings/SettingsView.luau index e34bb745..76ba2506 100644 --- a/src/UserSettings/SettingsView.luau +++ b/src/UserSettings/SettingsView.luau @@ -1,6 +1,8 @@ local React = require("@pkg/React") local Sift = require("@pkg/Sift") +local Modal = require("@root/Modal/Modal") +local ModalPortal = require("@root/Modal/ModalPortal") local ScrollingFrame = require("@root/Common/ScrollingFrame") local SettingRow = require("@root/UserSettings/SettingRow") local SettingsContext = require("@root/UserSettings/SettingsContext") @@ -24,6 +26,11 @@ local function SettingsView() end) end, { settingsContext.settings }) + local isModalShown, setIsModalShown = React.useState(true) + local onCloseModal = React.useCallback(function() + setIsModalShown(false) + end, {}) + local children = {} for index, setting in orderedSettings do children[setting.name] = React.createElement(SettingRow, { @@ -69,6 +76,15 @@ local function SettingsView() Padding = theme.padding, }), }, children), + + Sample = if isModalShown + then React.createElement(ModalPortal, {}, { + Modal = React.createElement(Modal, { + title = "Example", + onClose = onCloseModal, + }, {}), + }) + else nil, }) end