Use reviews Previewwidget to display rating levels in Ubuntu scope

Source: Internet
Author: User

We can use reviews Previewwidget to show our results. For the review, for example, if it is a 5-star rating, we can show 5 stars indicating the highest level of customer acceptance of a product.


To see our API's connection, we can see the following code:


{
    previewwidget W1 ("Summary", "reviews");
    W1.add_attribute_value ("Rating-icon-empty", Variant ("File:///tmp/star-empty.svg"));
    W1.add_attribute_value ("Rating-icon-full", Variant ("File:///tmp/star-full.svg"));
    Variantbuilder Builder;
    Builder.add_tuple ({
        {"author", Variant ("John Doe")},
        {"rating", Variant (3)}
    );
    Builder.add_tuple ({
        {"author", Variant ("Mr Smith")},
        {"rating", Variant (5)}
    );
    W1.add_attribute_value ("Reviews", Builder.end ());
    ...
}

Although the use of their own definition of the picture "Rating-icon-empty" and "Rating-icon-full", but I think it is generally not recommended to use although it can be customized. The reason is that we have to strictly follow the Ubuntu standard icon to design their own pictures, so that the display is correct.


In combination with the above code, we use the following code in our own code:


    Previewwidget Review ("reviews", "reviews");
    Variantbuilder Builder;
    Builder.add_tuple ({
                          {"author", Variant ("John Doe")},
                          {"Review", Variant ("Very good")},
                          {"rating", Variant (3.5)}
                      });
    Builder.add_tuple ({
                          {"author", Variant ("Mr Smith")},
                          {"Review", Variant ("Very poor")},
                          {"rating", Variant (5)}
                      });
    Review.add_attribute_value ("Reviews", Builder.end ());
    Widgets.emplace_back (review);

Here we have added an item "review" to denote a textual evaluation of a product. Here we do not use any custom images, which by default are used by the system itself.


To run our scope, the following is displayed:




The source code of the whole project is: Https://github.com/liu-xiao-guo/scopetemplates_review

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.