35 lines
1.0 KiB
Dart
35 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:percent_indicator/percent_indicator.dart';
|
|
|
|
// TODO: change colors
|
|
class RemainingTrafficIndicator extends StatelessWidget {
|
|
const RemainingTrafficIndicator(this.ratio, {super.key});
|
|
|
|
final double ratio;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final startColor = ratio < 0.25
|
|
? const Color.fromRGBO(93, 205, 251, 1.0)
|
|
: ratio < 0.65
|
|
? const Color.fromRGBO(205, 199, 64, 1.0)
|
|
: const Color.fromRGBO(241, 82, 81, 1.0);
|
|
final endColor = ratio < 0.25
|
|
? const Color.fromRGBO(49, 146, 248, 1.0)
|
|
: ratio < 0.65
|
|
? const Color.fromRGBO(98, 115, 32, 1.0)
|
|
: const Color.fromRGBO(139, 30, 36, 1.0);
|
|
|
|
return LinearPercentIndicator(
|
|
percent: ratio,
|
|
animation: true,
|
|
padding: EdgeInsets.zero,
|
|
lineHeight: 6,
|
|
barRadius: const Radius.circular(16),
|
|
linearGradient: LinearGradient(
|
|
colors: [startColor, endColor],
|
|
),
|
|
);
|
|
}
|
|
}
|