|
|
@ -1,6 +1,6 @@ |
|
|
|
import 'dart:io'; |
|
|
|
|
|
|
|
import 'package:Capsule/views/main/conversation/message.dart'; |
|
|
|
import 'package:Envelope/views/main/conversation/message.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:image_picker/image_picker.dart'; |
|
|
|
|
|
|
@ -25,6 +25,7 @@ class ConversationDetail extends StatefulWidget{ |
|
|
|
|
|
|
|
class _ConversationDetailState extends State<ConversationDetail> { |
|
|
|
List<Message> messages = []; |
|
|
|
|
|
|
|
MyProfile profile = MyProfile( |
|
|
|
id: '', |
|
|
|
username: '', |
|
|
@ -36,6 +37,8 @@ class _ConversationDetailState extends State<ConversationDetail> { |
|
|
|
bool showFilePicker = false; |
|
|
|
List<File> selectedImages = []; |
|
|
|
|
|
|
|
bool sendDisabled = false; |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Scaffold( |
|
|
@ -81,6 +84,9 @@ class _ConversationDetailState extends State<ConversationDetail> { |
|
|
|
|
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
print(widget.conversation.admin); |
|
|
|
print(widget.conversation.adminSendMessages); |
|
|
|
sendDisabled = widget.conversation.adminSendMessages && !widget.conversation.admin; |
|
|
|
super.initState(); |
|
|
|
fetchMessages(); |
|
|
|
} |
|
|
@ -202,6 +208,10 @@ class _ConversationDetailState extends State<ConversationDetail> { |
|
|
|
GestureDetector( |
|
|
|
onTap: (){ |
|
|
|
setState(() { |
|
|
|
if (sendDisabled) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
showFilePicker = !showFilePicker; |
|
|
|
}); |
|
|
|
}, |
|
|
@ -224,8 +234,11 @@ class _ConversationDetailState extends State<ConversationDetail> { |
|
|
|
|
|
|
|
Expanded( |
|
|
|
child: TextField( |
|
|
|
enabled: !sendDisabled, |
|
|
|
decoration: InputDecoration( |
|
|
|
hintText: 'Write message...', |
|
|
|
hintText: sendDisabled ? |
|
|
|
'Messages disabled for non-admins' : |
|
|
|
'Write message...', |
|
|
|
hintStyle: TextStyle( |
|
|
|
color: Theme.of(context).hintColor, |
|
|
|
), |
|
|
@ -244,7 +257,7 @@ class _ConversationDetailState extends State<ConversationDetail> { |
|
|
|
child: FittedBox( |
|
|
|
child: FloatingActionButton( |
|
|
|
onPressed: () async { |
|
|
|
if (msgController.text == '' && selectedImages.isEmpty) { |
|
|
|
if ((msgController.text == '' && selectedImages.isEmpty) || sendDisabled) { |
|
|
|
return; |
|
|
|
} |
|
|
|
await sendMessage( |
|
|
|