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

Add FXIOS-10913 [Homepage] [Top Sites] full layout configuration for top sites #23918

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

Conversation

cyndichin
Copy link
Contributor

📜 Tickets

Jira ticket
Github issue

💡 Description

Continues with implementing the rest of the logic for the layout configuration for the top sites section. See part I here.

This PR adds the ability to configure the number of rows shown for top sites section specified in the homepage settings.

  • Update the top sites section state to not only include the topSitesData, but also new fields numberOfRows and numberOfTilesPerRow
  • The state for the numberOfRows is set initially and updates when the user changes the configuration in settings, which is why we dispatch an action to update the state in TopSitesSettingsViewController
  • The state for numberOfTilesPerRow is updated when the value changes when being calculated in TopSitesDimensionImplementation, which is initialized in HomepageSectionLayoutProvider. Although it's a bit weird to have the layout update based on this and then use the layout configuration to update the data, I decided to go this route and follow what the existing logic is doing but simplifying and adopting Redux. This section may change as we want to revisit the whole logic in the future.
  • Using the two values, numberOfTilesPerRow and numberOfRows, we only get the first X amount of top data sites + update our datasource based on this calculation
  • Added tests

Note: I notice a discrepancy in the previous PR in that in landscape we are showing 7 tiles instead of 8. Most likely due to my change in using environment.container.effectiveContentSize instead of view.size like the previous code. Will create a separate ticket to address this.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed, I updated documentation / comments for complex code and public methods
  • If needed, added a backport comment (example @Mergifyio backport release/v120)

Screenshots

iPhone

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-12-20.at.11.28.48.mp4

iPad

ScreenRecording_12-20-2024.12-29-40_1.MP4

var numberOfTilesPerRow: Int? {
willSet {
guard newValue != numberOfTilesPerRow else { return }
queue.async {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that dispatching actions were already only dispatching on main thread, so not sure why I need to add this, but I was getting a crash and ensuring the call happens on main thread, addresses the issue. Going to look at this again with fresh eyes on Monday, but opened a PR to review to get early eyes + if anyone has a clue.

@cyndichin cyndichin force-pushed the cc/FXIOS-10913_add-number-of-rows-for-top-site-cal branch from bdaf5e9 to 23cc16a Compare December 20, 2024 17:38
@cyndichin cyndichin marked this pull request as ready for review December 20, 2024 17:38
@cyndichin cyndichin requested a review from a team as a code owner December 20, 2024 17:38
Copy link
Contributor

@lmarceau lmarceau left a comment

Choose a reason for hiding this comment

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

LGTM! I'll let Carson do the final review 👍

@cyndichin cyndichin force-pushed the cc/FXIOS-10913_add-number-of-rows-for-top-site-cal branch from 23cc16a to fe685f6 Compare December 20, 2024 17:55
@cyndichin cyndichin force-pushed the cc/FXIOS-10913_add-number-of-rows-for-top-site-cal branch from fe685f6 to 47c611f Compare December 20, 2024 17:57
@mobiletest-ci-bot
Copy link

Messages
📖 Project coverage: 34.38%
📖 Edited 13 files
📖 Created 0 files

Client.app: Coverage: 32.53

File Coverage
TopSitesAction.swift 100.0%
HomepageSectionLayoutProvider.swift 95.26%
HomepageDiffableDataSource.swift 97.78%
TopSitesSectionState.swift 96.2%
TopSitesDimensionImplementation.swift 100.0%
HomepageViewController.swift 42.21% ⚠️
TopSitesSettingsViewController.swift 8.97% ⚠️

Generated by 🚫 Danger Swift against 47c611f

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.

3 participants