| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- import 'package:clean/utils/expand.dart';
- import 'package:flutter/Material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import '../resource/assets.gen.dart';
- class UploadingDialog extends StatefulWidget {
- final Duration duration;
- final VoidCallback? onComplete;
- const UploadingDialog({
- super.key,
- this.duration = const Duration(seconds: 3),
- this.onComplete,
- });
- @override
- State<UploadingDialog> createState() => _UploadingDialogState();
- }
- class _UploadingDialogState extends State<UploadingDialog>
- with SingleTickerProviderStateMixin {
- late AnimationController _controller;
- late Animation<double> _animation;
- @override
- void initState() {
- super.initState();
- _controller = AnimationController(
- duration: widget.duration,
- vsync: this,
- );
- _animation = Tween<double>(begin: 0, end: 1).animate(_controller)
- ..addStatusListener((status) {
- if (status == AnimationStatus.completed) {
- widget.onComplete?.call();
- Navigator.of(context).pop();
- }
- });
- _controller.forward();
- }
- @override
- void dispose() {
- _controller.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- return Dialog(
- backgroundColor: Colors.transparent,
- elevation: 0,
- child: Container(
- padding: EdgeInsets.all(25.w),
- decoration: BoxDecoration(
- color: "#23232A".color,
- borderRadius: BorderRadius.circular(20.r),
- ),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 240.w,
- height: 20.h,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(26.r),
- color: Colors.transparent,
- ),
- ),
- // 进度条背景
- Container(
- width: 240.w,
- height: 13.h,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(26.r),
- color: "#44444D".color,
- ),
- ),
- // 进度条
- AnimatedBuilder(
- animation: _animation,
- builder: (context, child) {
- return Align(
- alignment: Alignment.centerLeft,
- child: Container(
- width: 240.w * _animation.value,
- height: 13.h,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(26.r),
- gradient: LinearGradient(
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- colors: ['#0279FB'.color, '#61A5F8'.color],
- ),
- ),
- ),
- );
- },
- ),
- // 图标
- AnimatedBuilder(
- animation: _animation,
- builder: (context, child) {
- return Positioned(
- left: (226.w * _animation.value) - 10.w, // 调整图标位置
- child: Container(
- width: 20.w,
- height: 20.h,
- decoration: const BoxDecoration(
- color: Colors.blue,
- shape: BoxShape.circle,
- ),
- child: const Center(
- child: Icon(
- Icons.rocket_launch,
- color: Colors.white,
- size: 12,
- ),
- ),
- ),
- );
- },
- ),
- ],
- ),
- SizedBox(height: 22.h),
- Text(
- 'Uploading...',
- style: TextStyle(
- color: Colors.white,
- fontSize: 14.sp,
- fontWeight: FontWeight.w500),
- ),
- ],
- ),
- ),
- );
- }
- }
|