* integrate CoursePlansRepo.translateActivity, translateTopic, translateCoursePlan * move translation functions to requisite files * integrate translation endpoint * refactor: reorganize course-related repos, add request and response model classes * remove l2s from translation requests * update translation request and response models, use translation endpoint to get course info, cache courses with L1s in cache key * update topics repo to use translation endpoint * use activity translation endpoint * refactor: incremental loading of individual course info, account for discrepancy between translated IDs and original IDs * incremental loading of course batches * Update lib/pangea/course_plans/courses/course_plan_room_extension.dart Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * cleanup * cleanup * fix: some name changes * formatting --------- Co-authored-by: WilsonLe <leanhminh2907@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: wcjord <32568597+wcjord@users.noreply.github.com>
118 lines
2.7 KiB
Dart
118 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:fluffychat/l10n/l10n.dart';
|
|
import 'package:fluffychat/pangea/course_plans/courses/course_plan_builder.dart';
|
|
import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_enum.dart';
|
|
|
|
class CourseInfoChip extends StatelessWidget {
|
|
final IconData icon;
|
|
final String text;
|
|
|
|
final double? fontSize;
|
|
final double? iconSize;
|
|
final EdgeInsets? padding;
|
|
|
|
const CourseInfoChip({
|
|
super.key,
|
|
required this.icon,
|
|
required this.text,
|
|
required this.fontSize,
|
|
required this.iconSize,
|
|
this.padding,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: padding ?? EdgeInsets.zero,
|
|
child: Row(
|
|
spacing: 4.0,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
size: iconSize,
|
|
),
|
|
Text(
|
|
text,
|
|
style: TextStyle(
|
|
fontSize: fontSize,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class CourseInfoChips extends StatefulWidget {
|
|
final String courseId;
|
|
final double? fontSize;
|
|
final double? iconSize;
|
|
final EdgeInsets? padding;
|
|
|
|
const CourseInfoChips(
|
|
this.courseId, {
|
|
super.key,
|
|
this.fontSize,
|
|
this.iconSize,
|
|
this.padding,
|
|
});
|
|
|
|
@override
|
|
State<CourseInfoChips> createState() => CourseInfoChipsState();
|
|
}
|
|
|
|
class CourseInfoChipsState extends State<CourseInfoChips>
|
|
with CoursePlanProvider {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
loadCourse(widget.courseId);
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(covariant CourseInfoChips oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (oldWidget.courseId != widget.courseId) {
|
|
loadCourse(widget.courseId);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (course == null) {
|
|
return const SizedBox.shrink();
|
|
}
|
|
|
|
return Wrap(
|
|
spacing: 8.0,
|
|
runSpacing: 8.0,
|
|
alignment: WrapAlignment.center,
|
|
children: [
|
|
CourseInfoChip(
|
|
icon: Icons.language,
|
|
text:
|
|
"${course!.baseLanguageDisplay} → ${course!.targetLanguageDisplay}",
|
|
fontSize: widget.fontSize,
|
|
iconSize: widget.iconSize,
|
|
padding: widget.padding,
|
|
),
|
|
CourseInfoChip(
|
|
icon: Icons.school,
|
|
text: course!.cefrLevel.string,
|
|
fontSize: widget.fontSize,
|
|
iconSize: widget.iconSize,
|
|
padding: widget.padding,
|
|
),
|
|
CourseInfoChip(
|
|
icon: Icons.location_on,
|
|
text: L10n.of(context).numModules(course!.topicIds.length),
|
|
fontSize: widget.fontSize,
|
|
iconSize: widget.iconSize,
|
|
padding: widget.padding,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|