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