Skip to content

Migrate from country and langauge picker to internal solution #42

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

Merged

Conversation

fulleni
Copy link
Member

@fulleni fulleni commented Jul 31, 2025

Status

READY/IN DEVELOPMENT/HOLD

Description

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

fulleni added 30 commits July 31, 2025 07:09
- Remove country_picker, language_picker, recase, and universal_io packages
- These dependencies were no longer in use and have been purged from both pubspec.yaml and pubspec.lock
- Update resolved-ref in pubspec.lock from 3022edcb06d7c55ea81f25126b7f8c28c9105d4c to 7a1b54f8c0f94f6c04af3404c8110181e080b5c4
- Remove 'utils/utils.dart' export from shared.dart
- Delete country_adapter.dart and language_adapter.dart
- Remove unused Utils exports
…ories

- Add DataClient implementations for Country and Language models
- Create DataRepository instances for countries and languages
- Integrate new repositories into the App widget
- Implement both in-memory and API-based data clients for development environments
- Add DataRepository<Country> and DataRepository<Language> to App constructor
- Update RepositoryProvider values in MultiRepositoryProvider
- Add countriesRepository to CreateHeadlineBloc constructor
- Fetch countries data in _onDataLoaded event handler
- Store countries in CreateHeadlineState
- Update imports to include Country model
- Add countries parameter to CreateHeadlineState constructor
- Include countries in the list of properties of CreateHeadlineState
- Update copyWith method to handle countries parameter
- Remove unnecessary adaptation of package country to core country
- Directly update state with the new country value
…ineCountryChanged

- Replace picker.Country with Country in CreateHeadlineCountryChanged event
- Remove unused import statement for 'shared.dart' in create_headline_bloc.dart
- Create a reusable dropdown form field for selecting a language
- Add support for custom languages list, initial value, and label text
- Implement localization using AppLocalizationsX
- Replace LanguagePickerFormField with LanguageDropdownFormField
- Replace CountryPickerFormField with CountryDropdownFormField
- Optimize CreateSourceBloc initialization
- Improve code readability in form field onChanged callbacks
- Remove CountryPickerFormField and LanguagePickerFormField
- Introduce CountryDropdownFormField and LanguageDropdownFormField
- Update form field implementations for language and headquarters
- Adjust import statements to remove unused package
…wn export

- Move language_dropdown_form_field.dart to lib/shared/widgets/
- Update widgets.dart to export the new language dropdown widget
…access

- Remove implicit call to CreateSourceBloc
- Replace direct repository access with context.read<DataRepository>()
- Apply the same change to countriesRepository and languagesRepository
- Remove country_picker package
- Add CountryDropdownFormField to _CreateHeadlineViewState
- Update CreateHeadlineBloc to include countriesRepository
- Adapt country selection logic to use core.Country directly
…ntryDropdownFormField

- Remove unused import of country_picker package
- Replace CountryPickerFormField with CountryDropdownFormField for better usability
- Update country selection logic to use Country objects directly instead of adapting from core package
- Improve error handling when matching selected country with available countries
fulleni added 9 commits July 31, 2025 18:43
- Create new extension `SourceTypeL10n` for SourceType enum
- Add `localizedName` method to return localized name based on AppLocalizations
- Cover all SourceType cases for localization
- Deleted the SourceTypeL10n extension from edit_source_bloc.dart
- This extension was likely redundant, given that similar localization
  functionality is already provided by the existing SourceType extension
- Removing this code improves maintainability and reduces potential
  confusion in the codebase
…e_page

- Import SourceTypeL10n extension to support localization of source types
- This change enhances the page's ability to display source types in different languages
- Import SourceTypeL10n extension to enable localization of source types
…y displayed

- Update logic to find the correct language object from the full list
- Modify DropdownButton selection logic to use reference equality
- Preserve initial selection when the source already contains a language
- Remove unnecessary `.code` accessor when assigning language value
- This change ensures that the full language object is used, not just its code
- Remove unnecessary 'code' property access for language in EditSourceBloc
- Simplify state update by using language directly
- Remove unused import of edit_source_bloc.dart
- Add missing import of source_type_l10n.dart
@fulleni fulleni merged commit 0cd3394 into main Jul 31, 2025
1 check failed
@fulleni fulleni deleted the migrate-from-country-and-langauge-picker-to-internal-solution branch July 31, 2025 18:00
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant migration by replacing third-party country and language picker solutions with an internally managed system. This change involves updating core application dependencies, introducing new data repositories for countries and languages, and refactoring relevant BLoC logic and UI components to utilize these internal solutions. The primary goal is to gain more control over data and UI presentation, reduce external dependencies, and improve maintainability.

Highlights

  • Dependency Removal: Removed external country_picker and language_picker packages, reducing third-party dependencies and streamlining the codebase.
  • Internal Data Management: Integrated internal Country and Language data models throughout the application, including their respective data repositories, ensuring consistent data handling.
  • UI Component Migration: Replaced external country and language picker UI components with custom-built CountryDropdownFormField and LanguageDropdownFormField widgets, providing more control over the UI/UX.
  • Bloc Logic Updates: Updated CreateHeadlineBloc, CreateSourceBloc, EditHeadlineBloc, and EditSourceBloc to fetch and manage Country and Language data using the new internal repositories, simplifying data flow within the BLoCs.
  • Code Cleanup: Removed adapter utilities (country_adapter.dart, language_adapter.dart) and relocated the SourceTypeL10n extension, cleaning up the shared directory.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully migrates the application from using external country_picker and language_picker packages to an internal solution, which involves creating new data repositories for countries and languages and replacing the picker form fields with new dropdown widgets. The changes are well-integrated across the BLoCs and views.

My review includes a couple of suggestions to improve maintainability and robustness:

  • Refactoring duplicated code in bootstrap.dart for setting up data clients.
  • Improving error handling in CreateSourceBloc to be more specific and consistent with the rest of the application.

Overall, this is a solid refactoring that reduces external dependencies.

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