Hi everyone! 👋
Currently, the ThemeModel in DevLint/Core/ThemeManager.swift is hardcoded, making it difficult to add or modify themes without changing the source code. To make the theming system more flexible and user-friendly, we’d like to separate the theme definitions into a JSON file or another external configuration format.
This change will allow users to:
- Easily add new themes without modifying the code.
- Share and import themes via JSON files.
- Customize themes dynamically at runtime.
Current Implementation
The ThemeModel is currently defined like this:
ThemeModel(
name: "Dark",
primaryColor: NSColor(hex: "#D9D9D9"), // Light gray for readability
secondaryColor: NSColor(hex: "#2C2C2C"), // Dark secondary color
backgroundColor: NSColor(hex: "#1D1F21"), // Dark background
font: .system(size: 14, weight: .regular, design: .monospaced),
keywordColor: NSColor(hex: "#C678DD"), // Purple for keywords
typeColor: NSColor(hex: "#56B6C2"), // Cyan for types
operatorColor: NSColor(hex: "#E06C75"), // Red for operators
stringColor: NSColor(hex: "#98C379"), // Green for strings
numberColor: NSColor(hex: "#D19A66"), // Orange for numbers
commentColor: NSColor(hex: "#5C6370"), // Dim gray-blue for comments
booleanColor: NSColor(hex: "#56B6C2"), // Cyan for booleans
functionColor: NSColor(hex: "#61AFEF"), // Blue for functions
enumColor: NSColor(hex: "#56B6C2"), // Cyan for enums
structColor: NSColor(hex: "#D19A66"), // Orange for structs
attributeColor: NSColor(hex: "#C678DD"), // Purple for attributes
preprocessorColor: NSColor(hex: "#FF7B72"), // Red for preprocessor directives
escapeColor: NSColor(hex: "#D19A66"), // Orange for escape sequences
punctuationColor: NSColor(hex: "#D9D9D9")
)
Proposed Solution
We’d like to move the theme definitions into a JSON file or another external configuration format. For example:
Example JSON Theme File
{
"name": "Dark",
"primaryColor": "#D9D9D9",
"secondaryColor": "#2C2C2C",
"backgroundColor": "#1D1F21",
"font": {
"size": 14,
"weight": "regular",
"design": "monospaced"
},
"keywordColor": "#C678DD",
"typeColor": "#56B6C2",
"operatorColor": "#E06C75",
"stringColor": "#98C379",
"numberColor": "#D19A66",
"commentColor": "#5C6370",
"booleanColor": "#56B6C2",
"functionColor": "#61AFEF",
"enumColor": "#56B6C2",
"structColor": "#D19A66",
"attributeColor": "#C678DD",
"preprocessorColor": "#FF7B72",
"escapeColor": "#D19A66",
"punctuationColor": "#D9D9D9"
}
Why This Feature is Important
- Flexibility: Users can add or modify themes without touching the source code.
- Ease of Use: Themes can be shared and imported via JSON files.
- Dynamic Customization: Themes can be loaded and applied at runtime.
How to Implement
-
Create a JSON Parser
Add a JSON parser to load theme configurations from external files.
-
Update ThemeManager
Modify ThemeManager to load themes from JSON files instead of hardcoded values.
-
Add Example Themes
Provide example JSON theme files (e.g., Dark.json, Light.json, Solarized.json).
-
Test the Changes
Ensure that themes are loaded and applied correctly.
-
Submit a Pull Request (PR)
If everything works, submit a PR with your changes.
Help Wanted
If you’re familiar with JSON parsing, theming systems, or Swift file handling, your help would be greatly appreciated! 🎨
How to Contribute
- Fork the repository.
- Implement the JSON-based theming system.
- Submit a PR with a clear description of your changes.
Additional Notes
- If you need help getting started, feel free to ask in the comments!
Hi everyone! 👋
Currently, the
ThemeModelinDevLint/Core/ThemeManager.swiftis hardcoded, making it difficult to add or modify themes without changing the source code. To make the theming system more flexible and user-friendly, we’d like to separate the theme definitions into a JSON file or another external configuration format.This change will allow users to:
Current Implementation
The
ThemeModelis currently defined like this:Proposed Solution
We’d like to move the theme definitions into a JSON file or another external configuration format. For example:
Example JSON Theme File
{ "name": "Dark", "primaryColor": "#D9D9D9", "secondaryColor": "#2C2C2C", "backgroundColor": "#1D1F21", "font": { "size": 14, "weight": "regular", "design": "monospaced" }, "keywordColor": "#C678DD", "typeColor": "#56B6C2", "operatorColor": "#E06C75", "stringColor": "#98C379", "numberColor": "#D19A66", "commentColor": "#5C6370", "booleanColor": "#56B6C2", "functionColor": "#61AFEF", "enumColor": "#56B6C2", "structColor": "#D19A66", "attributeColor": "#C678DD", "preprocessorColor": "#FF7B72", "escapeColor": "#D19A66", "punctuationColor": "#D9D9D9" }Why This Feature is Important
How to Implement
Create a JSON Parser
Add a JSON parser to load theme configurations from external files.
Update ThemeManager
Modify
ThemeManagerto load themes from JSON files instead of hardcoded values.Add Example Themes
Provide example JSON theme files (e.g.,
Dark.json,Light.json,Solarized.json).Test the Changes
Ensure that themes are loaded and applied correctly.
Submit a Pull Request (PR)
If everything works, submit a PR with your changes.
Help Wanted
If you’re familiar with JSON parsing, theming systems, or Swift file handling, your help would be greatly appreciated! 🎨
How to Contribute
Additional Notes