placementDialog function
- BuildContext context,
- PlacementInfo info
A caixa do nivelamento, sempre com os dois botões ("Começar no…" e "Ficar onde estou"). Para um passo adiante, "Começar" é o principal; no mesmo passo ou atrás, "Ficar onde estou" é, porque começar ali apaga o que o aluno já fez.
Implementation
AlertDialog placementDialog(BuildContext context, PlacementInfo info) {
final (:start, :here, :title, :text) = info;
final stayMain = start.index.compareTo(here.index) <= 0;
final stay = stayMain
? FilledButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Ficar onde estou'),
)
: TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Ficar onde estou'),
);
final go = stayMain
? TextButton(
onPressed: () => Navigator.pop(context, true),
child: Text('Começar no ${start.name}'),
)
: FilledButton(
onPressed: () => Navigator.pop(context, true),
child: Text('Começar no ${start.name}'),
);
return AlertDialog(
title: Text(title),
content: Text(text),
actions: stayMain ? [go, stay] : [stay, go],
);
}