Disable scroll glow in product detail

This commit is contained in:
Moe Poi ~ 2022-04-27 17:28:20 +07:00
parent 4218c0cf85
commit 5d89ca319a
2 changed files with 71 additions and 58 deletions

View file

@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:nekoya_flutter/api/api.dart';
import 'package:nekoya_flutter/data/cart.dart';
import 'package:nekoya_flutter/utils/utils.dart';
Widget makeDismissible({required context, required Widget child}) => GestureDetector(
behavior: HitTestBehavior.opaque,
@ -33,68 +34,71 @@ Widget productDetail(context, id) {
borderRadius: BorderRadius.vertical(top: Radius.circular(20))
),
padding: const EdgeInsets.all(16),
child: ListView(
controller: controller,
children: [
CachedNetworkImage(
imageUrl: 'https://nekoya.moe.team/img/' + data[0]['IMAGE'],
placeholder: (context, url) =>
const CircularProgressIndicator(
color: Color(0xff8B0000),
child: ScrollConfiguration(
behavior: HideScrollGlow(),
child: ListView(
controller: controller,
children: [
CachedNetworkImage(
imageUrl: 'https://nekoya.moe.team/img/' + data[0]['IMAGE'],
placeholder: (context, url) =>
const CircularProgressIndicator(
color: Color(0xff8B0000),
),
errorWidget: (context, url, error) => Image.asset('assets/image-error.webp'),
fadeOutDuration: const Duration(milliseconds: 5),
imageBuilder: (context, imageProvider) => Container(
margin: const EdgeInsets.all(5.0),
width: 300,
height: 300,
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider, fit: BoxFit.cover)),
),
),
errorWidget: (context, url, error) => Image.asset('assets/image-error.webp'),
fadeOutDuration: const Duration(milliseconds: 5),
imageBuilder: (context, imageProvider) => Container(
margin: const EdgeInsets.all(5.0),
width: 300,
height: 300,
Text(data[0]['TITLE'], style: const TextStyle(color: Colors.white, fontSize: 30.0, fontWeight: FontWeight.w700),),
const SizedBox(height: 15.0),
Text(data[0]['DESCRIPTION'], style: const TextStyle(color: Colors.white, fontSize: 18.0),),
const SizedBox(height: 15.0),
Text('Price : ' + data[0]['PRICE'].toString(), style: const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.w500),),
Text('Stock : ' + data[0]['STOCK'].toString(), style: const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.w500),),
Text('Size : ' + data[0]['SIZE'], style: const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.w500),),
const SizedBox(height: 30.0),
Tooltip(
key: _cartToolTipKey,
triggerMode: TooltipTriggerMode.manual,
showDuration: const Duration(seconds: 3),
waitDuration: const Duration(seconds: 3),
message: 'Successfully added to Cart ~',
padding: const EdgeInsets.all(30),
margin: const EdgeInsets.only(top: 30, left:30,right: 30),
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider, fit: BoxFit.cover)),
),
),
Text(data[0]['TITLE'], style: const TextStyle(color: Colors.white, fontSize: 30.0, fontWeight: FontWeight.w700),),
const SizedBox(height: 15.0),
Text(data[0]['DESCRIPTION'], style: const TextStyle(color: Colors.white, fontSize: 18.0),),
const SizedBox(height: 15.0),
Text('Price : ' + data[0]['PRICE'].toString(), style: const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.w500),),
Text('Stock : ' + data[0]['STOCK'].toString(), style: const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.w500),),
Text('Size : ' + data[0]['SIZE'], style: const TextStyle(color: Colors.white, fontSize: 18.0, fontWeight: FontWeight.w500),),
const SizedBox(height: 30.0),
Tooltip(
key: _cartToolTipKey,
triggerMode: TooltipTriggerMode.manual,
showDuration: const Duration(seconds: 3),
waitDuration: const Duration(seconds: 3),
message: 'Successfully added to Cart ~',
padding: const EdgeInsets.all(30),
margin: const EdgeInsets.only(top: 30, left:30,right: 30),
decoration: BoxDecoration(
color: const Color(0xff212226),
borderRadius: BorderRadius.circular(22)),
textStyle: const TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,
color: Colors.white),
child: ElevatedButton.icon(
onPressed: (){
addToCart(id);
final dynamic _cartToolTip = _cartToolTipKey.currentState;
_cartToolTip.ensureTooltipVisible();
},
icon: const Icon(Icons.add_shopping_cart),
label: const Text('Add to Cart', style: TextStyle(color: Colors.white, fontSize: 18.0),),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(const Color(0xff8B0000)),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0)
color: const Color(0xff212226),
borderRadius: BorderRadius.circular(22)),
textStyle: const TextStyle(
fontSize: 15,
fontStyle: FontStyle.italic,
color: Colors.white),
child: ElevatedButton.icon(
onPressed: (){
addToCart(id);
final dynamic _cartToolTip = _cartToolTipKey.currentState;
_cartToolTip.ensureTooltipVisible();
},
icon: const Icon(Icons.add_shopping_cart),
label: const Text('Add to Cart', style: TextStyle(color: Colors.white, fontSize: 18.0),),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(const Color(0xff8B0000)),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0)
)
)
)
)
),
)
],
),
)
],
),
)
);
}

9
lib/utils/utils.dart Normal file
View file

@ -0,0 +1,9 @@
import 'package:flutter/material.dart';
class HideScrollGlow extends ScrollBehavior {
@override
Widget buildOverscrollIndicator(
BuildContext context, Widget child, ScrollableDetails details) {
return child;
}
}