Closed
Conversation
The `ViewModelInstance` and `ViewModelInstanceString` are now stored as instance variables in the `_GameButtonState`. This change allows for their proper disposal in the `dispose` method, preventing potential memory leaks by clearing listeners and disposing of the view model instance when the widget is removed from the tree.
The method for setting the text value on the Rive artboard has been updated. The deprecated direct `artboard.setText()` method has been replaced with data binding using `viewModelInstance.string('buttonText')?.value`. This aligns with modern Rive data binding practices.
This commit refactors the `Hint` widget to use Rive's ViewModel API for more efficient state management of the animation. Key changes include: * Replaced direct `StateMachine` controllers with `ViewModelInstance`. * Bound animation properties (`isLightOn`, `isDarkTheme`, `hintCount`, `textColour`) directly to the ViewModel. * Simplified the widget tree by removing the explicit `Text` for the hint count and integrating it into the Rive animation itself. * Removed the now-redundant `Row` and `Baseline` widgets.
…clude a hint count as part of the animation itself
…the new `hint.riv`
The method for loading Rive assets has been updated from `rootBundle.load` to the recommended `File.asset`. This change simplifies the code by removing manual decoding of `Uint8List` and aligns with current best practices for the Rive library. Additionally, the unused `flutter/services.dart` import has been removed.
The `GamePlayBoard` widget was converted from a `StatelessWidget` to a `StatefulWidget`. This change allows for the proper management of the `GridBoardController`'s lifecycle. The controller is now initialized in `initState` and disposed of in `dispose`, preventing potential memory leaks and ensuring it is correctly handled within the widget's state.
A new `Scorecard` widget, built with Rive, has been introduced to display game statistics like the current level and failed attempts. This animated widget replaces the simple text title in the `GamePlayHeader`. The `GamePlayHeader` is now responsive, showing a different layout for mobile and desktop screens. Additionally, the `GamePlayPage` has been updated to include a bottom border on the header for better visual separation.
The `Scorecard` widget has been refactored to utilize a Rive state machine for managing its appearance and layout, including dark mode awareness and responsiveness. Key changes include: - Removing manual color properties and instead controlling the theme via a `isDarkMode` boolean input in the Rive state machine. - Implementing responsive layouts for narrow and wide screens by adjusting Rive state machine enums. - Updating `GamePlayHeader` to support the refactored `Scorecard` and improve its layout for different screen sizes. - Removing a redundant `DecoratedBox` from `GamePlayPage`.
A new test file has been created for the `Scorecard` widget to ensure it renders correctly. The test provides a mock `ThemeCubit` and verifies that a single `Scorecard` widget is found on the screen.
The CI build was failing during the test phase with an error indicating that the Rive native library (`librive_native_plugin.so`) could not be found. This was caused by the absence of required system libraries for Rive on the GitHub Actions Linux runner. This commit updates the `main.yaml` workflow to install the necessary Mesa OpenGL libraries (`libgl1-mesa-glx` and `libegl1-mesa-dev`) before running the tests. This resolves the native library loading issue and allows Rive-dependent tests to pass in the CI environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of Change