Add controller parameter to enable/disable button on cartbox
This commit is contained in:
parent
72fbe5f798
commit
0563e50b9a
2 changed files with 58 additions and 30 deletions
|
@ -2,8 +2,18 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CartBox extends StatefulWidget {
|
class CartBox extends StatefulWidget {
|
||||||
const CartBox({Key? key, required this.imageUrl, required this.title, required this.quantity, required this.plus, required this.minus, required this.remove}) : super(key: key);
|
const CartBox({
|
||||||
|
Key? key,
|
||||||
|
required this.controller,
|
||||||
|
required this.imageUrl,
|
||||||
|
required this.title,
|
||||||
|
required this.quantity,
|
||||||
|
required this.plus,
|
||||||
|
required this.minus,
|
||||||
|
required this.remove
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final bool controller;
|
||||||
final String imageUrl;
|
final String imageUrl;
|
||||||
final String title;
|
final String title;
|
||||||
final int quantity;
|
final int quantity;
|
||||||
|
@ -54,7 +64,7 @@ class _CartBoxState extends State<CartBox> {
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(left: 10.0, right: 10.0),
|
margin: const EdgeInsets.only(left:10.0, right: 10.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.title,
|
widget.title,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
@ -65,7 +75,7 @@ class _CartBoxState extends State<CartBox> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10,),
|
const SizedBox(height: 10,),
|
||||||
Row(
|
widget.controller == true ? Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
|
@ -94,6 +104,22 @@ class _CartBoxState extends State<CartBox> {
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
: Container(
|
||||||
|
margin: const EdgeInsets.only(left: 10.0, right: 10.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Quantity : ${widget.quantity.toString()}",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w400
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -38,6 +38,7 @@ class _CartState extends State<Cart> {
|
||||||
var productData = snapshotx.data;
|
var productData = snapshotx.data;
|
||||||
if (productData != null) {
|
if (productData != null) {
|
||||||
return CartBox(
|
return CartBox(
|
||||||
|
controller: true,
|
||||||
imageUrl: 'https://nekoya.moe.team/img/' + productData[0]['IMAGE'],
|
imageUrl: 'https://nekoya.moe.team/img/' + productData[0]['IMAGE'],
|
||||||
title: productData[0]['TITLE'],
|
title: productData[0]['TITLE'],
|
||||||
quantity: data[index]["quantity"],
|
quantity: data[index]["quantity"],
|
||||||
|
@ -64,6 +65,7 @@ class _CartState extends State<Cart> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return CartBox(
|
return CartBox(
|
||||||
|
controller: true,
|
||||||
imageUrl: 'https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp',
|
imageUrl: 'https://i.ibb.co/QJFLZC4/La-Darknesss-Portrait.webp',
|
||||||
title: 'Loading...',
|
title: 'Loading...',
|
||||||
quantity: 0,
|
quantity: 0,
|
||||||
|
|
Loading…
Reference in a new issue