mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
improve mouse hover effects on click areas
This commit is contained in:
@@ -41,13 +41,29 @@ class AnimatedTapRegion extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AnimatedTapRegionState extends State<AnimatedTapRegion> {
|
class _AnimatedTapRegionState extends State<AnimatedTapRegion> {
|
||||||
|
bool isScaled = false;
|
||||||
|
|
||||||
bool isHovered = false;
|
bool isHovered = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MouseRegion(
|
return MouseRegion(
|
||||||
onEnter: (_) => setState(() => isHovered = true),
|
onEnter: (_) {
|
||||||
onExit: (_) => setState(() => isHovered = false),
|
isHovered = true;
|
||||||
|
if (!isScaled) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
if (isHovered) {
|
||||||
|
setState(() => isScaled = true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onExit: (_) {
|
||||||
|
isHovered = false;
|
||||||
|
if(isScaled) {
|
||||||
|
setState(() => isScaled = false);
|
||||||
|
}
|
||||||
|
},
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: widget.onTap,
|
onTap: widget.onTap,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
@@ -55,7 +71,7 @@ class _AnimatedTapRegionState extends State<AnimatedTapRegion> {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: AnimatedScale(
|
child: AnimatedScale(
|
||||||
duration: _fastAnimationDuration,
|
duration: _fastAnimationDuration,
|
||||||
scale: isHovered ? 1.1 : 1,
|
scale: isScaled ? 1.1 : 1,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@@ -264,7 +264,8 @@ class _HistoryState extends State<_History> {
|
|||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: history.length,
|
itemCount: history.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return InkWell(
|
return AnimatedTapRegion(
|
||||||
|
borderRadius: 8,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.to(
|
context.to(
|
||||||
() => ComicPage(
|
() => ComicPage(
|
||||||
@@ -273,11 +274,9 @@ class _HistoryState extends State<_History> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 92,
|
width: 92,
|
||||||
height: 114,
|
height: 114,
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
@@ -293,7 +292,7 @@ class _HistoryState extends State<_History> {
|
|||||||
filterQuality: FilterQuality.medium,
|
filterQuality: FilterQuality.medium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
).paddingHorizontal(8);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
).paddingHorizontal(8).paddingBottom(16),
|
).paddingHorizontal(8).paddingBottom(16),
|
||||||
@@ -386,15 +385,14 @@ class _LocalState extends State<_Local> {
|
|||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: local.length,
|
itemCount: local.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return InkWell(
|
return AnimatedTapRegion(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
local[index].read();
|
local[index].read();
|
||||||
},
|
},
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: 8,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 92,
|
width: 92,
|
||||||
height: 114,
|
height: 114,
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
@@ -412,7 +410,7 @@ class _LocalState extends State<_Local> {
|
|||||||
filterQuality: FilterQuality.medium,
|
filterQuality: FilterQuality.medium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
).paddingHorizontal(8);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
).paddingHorizontal(8),
|
).paddingHorizontal(8),
|
||||||
|
Reference in New Issue
Block a user