-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: created DSProgressiveProgress widget
- Loading branch information
Andre Rossi
committed
Nov 13, 2023
1 parent
6ed4641
commit 3073413
Showing
4 changed files
with
78 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:file_sizes/file_sizes.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get/get.dart'; | ||
|
||
import '../../themes/colors/ds_colors.theme.dart'; | ||
import '../texts/ds_caption_small_text.widget.dart'; | ||
|
||
class DSProgressiveProgress extends StatelessWidget { | ||
final RxInt maximumProgress; | ||
final RxInt currentProgress; | ||
final Color? foregroundColor; | ||
|
||
const DSProgressiveProgress({ | ||
super.key, | ||
required this.maximumProgress, | ||
required this.currentProgress, | ||
this.foregroundColor, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Obx( | ||
() { | ||
final double percent = maximumProgress.value > 0 | ||
? currentProgress.value / maximumProgress.value | ||
: 0; | ||
|
||
return SizedBox( | ||
width: double.infinity, | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
mainAxisSize: MainAxisSize.max, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: CircularProgressIndicator( | ||
color: DSColors.primary, | ||
backgroundColor: Colors.grey, | ||
value: currentProgress.value < maximumProgress.value | ||
? percent | ||
: null, | ||
), | ||
), | ||
DSCaptionSmallText( | ||
_buildProgress(), | ||
color: foregroundColor ?? DSColors.neutralDarkCity, | ||
) | ||
], | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
|
||
String _buildProgress() { | ||
String getSize(int value) => FileSize.getSize( | ||
value, | ||
precision: PrecisionValue.One, | ||
); | ||
|
||
return '${getSize(currentProgress.value)} / ${getSize(maximumProgress.value)}'; | ||
} | ||
} |