|
| 1 | +import 'package:bc_golden_plugin/bc_golden_plugin.dart'; |
| 2 | +import 'package:flutter/material.dart'; |
| 3 | + |
| 4 | +void main() { |
| 5 | + // Test de ejemplo simple para demostrar la funcionalidad |
| 6 | + BcGoldenCapture.animation( |
| 7 | + 'Simple fade animation test', |
| 8 | + const SimpleFadeAnimation(), |
| 9 | + GoldenAnimationConfig( |
| 10 | + testName: 'simple_fade', |
| 11 | + totalDuration: const Duration(milliseconds: 500), |
| 12 | + animationSteps: const [ |
| 13 | + GoldenAnimationStep( |
| 14 | + timestamp: Duration.zero, |
| 15 | + frameName: 'start_invisible', |
| 16 | + ), |
| 17 | + GoldenAnimationStep( |
| 18 | + timestamp: Duration(milliseconds: 290), |
| 19 | + frameName: 'half_visible', |
| 20 | + ), |
| 21 | + GoldenAnimationStep( |
| 22 | + timestamp: Duration(milliseconds: 320), |
| 23 | + frameName: 'fully_visible', |
| 24 | + ), |
| 25 | + GoldenAnimationStep( |
| 26 | + timestamp: Duration(milliseconds: 340), |
| 27 | + frameName: 'fully_visible', |
| 28 | + ), |
| 29 | + GoldenAnimationStep( |
| 30 | + timestamp: Duration(milliseconds: 360), |
| 31 | + frameName: 'fully_visible', |
| 32 | + ), |
| 33 | + GoldenAnimationStep( |
| 34 | + timestamp: Duration(milliseconds: 380), |
| 35 | + frameName: 'fully_visible', |
| 36 | + ), |
| 37 | + GoldenAnimationStep( |
| 38 | + timestamp: Duration(milliseconds: 400), |
| 39 | + frameName: 'fully_visible', |
| 40 | + ), |
| 41 | + GoldenAnimationStep( |
| 42 | + timestamp: Duration(milliseconds: 420), |
| 43 | + frameName: 'fully_visible', |
| 44 | + ), |
| 45 | + GoldenAnimationStep( |
| 46 | + timestamp: Duration(milliseconds: 440), |
| 47 | + frameName: 'fully_visible', |
| 48 | + ), |
| 49 | + GoldenAnimationStep( |
| 50 | + timestamp: Duration(milliseconds: 460), |
| 51 | + frameName: 'fully_visible', |
| 52 | + ), |
| 53 | + GoldenAnimationStep( |
| 54 | + timestamp: Duration(milliseconds: 480), |
| 55 | + frameName: 'fully_visible', |
| 56 | + ), |
| 57 | + GoldenAnimationStep( |
| 58 | + timestamp: Duration(milliseconds: 500), |
| 59 | + frameName: 'fully_visible', |
| 60 | + ), |
| 61 | + ], |
| 62 | + layoutType: CaptureLayoutType.horizontal, |
| 63 | + spacing: 20.0, |
| 64 | + showTimelineLabels: true, |
| 65 | + device: GoldenDeviceData.iPhone13, |
| 66 | + ), |
| 67 | + ); |
| 68 | + |
| 69 | + BcGoldenCapture.animation( |
| 70 | + 'Loading spinner rotation', |
| 71 | + const CircularProgressIndicator(), |
| 72 | + const GoldenAnimationConfig( |
| 73 | + testName: 'spinner_rotation', |
| 74 | + totalDuration: Duration(milliseconds: 1000), |
| 75 | + showTimelineLabels: true, |
| 76 | + animationSteps: [ |
| 77 | + GoldenAnimationStep( |
| 78 | + timestamp: Duration.zero, |
| 79 | + frameName: '0_degrees', |
| 80 | + ), |
| 81 | + GoldenAnimationStep( |
| 82 | + timestamp: Duration(milliseconds: 250), |
| 83 | + frameName: '90_degrees', |
| 84 | + ), |
| 85 | + GoldenAnimationStep( |
| 86 | + timestamp: Duration(milliseconds: 500), |
| 87 | + frameName: '180_degrees', |
| 88 | + ), |
| 89 | + GoldenAnimationStep( |
| 90 | + timestamp: Duration(milliseconds: 750), |
| 91 | + frameName: '270_degrees', |
| 92 | + ), |
| 93 | + ], // Mismos pasos |
| 94 | + layoutType: CaptureLayoutType.grid, |
| 95 | + maxScreensPerRow: 2, |
| 96 | + ), |
| 97 | + ); |
| 98 | +} |
| 99 | + |
| 100 | +/// Widget de ejemplo simple con animación de fade |
| 101 | +class SimpleFadeAnimation extends StatefulWidget { |
| 102 | + const SimpleFadeAnimation({super.key}); |
| 103 | + |
| 104 | + @override |
| 105 | + State<SimpleFadeAnimation> createState() => _SimpleFadeAnimationState(); |
| 106 | +} |
| 107 | + |
| 108 | +class _SimpleFadeAnimationState extends State<SimpleFadeAnimation> |
| 109 | + with SingleTickerProviderStateMixin { |
| 110 | + late AnimationController _controller; |
| 111 | + late Animation<double> _fadeAnimation; |
| 112 | + |
| 113 | + @override |
| 114 | + void initState() { |
| 115 | + super.initState(); |
| 116 | + _controller = AnimationController( |
| 117 | + duration: const Duration(milliseconds: 500), |
| 118 | + vsync: this, |
| 119 | + ); |
| 120 | + |
| 121 | + _fadeAnimation = Tween<double>( |
| 122 | + begin: 0.0, |
| 123 | + end: 1.0, |
| 124 | + ).animate(_controller); |
| 125 | + |
| 126 | + // Iniciar la animación automáticamente |
| 127 | + WidgetsBinding.instance.addPostFrameCallback((_) { |
| 128 | + _controller.forward(); |
| 129 | + }); |
| 130 | + } |
| 131 | + |
| 132 | + @override |
| 133 | + void dispose() { |
| 134 | + _controller.dispose(); |
| 135 | + super.dispose(); |
| 136 | + } |
| 137 | + |
| 138 | + @override |
| 139 | + Widget build(BuildContext context) { |
| 140 | + return MaterialApp( |
| 141 | + home: Scaffold( |
| 142 | + backgroundColor: Colors.white, |
| 143 | + body: Center( |
| 144 | + child: AnimatedBuilder( |
| 145 | + animation: _fadeAnimation, |
| 146 | + builder: (context, child) { |
| 147 | + return Opacity( |
| 148 | + opacity: _fadeAnimation.value, |
| 149 | + child: Container( |
| 150 | + width: 200, |
| 151 | + height: 100, |
| 152 | + decoration: BoxDecoration( |
| 153 | + color: Colors.blue, |
| 154 | + borderRadius: BorderRadius.circular(12), |
| 155 | + boxShadow: [ |
| 156 | + BoxShadow( |
| 157 | + color: Colors.grey.withValues(alpha: 0.3), |
| 158 | + spreadRadius: 2, |
| 159 | + blurRadius: 8, |
| 160 | + offset: const Offset(0, 4), |
| 161 | + ), |
| 162 | + ], |
| 163 | + ), |
| 164 | + child: const Center( |
| 165 | + child: Text( |
| 166 | + 'Fade Animation', |
| 167 | + style: TextStyle( |
| 168 | + color: Colors.white, |
| 169 | + fontSize: 18, |
| 170 | + fontWeight: FontWeight.bold, |
| 171 | + ), |
| 172 | + ), |
| 173 | + ), |
| 174 | + ), |
| 175 | + ); |
| 176 | + }, |
| 177 | + ), |
| 178 | + ), |
| 179 | + ), |
| 180 | + ); |
| 181 | + } |
| 182 | +} |
0 commit comments