Skip to content

Commit

Permalink
Merge pull request #10 from shaunhossain/check_out_screen
Browse files Browse the repository at this point in the history
Check out screen
  • Loading branch information
shaunhossain authored Jul 12, 2022
2 parents 808fe8b + a3ea011 commit a8248a4
Show file tree
Hide file tree
Showing 25 changed files with 1,200 additions and 393 deletions.
Binary file added assets/empty_cart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/empty_order.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/empty_wishlist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 10 additions & 11 deletions lib/db/cart_db_operation/cart_db_operation.dart
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
import 'dart:developer';

import 'package:platzi_fake_store/db/database_helper.dart';
import 'package:platzi_fake_store/model/product/product_item.dart';
import 'package:platzi_fake_store/db/db_model/add_cart_product.dart';

class CartDbOperation{
CartDbOperation._privateConstructor();

static final CartDbOperation instance = CartDbOperation._privateConstructor();
Future<List<ProductItem>> getAddCartProductsList({required int status}) async {
Future<List<AddCartProduct>> getAddCartProductsList() async {
final db = await DatabaseHelper.instance.database;
var products = await db.query('cartTable');
List<ProductItem> productsList = products.isNotEmpty
? products.map((c)=> ProductItem.fromJson(c)).toList()
List<AddCartProduct> productsList = products.isNotEmpty
? products.map((c)=> AddCartProduct.fromJson(c)).toList()
: [];
return productsList;
}

Future <int> addCart(ProductItem productItem) async {
Future <int> addCart(AddCartProduct addCartProductItem) async {
final db = await DatabaseHelper.instance.database;
return await db.insert('cartTable',productItem.toJson());
return await db.insert('cartTable',addCartProductItem.toJson());
}

Future<int> remove(int id) async {
final db = await DatabaseHelper.instance.database;
return await db.delete('cartTable',where: 'id = ?', whereArgs: [id]);
}

Future<int> update(ProductItem productItem) async{
Future<int> update(AddCartProduct addCartProductItem) async{
log('update called');
final db = await DatabaseHelper.instance.database;
return db.update('cartTable',productItem.toJson(),where: 'id =?',whereArgs: [productItem.id]);
return db.update('cartTable',addCartProductItem.toJson(),where: 'id =?',whereArgs: [addCartProductItem.id]);
}

Future<ProductItem?> getSingleAddCartProduct(int id) async{
Future<AddCartProduct?> getSingleAddCartProduct(int id) async{
final db = await DatabaseHelper.instance.database;
List<Map> maps = await db.query('cartTable',
where: 'id = ?',
whereArgs: [id]);
if (maps.length > 0) {
return ProductItem.fromJson(maps.first);
return AddCartProduct.fromJson(maps.first);
}
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/db/database_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class DatabaseHelper{
description TEXT NOT NULL,
category TEXT NOT NULL,
images TEXT NOT NULL,
color INTEGER NOT NULL,
size TEXT NOT NULL,
color TEXT NOT NULL,
quantity INTEGER NOT NULL,
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
Expand Down
55 changes: 55 additions & 0 deletions lib/db/db_model/add_cart_product.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class AddCartProduct{
AddCartProduct({
this.id,
required this.title,
required this.price,
required this.description,
required this.category,
required this.images,
required this.color,
required this.size,
required this.quantity,
required this.createdAt,
required this.updatedAt,
});

final int? id;
final String title;
final int price;
final String description;
final String category;
final String images;
final int color;
final String size;
final int quantity;
final String createdAt;
final String updatedAt;

factory AddCartProduct.fromJson(Map<dynamic, dynamic> json) => AddCartProduct(
id: json["id"],
title: json["title"],
price: json["price"],
description: json["description"],
category: json["category"],
images: json["images"],
color: json["color"],
size: json["size"],
quantity: json["quantity"],
createdAt: json["created_at"],
updatedAt: json["updated_at"],
);

Map<String, dynamic> toJson() => {
"id": id,
"title": title,
"price": price,
"description": description,
"category": category,
"images": images,
"color": color,
"size": size,
"quantity": quantity,
"created_at": createdAt,
"updated_at": updatedAt,
};
}
1 change: 1 addition & 0 deletions lib/view/components/navigator/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AppRoutes {
static const String specialOfferScreen = '/special-offer-screen';
static const String viewSingleCarouselScreen = '/view-single-carousel-screen';
static const String mostPopularScreen = '/most-popular-screen';
static const String checkoutScreen = '/checkout-screen';
static const String viewSingleCategoryScreen = '/view-single-category-screen';
static const String viewProductScreen = '/view-product-screen';

Expand Down
8 changes: 7 additions & 1 deletion lib/view/components/navigator/app_routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:platzi_fake_store/view/page/auth/sign_up_screen/sign_up_screen.d
import 'package:platzi_fake_store/view/page/auth/start_up_screen/start_up_binding/start_up_binding.dart';
import 'package:platzi_fake_store/view/page/auth/start_up_screen/start_up_screen.dart';
import 'package:platzi_fake_store/view/page/cart_screen/cart_screen.dart';
import 'package:platzi_fake_store/view/page/checkout_screen/checkout_binding/checkout_binding.dart';
import 'package:platzi_fake_store/view/page/checkout_screen/checkout_screen.dart';
import 'package:platzi_fake_store/view/page/edit_profile_screen/edit_profile_binding/edit_profile_binding.dart';
import 'package:platzi_fake_store/view/page/edit_profile_screen/edit_profile_screen.dart';
import 'package:platzi_fake_store/view/page/home_screen/home_screen.dart';
Expand All @@ -19,7 +21,6 @@ import 'package:platzi_fake_store/view/page/my_wishlist_screen/my_wishlist_scree
import 'package:platzi_fake_store/view/page/notification_screen/notification_binding/notification_binding.dart';
import 'package:platzi_fake_store/view/page/notification_screen/notification_screen.dart';
import 'package:platzi_fake_store/view/page/order_screen/order_screen.dart';
import 'package:platzi_fake_store/view/page/profile_screen/profile_binding/profile_binding.dart';
import 'package:platzi_fake_store/view/page/profile_screen/profile_screen.dart';
import 'package:platzi_fake_store/view/page/search_product_screen/search_product_binding/search_product_binding.dart';
import 'package:platzi_fake_store/view/page/search_product_screen/search_product_screen.dart';
Expand Down Expand Up @@ -133,6 +134,11 @@ class AppPages {
page: () => const WalletScreen(),
binding: MainBinding(),
transition: Transition.rightToLeft),
GetPage(
name: AppRoutes.checkoutScreen,
page: () => const CheckoutScreen(),
binding: CheckoutBinding(),
transition: Transition.rightToLeft),

];
}
32 changes: 32 additions & 0 deletions lib/view/components/widget/custom_empty_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:platzi_fake_store/utils/size_config.dart';
import 'package:platzi_fake_store/view/components/widget/custom_text_view.dart';

class CustomEmptyPage extends StatelessWidget {
const CustomEmptyPage({Key? key, required this.asset, required this.warningTitle, required this.warningDes}) : super(key: key);
final String asset;
final String warningTitle;
final String warningDes;

@override
Widget build(BuildContext context) {
return Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(asset,fit: BoxFit.scaleDown,),
CustomTextView(
text: warningTitle,
fontSize: SizeConfig.textScaleFactor! * 18,
fontWeight: FontWeight.w500,
color: Colors.black),
CustomTextView(
text: warningDes,
fontSize: SizeConfig.textScaleFactor! * 14,
fontWeight: FontWeight.w400,
color: Colors.grey),
],
));
}
}
Loading

0 comments on commit a8248a4

Please sign in to comment.