Line data Source code
1 : import 'package:amadeus_proto/exercises/exercises_provider.dart';
2 : import 'package:amadeus_proto/exercises/widget/pressable_button.dart';
3 : import 'package:flutter/material.dart';
4 : import 'package:localization/localization.dart';
5 : import 'package:provider/provider.dart';
6 : import 'package:amadeus_proto/constants.dart';
7 :
8 : class ExerciseEndDialog<T extends ExerciseProvider> extends StatelessWidget {
9 0 : const ExerciseEndDialog(
10 : {super.key,
11 : required this.leavingExerciseCallback,
12 : required this.resetExerciseCallback,
13 : required this.exerciseTitle,
14 : required this.exerciseCategory});
15 :
16 : final VoidCallback leavingExerciseCallback;
17 : final VoidCallback resetExerciseCallback;
18 : final String exerciseTitle;
19 : final String? exerciseCategory;
20 :
21 0 : @override
22 : Widget build(BuildContext context) {
23 0 : final double height = MediaQuery.of(context).size.height;
24 0 : final double width = MediaQuery.of(context).size.width;
25 :
26 0 : return Consumer<T>(
27 0 : builder: (context, provider, child) {
28 0 : return Material(
29 : type: MaterialType.transparency,
30 0 : child: PopScope(
31 : canPop: false,
32 0 : child: Center(
33 0 : child: Container(
34 0 : height: height / 3,
35 : width: 350,
36 0 : decoration: BoxDecoration(
37 : color: Colors.white,
38 0 : borderRadius: BorderRadius.circular(smallBorderRadius)),
39 0 : child: Padding(
40 : padding: const EdgeInsets.all(smallPadding),
41 0 : child: Column(
42 : mainAxisSize: MainAxisSize.min,
43 : mainAxisAlignment: MainAxisAlignment.spaceBetween,
44 0 : children: [
45 0 : SizedBox(
46 0 : height: height / 4.5,
47 0 : child: Column(
48 : mainAxisAlignment: MainAxisAlignment.spaceAround,
49 0 : children: [
50 0 : Icon(
51 0 : provider.lives == 0
52 : ? Icons.cancel
53 : : Icons.check_circle,
54 : color:
55 0 : provider.lives == 0 ? Colors.red : Colors.green,
56 : size: 80.0,
57 : ),
58 0 : provider.lives == 0
59 0 : ? Text(
60 0 : "exercises.lose".i18n(),
61 : style: const TextStyle(
62 : color: Colors.red,
63 : fontSize: mediumTextSize,
64 : fontWeight: FontWeight.bold),
65 : )
66 0 : : Text(
67 0 : "exercises.win".i18n(),
68 : style: const TextStyle(
69 : color: Colors.lightGreen,
70 : fontSize: mediumTextSize,
71 : fontWeight: FontWeight.bold),
72 : ),
73 0 : SizedBox(
74 0 : child: Column(
75 0 : children: [
76 0 : Text(exerciseTitle,
77 : style: const TextStyle(
78 : fontSize: mediumTextSize,
79 : fontWeight: FontWeight.bold)),
80 0 : if (exerciseCategory != null)
81 0 : Text(exerciseCategory!,
82 : style: const TextStyle(
83 : fontSize: smallTextSize,
84 : color: Colors.grey,
85 : )),
86 : ],
87 : ),
88 : )
89 : ],
90 : ),
91 : ),
92 0 : Row(
93 : mainAxisAlignment: MainAxisAlignment.spaceBetween,
94 0 : children: [
95 0 : Padding(
96 : padding: const EdgeInsets.only(bottom: smallPadding),
97 0 : child: PressableButton(
98 0 : body: Center(
99 0 : child: Text(
100 0 : "buttons.return".i18n(),
101 : style: const TextStyle(
102 : color: Colors.white,
103 : fontSize: smallTextSize,
104 : fontWeight: FontWeight.bold),
105 : overflow: TextOverflow.fade,
106 : textAlign: TextAlign.center,
107 : ),
108 : ),
109 0 : height: height / 20,
110 0 : width: width / 2.5,
111 : shadowColor:
112 0 : Theme.of(context).colorScheme.primary,
113 : buttonColor:
114 0 : Theme.of(context).colorScheme.primary,
115 : isEnable: true,
116 0 : onPressed: leavingExerciseCallback),
117 : ),
118 0 : Padding(
119 : padding: const EdgeInsets.only(bottom: smallPadding),
120 0 : child: PressableButton(
121 0 : body: Center(
122 0 : child: Text(
123 0 : "buttons.restart".i18n(),
124 : style: const TextStyle(
125 : color: Colors.white,
126 : fontSize: smallTextSize,
127 : fontWeight: FontWeight.bold),
128 : overflow: TextOverflow.fade,
129 : textAlign: TextAlign.center,
130 : ),
131 : ),
132 0 : height: height / 20,
133 0 : width: width / 2.5,
134 0 : shadowColor: Theme.of(context)
135 0 : .colorScheme
136 0 : .secondary
137 0 : .withOpacity(0.5),
138 : buttonColor:
139 0 : Theme.of(context).colorScheme.primary,
140 : isEnable: true,
141 0 : onPressed: resetExerciseCallback),
142 : ),
143 : ],
144 : )
145 : ],
146 : ),
147 : ),
148 : )),
149 : ),
150 : );
151 : },
152 : );
153 : }
154 : }
|