// import 'package:flutter/material.dart'; // import 'package:get/get.dart'; // import 'package:vbvs_app/common/color/appConstants.dart'; // import 'package:vbvs_app/common/util/FitTool.dart'; // import 'package:vbvs_app/common/util/MyUtils.dart'; // class CalibrationProgressWidget extends StatelessWidget { // final ValueNotifier progressNotifier; // final ValueNotifier failureNotifier; // const CalibrationProgressWidget({ // Key? key, // required this.progressNotifier, // required this.failureNotifier, // }) : super(key: key); // @override // Widget build(BuildContext context) { // return ValueListenableBuilder( // valueListenable: progressNotifier, // builder: (context, progress, _) { // return ValueListenableBuilder( // valueListenable: failureNotifier, // builder: (context, isFailure, __) { // return Column( // mainAxisSize: MainAxisSize.min, // children: [ // Text( // isFailure ? '失败'.tr : '${progress.toStringAsFixed(0)}%', // style: TextStyle( // fontSize: 26.rpx, // color: isFailure // ? Colors.red // : themeController.currentColor.sc3, // ), // ), // SizedBox(height: 40.rpx), // Stack( // children: [ // Container( // width: double.infinity, // height: 21.rpx, // decoration: BoxDecoration( // color: stringToColor("#D9D9D9"), // borderRadius: BorderRadius.circular( // AppConstants().button_container_radius, // ), // ), // ), // Container( // width: progress / 100 * // MediaQuery.of(context).size.width * // 0.8, // height: 21.rpx, // decoration: BoxDecoration( // gradient: LinearGradient( // colors: isFailure // ? [themeController.currentColor.sc9] // : [ // themeController.currentColor.sc2, // themeController.currentColor.sc2, // ], // begin: Alignment.centerLeft, // end: Alignment.centerRight, // ), // borderRadius: BorderRadius.circular( // AppConstants().button_container_radius, // ), // ), // ), // ], // ), // ], // ); // }, // ); // }, // ); // } // } import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; class CalibrationProgressWidget extends StatelessWidget { final ValueNotifier progressNotifier; final ValueNotifier failureNotifier; const CalibrationProgressWidget({ Key? key, required this.progressNotifier, required this.failureNotifier, }) : super(key: key); @override Widget build(BuildContext context) { return ValueListenableBuilder( valueListenable: progressNotifier, builder: (context, progress, _) { return ValueListenableBuilder( valueListenable: failureNotifier, builder: (context, isFailure, __) { return Column( mainAxisSize: MainAxisSize.min, children: [ Text( isFailure ? '失败'.tr : '${progress.toStringAsFixed(0)}%', style: TextStyle( fontSize: 26.rpx, color: isFailure ? Colors.red : themeController.currentColor.sc3, ), ), SizedBox(height: 40.rpx), Stack( children: [ // 背景进度条 Container( width: double.infinity, height: 21.rpx, decoration: BoxDecoration( color: stringToColor("#D9D9D9"), borderRadius: BorderRadius.circular( AppConstants().button_container_radius, ), ), ), // 使用LayoutBuilder获取父容器宽度 LayoutBuilder( builder: (context, constraints) { return Container( width: progress / 100 * constraints.maxWidth, height: 21.rpx, decoration: BoxDecoration( gradient: LinearGradient( colors: isFailure ? [themeController.currentColor.sc9] : [ themeController.currentColor.sc2, themeController.currentColor.sc2, ], begin: Alignment.centerLeft, end: Alignment.centerRight, ), borderRadius: BorderRadius.circular( AppConstants().button_container_radius, ), ), ); }, ), ], ), ], ); }, ); }, ); } }