Line data Source code
1 : import 'package:amadeus_proto/constants.dart';
2 : import 'package:amadeus_proto/exercises/lesson/exercise_lesson_list.dart';
3 : import 'package:amadeus_proto/exercises/lesson/exercise_lesson_page.dart';
4 : import 'package:amadeus_proto/exercises/load_json.dart';
5 : import 'package:amadeus_proto/page_route_transition.dart';
6 : import 'package:flutter/material.dart';
7 : import 'package:flutter_svg/svg.dart';
8 :
9 : class ExerciseLessonWidget extends StatelessWidget {
10 12 : const ExerciseLessonWidget(
11 : {super.key, required this.icon, required this.filepath});
12 :
13 : final IconData icon;
14 : final String filepath;
15 :
16 0 : @override
17 : Widget build(BuildContext context) {
18 0 : String languageCode = Localizations.localeOf(context).languageCode;
19 :
20 0 : return FutureBuilder(
21 0 : future: loadJsonData("$filepath$languageCode.json"),
22 0 : builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
23 0 : if (!snapshot.hasData) {
24 : return const SizedBox(
25 : height: 100,
26 : child: Center(
27 : child: CircularProgressIndicator(),
28 : ),
29 : );
30 : } else {
31 0 : return GestureDetector(
32 0 : onTap: () {
33 : // Navigator.of(context).push(pageRouteTransition(LessonList())
34 0 : Navigator.of(context)
35 0 : .push(pageRouteTransition(ExerciseLessonPage(
36 0 : data: snapshot.data,
37 : ))
38 : // categoryName: exercisesType.categoryName,
39 : // exercises: exercisesType.exercises))
40 : // MaterialPageRoute(
41 : // builder: (context) => CategoriesExercises(
42 : // categoryName: exercisesType.categoryName,
43 : // exercises: exercisesType.exercises),
44 : // maintainState: true));
45 : );
46 : },
47 0 : child: Center(
48 0 : child: Card(
49 0 : child: Column(
50 : mainAxisSize: MainAxisSize.min,
51 0 : children: <Widget>[
52 0 : ListTile(
53 0 : leading: Icon(icon, size: 40),
54 0 : title: Text(snapshot.data["title"],
55 : overflow: TextOverflow.visible,
56 : style: const TextStyle(
57 : color: Colors.black,
58 : fontSize: mediumTextSize,
59 : fontWeight: FontWeight.bold)),
60 0 : subtitle: Text(
61 0 : snapshot.data["description"],
62 : style: const TextStyle(
63 : color: Colors.black54, fontSize: smallTextSize),
64 : ),
65 : )
66 : ],
67 : )),
68 : ),
69 : );
70 : }
71 : });
72 : }
73 : }
|