/
Ru5Kasper
/
Trackly
Обзор
Документация
Войти
/
Ru5Kasper
/
Trackly
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop
frontend/lib/widgets/circular_progress_ring.dart
99 строк
3 KB
DORANDKOR
feat(frontend): implement dark theme
21 май 2026, 16:08
21 май 2026, 16:08
412c063
Код
Авторство
О чём код?
import 'dart:math' as math; import 'package:flutter/material.dart'; class CircularProgressRing extends StatelessWidget { final double progress; final Color color; final String title; final String subtitle; const CircularProgressRing({ super.key, required this.progress, required this.color, required this.title, required this.subtitle, }); @override Widget build(BuildContext context) { final clampedProgress = progress.clamp(0, 1).toDouble(); return CustomPaint( painter: _RingPainter( progress: clampedProgress, color: color, ), child: SizedBox( width: 200, height: 200, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( '${(clampedProgress * 100).round()}%', style: const TextStyle( fontSize: 34, fontWeight: FontWeight.w800, height: 1, ), ), const SizedBox(height: 8), Text( title, textAlign: TextAlign.center, style: const TextStyle( fontSize: 15, fontWeight: FontWeight.w700, ), ), const SizedBox(height: 4), Text( subtitle, textAlign: TextAlign.center, style: TextStyle( fontSize: 12, color: Theme.of(context).colorScheme.onSurfaceVariant, ), ), ], ), ), ); } } class _RingPainter extends CustomPainter { final double progress; final Color color; _RingPainter({required this.progress, required this.color}); @override void paint(Canvas canvas, Size size) { final center = Offset(size.width / 2, size.height / 2); final radius = math.min(size.width, size.height) / 2 - 12; final rect = Rect.fromCircle(center: center, radius: radius); final backgroundPaint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 18 ..strokeCap = StrokeCap.round ..color = const Color(0xFFE8EEF2); final foregroundPaint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 18 ..strokeCap = StrokeCap.round ..color = color; canvas.drawArc(rect, 0, math.pi * 2, false, backgroundPaint); canvas.drawArc(rect, -math.pi / 2, math.pi * 2 * progress, false, foregroundPaint); } @override bool shouldRepaint(covariant _RingPainter oldDelegate) { return oldDelegate.progress != progress || oldDelegate.color != color; } }