Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
course_card.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'package:flutter_screenutil/flutter_screenutil.dart';
3import 'package:hugeicons/hugeicons.dart';
4
5import '../../domain/entities/course_entity.dart';
6
7class CourseCard extends StatelessWidget {
9 final VoidCallback onTap;
10
11 const CourseCard({
12 Key? key,
13 required this.course,
14 required this.onTap,
15 }) : super(key: key);
16
17 @override
18 Widget build(BuildContext context) {
19 Color iconColor = _parseColor(course.iconColor ?? '#4CAF50', context);
20
21 return InkWell(
22 onTap: onTap,
23 borderRadius: BorderRadius.circular(16.r),
24 child: Container(
25 padding: EdgeInsets.all(16.r),
26 decoration: BoxDecoration(
27 borderRadius: BorderRadius.circular(16.r),
28 color: Theme.of(context).colorScheme.surface,
29 ),
30 child: Column(
31 mainAxisSize: MainAxisSize.min,
32 crossAxisAlignment: CrossAxisAlignment.start,
33 children: [
34 Container(
35 width: 45.r,
36 height: 45.r,
37 decoration: BoxDecoration(
38 color: iconColor.withOpacity(0.11),
39 borderRadius: BorderRadius.circular(16.r),
40 ),
41 child: Icon(
42 HugeIcons.strokeRoundedFile01,
44 size: 30.sp,
45 ),
46 ),
47 SizedBox(height: 20.r),
48
50 Text(
51 course.title ?? '',
52 maxLines: 2,
53 overflow: TextOverflow.ellipsis,
54 style: Theme.of(context).textTheme.titleMedium?.copyWith(
55 fontWeight: FontWeight.bold,
56 ),
57 ),
58 SizedBox(height: 10.r),
59
61 Align(
62 alignment: Alignment.centerRight,
63 child: Text(
64 '${(course.progress! * 100).toInt()}%',
65 style: Theme.of(context)
66 .textTheme
67 .bodySmall
68 ?.copyWith(color: iconColor),
69 ),
70 ),
71 SizedBox(height: 5.r),
72
74 LinearProgressIndicator(
75 value: course.progress,
76 backgroundColor: iconColor.withOpacity(0.11),
78 valueColor: AlwaysStoppedAnimation<Color>(iconColor),
79 ),
80 SizedBox(height: 15.r),
81
83 Row(
84 children: [
85 Icon(
86 HugeIcons.strokeRoundedClock01,
87 size: 15.sp,
89 ),
90 SizedBox(width: 5.r),
91 Text(
92 '${course.durationMinutes} min',
93 style: Theme.of(context).textTheme.bodySmall,
94 ),
95 ],
96 ),
97 ],
98 ),
99 ),
100 );
101 }
102
103 Color _parseColor(String hexColor, BuildContext context) {
104 try {
105 hexColor = hexColor.replaceAll('#', '');
106 if (hexColor.length == 6) hexColor = 'FF$hexColor';
107 return Color(int.parse(hexColor, radix: 16));
108 } catch (_) {
109 return Theme.of(context).colorScheme.primary;
110 }
111 }
112}
final VoidCallback onTap
final Widget child
const CourseCard({ Key? key, required this.course, required this.onTap, }) override Widget build(BuildContext context)
Color _parseColor(String hexColor, BuildContext context)
final CourseEntity course
final Color backgroundColor
final Color iconColor