Skip to content

Comments

Platform supporting#401

Closed
felipecastrosales wants to merge 19 commits intoStacDev:devfrom
SuaMusica:platform
Closed

Platform supporting#401
felipecastrosales wants to merge 19 commits intoStacDev:devfrom
SuaMusica:platform

Conversation

@felipecastrosales
Copy link

@felipecastrosales felipecastrosales commented Dec 30, 2025

Description

Implemented new platform-specific widgets functionality in the Stac framework. It's now possible to specify on which platforms a widget should be rendered through the platform property in JSON.

Features:

  • platform property: Can be a single string or a list of strings
  • Automatic validation: Checks if the current platform is in the allowed list
  • Logging: When platform is not supported, returns null and logs an informative message
  • Supported platforms: android, fuchsia, ios, linux, macos, windows

Usage examples:

Multiple platforms:

{
  "platform": ["android", "ios"],
  "type": "text",
  "data": "Widget only for mobile"
}

Single platform:

{
  "platform": "android",
  "type": "text",
  "data": "Widget only for Android"
}

Behavior:

  • If current platform is allowed: widget renders normally
  • If current platform is NOT allowed: returns null and logs:
    Widget not supported on platform [linux]. Only available for: android, ios
    

Related Issues

Closes #

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code refactor
  • Build configuration change
  • Documentation
  • Chore

Summary by CodeRabbit

  • New Features

    • Added build number registration during app initialization
    • Implemented version and platform-based widget gating
    • Added custom color parser injection
    • Introduced version constraint system with conditional evaluation
  • Tests

    • Added comprehensive test coverage for version management

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 3 committers have signed the CLA.

❌ lstonussi
❌ atrope
❌ felipecastrosales


lstonussi seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The PR extends the STAC framework with build number tracking and version/platform-based widget gating. It introduces a new version management system with conditional operators, adds custom color parser injection, updates theme parsers to use newer Flutter widget data types, and includes comprehensive tests for the version system.

Changes

Cohort / File(s) Summary
Formatting and Configuration
examples/counter_example/pubspec.yaml, examples/movie_app/pubspec.yaml, pubspec.yaml
YAML string quotation normalization (single to double quotes) and trailing whitespace cleanup; no semantic or dependency changes.
Framework Core API Extensions
packages/stac/lib/src/framework/stac.dart, packages/stac/lib/src/framework/stac_registry.dart
Added optional buildNumber parameter to Stac.initialize(), new Stac.setParseCustomColor() static method, and StacRegistry registration for build numbers and custom color parsers; added runtime version/platform gating in widget parsing.
Theme Parser Type Updates
packages/stac/lib/src/parsers/theme/stac_dialog_theme/stac_dialog_theme.dart, packages/stac/lib/src/parsers/theme/stac_tab_bar_theme_data/stac_tab_bar_theme_data.dart
Return type changes from DialogTheme/TabBarTheme to newer DialogThemeData/TabBarThemeData Flutter widget classes.
Theme Parser Cleanup
packages/stac/lib/src/parsers/theme/stac_theme/stac_theme.dart
Removed redundant .data accessor from dialogTheme assignment following theme data type updates.
Color and Utility Enhancements
packages/stac/lib/src/utils/color_utils.dart, packages/stac/lib/src/utils/utils.dart
Added custom color parser hook in _parseThemeColor() via StacRegistry; exported new version utility module.
New Version Management System
packages/stac/lib/src/utils/version/stac_version.dart
Introduced StacVersion class with build number and condition constraints, StacConditionVersion enum (6 operators), platform-aware JSON parsing, and isSatisfied() constraint evaluation logic with comprehensive documentation.
Version System Tests
packages/stac/test/src/utils/version/stac_version_test.dart
Comprehensive test suite covering construction, JSON parsing (including platform overrides), condition evaluation, and build number constraint satisfaction across multiple scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant Stac as Stac Framework
    participant Registry as StacRegistry
    participant Parser as Widget Parser
    participant VersionCheck as Version Validator

    rect rgb(200, 240, 220)
    Note over App,Registry: Initialization Phase
    App->>Stac: initialize(buildNumber: 42)
    Stac->>Registry: registerBuildNumber(42)
    Registry->>Registry: store _buildNumber
    Stac->>Stac: setParseCustomColor(customFn)
    Stac->>Registry: parseCustomColor = customFn
    end

    rect rgb(220, 240, 260)
    Note over Parser,VersionCheck: Runtime Widget Parsing Phase
    App->>Stac: fromJson(widgetConfig)
    Stac->>Stac: extract version constraints
    
    alt version && buildNumber constraints present
        Stac->>VersionCheck: isSatisfied(buildNumber: 42)
        VersionCheck->>VersionCheck: evaluate condition
        alt condition NOT satisfied
            VersionCheck-->>Stac: constraint failed
            Stac->>Stac: log warning, return null
        else condition satisfied
            VersionCheck-->>Stac: constraint passed
        end
    end

    alt platform constraint present
        Stac->>Stac: check current platform
        alt platform mismatch
            Stac->>Stac: log warning, return null
        end
    end

    Stac->>Parser: continue parsing
    Parser->>Parser: parse widget properties
    
    alt custom color needed
        Parser->>Registry: parseCustomColor?.call(colorStr)
        Registry-->>Parser: custom Color or null
    end
    
    Parser-->>App: return parsed Widget
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • divyanshub024
  • Potatomonsta

Poem

🐰 A rabbit hops through version trees,
Gating widgets with such ease—
Build numbers dance, constraints align,
Custom colors now so fine!
Platform checks hop left and right,
Stac's extensions take flight! ✨


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19f0ea7 and 8f84f83.

📒 Files selected for processing (13)
  • examples/counter_example/pubspec.yaml
  • examples/movie_app/pubspec.yaml
  • packages/stac/lib/src/framework/stac.dart
  • packages/stac/lib/src/framework/stac_registry.dart
  • packages/stac/lib/src/parsers/theme/stac_dialog_theme/stac_dialog_theme.dart
  • packages/stac/lib/src/parsers/theme/stac_tab_bar_theme_data/stac_tab_bar_theme_data.dart
  • packages/stac/lib/src/parsers/theme/stac_theme/stac_theme.dart
  • packages/stac/lib/src/utils/color_utils.dart
  • packages/stac/lib/src/utils/utils.dart
  • packages/stac/lib/src/utils/version/stac_version.dart
  • packages/stac/pubspec.yaml
  • packages/stac/test/src/utils/version/stac_version_test.dart
  • pubspec.yaml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants