@@ -12,19 +12,17 @@ import 'package:flutter/material.dart';
1212import 'package:flutter_app/bootstrap/extensions.dart' ;
1313import 'package:flutter_app/resources/pages/shopify/product_detail_page.dart' ;
1414import 'package:flutter_app/resources/widgets/safearea_widget.dart' ;
15+ import 'package:woosignal_shopify_api/models/product.dart' ;
1516import '/bootstrap/helpers.dart' ;
1617import '/resources/widgets/cached_image_widget.dart' ;
1718import 'package:nylo_framework/nylo_framework.dart' ;
18- import 'package:woosignal_shopify_api/models/response/shopify_product_response.dart' ;
1919
2020class WishListPageWidget extends NyStatefulWidget {
2121 static String path = "/wishlist" ;
2222 WishListPageWidget () : super (path, child: _WishListPageWidgetState ());
2323}
2424
2525class _WishListPageWidgetState extends NyState <WishListPageWidget > {
26- bool ? hasNextPage = true ;
27- String ? endCursor;
2826
2927 @override
3028 Widget build (BuildContext context) {
@@ -34,74 +32,77 @@ class _WishListPageWidgetState extends NyState<WishListPageWidget> {
3432 title: Text (trans ("Wishlist" )),
3533 ),
3634 body: SafeAreaWidget (
37- child: NyPullToRefresh .grid (
38- crossAxisCount: 1 ,
39- mainAxisSpacing: 20 ,
40- data: (page) async {
41- if (hasNextPage == false ) return [];
35+ child: NyListView .separated (
36+ separatorBuilder: (context, index) => Divider (
37+ height: 1 ,
38+ color: Colors .grey.shade100,
39+ ),
40+ data: () async {
4241 List <String > favouriteProducts = await getWishlistProducts ();
43- ShopifyProductResponse ? shopifyProductResponse =
44- await (appWooSignalShopify (
45- (api) => api.getProductsJson (ids: favouriteProducts.map ((e) => int .parse (e)).toList ())));
46- if (shopifyProductResponse? .pageInfo? .hasNextPage != true ) {
47- hasNextPage = false ;
42+ if (favouriteProducts.isEmpty) {
43+ return [];
4844 }
49- endCursor = shopifyProductResponse? .pageInfo? .endCursor;
50- return shopifyProductResponse? .products ?? [];
45+ List <Product >? products =
46+ await (appWooSignalShopify (
47+ (api) => api.getProductsRestApi (ids: favouriteProducts.map ((e) => int .parse (e)).toList ())));
48+ return products;
5149 },
5250 child: (context, product) {
53- product as ShopifyProduct ;
51+ product as Product ;
5452 return Container (
53+ height: 160 ,
54+ margin: EdgeInsets .symmetric (vertical: 16 ),
5555 child: Row (
5656 children: [
5757 Container (
5858 child: ClipRRect (
5959 borderRadius: BorderRadius .circular (16 ),
6060 child: CachedImageWidget (
61- image: (product.featuredImage? .url != null
62- ? product.featuredImage! .url
63- : getEnv ("PRODUCT_PLACEHOLDER_IMAGE" )),
64- fit: BoxFit .cover,
65- width: double .infinity,
66- ),
61+ image: product.image? .src ?? getEnv ("PRODUCT_PLACEHOLDER_IMAGE" ),
62+ fit: BoxFit .cover,
63+ width: double .infinity,
64+ ),
6765 ),
68- width: MediaQuery .of (context).size.width / 4 ,
66+ width: MediaQuery .of (context).size.width / 3.5 ,
67+ height: 160 ,
6968 ).paddingOnly (right: 8 ),
7069 Expanded (
7170 child: Container (
7271 child: Column (
7372 crossAxisAlignment: CrossAxisAlignment .start,
74- mainAxisAlignment: MainAxisAlignment .center ,
73+ mainAxisAlignment: MainAxisAlignment .spaceAround ,
7574 children: [
75+ Row (
76+ crossAxisAlignment: CrossAxisAlignment .center,
77+ mainAxisAlignment: MainAxisAlignment .end,
78+ children: [
79+ IconButton (
80+ alignment: Alignment .topRight,
81+ icon: Icon (
82+ Icons .favorite,
83+ color: Colors .red,
84+ ),
85+ onPressed: () => _removeFromWishlist (product.id.toString ()),
86+ ),
87+ ],
88+ ),
7689 Text (
7790 product.title ?? "" ,
78- style: TextStyle (fontWeight : FontWeight .bold) ,
91+ style: textTheme.headlineSmall ,
7992 maxLines: 2 ,
8093 overflow: TextOverflow .ellipsis,
8194 ),
8295 Text (
83- product.priceRange? .minVariantPrice? .amount
84- .toMoney () ??
85- "" ,
86- ),
96+ product.price.toMoney (),
97+ style: textTheme.bodyLarge,
98+ ).fontWeightBold ().paddingOnly (top: 14 ),
8799 ],
88100 ),
89101 ),
90102 ),
91- Container (
92- width: MediaQuery .of (context).size.width / 5 ,
93- alignment: Alignment .center,
94- child: IconButton (
95- icon: Icon (
96- Icons .favorite,
97- color: Colors .red,
98- ),
99- onPressed: () => _removeFromWishlist (product),
100- ),
101- )
102103 ],
103104 ),
104- ).onTapRoute (ProductDetailPage .path, data: product.uId );
105+ ).onTapRoute (ProductDetailPage .path, data: product.id );
105106 },
106107 empty: Center (
107108 child: Column (
@@ -128,8 +129,8 @@ class _WishListPageWidgetState extends NyState<WishListPageWidget> {
128129 );
129130 }
130131
131- _removeFromWishlist (ShopifyProduct product ) async {
132- await removeWishlistProduct (productId: product.id ?? "" );
132+ _removeFromWishlist (String productId ) async {
133+ await removeWishlistProduct (productId: productId );
133134 showToastNotification (
134135 context,
135136 title: trans ('Success' ),
0 commit comments