93 lines
3.6 KiB
Dart
93 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../core/navigation_provider.dart';
|
|
import '../../providers/data_providers.dart';
|
|
|
|
/// 医生列表页
|
|
class DoctorListPage extends ConsumerWidget {
|
|
const DoctorListPage({super.key});
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final doctors = ref.watch(doctorListProvider);
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('选择医生')),
|
|
body: doctors.when(
|
|
data: (list) {
|
|
if (list.isEmpty) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.person_search, size: 64, color: Colors.grey[300]),
|
|
const SizedBox(height: 12),
|
|
Text('暂无可用医生', style: Theme.of(context).textTheme.bodyMedium),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
return ListView.builder(
|
|
itemCount: list.length,
|
|
itemBuilder: (ctx, i) {
|
|
final d = list[i];
|
|
return Card(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Row(children: [
|
|
CircleAvatar(
|
|
radius: 28,
|
|
backgroundColor: const Color(0xFFF0F2FF),
|
|
child: Text(
|
|
(d['name'] as String?)?.isNotEmpty == true ? d['name']![0] : '?',
|
|
style: const TextStyle(fontSize: 22, color: Color(0xFF8B9CF7)),
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(children: [
|
|
Text(d['name'] ?? '', style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600)),
|
|
const SizedBox(width: 8),
|
|
Text(d['title'] ?? '', style: const TextStyle(fontSize: 14, color: Color(0xFF666666))),
|
|
]),
|
|
const SizedBox(height: 4),
|
|
Text(d['department'] ?? '', style: const TextStyle(fontSize: 14, color: Color(0xFF8B9CF7))),
|
|
const SizedBox(height: 2),
|
|
Text(d['introduction'] ?? '', style: const TextStyle(fontSize: 14, color: Color(0xFF999999))),
|
|
],
|
|
),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () => pushRoute(ref, 'consultation', params: {'id': d['id']?.toString() ?? ''}),
|
|
child: const Text('咨询'),
|
|
),
|
|
]),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
error: (_, _) => Center(
|
|
child: Text('加载失败', style: Theme.of(context).textTheme.bodyMedium),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 问诊对话页
|
|
class DoctorChatPage extends ConsumerWidget {
|
|
final String id;
|
|
const DoctorChatPage({super.key, required this.id});
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) => Scaffold(
|
|
appBar: AppBar(title: const Text('问诊对话')),
|
|
body: Center(
|
|
child: Text('问诊 #$id', style: Theme.of(context).textTheme.bodyLarge),
|
|
),
|
|
);
|
|
}
|