145 lines
4.0 KiB
Dart
145 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:onufitness/screens/chat/controllers/chat_controller.dart';
|
|
|
|
void showMediaOptions(
|
|
BuildContext context,
|
|
String targetUserId, {
|
|
bool isGroup = false,
|
|
}) {
|
|
final chatCtrl = Get.find<ChatController>();
|
|
|
|
Get.bottomSheet(
|
|
Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: const BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey.shade300,
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
const Text(
|
|
"Share Media",
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 20),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
MediaOptionButton(
|
|
icon: Icons.camera_alt,
|
|
label: "Camera",
|
|
color: Colors.blue,
|
|
onTap: () async {
|
|
Get.back();
|
|
await chatCtrl.sendImageFromCamera(
|
|
targetUserId,
|
|
isGroup: isGroup,
|
|
);
|
|
},
|
|
),
|
|
MediaOptionButton(
|
|
icon: Icons.image,
|
|
label: "Gallery",
|
|
color: Colors.purple,
|
|
onTap: () async {
|
|
Get.back();
|
|
await chatCtrl.sendImageFromGallery(
|
|
targetUserId,
|
|
isGroup: isGroup,
|
|
);
|
|
},
|
|
),
|
|
MediaOptionButton(
|
|
icon: Icons.videocam,
|
|
label: "Video",
|
|
color: Colors.red,
|
|
onTap: () async {
|
|
Get.back();
|
|
await chatCtrl.sendVideo(targetUserId, isGroup: isGroup);
|
|
},
|
|
),
|
|
MediaOptionButton(
|
|
icon: Icons.insert_drive_file,
|
|
label: "Document",
|
|
color: Colors.orange,
|
|
onTap: () async {
|
|
Get.back();
|
|
await chatCtrl.sendDocument(targetUserId, isGroup: isGroup);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
Container(
|
|
color: Colors.white,
|
|
|
|
padding: EdgeInsetsDirectional.only(
|
|
bottom: MediaQuery.of(context).viewPadding.bottom,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
isScrollControlled: true,
|
|
);
|
|
}
|
|
|
|
// MediaOptionButton widget if not already defined
|
|
class MediaOptionButton extends StatelessWidget {
|
|
final IconData icon;
|
|
final String label;
|
|
final Color color;
|
|
final VoidCallback onTap;
|
|
|
|
const MediaOptionButton({
|
|
super.key,
|
|
required this.icon,
|
|
required this.label,
|
|
required this.color,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
width: 60,
|
|
height: 60,
|
|
decoration: BoxDecoration(
|
|
color: color.withValues(alpha: 0.1),
|
|
shape: BoxShape.circle,
|
|
border: Border.all(color: color.withValues(alpha: 0.3)),
|
|
),
|
|
child: Icon(icon, color: color, size: 28),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
label,
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.grey.shade700,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|