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

feat: 🎸 [JIRA:HCPSDKFIORIUIKIT-2707] SwiftUI RatingControl Enhancement #794

Merged
merged 4 commits into from
Sep 12, 2024

Conversation

janhuachu
Copy link
Contributor

SwiftUI RatingControl enhancement with value label and review count label

✅ Closes: HCPSDKFIORIUIKIT-2707

SwiftUI RatingControl enhancement with value label and review count
label

✅ Closes: HCPSDKFIORIUIKIT-2707
@janhuachu janhuachu requested a review from a team as a code owner September 5, 2024 22:58
@janhuachu janhuachu requested review from billzhou0223 and removed request for a team September 5, 2024 22:58
@dyongxu dyongxu requested a review from JunSong-SH September 7, 2024 16:46

This `RatingControl` is read-only. Each rating star is in large scale.
*/
case standardLarge
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to use the Bool variable isLarge with the UIKit FUIRatingControl. By default, it is set to false for the read-only state and always true for the editable and disabled states. This approach is more simple to me when a smaller size is needed for the editable or disabled states, or for any new states that may be introduced in the future. For us, this means that we do not need to add too many styles, and for the App team, it makes it easy to understand that there are two sizes for each state.
I just want to let you know about the difference between your API and mine. However, I am definitely okay with your implementation for these two new styles here for SWiftUI Rating Control.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JunSong-SH I was originally using the isLarge property. However, later I removed it to reduce the number of properties. I think there are too many properties already.

configuration.getOnImageView()
} else {
configuration.getOffImageView()
if configuration.showsValueLabel, self.getReadOnly(configuration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a little confused about the left value for the editable/disabled state. The design spec mentions 'Left value (optional) except for editable and disabled variants.'. From my understanding, this means that the left value is required/mandatory for the editable and disabled states. I have consulted the designer about this in Figma.
There's a high probability that my understanding of the above sentence might be incorrect. But, just want to let you know this. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JunSong-SH I have not thought about the behavior you mentioned above. Let's wait for the designer to clarify the behavior.

}
}
if configuration.showsValueLabel, !self.getReadOnly(configuration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Now, I understand the meaning of valueLabel and reviewCountLabel you always mentioned during our discussion But, for me, I would think it is the value concept for displaying on left and right. And, I feel it is not very straightforward. For example, here, if App team want to customize the value displayed on the right, they must to know when they should set the value for one of 'ratingValueFormat', 'averageRatingFormat', 'reviewCountFormat' and 'reviewCountCeilingFormat'.

For me, I'd like to use more simple or straightforward logic on UIKit: To use two 'showXXXLabel' bool flag to control label display and use two 'XXXLabelFormat' for customization whatever we call it 'leftLabel/leadingLabel/valueLabel' or 'rightLabel/trailingLabel/reviewCountLabel'(Now, I use valueLabel and reviewCountLabel base on our discussion before). Absolutely, 'reviewCount' and 'reviewCountCeiling' were needed. Then, App team just to know there are two 'XXXLabelFormat' for customization and the default value for those two labels was that the label on left will use default formatted rating value or average rating value according to the style(confirming with designer about should display value for NON-readonly state). For the value of label on right, by default, to use '3 of 5' or '2.3 of 5' if there is no review count and use '9 review' or '8+ reviews' if there has reviewCount or reviewCount>reviewCountCeiling.

Certainly, I just want to let you know about the different between your API and mine. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JunSong-SH Thanks for letting me know the differences of the APIs. I understand your reasonings. However, I think it is better to have a meaning to the label instead of the left and right. What if the designer changing the position to both on the right in the future? Also, in the large font categories, the labels are on the top and bottom.

I think it is fine to have different APIs.

Copy link
Contributor

@JunSong-SH JunSong-SH left a comment

Choose a reason for hiding this comment

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

LGTM!

let diff = averageRating - CGFloat(i)
if diff < 0.3 {
items.append(RatingItem(isOn: false, isHalf: false))
} else if diff < 0.7 {
Copy link
Contributor

Choose a reason for hiding this comment

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

See FIORITECHE1-8222, web component use 1.0-1.2 -> 1, 1.3-1.7 -> 1.5 and 1.8-1.9 -> 2. So, here, shouldn't diff <= 0.7 or diff < 0.8?

Copy link
Contributor Author

@janhuachu janhuachu Sep 9, 2024

Choose a reason for hiding this comment

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

Yes, you're right. I'll change it. Actually, I think use half star for 0.25 to 0.75 is more reasonable, since it is a Float. I'll check with the designer. Let's merge this code first and will change later with the changes needed for large text font.

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _HalfStarImageComponent {
//// The image to be used for "half" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OffStarImageComponent {
//// The image to be used for "Off" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OnStarImageComponent {
/// The image to be used for "On" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _HalfStarImageComponent {
//// The image to be used for "half" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OffStarImageComponent {
//// The image to be used for "Off" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OnStarImageComponent {
/// The image to be used for "On" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _HalfStarImageComponent {
//// The image to be used for "half" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OffStarImageComponent {
//// The image to be used for "Off" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OnStarImageComponent {
/// The image to be used for "On" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _HalfStarImageComponent {
//// The image to be used for "half" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OffStarImageComponent {
//// The image to be used for "Off" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OnStarImageComponent {
/// The image to be used for "On" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _HalfStarImageComponent {
//// The image to be used for "half" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OffStarImageComponent {
//// The image to be used for "Off" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OnStarImageComponent {
/// The image to be used for "On" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _HalfStarImageComponent {
//// The image to be used for "half" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OffStarImageComponent {
//// The image to be used for "Off" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

// sourcery: BaseComponent
// sourcery: importFrameworks = ["FioriThemeManager"]
protocol _OnStarImageComponent {
/// The image to be used for "On" rating star.
Copy link

Choose a reason for hiding this comment

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

Orphaned Doc Comment Violation: A doc comment should be attached to a declaration. (orphaned_doc_comment)

@janhuachu janhuachu merged commit eec8d9c into SAP:main Sep 12, 2024
12 checks passed
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