Skip to content
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

Upgrade image_cropper from v5.0.1 to v8.0.2 with updated implementations and tests #2711

Open
wants to merge 8 commits into
base: develop-postgres
Choose a base branch
from

Conversation

may-tas
Copy link
Contributor

@may-tas may-tas commented Jan 19, 2025

What kind of change does this PR introduce?

  • Upgraded package image_cropper to v8.0.2

Issue Number:

Did you add tests for your changes?

  • Yes

  • Tests are written for all changes made in this PR.

  • Test coverage meets or exceeds the current coverage (~90/95%).

Snapshots/Videos:

Screenshot 2025-01-19 at 8 48 03 PM

Summary

  • Migrated image_cropper from v5.0.1 to v8.0.2, updated implementation to meet new version requirements, and fixed related test cases.

Does this PR introduce a breaking change?

  • No

Checklist for Repository Standards

  • Have you reviewed and implemented all applicable coderaabbitai review suggestions?
  • Have you ensured that the PR aligns with the repository’s contribution guidelines?

Other information

  • Starting from version v7.0.0 of the image_cropper package, there were breaking changes: :
    • The cropImage() method now requires cropStyle and aspectRatioPresets to be specified within AndroidUiSettings and IOUiSettings respectively.

Have you read the contributing guide?

  • Yes

Summary by CodeRabbit

  • Platform Support

    • Increased minimum iOS version support from 9.0 to 12.0
    • Updated Android and iOS project configurations
  • Image Handling

    • Enhanced image cropping functionality with additional aspect ratio presets
    • Updated image cropper dependency to version 8.0.2
  • App Configuration

    • Added support for indirect input events
    • Enabled SMS and telephone scheme queries
    • Improved frame duration handling on phones
  • Testing Enhancements

    • Improved test coverage for image cropping functionality and aspect ratio presets
    • Streamlined test structure for media picker service

Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

Walkthrough

The pull request focuses on upgrading the image_cropper package from version 5.0.1 to 8.0.2. This upgrade involves modifications across multiple files in the project, including configuration files for Android and iOS, service and test files. The changes primarily address compatibility with the new package version, updating method signatures, adding aspect ratio presets, and adjusting project settings to support the latest version of the image cropping functionality.

Changes

File Change Summary
android/settings.gradle Stylistic change from double quotes to single quotes for plugin version
ios/Flutter/AppFrameworkInfo.plist Updated minimum OS version from 9.0 to 12.0
ios/Runner.xcodeproj/project.pbxproj Updated project file version, deployment target, and build configurations
ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme Updated scheme version
ios/Runner/Info.plist Added new keys for frame duration and input events, updated query schemes
lib/services/image_service.dart Added more aspect ratio presets for image cropping
pubspec.yaml Updated image_cropper dependency to version 8.0.2, removed commented dependencies
test/helpers/test_helpers.mocks.dart Modified MockImageCropper method signature
test/service_tests/image_service_test.dart Enhanced test coverage for image cropping
test/service_tests/multi_media_pick_service_test.dart Updated tests for image cropping functionality

Assessment against linked issues

Objective Addressed Explanation
Upgrade image_cropper from 5.0.1 to 8.0.2
Update project configurations
Modify test suites for new package version

Possibly related PRs

Suggested reviewers

  • noman2002

Poem

🥕 A Rabbit's Crop of Code Delight 🥕
With image cropper's new might,
Pixels dance in preset's grace,
Versions leap with playful pace,
Code transforms with bunny's flair,
Upgrading without a care! 🐰✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c6ac20 and 1a4547c.

