Refactor progress indicators to use stateful widgets, enhance animation control, and remove unnecessary subtitles in section cards
This commit is contained in:
parent
687bca8817
commit
b4ccdd7750
11 changed files with 316 additions and 130 deletions
|
|
@ -3,17 +3,49 @@ import 'package:m3e_collection/m3e_collection.dart';
|
|||
|
||||
import 'section_card.dart';
|
||||
|
||||
class ProgressSection extends StatelessWidget {
|
||||
class ProgressSection extends StatefulWidget {
|
||||
const ProgressSection({super.key});
|
||||
|
||||
@override
|
||||
State<ProgressSection> createState() => _ProgressSectionState();
|
||||
}
|
||||
|
||||
class _ProgressSectionState extends State<ProgressSection>
|
||||
with SingleTickerProviderStateMixin {
|
||||
double? _value = 0.6;
|
||||
late final AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 2400))
|
||||
..repeat();
|
||||
_controller.addListener(() {
|
||||
if (mounted) setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SectionCard(
|
||||
title: 'ProgressIndicatorM3E',
|
||||
subtitle: 'Generated from enums: circular sizes and linear variants.',
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Value: $_value (set 0 for null)'),
|
||||
SliderM3E(
|
||||
value: _value ?? 0,
|
||||
onChanged: (v) => setState(
|
||||
() => _value = v == 0 ? null : v,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Text('Circular - Wavy',
|
||||
|
|
@ -26,12 +58,12 @@ class ProgressSection extends StatelessWidget {
|
|||
for (final s in CircularProgressM3ESize.values) ...[
|
||||
CircularProgressIndicatorM3E(
|
||||
size: s,
|
||||
value: 0.4,
|
||||
value: _value,
|
||||
shape: ProgressM3EShape.wavy,
|
||||
),
|
||||
CircularProgressIndicatorM3E(
|
||||
size: s,
|
||||
value: 0.6,
|
||||
value: _value,
|
||||
shape: ProgressM3EShape.wavy,
|
||||
),
|
||||
],
|
||||
|
|
@ -50,13 +82,13 @@ class ProgressSection extends StatelessWidget {
|
|||
for (final s in CircularProgressM3ESize.values) ...[
|
||||
CircularProgressIndicatorM3E(
|
||||
size: s,
|
||||
value: 0.4,
|
||||
value: _value,
|
||||
shape: ProgressM3EShape.flat,
|
||||
),
|
||||
CircularProgressIndicatorM3E(
|
||||
size: s,
|
||||
shape: ProgressM3EShape.flat,
|
||||
value: 0.6,
|
||||
value: _value,
|
||||
),
|
||||
],
|
||||
],
|
||||
|
|
@ -74,14 +106,16 @@ class ProgressSection extends StatelessWidget {
|
|||
SizedBox(
|
||||
width: 250,
|
||||
child: LinearProgressIndicatorM3E(
|
||||
value: null,
|
||||
value: _value,
|
||||
size: LinearProgressM3ESize.s,
|
||||
shape: ProgressM3EShape.wavy,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: LinearProgressIndicatorM3E(
|
||||
value: 0.6,
|
||||
value: _value,
|
||||
size: LinearProgressM3ESize.m,
|
||||
shape: ProgressM3EShape.wavy,
|
||||
),
|
||||
),
|
||||
|
|
@ -100,14 +134,16 @@ class ProgressSection extends StatelessWidget {
|
|||
SizedBox(
|
||||
width: 250,
|
||||
child: LinearProgressIndicatorM3E(
|
||||
value: null,
|
||||
value: _value,
|
||||
size: LinearProgressM3ESize.s,
|
||||
shape: ProgressM3EShape.flat,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: LinearProgressIndicatorM3E(
|
||||
value: 0.6,
|
||||
value: _value,
|
||||
size: LinearProgressM3ESize.m,
|
||||
shape: ProgressM3EShape.flat,
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue