Line data Source code
1 : import 'dart:async';
2 :
3 : import 'package:amadeus_proto/constants.dart';
4 : import 'package:amadeus_proto/exercises/exercise_widget.dart';
5 : import 'package:amadeus_proto/exercises/exercises_category.dart';
6 : import 'package:amadeus_proto/exercises/lesson/exercise_lesson_button.dart';
7 : import 'package:amadeus_proto/utils/searchbar.dart';
8 : import 'package:flutter/material.dart';
9 : import 'package:amadeus_proto/exercises/exercises_constants.dart' as constants;
10 : import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
11 : import 'package:localization/localization.dart';
12 :
13 : class ExerciseValue {
14 0 : ExerciseValue(
15 : {required this.category,
16 : required this.description,
17 : required this.iconPath,
18 : required this.exercises});
19 :
20 : final ExerciseCategoryEnum category;
21 : final String description;
22 : final String iconPath;
23 : final List<ExerciseWidget> exercises;
24 : }
25 :
26 : enum ExerciseCategoryEnum {
27 : RHYTHM,
28 : LISTENING,
29 : READING,
30 : THEORY
31 : }
32 :
33 : extension Name on ExerciseCategoryEnum {
34 0 : String get categoryName {
35 : switch (this) {
36 0 : case ExerciseCategoryEnum.RHYTHM:
37 : return "exercises.rhythm.title";
38 0 : case ExerciseCategoryEnum.LISTENING:
39 : return "exercises.listening.title";
40 0 : case ExerciseCategoryEnum.READING:
41 : return "exercises.reading.title";
42 0 : case ExerciseCategoryEnum.THEORY:
43 : return "exercises.theory.title";
44 : }
45 : }
46 : }
47 :
48 : class ExercisesPage extends StatefulWidget {
49 12 : const ExercisesPage({super.key});
50 :
51 0 : @override
52 0 : State<ExercisesPage> createState() => _ExercisesPageState();
53 : }
54 :
55 : class _ExercisesPageState extends State<ExercisesPage>
56 : with SingleTickerProviderStateMixin {
57 : late FocusNode _focusNode;
58 : late StreamSubscription<bool> keyboardSubscription;
59 :
60 0 : @override
61 : void initState() {
62 0 : super.initState();
63 0 : final controller = KeyboardVisibilityController();
64 0 : keyboardSubscription = controller.onChange.listen((bool visible) {});
65 0 : _focusNode = FocusNode();
66 0 : _focusNode.attach(context);
67 : }
68 :
69 0 : @override
70 : void dispose() {
71 0 : _focusNode.dispose();
72 0 : keyboardSubscription.cancel();
73 0 : super.dispose();
74 : }
75 :
76 0 : void onInputChanged(String newInput) {}
77 :
78 0 : @override
79 : Widget build(BuildContext context) {
80 0 : return Padding(
81 : padding: const EdgeInsets.symmetric(horizontal: mediumPadding, vertical: largePadding),
82 : // padding: const EdgeInsets.only(top: 35, right: 15, bottom: 15, left: 15),
83 0 : child: SizedBox(
84 0 : child: SingleChildScrollView(
85 0 : child: Column(
86 0 : children: [
87 0 : Padding(
88 : padding: const EdgeInsets.symmetric(horizontal: mediumPadding),
89 0 : child: Align(
90 : alignment: Alignment.topLeft,
91 0 : child: Text(
92 0 : "exercises.list".i18n(),
93 : style: const TextStyle(
94 : fontWeight: FontWeight.bold,
95 : fontSize: mediumTextSize),
96 : )),
97 : ),
98 : const SearchBarWidget(),
99 : const ExerciseLessonButton(),
100 0 : ...List.generate(
101 0 : constants.exercises.length,
102 0 : (index) => ExerciseCategory(
103 0 : exercisesType: constants.exercises[index]))
104 : // for (ExerciseValue ex in constants.exercises)
105 : // ExerciseCategory(
106 : // exercisesType: ex,
107 : // )
108 : ],
109 : ),
110 : ),
111 : ),
112 : );
113 : }
114 : }
|