📒 Files selected for processing (1)
  • test/service_tests/multi_media_pick_service_test.dart (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/service_tests/multi_media_pick_service_test.dart
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Checking codebase

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Our Pull Request Approval Process

Thanks for contributing!

Testing Your Code

Remember, your PRs won't be reviewed until these criteria are met:

  1. We don't merge PRs with poor code quality.
    1. Follow coding best practices such that CodeRabbit.ai approves your PR.
  2. We don't merge PRs with failed tests.
    1. When tests fail, click on the Details link to learn more.
    2. Write sufficient tests for your changes (CodeCov Patch Test). Your testing level must be better than the target threshold of the repository
    3. Tests may fail if you edit sensitive files. Ask to add the ignore-sensitive-files-pr label if the edits are necessary.
  3. We cannot merge PRs with conflicting files. These must be fixed.

Our policies make our code better.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

Other

🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (2)
ios/Runner/Info.plist (1)

Line range hint 1-72: Fix duplicate LSApplicationQueriesSchemes key.

There are two instances of the LSApplicationQueriesSchemes key in the plist file. This could lead to unexpected behavior.

Merge the schemes into a single array:

  <key>LSApplicationQueriesSchemes</key>
  <array>
    <string>instagram-stories</string>
    <string>facebook-stories</string>
    <string>facebook</string>
    <string>instagram</string>
    <string>twitter</string>
    <string>whatsapp</string>
    <string>tg</string>
-  </array>
-  <key>LSApplicationQueriesSchemes</key>
-  <array>
    <string>sms</string>
    <string>tel</string>
  </array>
pubspec.yaml (1)

Custom lint dependencies should not be removed

The analyzer-related dependencies cannot be safely removed as they are required by the talawa_lint custom rules package:

  • The talawa_lint package (in talawa_lint/ directory) directly depends on these packages
  • The project's analysis_options.yaml actively uses the custom lint rules
  • Removing these dependencies would break the custom lint functionality
🔗 Analysis chain

Line range hint 16-19: Verify removal of analyzer dependencies.

Please verify that the removed analyzer dependencies are not required by any other packages or development tools in the project.

Also applies to: 24-26

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if any remaining files reference the removed packages
echo "Checking for references to removed packages..."
rg -l "_fe_analyzer_shared|analyzer[^_]|analyzer_plugin|custom_lint_builder" --type yaml --type dart

Length of output: 647


Script:

#!/bin/bash
# Check the contents of relevant files
echo "=== talawa_lint/pubspec.yaml ==="
cat talawa_lint/pubspec.yaml

echo -e "\n=== analysis_options.yaml ==="
cat analysis_options.yaml

echo -e "\n=== Main pubspec.yaml analyzer references ==="
rg "analyzer|custom_lint" pubspec.yaml

Length of output: 3093

🧹 Nitpick comments (3)
lib/services/image_service.dart (1)

41-47: Consider making aspectRatioPresets configurable.

The aspectRatioPresets are currently hardcoded. Consider making them configurable through method parameters to support different use cases.

-Future<File?> cropImage({required File imageFile}) async {
+Future<File?> cropImage({
+  required File imageFile,
+  List<CropAspectRatioPreset>? aspectRatioPresets,
+}) async {

Also applies to: 51-57

test/service_tests/image_service_test.dart (1)

96-115: Consider using a helper method for aspect ratio preset verification.

The aspect ratio preset verification is repeated multiple times. Consider extracting it into a helper method to improve maintainability.

void verifyAspectRatioPresets(List<CropAspectRatioPreset> presets) {
  for (final preset in [
    CropAspectRatioPreset.square,
    CropAspectRatioPreset.original,
    CropAspectRatioPreset.ratio3x2,
    CropAspectRatioPreset.ratio4x3,
    CropAspectRatioPreset.ratio16x9,
  ]) {
    expect(presets, contains(preset));
  }
}
pubspec.yaml (1)

54-54: Consider using a caret version constraint.

The strict version constraint 8.0.2 might cause dependency resolution issues. Consider using ^8.0.2 to allow compatible minor and patch updates.

-  image_cropper: 8.0.2
+  image_cropper: ^8.0.2
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da8eb3e and 274eaa5.

⛔ Files ignored due to path filters (2)
  • ios/Podfile.lock is excluded by !**/*.lock
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • android/settings.gradle (1 hunks)
  • ios/Flutter/AppFrameworkInfo.plist (1 hunks)
  • ios/Runner.xcodeproj/project.pbxproj (11 hunks)
  • ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme (1 hunks)
  • ios/Runner/Info.plist (1 hunks)
  • lib/services/image_service.dart (1 hunks)
  • pubspec.yaml (1 hunks)
  • test/helpers/test_helpers.mocks.dart (0 hunks)
  • test/service_tests/image_service_test.dart (2 hunks)
  • test/service_tests/multi_media_pick_service_test.dart (2 hunks)
💤 Files with no reviewable changes (1)
  • test/helpers/test_helpers.mocks.dart
✅ Files skipped from review due to trivial changes (2)
  • ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  • android/settings.gradle
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Checking codebase
🔇 Additional comments (6)
ios/Flutter/AppFrameworkInfo.plist (1)

24-24: Verify iOS deployment target compatibility.

The minimum iOS version has been updated from 9.0 to 12.0 to support image_cropper v8.0.2. This change may affect users with older iOS devices.

Consider adding this compatibility requirement to the app's documentation to inform users and developers about the minimum supported iOS version.

ios/Runner/Info.plist (1)

67-70: LGTM! Required iOS configuration keys added.

The new configuration keys enhance iOS compatibility:

  • CADisableMinimumFrameDurationOnPhone: Improves frame rate handling
  • UIApplicationSupportsIndirectInputEvents: Enables proper input event handling
ios/Runner.xcodeproj/project.pbxproj (4)

6-6: LGTM! Project and build settings updated.

The Xcode project has been properly updated:

  • objectVersion increased to 54
  • LastUpgradeCheck updated to 1510

Also applies to: 160-160


364-364: LGTM! Deployment target consistently updated.

The iOS deployment target has been updated to 12.0 across all build configurations (Profile, Debug, Release), maintaining consistency with the image_cropper v8.0.2 requirements.

Also applies to: 441-441, 490-490


240-256: LGTM! Required Pods resources build phase added.

The [CP] Copy Pods Resources build phase has been added to handle resource files from CocoaPods dependencies properly.


382-385: LGTM! Search paths format updated.

The LD_RUNPATH_SEARCH_PATHS has been updated to use the modern array format across all configurations.

Also applies to: 509-512, 531-534

lib/services/image_service.dart Show resolved Hide resolved
test/service_tests/multi_media_pick_service_test.dart Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.55%. Comparing base (da8eb3e) to head (1a4547c).
Report is 2 commits behind head on develop-postgres.

Additional details and impacted files
@@                Coverage Diff                @@
##           develop-postgres    #2711   +/-   ##
=================================================
  Coverage             96.55%   96.55%           
=================================================
  Files                   189      189           
  Lines                  9994     9995    +1     
=================================================
+ Hits                   9650     9651    +1     
  Misses                  344      344           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 19, 2025
@may-tas
Copy link
Contributor Author

may-tas commented Jan 19, 2025

@noman2002 please review.

@may-tas
Copy link
Contributor Author

may-tas commented Jan 20, 2025

@palisadoes Please review.

@palisadoes palisadoes added the ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files label Jan 20, 2025
@palisadoes
Copy link
Contributor

Please make a minor commit to trigger the workflows again. @noman2002 will be reviewing this shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants