2024-10-31 09:03:22 +00:00
|
|
|
import 'package:english_learning/core/services/constants.dart';
|
2024-10-10 05:49:33 +00:00
|
|
|
import 'package:english_learning/features/learning/modules/model/section_model.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:english_learning/core/utils/styles/theme.dart';
|
|
|
|
|
|
2024-10-31 09:03:22 +00:00
|
|
|
class LearningCard extends StatefulWidget {
|
2024-10-10 05:49:33 +00:00
|
|
|
final Section section;
|
|
|
|
|
final VoidCallback? onTap;
|
|
|
|
|
|
|
|
|
|
const LearningCard({
|
|
|
|
|
super.key,
|
|
|
|
|
required this.section,
|
|
|
|
|
this.onTap,
|
|
|
|
|
});
|
|
|
|
|
|
2024-10-31 09:03:22 +00:00
|
|
|
@override
|
|
|
|
|
State<LearningCard> createState() => _LearningCardState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _LearningCardState extends State<LearningCard>
|
|
|
|
|
with SingleTickerProviderStateMixin {
|
2024-10-10 05:49:33 +00:00
|
|
|
String _getFullImageUrl(String thumbnail) {
|
|
|
|
|
if (thumbnail.startsWith('http')) {
|
|
|
|
|
return thumbnail;
|
|
|
|
|
} else {
|
Updated various files, including constants, exercise providers, question widgets, section models, and screens for topics, learning, and settings, with changes to URLs, error handling, and UI components.
2024-11-21 05:45:41 +00:00
|
|
|
return '${baseUrl}api/uploads/section/$thumbnail';
|
2024-10-10 05:49:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return GestureDetector(
|
2024-10-31 09:03:22 +00:00
|
|
|
onTap: widget.onTap,
|
2024-10-10 05:49:33 +00:00
|
|
|
child: Card(
|
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
elevation: 1,
|
|
|
|
|
margin: const EdgeInsets.symmetric(vertical: 6.0),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
ClipRRect(
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
child: Image.network(
|
Updated various files, including constants, exercise providers, question widgets, section models, and screens for topics, learning, and settings, with changes to URLs, error handling, and UI components.
2024-11-21 05:45:41 +00:00
|
|
|
_getFullImageUrl(widget.section.thumbnail ?? ''),
|
2024-10-10 05:49:33 +00:00
|
|
|
width: 90,
|
|
|
|
|
height: 104,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
errorBuilder: (context, error, stackTrace) {
|
|
|
|
|
print('Error loading image: $error');
|
|
|
|
|
return Container(
|
|
|
|
|
width: 90,
|
|
|
|
|
height: 104,
|
|
|
|
|
color: Colors.grey[300],
|
2024-10-23 04:16:07 +00:00
|
|
|
child: const Icon(
|
2024-10-10 05:49:33 +00:00
|
|
|
Icons.image_not_supported,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
loadingBuilder: (context, child, loadingProgress) {
|
|
|
|
|
if (loadingProgress == null) return child;
|
|
|
|
|
return Container(
|
|
|
|
|
width: 90,
|
|
|
|
|
height: 104,
|
|
|
|
|
color: Colors.grey[300],
|
|
|
|
|
child: Center(child: CircularProgressIndicator()),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
)),
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
2024-10-31 09:03:22 +00:00
|
|
|
widget.section.name,
|
2024-10-10 05:49:33 +00:00
|
|
|
style: AppTextStyles.blackTextStyle.copyWith(
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
Text(
|
2024-10-31 09:03:22 +00:00
|
|
|
widget.section.description,
|
2024-10-10 05:49:33 +00:00
|
|
|
style: AppTextStyles.disableTextStyle.copyWith(
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
maxLines: 4,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|