forked from yaso_meth/mih-project
fix overflow issue
This commit is contained in:
@@ -226,25 +226,15 @@ class _MihCardsState extends State<MihCards> {
|
||||
Widget build(BuildContext context) {
|
||||
return MihAppToolBody(
|
||||
borderOn: true,
|
||||
bodyItem: bodyItem(),
|
||||
bodyItem: getBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget bodyItem() {
|
||||
return FutureBuilder(
|
||||
future: cardList,
|
||||
builder: (context, snapshot) {
|
||||
//print(snapshot.connectionState);
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
listOfCards = snapshot.data!;
|
||||
searchShop();
|
||||
//print(listOfCards);
|
||||
return Column(
|
||||
Widget getBody() {
|
||||
return Stack(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -260,20 +250,8 @@ class _MihCardsState extends State<MihCards> {
|
||||
.secondaryColor(),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add_card),
|
||||
alignment: Alignment.topRight,
|
||||
color:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
onPressed: () {
|
||||
addCardWindow(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
// Divider(
|
||||
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
// ),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@@ -304,24 +282,57 @@ class _MihCardsState extends State<MihCards> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: searchShopName,
|
||||
builder: (BuildContext context, List<MIHLoyaltyCard> value,
|
||||
Widget? child) {
|
||||
return BuildLoyaltyCardList(
|
||||
cardList: searchShopName.value,
|
||||
signedInUser: widget.signedInUser,
|
||||
);
|
||||
FutureBuilder(
|
||||
future: cardList,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
listOfCards = snapshot.data!;
|
||||
searchShop();
|
||||
return ValueListenableBuilder(
|
||||
valueListenable: searchShopName,
|
||||
builder: (BuildContext context,
|
||||
List<MIHLoyaltyCard> value, Widget? child) {
|
||||
return BuildLoyaltyCardList(
|
||||
cardList: searchShopName.value,
|
||||
signedInUser: widget.signedInUser,
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return const Center(
|
||||
child: Text("Error Loading Loyalty Cards"),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Center(
|
||||
child: Text("Error Loading Loyalty Cards"),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(50),
|
||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
),
|
||||
child: IconButton(
|
||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
onPressed: () {
|
||||
addCardWindow(context);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.add_card,
|
||||
size: 50,
|
||||
),
|
||||
),
|
||||
))
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,32 +143,35 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
// final double width = size.width;
|
||||
//final double height = size.height;
|
||||
if (widget.cardList.isNotEmpty) {
|
||||
return GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.only(
|
||||
left: getHorizontalPaddingSize(size),
|
||||
right: getHorizontalPaddingSize(size),
|
||||
//bottom: height / 5,
|
||||
//top: 20,
|
||||
return SizedBox(
|
||||
height: size.height,
|
||||
child: GridView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.only(
|
||||
left: getHorizontalPaddingSize(size),
|
||||
right: getHorizontalPaddingSize(size),
|
||||
//bottom: height / 5,
|
||||
//top: 20,
|
||||
),
|
||||
// physics: ,
|
||||
// shrinkWrap: true,
|
||||
itemCount: widget.cardList.length,
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 0,
|
||||
crossAxisSpacing: 10,
|
||||
maxCrossAxisExtent: 200,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
return GestureDetector(
|
||||
child: MihCardDisplay(
|
||||
shopName: widget.cardList[index].shop_name, height: 100),
|
||||
onTap: () {
|
||||
viewCardWindow(index);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
// physics: ,
|
||||
// shrinkWrap: true,
|
||||
itemCount: widget.cardList.length,
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 0,
|
||||
crossAxisSpacing: 10,
|
||||
maxCrossAxisExtent: 175,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
return GestureDetector(
|
||||
child: MihCardDisplay(
|
||||
shopName: widget.cardList[index].shop_name, height: 100),
|
||||
onTap: () {
|
||||
viewCardWindow(index);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
// return ListView.separated(
|
||||
// shrinkWrap: true,
|
||||
@@ -191,13 +194,17 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||
// },
|
||||
// );
|
||||
} else {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.only(top: 25.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No Cards Available",
|
||||
style: TextStyle(fontSize: 25, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 25.0),
|
||||
child: SizedBox(
|
||||
height: size.height,
|
||||
child: const Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Text(
|
||||
"No Cards Available",
|
||||
style: TextStyle(fontSize: 25, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -17,100 +17,43 @@ class _MihCardDisplayState extends State<MihCardDisplay> {
|
||||
Widget displayLoyaltyCard() {
|
||||
switch (widget.shopName.toLowerCase()) {
|
||||
case "best before":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/best_before.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/best_before.png');
|
||||
case "checkers":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/checkers.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/checkers.png');
|
||||
case "clicks":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/Clicks_Club.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/Clicks_Club.png');
|
||||
case "cotton:on":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/cotton_on_perks.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/cotton_on_perks.png');
|
||||
case "dis-chem":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/dischem_benefit.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/dischem_benefit.png');
|
||||
case "pick n pay":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/pnp_smart.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/pnp_smart.png');
|
||||
case "shoprite":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/shoprite.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/shoprite.png');
|
||||
case "spar":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/spar_rewards.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/spar_rewards.png');
|
||||
case "woolworths":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/wrewards.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/wrewards.png');
|
||||
case "makro":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/makro.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/makro.png');
|
||||
case "fresh stop":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/fresh_stop.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/fresh_stop.png');
|
||||
case "panarottis":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/panarottis.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/panarottis.png');
|
||||
case "shell":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/Shell.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/Shell.png');
|
||||
case "edgars":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/edgars.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/edgars.png');
|
||||
case "jet":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/jet.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/jet.png');
|
||||
case "spur":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/spur.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/spur.png');
|
||||
case "infinity":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/infinity.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/infinity.png');
|
||||
case "eskom":
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: Image.asset('images/loyalty_cards/eskom.png'),
|
||||
);
|
||||
return Image.asset('images/loyalty_cards/eskom.png');
|
||||
default:
|
||||
return SizedBox(
|
||||
height: widget.height,
|
||||
child: const Placeholder(),
|
||||
);
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user