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

Added navigation buttons "Next section" and "Random song" #385

Merged
merged 3 commits into from
May 28, 2023
Merged

Added navigation buttons "Next section" and "Random song" #385

merged 3 commits into from
May 28, 2023

Conversation

SamuelPalma
Copy link
Contributor

  • Added navigation button (Blue) "Next section" that selects the next letter with respect to the current song.

  • Navigation button (Orange) is added to select a random song.
    NextSectionAndRandomSongButtons

… letter with respect to the current song.

* Navigation button (Orange) is added to select a random song.
UpdateSongViews();
UpdateScrollbar();
}

private void setFirstLetters(){
Copy link
Member

Choose a reason for hiding this comment

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

Follow naming conventions (should be SetFirstLetters)

_songs
.OfType<SongViewType>()
.Select(song => song.SongEntry.NameNoParenthesis)
.Where(name => name != null && name.Any())
Copy link
Member

Choose a reason for hiding this comment

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

string.IsNullOrEmpty may be better here.

}

private string GetNextLetterOrNumber(string input){
string firstCharacter = input.Substring(0, 1).ToUpper();;
Copy link
Member

Choose a reason for hiding this comment

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

This should become input[0].ToUpper(). A string.IsNullOrEmpty check should also be added above to prevent errors. If an error state is needed (or in this case, "" is returned), it may be favorable to return char? (where "" would become null).

string firstCharacter = input.Substring(0, 1).ToUpper();;

int indexOfActualLetter = songsFirstLetter.FindIndex(letter => {
return Char.ToString(letter) == firstCharacter;
Copy link
Member

Choose a reason for hiding this comment

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

If above comment occurs, this can become letter == firstCharacter

return Char.ToString(letter) == firstCharacter;
});

bool isLast = indexOfActualLetter == (songsFirstLetter.Count() - 1);
Copy link
Member

Choose a reason for hiding this comment

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

Use songsFirstLetter.Count instead of songsFirstLetter.Count().

string nextCharacter = GetNextLetterOrNumber(song.SongEntry.NameNoParenthesis);

var index = _songs.FindIndex(skip, song => {
return song is SongViewType songType &&
Copy link
Member

Choose a reason for hiding this comment

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

The lambda can be simplified to song => [RETURN VALUE] instead of song => { return [RETURN VALUE] }

@TheNathannator
Copy link
Collaborator

I'd suggest making orange the button to go to the next section, to match how RB/CH do it.

Random song might also be better in a separate menu that contains other less common options as well, but I don't think we have that implemented currently so a button should be fine for now.

@SamuelPalma
Copy link
Contributor Author

Hi @EliteAsian123 , I have already made the requested changes.
Thank you for the review 😄

@EliteAsian123 EliteAsian123 merged commit cca8bbb into YARC-Official:dev May 28, 2023
EliteAsian123 pushed a commit that referenced this pull request Jun 2, 2023
…410)

* * Added navigation button (Blue) "Next section" that selects the next letter with respect to the current song.

* Navigation button (Orange) is added to select a random song.

* Changes made based on conversation [#385]

* * The navigation bar is updated to show the following action for pressing the search and sort buttons

* Improvement of the sorting code and addition of sorting by year, genre, album and charter.

* The code that performs song sorting (SongSorting.cs) is separated from the class that performs song selection (SongSelection.cs).

* Changes made as a result of the discussion #410
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