Update download popup

This commit is contained in:
Thomas Fransolet 2024-10-17 14:03:55 +02:00
parent 44581c12c5
commit 8b88b50c1f
2 changed files with 50 additions and 49 deletions

View File

@ -350,11 +350,12 @@ class _ConfigurationsListState extends State<ConfigurationsList> {
borderRadius: BorderRadius.all(Radius.circular(20.0)) borderRadius: BorderRadius.all(Radius.circular(20.0))
), ),
content: SizedBox( content: SizedBox(
width: 400, width: 350,
height: 200, height: 125,
child: DownloadConfigurationWidget(configuration: configuration), child: Center(
child: DownloadConfigurationWidget(configuration: configuration)
),
), ),
actions: const <Widget>[],
), context: context ), context: context
); );
isDialogOpen = false; isDialogOpen = false;

View File

@ -262,24 +262,23 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
VisitAppContext visitAppContext = appContext.getContext(); VisitAppContext visitAppContext = appContext.getContext();
Size size = MediaQuery.of(context).size; Size size = MediaQuery.of(context).size;
return Column( return Center(
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: FutureBuilder(future: download(context, visitAppContext), builder: (context, snapshot) {
children: [ return ValueListenableBuilder<int>(
Spacer(), valueListenable: currentResourceNbr,
Padding( builder: (context, valueNbr, _) {
padding: const EdgeInsets.only(bottom: 10.0),
child: FutureBuilder(future: download(context, visitAppContext), builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
Color primaryColor = kMainColor1;
return Center(child: CircularProgressIndicator(color: primaryColor));
} else {
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: currentResourceNbr, valueListenable: currentResourceIndex,
builder: (context, valueNbr, _) { builder: (context, valueIndex, _) {
return ValueListenableBuilder<int>( var valueInPercentage = valueNbr > 0 ? (valueIndex / valueNbr) * 100 : 100;
valueListenable: currentResourceIndex, String formattedPercentage = valueInPercentage.toStringAsFixed(0);
builder: (context, valueIndex, _) { return Column(
return Center( mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text( child: Text(
textAlign: TextAlign.center, textAlign: TextAlign.center,
valueIndex == valueNbr && valueNbr != -1 ? valueNbr == 0 ? valueIndex == valueNbr && valueNbr != -1 ? valueNbr == 0 ?
@ -292,38 +291,39 @@ class _DownloadConfigurationWidgetState extends State<DownloadConfigurationWidge
appContext.getContext()), appContext.getContext()),
style: const TextStyle(fontSize: 20), style: const TextStyle(fontSize: 20),
), ),
); ),
} ),
if(valueNbr != -1 && valueNbr != 0)
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: LinearProgressIndicator(
value: valueInPercentage / 100,
semanticsLabel: 'Linear progress indicator',
color: kMainColor0,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'$formattedPercentage%',
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
),
),
],
),
)
],
); );
} }
); );
} }
}), );
), }),
ValueListenableBuilder<int>(
valueListenable: currentResourceNbr,
builder: (context, valueNbr, _) {
return ValueListenableBuilder<int>(
valueListenable: currentResourceIndex,
builder: (context, valueIndex, _) {
var valueInPercentage = valueNbr > 0 ? (valueIndex / valueNbr) * 100 : 100;
String formattedPercentage = valueInPercentage.toStringAsFixed(0); // Limite à 2 décimales
return valueNbr != -1 && valueNbr != 0 ? Center(
child: Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
'$formattedPercentage%',
style: const TextStyle(fontSize: 45, fontWeight: FontWeight.w500),
),
),
) : const SizedBox(height: 0,width: 0);
}
);
}
),
Spacer()
],
); );
} }
} }