Line data Source code
1 : import 'package:amadeus_proto/constants.dart';
2 : import 'package:amadeus_proto/exercises/widget/pressable_button.dart';
3 : import 'package:amadeus_proto/page_route_transition.dart';
4 : import 'package:auto_size_text/auto_size_text.dart';
5 : import 'package:flutter/material.dart';
6 : import 'package:flutter_svg/flutter_svg.dart';
7 : import 'package:localization/localization.dart';
8 :
9 : class ExerciseWidget extends StatefulWidget {
10 0 : const ExerciseWidget(
11 : {super.key,
12 : required this.data,
13 : required this.exercisePage,
14 : required this.iconPath});
15 :
16 : final dynamic data;
17 : final String iconPath;
18 : final Widget Function(dynamic data) exercisePage;
19 :
20 0 : @override
21 0 : State<ExerciseWidget> createState() => _ExerciseWidgetState();
22 : }
23 :
24 : class _ExerciseWidgetState extends State<ExerciseWidget>
25 : with SingleTickerProviderStateMixin {
26 0 : @override
27 : void initState() {
28 0 : super.initState();
29 : }
30 :
31 0 : @override
32 : Widget build(BuildContext context) {
33 : // String languageCode = Localizations.localeOf(context).languageCode;
34 :
35 0 : return Card(
36 0 : child: Theme(
37 0 : data: ThemeData(
38 : splashColor: Colors.transparent,
39 : highlightColor: Colors.transparent),
40 0 : child: ExpansionTile(
41 : shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
42 0 : title: Expanded(
43 0 : child: Row(
44 0 : children: [
45 0 : Expanded(
46 : flex: 3,
47 0 : child: SvgPicture.asset(
48 0 : widget.iconPath,
49 : fit: BoxFit.contain,
50 : ),
51 : ),
52 : const Spacer(),
53 0 : Expanded(
54 : flex: 8,
55 0 : child: Column(
56 : mainAxisAlignment: MainAxisAlignment.start,
57 : crossAxisAlignment: CrossAxisAlignment.start,
58 0 : children: [
59 0 : AutoSizeText(
60 0 : widget.data["title"],
61 : style: const TextStyle(
62 : color: Colors.black54,
63 : fontSize: 18.0,
64 : fontWeight: FontWeight.bold),
65 : maxLines: 1,
66 : ),
67 0 : if (widget.data["category"] != null)
68 0 : AutoSizeText(
69 0 : widget.data["category"],
70 : overflow: TextOverflow.visible,
71 : style: const TextStyle(
72 : color: Colors.black54,
73 : fontSize: 16.0,
74 : ),
75 : maxLines: 1,
76 : ),
77 0 : Row(
78 0 : children: [
79 0 : Text("${"exercises.difficulty".i18n()} : ",
80 : style: const TextStyle(
81 : color: Colors.black54,
82 : fontSize: 14.0,
83 : fontWeight: FontWeight.bold)),
84 0 : ...List.generate(
85 0 : widget.data["difficulty"],
86 0 : (index) => SvgPicture.asset(
87 : "assets/FigmaDesign/Asset/SVG/Music Note.svg",
88 : width: 20,
89 : height: 20,
90 : colorFilter: const ColorFilter.mode(
91 : Colors.black54, BlendMode.srcIn),
92 : fit: BoxFit.fill),
93 : )
94 : ],
95 : )
96 : ],
97 : ),
98 : ),
99 : ],
100 : ),
101 : ),
102 0 : children: <Widget>[
103 0 : Padding(
104 : padding: const EdgeInsets.all(smallPadding),
105 0 : child: Text(
106 0 : widget.data["description"],
107 : ),
108 : ),
109 0 : Padding(
110 : padding: const EdgeInsets.all(smallPadding),
111 0 : child: PressableButton(
112 0 : body: Center(child: Text("buttons.start".i18n())),
113 : height: startButtonHeight,
114 : width: startButtonWidth,
115 : shadowColor:
116 0 : Theme.of(context).colorScheme.secondary.withOpacity(0.5),
117 0 : buttonColor: Theme.of(context).colorScheme.secondary,
118 : isEnable: true,
119 0 : onPressed: () => {
120 0 : Navigator.of(context).push(pageRouteTransition(
121 0 : widget.exercisePage(widget.data))),
122 : // MaterialPageRoute(
123 : // builder: (context) =>
124 : // widget.exerciseWidget,
125 : // maintainState: true))
126 : }),
127 : )
128 : ],
129 : ),
130 : ),
131 : );
132 : }
133 : }
|