150 lines
3.8 KiB
Dart
150 lines
3.8 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
/// AI导师类型枚举
|
||
|
|
enum TutorType {
|
||
|
|
business,
|
||
|
|
daily,
|
||
|
|
travel,
|
||
|
|
academic,
|
||
|
|
}
|
||
|
|
|
||
|
|
/// AI导师扩展方法
|
||
|
|
extension TutorTypeExtension on TutorType {
|
||
|
|
String get displayName {
|
||
|
|
switch (this) {
|
||
|
|
case TutorType.business:
|
||
|
|
return '商务导师';
|
||
|
|
case TutorType.daily:
|
||
|
|
return '日常导师';
|
||
|
|
case TutorType.travel:
|
||
|
|
return '旅行导师';
|
||
|
|
case TutorType.academic:
|
||
|
|
return '学术导师';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
String get description {
|
||
|
|
switch (this) {
|
||
|
|
case TutorType.business:
|
||
|
|
return '专业商务场景';
|
||
|
|
case TutorType.daily:
|
||
|
|
return '生活场景对话';
|
||
|
|
case TutorType.travel:
|
||
|
|
return '旅游场景专训';
|
||
|
|
case TutorType.academic:
|
||
|
|
return '学术讨论演讲';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
IconData get icon {
|
||
|
|
switch (this) {
|
||
|
|
case TutorType.business:
|
||
|
|
return Icons.business_center;
|
||
|
|
case TutorType.daily:
|
||
|
|
return Icons.chat;
|
||
|
|
case TutorType.travel:
|
||
|
|
return Icons.flight;
|
||
|
|
case TutorType.academic:
|
||
|
|
return Icons.school;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
Color get color {
|
||
|
|
switch (this) {
|
||
|
|
case TutorType.business:
|
||
|
|
return Colors.blue;
|
||
|
|
case TutorType.daily:
|
||
|
|
return Colors.green;
|
||
|
|
case TutorType.travel:
|
||
|
|
return Colors.orange;
|
||
|
|
case TutorType.academic:
|
||
|
|
return Colors.purple;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// AI导师模型
|
||
|
|
class AITutor {
|
||
|
|
final String id;
|
||
|
|
final TutorType type;
|
||
|
|
final String name;
|
||
|
|
final String avatar;
|
||
|
|
final String introduction;
|
||
|
|
final List<String> specialties;
|
||
|
|
final List<String> sampleQuestions;
|
||
|
|
final String personality;
|
||
|
|
final DateTime createdAt;
|
||
|
|
final DateTime updatedAt;
|
||
|
|
|
||
|
|
const AITutor({
|
||
|
|
required this.id,
|
||
|
|
required this.type,
|
||
|
|
required this.name,
|
||
|
|
required this.avatar,
|
||
|
|
required this.introduction,
|
||
|
|
required this.specialties,
|
||
|
|
required this.sampleQuestions,
|
||
|
|
required this.personality,
|
||
|
|
required this.createdAt,
|
||
|
|
required this.updatedAt,
|
||
|
|
});
|
||
|
|
|
||
|
|
factory AITutor.fromJson(Map<String, dynamic> json) {
|
||
|
|
return AITutor(
|
||
|
|
id: json['id'] as String,
|
||
|
|
type: TutorType.values.firstWhere(
|
||
|
|
(e) => e.name == json['type'],
|
||
|
|
orElse: () => TutorType.daily,
|
||
|
|
),
|
||
|
|
name: json['name'] as String,
|
||
|
|
avatar: json['avatar'] as String,
|
||
|
|
introduction: json['introduction'] as String,
|
||
|
|
specialties: List<String>.from(json['specialties'] as List),
|
||
|
|
sampleQuestions: List<String>.from(json['sampleQuestions'] as List),
|
||
|
|
personality: json['personality'] as String,
|
||
|
|
createdAt: DateTime.parse(json['createdAt'] as String),
|
||
|
|
updatedAt: DateTime.parse(json['updatedAt'] as String),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
Map<String, dynamic> toJson() {
|
||
|
|
return {
|
||
|
|
'id': id,
|
||
|
|
'type': type.name,
|
||
|
|
'name': name,
|
||
|
|
'avatar': avatar,
|
||
|
|
'introduction': introduction,
|
||
|
|
'specialties': specialties,
|
||
|
|
'sampleQuestions': sampleQuestions,
|
||
|
|
'personality': personality,
|
||
|
|
'createdAt': createdAt.toIso8601String(),
|
||
|
|
'updatedAt': updatedAt.toIso8601String(),
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
AITutor copyWith({
|
||
|
|
String? id,
|
||
|
|
TutorType? type,
|
||
|
|
String? name,
|
||
|
|
String? avatar,
|
||
|
|
String? introduction,
|
||
|
|
List<String>? specialties,
|
||
|
|
List<String>? sampleQuestions,
|
||
|
|
String? personality,
|
||
|
|
DateTime? createdAt,
|
||
|
|
DateTime? updatedAt,
|
||
|
|
}) {
|
||
|
|
return AITutor(
|
||
|
|
id: id ?? this.id,
|
||
|
|
type: type ?? this.type,
|
||
|
|
name: name ?? this.name,
|
||
|
|
avatar: avatar ?? this.avatar,
|
||
|
|
introduction: introduction ?? this.introduction,
|
||
|
|
specialties: specialties ?? this.specialties,
|
||
|
|
sampleQuestions: sampleQuestions ?? this.sampleQuestions,
|
||
|
|
personality: personality ?? this.personality,
|
||
|
|
createdAt: createdAt ?? this.createdAt,
|
||
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|