213 lines
6.5 KiB
Dart
213 lines
6.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class EmergencyOverlay extends StatefulWidget {
|
|
const EmergencyOverlay({super.key});
|
|
|
|
@override
|
|
State<EmergencyOverlay> createState() => _EmergencyOverlayState();
|
|
}
|
|
|
|
class _EmergencyOverlayState extends State<EmergencyOverlay>
|
|
with SingleTickerProviderStateMixin {
|
|
late AnimationController _controller;
|
|
late Animation<double> _opacityAnimation;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(milliseconds: 1500),
|
|
)..repeat(reverse: true);
|
|
|
|
_opacityAnimation = Tween<double>(
|
|
begin: 0.3,
|
|
end: 0.6,
|
|
).animate(CurvedAnimation(
|
|
parent: _controller,
|
|
curve: Curves.easeInOut,
|
|
));
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AnimatedBuilder(
|
|
animation: _opacityAnimation,
|
|
builder: (context, child) {
|
|
return IgnorePointer(
|
|
child: Stack(
|
|
children: [
|
|
// 顶部渐变
|
|
Positioned(
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: Container(
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 底部渐变
|
|
Positioned(
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: Container(
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.bottomCenter,
|
|
end: Alignment.topCenter,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 左侧渐变
|
|
Positioned(
|
|
top: 0,
|
|
bottom: 0,
|
|
left: 0,
|
|
child: Container(
|
|
width: 60,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 右侧渐变
|
|
Positioned(
|
|
top: 0,
|
|
bottom: 0,
|
|
right: 0,
|
|
child: Container(
|
|
width: 60,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.centerRight,
|
|
end: Alignment.centerLeft,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 左上角渐变
|
|
Positioned(
|
|
top: 0,
|
|
left: 0,
|
|
child: Container(
|
|
width: 80,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
gradient: RadialGradient(
|
|
center: Alignment.topLeft,
|
|
radius: 1.2,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 右上角渐变
|
|
Positioned(
|
|
top: 0,
|
|
right: 0,
|
|
child: Container(
|
|
width: 80,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
gradient: RadialGradient(
|
|
center: Alignment.topRight,
|
|
radius: 1.2,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 左下角渐变
|
|
Positioned(
|
|
bottom: 0,
|
|
left: 0,
|
|
child: Container(
|
|
width: 80,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
gradient: RadialGradient(
|
|
center: Alignment.bottomLeft,
|
|
radius: 1.2,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// 右下角渐变
|
|
Positioned(
|
|
bottom: 0,
|
|
right: 0,
|
|
child: Container(
|
|
width: 80,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
gradient: RadialGradient(
|
|
center: Alignment.bottomRight,
|
|
radius: 1.2,
|
|
colors: [
|
|
Colors.red.withOpacity(_opacityAnimation.value),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 1.0],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|