-- PageBase.lua
--
-- Provides a lightweight, reusable base for all standalone UI pages in Sin's Toolkit.
-- Future pages (e.g., General.lua, Gear.lua) should be created as tables and use this
-- PageBase as their metatable. This ensures that all pages adhere to a consistent API
-- and provides safe, no-op default implementations for common methods.
--
-- GOAL:
-- The purpose of this framework is to allow pages to be migrated out of the monolithic
-- UI/SinsToolkit_Window.lua into their own self-contained files under UI/Pages/.
--
-- FUTURE MIGRATION EXAMPLE (for a new file like UI/Pages/General.lua):
--
--   local addonName, SinsToolkit = ...
--   local Page = setmetatable({}, { __index = SinsToolkit.UI.Pages.Base })
--   SinsToolkit.UI.Pages.General = Page
--
--   function Page:Create(parent)
--       -- This is where the page's frames, buttons, checkboxes, etc. are created.
--       -- The 'parent' is the container frame provided by the main window.
--       self.frame = CreateFrame("Frame", "SinsToolkitGeneralPageFrame", parent)
--       self.frame:SetAllPoints()
--
--       -- ... create widgets inside self.frame ...
--
--       -- IMPORTANT: A page must hide its main frame by default.
--       self.frame:Hide()
--   end
--
--   function Page:Show()
--       -- This is called by the registry when the page should become visible.
--       if self.frame then
--           self.frame:Show()
--           self:Refresh() -- It's good practice to refresh data when shown.
--       end
--   end
--
--   function Page:Refresh()
--       -- This is where the page updates its state from the database, e.g.,
--       -- setting checkbox states, slider values, etc.
--   end
--
--   -- Other methods like :Hide, :ApplySettings, etc. can be implemented as needed.
--   -- If a method is not implemented by the page, the safe default from PageBase will be used.
--

local addonName, SinsToolkit = ...

-- Ensure the namespace exists.
SinsToolkit.UI = SinsToolkit.UI or {}
SinsToolkit.UI.Pages = SinsToolkit.UI.Pages or {}

local PageBase = {}
SinsToolkit.UI.Pages.Base = PageBase

--[[
    Called once to create the page's UI elements.
    @param parent The parent frame that will contain the page.
    @param window The main window object, providing access to UI factory methods.
--]]
function PageBase:Create(parent, window)
    -- Default: Do nothing.
end

--[[
    Called when the page should be displayed.
--]]
function PageBase:Show()
    -- Default: Do nothing. A page must implement this to be visible.
end

--[[
    Called when the page should be hidden.
--]]
function PageBase:Hide()
    -- Default: Do nothing. A page must implement this to be hidden correctly.
end

--[[
    Called to refresh the page's display with current data.
    This is often called after showing the page or after a setting has changed.
--]]
function PageBase:Refresh()
    -- Default: Do nothing.
end

--[[
    Called when global settings are applied, giving the page a chance
    to react to changes that might affect it (e.g., theme or font changes).
--]]
function PageBase:ApplySettings()
    -- Default: Do nothing.
end

--[[
    Called when the main window is resized.
    @param width The new width of the content area.
    @param height The new height of the content area.
--]]
function PageBase:OnResize(width, height)
    -- Default: Do nothing.
end
