|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:hyper_effects/hyper_effects.dart'; |
| 3 | + |
| 4 | +class WindowsSettingsTransition extends StatefulWidget { |
| 5 | + const WindowsSettingsTransition({super.key}); |
| 6 | + |
| 7 | + @override |
| 8 | + State<WindowsSettingsTransition> createState() => |
| 9 | + _WindowsSettingsTransitionState(); |
| 10 | +} |
| 11 | + |
| 12 | +class _WindowsSettingsTransitionState extends State<WindowsSettingsTransition> { |
| 13 | + @override |
| 14 | + Widget build(BuildContext context) { |
| 15 | + return Center( |
| 16 | + child: GridView.builder( |
| 17 | + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( |
| 18 | + crossAxisCount: 3, |
| 19 | + crossAxisSpacing: 4, |
| 20 | + mainAxisSpacing: 4, |
| 21 | + ), |
| 22 | + padding: const EdgeInsets.all(8), |
| 23 | + itemBuilder: (context, i) => Stack( |
| 24 | + alignment: Alignment.center, |
| 25 | + children: [ |
| 26 | + Container( |
| 27 | + clipBehavior: Clip.antiAlias, |
| 28 | + decoration: const BoxDecoration( |
| 29 | + color: Color(0xFF404040), |
| 30 | + ), |
| 31 | + child: Transform.scale( |
| 32 | + scale: 2, |
| 33 | + child: Container( |
| 34 | + decoration: BoxDecoration( |
| 35 | + gradient: RadialGradient( |
| 36 | + focalRadius: 10000, |
| 37 | + colors: [ |
| 38 | + Colors.white.withOpacity(0.5), |
| 39 | + Colors.white.withOpacity(0), |
| 40 | + ], |
| 41 | + ), |
| 42 | + ), |
| 43 | + ), |
| 44 | + ).pointerTransition( |
| 45 | + transitionBetweenBounds: false, |
| 46 | + resetOnExitBounds: false, |
| 47 | + (context, child, event) => child |
| 48 | + .opacity( |
| 49 | + event.isInsideBounds ? 1 : 0, |
| 50 | + ) |
| 51 | + .animate( |
| 52 | + toggle: event.isInsideBounds, |
| 53 | + duration: const Duration(milliseconds: 150), |
| 54 | + ) |
| 55 | + .translateXY( |
| 56 | + event.valueOffset.dx / 2, |
| 57 | + event.valueOffset.dy / 2, |
| 58 | + fractional: true, |
| 59 | + ), |
| 60 | + ), |
| 61 | + ), |
| 62 | + Container( |
| 63 | + margin: const EdgeInsets.all(1), |
| 64 | + decoration: const BoxDecoration( |
| 65 | + color: Color(0xFF404040), |
| 66 | + ), |
| 67 | + clipBehavior: Clip.antiAlias, |
| 68 | + child: Transform.scale( |
| 69 | + scale: 2, |
| 70 | + child: Container( |
| 71 | + decoration: BoxDecoration( |
| 72 | + gradient: RadialGradient( |
| 73 | + colors: [ |
| 74 | + Colors.white.withOpacity(0.2), |
| 75 | + Colors.white.withOpacity(0), |
| 76 | + ], |
| 77 | + ), |
| 78 | + ), |
| 79 | + ), |
| 80 | + ).pointerTransition( |
| 81 | + transitionBetweenBounds: false, |
| 82 | + resetOnExitBounds: false, |
| 83 | + (context, child, event) => child |
| 84 | + .opacity( |
| 85 | + event.isInsideBounds ? 1 : 0, |
| 86 | + ) |
| 87 | + .animate( |
| 88 | + toggle: event.isInsideBounds, |
| 89 | + duration: const Duration(milliseconds: 150), |
| 90 | + ) |
| 91 | + .translateXY( |
| 92 | + event.valueOffset.dx / 2, |
| 93 | + event.valueOffset.dy / 2, |
| 94 | + fractional: true, |
| 95 | + ), |
| 96 | + ), |
| 97 | + ), |
| 98 | + Container( |
| 99 | + width: 56, |
| 100 | + height: 56, |
| 101 | + alignment: Alignment.center, |
| 102 | + decoration: BoxDecoration( |
| 103 | + color: Colors.blue, |
| 104 | + borderRadius: BorderRadius.circular(4), |
| 105 | + ), |
| 106 | + child: Text( |
| 107 | + '$i', |
| 108 | + style: const TextStyle( |
| 109 | + fontSize: 32, |
| 110 | + color: Colors.white, |
| 111 | + ), |
| 112 | + ), |
| 113 | + ), |
| 114 | + ], |
| 115 | + ), |
| 116 | + ), |
| 117 | + ); |
| 118 | + } |
| 119 | +} |
0 commit comments