add smokeapi settings dialog & styling #67

This commit is contained in:
Novattz
2025-12-23 01:58:30 +01:00
parent ab057b8d10
commit 3675ff8fae
7 changed files with 354 additions and 1 deletions

View File

@@ -30,6 +30,12 @@ export interface ProgressDialogState {
instructions?: InstallationInstructions
}
export interface SmokeAPISettingsDialogState {
visible: boolean
gamePath: string
gameTitle: string
}
// Define the context type
export interface AppContextType {
// Game state
@@ -54,6 +60,11 @@ export interface AppContextType {
handleSettingsOpen: () => void
handleSettingsClose: () => void
// SmokeAPI settings
smokeAPISettingsDialog: SmokeAPISettingsDialogState
handleSmokeAPISettingsOpen: (gameId: string) => void
handleSmokeAPISettingsClose: () => void
// Toast notifications
showToast: (
message: string,

View File

@@ -4,6 +4,7 @@ import { useGames, useDlcManager, useGameActions, useToasts } from '@/hooks'
import { DlcInfo } from '@/types'
import { ActionType } from '@/components/buttons/ActionButton'
import { ToastContainer } from '@/components/notifications'
import { SmokeAPISettingsDialog } from '@/components/dialogs'
// Context provider component
interface AppProviderProps {
@@ -38,6 +39,17 @@ export const AppProvider = ({ children }: AppProviderProps) => {
// Settings dialog state
const [settingsDialog, setSettingsDialog] = useState({ visible: false })
// SmokeAPI settings dialog state
const [smokeAPISettingsDialog, setSmokeAPISettingsDialog] = useState<{
visible: boolean
gamePath: string
gameTitle: string
}>({
visible: false,
gamePath: '',
gameTitle: '',
})
// Settings handlers
const handleSettingsOpen = () => {
setSettingsDialog({ visible: true })
@@ -47,6 +59,25 @@ export const AppProvider = ({ children }: AppProviderProps) => {
setSettingsDialog({ visible: false })
}
// SmokeAPI settings handlers
const handleSmokeAPISettingsOpen = (gameId: string) => {
const game = games.find((g) => g.id === gameId)
if (!game) {
showError('Game not found')
return
}
setSmokeAPISettingsDialog({
visible: true,
gamePath: game.path,
gameTitle: game.title,
})
}
const handleSmokeAPISettingsClose = () => {
setSmokeAPISettingsDialog((prev) => ({ ...prev, visible: false }))
}
// Game action handler with proper error reporting
const handleGameAction = async (gameId: string, action: ActionType) => {
const game = games.find((g) => g.id === gameId)
@@ -201,6 +232,11 @@ export const AppProvider = ({ children }: AppProviderProps) => {
handleSettingsOpen,
handleSettingsClose,
// SmokeAPI Settings
smokeAPISettingsDialog,
handleSmokeAPISettingsOpen,
handleSmokeAPISettingsClose,
// Toast notifications
showToast,
}
@@ -209,6 +245,14 @@ export const AppProvider = ({ children }: AppProviderProps) => {
<AppContext.Provider value={contextValue}>
{children}
<ToastContainer toasts={toasts} onDismiss={removeToast} />
{/* SmokeAPI Settings Dialog */}
<SmokeAPISettingsDialog
visible={smokeAPISettingsDialog.visible}
onClose={handleSmokeAPISettingsClose}
gamePath={smokeAPISettingsDialog.gamePath}
gameTitle={smokeAPISettingsDialog.gameTitle}
/>
</AppContext.Provider>
)
}
}