Skip to content

Commit

Permalink
Enhance Dashboard: Implement Comprehensive Support for JSON Objects
Browse files Browse the repository at this point in the history
- Added functionality to fully process and display JSON objects within the dashboard.
- Updated data handling methods to accommodate nested structures and arrays.
- Improved UI components to render JSON data dynamically.

Add JSON manifest for generating platform-specific code from JSON files
- JSON manifest that enables the generation of platform-specific code based on the provided JSON files. This enhancement streamlines the development process and ensures better code organization for different platforms.

Enhance brand switching process by enabling resource copying
- Implemented functionality to copy resources associated with a brand during the switching process.
- Utilized a resources manifest to streamline the resource management.
- This improvement ensures a smoother transition between brands, maintaining consistency and reducing manual resource handling.
  • Loading branch information
MalekKamel committed Oct 18, 2024
1 parent 5db6721 commit c57f639
Show file tree
Hide file tree
Showing 54 changed files with 2,358 additions and 1,530 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
source "https://rubygems.org"

gem 'solara', '0.2.4'
gem "rspec", "~>3.13.0"
gemspec
32 changes: 17 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
PATH
remote: .
specs:
solara (0.4.0)
cgi (~> 0.4.1)
colorize (~> 1.1.0)
json-schema (~> 4.3.1)
plist (~> 3.7.1)
thor (~> 1.0)
webrick (~> 1.8.1)
xcodeproj (~> 1.25.0)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -20,6 +32,7 @@ GEM
nkf (0.2.0)
plist (3.7.1)
public_suffix (6.0.1)
rake (13.2.1)
rexml (3.3.8)
rspec (3.13.0)
rspec-core (~> 3.13.0)
Expand All @@ -30,18 +43,10 @@ GEM
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
solara (0.2.4)
cgi (~> 0.4.1)
colorize (~> 1.1.0)
json-schema (~> 4.3.1)
plist (~> 3.7.1)
thor (~> 1.0)
webrick (~> 1.8.1)
xcodeproj (~> 1.25.0)
thor (1.3.2)
webrick (1.8.2)
xcodeproj (1.25.1)
Expand All @@ -53,16 +58,13 @@ GEM
rexml (>= 3.3.6, < 4.0)

PLATFORMS
arm64-darwin-22
x64-mingw-ucrt
x64-mingw32
x86_64-darwin-23
x86_64-linux
x86_64-mingw32

DEPENDENCIES
bundler (~> 2.0)
rake (~> 13.0)
rspec (~> 3.13.0)
solara (= 0.2.4)
solara!

BUNDLED WITH
2.5.18
59 changes: 58 additions & 1 deletion solara/lib/core/brands/brand_switcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def start
def switch
BrandFontSwitcher.new(@brand_key).switch

ResourceManifestSwitcher.new(@brand_key).switch
JsonManifestSwitcher.new(@brand_key).switch

case @platform
when Platform::Flutter
IOSBrandSwitcher.new(@brand_key).switch
Expand All @@ -42,6 +45,60 @@ def switch
else
raise ArgumentError, "Invalid platform: #{@platform}"
end

end

end

class ResourceManifestSwitcher
def initialize(brand_key)
@brand_key = brand_key
end

def switch
Solara.logger.start_step("Process resource manifest: #{FilePath.resources_manifest}")
brand_resource_copier = ResourceManifestProcessor.new(@brand_key)
brand_resource_copier.copy
Solara.logger.debug("#{@brand_key} resources copied successfully according to the manifest: #{FilePath.resources_manifest}.")
Solara.logger.end_step("Process resource manifest: #{FilePath.resources_manifest}")
end

end

class JsonManifestSwitcher
def initialize(brand_key)
@brand_key = brand_key
@manifest_path = FilePath.brand_json_dir(brand_key)
end

def switch
Solara.logger.start_step("Process JSON manifest: #{@manifest_path}")


case SolaraSettingsManager.instance.platform
when Platform::Flutter
process_maifest(Language::Dart, FilePath.flutter_lib_artifacts)
process_maifest(Language::Dart, FilePath.brand_global_json_dir)
when Platform::IOS
process_maifest(Language::Swift, FilePath.ios_project_root_artifacts)
process_maifest(Language::Swift, FilePath.brand_global_json_dir)
when Platform::Android
process_maifest(Language::Kotlin, FilePath.android_project_java_artifacts )
process_maifest(Language::Kotlin, FilePath.brand_global_json_dir)
else
raise ArgumentError, "Invalid platform: #{@platform}"
end

Solara.logger.end_step("Process JSON manifest: #{@manifest_path}")
end

def process_maifest(language, output_path)
processor = JsonManifestProcessor.new(
@manifest_path,
language,
output_path
)
processor.process
end
end

Expand Down Expand Up @@ -225,7 +282,7 @@ def generate_swift
def generate_theme(name, language, platform)
Solara.logger.start_step("Generate #{name} for #{platform}")

theme_manager = ThemeGeneratorManager.new(FilePath.brand_theme(@brand_key))
theme_manager = ThemeGenerator.new(FilePath.brand_theme(@brand_key))
theme_manager.generate(language, FilePath.generated_config(name, platform))

Solara.logger.end_step("Generate #{name} for #{platform}")
Expand Down
36 changes: 34 additions & 2 deletions solara/lib/core/dashboard/brand/BrandDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@ import BrandDetailModel from './BrandDetailModel.js';
import BrandDetailView from './BrandDetailView.js';
import BrandDetailController from './BrandDetailController.js';

const modeToggle = document.getElementById('modeToggle');
const body = document.body;
const icon = modeToggle.querySelector('i');

function applyMode(mode) {
if (mode === 'dark') {
body.classList.add('dark-mode');
icon.classList.remove('fa-sun');
icon.classList.add('fa-moon');
} else {
body.classList.remove('dark-mode');
icon.classList.remove('fa-moon');
icon.classList.add('fa-sun');
}
}

const savedMode = localStorage.getItem('mode');
if (savedMode) {
applyMode(savedMode);
} else {
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
applyMode(systemPrefersDark ? 'dark' : 'light');
}

modeToggle.addEventListener('click', () => {
const currentMode = body.classList.contains('dark-mode') ? 'dark' : 'light';
const newMode = currentMode === 'dark' ? 'light' : 'dark';
applyMode(newMode);
localStorage.setItem('mode', newMode);
});

window.onload = function () {
document.getElementById('loadingOverlay').style.display = 'none';
};
Expand All @@ -20,10 +51,11 @@ window.addEventListener('scroll', function () {
}
lastScrollTop = scrollTop;
});

document.addEventListener('DOMContentLoaded', async () => {
const model = new BrandDetailModel();
const view = new BrandDetailView(model);
const controller = new BrandDetailController(model, view);
await controller.initializeApp();
});
});

Loading

0 comments on commit c57f639

Please sign in to comment.