120 lines
3.5 KiB
Dart
120 lines
3.5 KiB
Dart
// 分享 BottomSheet — 编辑器完成后选择分享到班级或仅自己可见
|
|
//
|
|
// 设计要点:
|
|
// - 温暖友好的文案(面向小学生)
|
|
// - 分享到班级(有班级时显示)/ 仅自己可见
|
|
// - 无班级时提示加入班级后可分享
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// 编辑器完成后的分享选择面板
|
|
class ShareBottomSheet extends StatelessWidget {
|
|
final String? classId;
|
|
final String className;
|
|
final void Function(bool shareToClass) onDecision;
|
|
|
|
const ShareBottomSheet({
|
|
super.key,
|
|
required this.classId,
|
|
required this.className,
|
|
required this.onDecision,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final hasClass = classId != null && classId!.isNotEmpty;
|
|
final theme = Theme.of(context);
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: theme.colorScheme.surface,
|
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(22)),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// 拖拽条
|
|
Center(
|
|
child: Container(
|
|
margin: const EdgeInsets.only(bottom: 16),
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey.shade300,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
'日记写好了!',
|
|
style: theme.textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'要分享给老师和同学们看看吗?',
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: Colors.grey.shade600,
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
|
|
// 分享到班级
|
|
if (hasClass) ...[
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 52,
|
|
child: FilledButton.icon(
|
|
onPressed: () {
|
|
onDecision(true);
|
|
Navigator.pop(context);
|
|
},
|
|
icon: const Icon(Icons.group),
|
|
label: Text('分享到 $className'),
|
|
style: FilledButton.styleFrom(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
],
|
|
|
|
// 仅自己可见
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 52,
|
|
child: OutlinedButton.icon(
|
|
onPressed: () {
|
|
onDecision(false);
|
|
Navigator.pop(context);
|
|
},
|
|
icon: const Icon(Icons.lock_outline),
|
|
label: const Text('仅自己可见'),
|
|
style: OutlinedButton.styleFrom(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
// 无班级时的提示
|
|
if (!hasClass) ...[
|
|
const SizedBox(height: 12),
|
|
Text(
|
|
'加入班级后可以分享给老师和同学哦',
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
|
color: Colors.grey.shade500,
|
|
),
|
|
),
|
|
],
|
|
|
|
const SizedBox(height: 8),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|