Files
AutoJudge-Flutter/lib/widgets/course_card.dart
2025-11-13 09:14:49 +08:00

134 lines
4.0 KiB
Dart

import 'package:flutter/material.dart';
import '../models/course.dart';
/// Course card widget
///
/// Displays course information in a card format
/// Shows course name, teacher, and evaluation status
class CourseCard extends StatelessWidget {
final Course course;
const CourseCard({super.key, required this.course});
@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.only(bottom: 12),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Course name and status
Row(
children: [
Expanded(
child: Text(
course.name,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(width: 8),
_buildStatusChip(context),
],
),
const SizedBox(height: 8),
// Teacher info
Row(
children: [
Icon(
Icons.person,
size: 16,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 4),
Text(
course.teacher,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
),
const SizedBox(height: 4),
// Evaluated people info
Row(
children: [
Icon(
Icons.group,
size: 16,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 4),
Text(
course.evaluatedPeople,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
),
],
),
),
);
}
Widget _buildStatusChip(BuildContext context) {
if (course.isEvaluated) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Colors.green.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.green.withValues(alpha: 0.3)),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.check_circle, size: 14, color: Colors.green),
const SizedBox(width: 4),
Text(
'已评',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Colors.green,
fontWeight: FontWeight.bold,
),
),
],
),
);
} else {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.pending,
size: 14,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
const SizedBox(width: 4),
Text(
'待评',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onPrimaryContainer,
fontWeight: FontWeight.bold,
),
),
],
),
);
}
}
}