Skip to content

Commit

Permalink
Code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
sinasystem committed Jul 4, 2022
1 parent 20a95e4 commit e545bbf
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
uses: ncipollo/release-action@v1
with:
artifacts: "build/app/outputs/apk/release/app-release.apk"
tag: v2.0.3
tag: v2.0.4
token: ${{ secrets.TOKEN }}
10 changes: 5 additions & 5 deletions lib/core/app_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AppData {
isFavorite: false,
title: 'Comhar All-in-One Standing Desk Glass',
description: dummyText,
price: '\$469.99',
price: 469.99,
score: 3.5,
images: [
AppAsset.comharStandingDesk1,
Expand All @@ -37,7 +37,7 @@ class AppData {
quantity: 1,
title: 'Ergonomic Gaming Desk with Mouse Pad',
description: dummyText,
price: '\$299.99',
price: 299.99,
score: 4.5,
images: [
AppAsset.ergonomicGamingDesk1,
Expand All @@ -56,7 +56,7 @@ class AppData {
isFavorite: false,
title: 'Kana Pro Bamboo Standing Desk',
description: dummyText,
price: '\$659.99',
price: 659.99,
score: 3.0,
images: [
AppAsset.kanaBambooDesk1,
Expand All @@ -76,7 +76,7 @@ class AppData {
isFavorite: false,
title: 'Soutien Ergonomic Office Chair',
description: dummyText,
price: '\$349.99',
price: 349.99,
score: 2.5,
images: [
AppAsset.soutienOfficeChair1,
Expand All @@ -96,7 +96,7 @@ class AppData {
isFavorite: false,
title: 'Theodore Standing Desk',
description: dummyText,
price: '\$499.99',
price: 499.99,
score: 2.8,
images: [
AppAsset.theodoreStandingDesk1,
Expand Down
4 changes: 0 additions & 4 deletions lib/core/app_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ extension StringExtension on String {
return "${substring(0, 15)}...";
}
}

double get dropSign {
return double.parse(replaceAll("\$", ""));
}
}


Expand Down
2 changes: 1 addition & 1 deletion lib/src/controller/office_furniture_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class OfficeFurnitureController extends GetxController {
calculateTotalPrice() {
totalPrice.value = 0;
for (var element in cartFurniture) {
totalPrice.value += element.quantity * element.price.dropSign;
totalPrice.value += element.quantity * element.price;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/furniture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:office_furniture_store/src/model/furniture_color.dart';
class Furniture {
String title;
String description;
String price;
double price;
int quantity;
double score;
List<String> images;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/screen/office_furniture_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OfficeFurnitureDetailScreen extends StatelessWidget {
color: Colors.black45, fontWeight: FontWeight.bold)),
),
const SizedBox(height: 5),
FittedBox(child: Text(furniture.price, style: h2Style))
FittedBox(child: Text("\$${furniture.price}", style: h2Style))
],
),
ElevatedButton(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/screen/office_furniture_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class OfficeFurnitureListScreen extends StatelessWidget {

@override
Widget build(BuildContext context) {
Future<Widget?> _navigate(Furniture furniture, int index) {
Future<Widget?> _navigate(Furniture furniture) {
return Navigator.push(
context,
PageRouteBuilder(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/widget/cart_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CartListView extends StatelessWidget {
children: [
Text(furniture.title.addOverFlow, style: h4Style),
const SizedBox(height: 5),
Text(furniture.price, style: h2Style),
Text("\$${furniture.price}", style: h2Style),
const SizedBox(height: 5),
Row(
children: [
Expand Down
7 changes: 4 additions & 3 deletions lib/src/view/widget/furniture_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '../../model/furniture.dart';

class FurnitureListView extends StatelessWidget {
final bool isHorizontal;
final Function(Furniture furniture, int index)? onTap;
final Function(Furniture furniture)? onTap;
final List<Furniture> furnitureList;

const FurnitureListView(
Expand Down Expand Up @@ -77,7 +77,7 @@ class FurnitureListView extends StatelessWidget {
);

return GestureDetector(
onTap: () => onTap?.call(furniture, index),
onTap: () => onTap?.call(furniture),
child: widget,
);
}
Expand All @@ -103,10 +103,11 @@ class FurnitureListView extends StatelessWidget {
)
: ListView.builder(
shrinkWrap: true,
reverse: true,
physics: const ClampingScrollPhysics(),
itemCount: furnitureList.length,
itemBuilder: (_, index) {
Furniture furniture = furnitureList.reversed.toList()[index];
Furniture furniture = furnitureList[index];
return Padding(
padding: const EdgeInsets.only(bottom: 15, top: 10),
child: _listViewItem(furniture, index),
Expand Down

0 comments on commit e545bbf

Please sign in to comment.