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,
children: [
Spacer(),
Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: FutureBuilder(future: download(context, visitAppContext), builder: (context, snapshot) { 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: currentResourceNbr,
builder: (context, valueNbr, _) { builder: (context, valueNbr, _) {
return ValueListenableBuilder<int>( return ValueListenableBuilder<int>(
valueListenable: currentResourceIndex, valueListenable: currentResourceIndex,
builder: (context, valueIndex, _) { builder: (context, valueIndex, _) {
return Center( var valueInPercentage = valueNbr > 0 ? (valueIndex / valueNbr) * 100 : 100;
String formattedPercentage = valueInPercentage.toStringAsFixed(0);
return Column(
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),
), ),
);
}
);
}
);
}
}),
), ),
ValueListenableBuilder<int>( ),
valueListenable: currentResourceNbr, if(valueNbr != -1 && valueNbr != 0)
builder: (context, valueNbr, _) { Center(
return ValueListenableBuilder<int>( child: Column(
valueListenable: currentResourceIndex, mainAxisAlignment: MainAxisAlignment.center,
builder: (context, valueIndex, _) { mainAxisSize: MainAxisSize.min,
var valueInPercentage = valueNbr > 0 ? (valueIndex / valueNbr) * 100 : 100; children: [
String formattedPercentage = valueInPercentage.toStringAsFixed(0); // Limite à 2 décimales Padding(
padding: const EdgeInsets.all(8.0),
return valueNbr != -1 && valueNbr != 0 ? Center( child: LinearProgressIndicator(
child: Padding( value: valueInPercentage / 100,
padding: const EdgeInsets.only(bottom: 8.0), semanticsLabel: 'Linear progress indicator',
color: kMainColor0,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text( child: Text(
'$formattedPercentage%', '$formattedPercentage%',
style: const TextStyle(fontSize: 45, fontWeight: FontWeight.w500), style: const TextStyle(fontSize: 28, fontWeight: FontWeight.w500),
), ),
), ),
) : const SizedBox(height: 0,width: 0); ],
),
)
],
);
} }
); );
} }
), );
Spacer() }),
],
); );
} }
} }