//Barra de progresso e nível
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('Tarefa'),
SizedBox(width: 10),
SizedBox(
width: 25,
height: 25,
child: IconButton(
padding: EdgeInsets.all(0),
iconSize: 25,
onPressed: () =>
setState(() {
level = TaskInherited
.of(context)
.level;
}),
icon: Icon(Icons.restart_alt)),
)
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
width: 200,
child: LinearProgressIndicator(
color: Colors.white,
value: TaskInherited
.of(context)
.level / 100,
),
),
SizedBox(width: 10),
Text('Level: ${TaskInherited
.of(context)
.level}')
],
)
]),
//Função de aumentar nível global
void increaseGlobalLevel(int taskLevel, int dificulade, int maestria) {
level = double.parse(
(level + (taskLevel / (dificulade * maestria * tasks.length)) / 10)
.toStringAsFixed(2));
}
//Ao apertar Level Up em alguma das tasks, elas chamam uma função de update do nível global
void levelUp() {
if (widget.level < 999) widget.level++;
TaskInherited.of(context).increaseGlobalLevel(
widget.level, widget.dificuldade, widget.maestry);
setState(() {
widget.progress =
(widget.level / (widget.dificuldade * widget.maestry)) / 10;
if (widget.progress >= 1.0 && widget.maestry < (colors.length)) {
widget.maestry++;
widget.level = 0;
widget.progress = 0;
}
});
}