Skip to content

Integrate Material You Dynamic Theming for Light & Dark Modes #743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

inderjsingh
Copy link
Contributor

Description

This PR enhances the theming system by integrating Material You dynamic colors for both light and dark modes. The app now adapts to the system’s color scheme if supported, ensuring a more personalized experience.

Proposed Changes

  1. Added Dynamic Theming Support

    • Implemented Material You dynamic colors for both light and dark themes.
    • If the device does not support dynamic colors, it falls back to predefined app colors.
  2. Introduced Dynamic Text Theme Support

    • Replaced static text themes with dynamic color-based text themes to ensure consistency with Material You.
  3. Replaced kPrimaryColor with a Function

    • Created getPrimaryColorTheme() and getSecondaryColorTheme() functions.
    • These functions fetch primary and secondary colors dynamically from Get.theme.colorScheme.
  4. Implemented Theme Update Logic

    • Added updateThemeColors() function to dynamically update colors based on:
      • Current theme mode (light/dark).
      • Dynamic color availability.
      • Falls back to predefined colors if dynamic colors are not available.
  5. Created a Unified Theme Getter

    • Added getThemeData({required bool isLight}) function:
      • Returns dynamic themes if available.
      • Otherwise, falls back to default themes (kLightThemeData / kThemeData).
  6. Refactored Theme Creation Methods

    • Created _createLightTheme(ColorScheme scheme) and _createDarkTheme(ColorScheme scheme) functions to:
      • Use Material You dynamic colors.
      • Ensure theme consistency with useMaterial3: true.

Fixes

Fixes #697

Screenshots

🔹 Light & Dark Theme Previews

✅ Checklist

  • Implemented Material You dynamic colors for both light and dark themes.
  • Replaced kPrimaryColor with dynamic color fetching functions for adaptability.
  • Added updateThemeColors() to manage theme colors dynamically based on system settings.
  • Ensured fallback to default theme when dynamic colors are not supported.

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.

1 participant