Skip to content

Commit

Permalink
Add FontAwesomeIcon for star rating
Browse files Browse the repository at this point in the history
  • Loading branch information
SinaSys committed Feb 22, 2024
1 parent 16147fd commit b66f859
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lib/src/view/screen/product_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:e_commerce_flutter/core/app_color.dart';
import 'package:e_commerce_flutter/src/model/product.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:e_commerce_flutter/src/view/widget/page_wrapper.dart';
import 'package:e_commerce_flutter/src/view/widget/carousel_slider.dart';
import 'package:e_commerce_flutter/src/controller/product_controller.dart';
Expand Down Expand Up @@ -48,15 +49,17 @@ class ProductDetailScreen extends StatelessWidget {
RatingBar.builder(
initialRating: product.rating,
direction: Axis.horizontal,
itemBuilder: (_, __) => const Icon(Icons.star, color: Colors.amber),
itemBuilder: (_, __) => const FaIcon(
FontAwesomeIcons.solidStar,
color: Colors.amber,
),
onRatingUpdate: (_) {},
),
Text(
"(4500 Reviews)",
style: Theme.of(context)
.textTheme
.displaySmall
?.copyWith(fontWeight: FontWeight.w300),
style: Theme.of(context).textTheme.displaySmall?.copyWith(
fontWeight: FontWeight.w300,
),
)
],
);
Expand All @@ -74,11 +77,12 @@ class ProductDetailScreen extends StatelessWidget {
alignment: Alignment.center,
width: controller.isNominal(product) ? 40 : 70,
decoration: BoxDecoration(
color: controller.sizeType(product)[index].isSelected == false
? Colors.white
: AppColor.lightOrange,
color: controller.sizeType(product)[index].isSelected == false ? Colors.white : AppColor.lightOrange,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Colors.grey, width: 0.4),
border: Border.all(
color: Colors.grey,
width: 0.4,
),
),
duration: const Duration(milliseconds: 300),
child: FittedBox(
Expand Down Expand Up @@ -126,9 +130,7 @@ class ProductDetailScreen extends StatelessWidget {
Row(
children: [
Text(
product.off != null
? "\$${product.off}"
: "\$${product.price}",
product.off != null ? "\$${product.off}" : "\$${product.price}",
style: Theme.of(context).textTheme.displayLarge,
),
const SizedBox(width: 3),
Expand All @@ -145,9 +147,7 @@ class ProductDetailScreen extends StatelessWidget {
),
const Spacer(),
Text(
product.isAvailable
? "Available in stock"
: "Not available",
product.isAvailable ? "Available in stock" : "Not available",
style: const TextStyle(fontWeight: FontWeight.w500),
)
],
Expand All @@ -170,9 +170,7 @@ class ProductDetailScreen extends StatelessWidget {
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: product.isAvailable
? () => controller.addToCart(product)
: null,
onPressed: product.isAvailable ? () => controller.addToCart(product) : null,
child: const Text("Add to cart"),
),
)
Expand Down

0 comments on commit b66f859

Please sign in to comment.