mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-19 10:39:26 +01:00
Add chat topic feature
This commit is contained in:
parent
1153085742
commit
b9be7affda
@ -14,6 +14,7 @@ import 'package:fluffychat/views/invitation_selection.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.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';
|
||||||
|
import 'package:link_text/link_text.dart';
|
||||||
import 'package:toast/toast.dart';
|
import 'package:toast/toast.dart';
|
||||||
|
|
||||||
class ChatDetails extends StatefulWidget {
|
class ChatDetails extends StatefulWidget {
|
||||||
@ -27,6 +28,7 @@ class ChatDetails extends StatefulWidget {
|
|||||||
|
|
||||||
class _ChatDetailsState extends State<ChatDetails> {
|
class _ChatDetailsState extends State<ChatDetails> {
|
||||||
List<User> members;
|
List<User> members;
|
||||||
|
bool topicEditMode = false;
|
||||||
void setDisplaynameAction(BuildContext context, String displayname) async {
|
void setDisplaynameAction(BuildContext context, String displayname) async {
|
||||||
final MatrixState matrix = Matrix.of(context);
|
final MatrixState matrix = Matrix.of(context);
|
||||||
final success = await matrix.tryRequestWithLoadingDialog(
|
final success = await matrix.tryRequestWithLoadingDialog(
|
||||||
@ -41,6 +43,21 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTopicAction(BuildContext context, String displayname) async {
|
||||||
|
setState(() => topicEditMode = false);
|
||||||
|
final MatrixState matrix = Matrix.of(context);
|
||||||
|
final success = await matrix.tryRequestWithLoadingDialog(
|
||||||
|
widget.room.setDescription(displayname),
|
||||||
|
);
|
||||||
|
if (success != false) {
|
||||||
|
Toast.show(
|
||||||
|
"Group description has been changed",
|
||||||
|
context,
|
||||||
|
duration: Toast.LENGTH_LONG,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setAvatarAction(BuildContext context) async {
|
void setAvatarAction(BuildContext context) async {
|
||||||
final File tempFile = await ImagePicker.pickImage(
|
final File tempFile = await ImagePicker.pickImage(
|
||||||
source: ImageSource.gallery,
|
source: ImageSource.gallery,
|
||||||
@ -111,30 +128,63 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ContentBanner(widget.room.avatar),
|
ContentBanner(widget.room.avatar),
|
||||||
Divider(height: 1),
|
Divider(height: 1),
|
||||||
widget.room.canSendEvent("m.room.avatar") && !kIsWeb
|
if (widget.room.canSendEvent("m.room.avatar") && !kIsWeb)
|
||||||
? ListTile(
|
ListTile(
|
||||||
title: Text("Upload group avatar"),
|
title: Text("Upload group avatar"),
|
||||||
leading: Icon(Icons.camera),
|
leading: Icon(Icons.camera),
|
||||||
onTap: () => setAvatarAction(context),
|
onTap: () => setAvatarAction(context),
|
||||||
)
|
),
|
||||||
: Container(),
|
if (widget.room.canSendEvent("m.room.name"))
|
||||||
widget.room.canSendEvent("m.room.name")
|
ListTile(
|
||||||
? ListTile(
|
|
||||||
leading: Icon(Icons.edit),
|
leading: Icon(Icons.edit),
|
||||||
title: TextField(
|
title: TextField(
|
||||||
textInputAction: TextInputAction.done,
|
textInputAction: TextInputAction.done,
|
||||||
onSubmitted: (s) =>
|
onSubmitted: (s) => setDisplaynameAction(context, s),
|
||||||
setDisplaynameAction(context, s),
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
labelText: "Set group name",
|
labelText: "Set group name",
|
||||||
labelStyle: TextStyle(color: Colors.black),
|
labelStyle: TextStyle(color: Colors.black),
|
||||||
hintText:
|
hintText: (RoomNameCalculator(widget.room).name),
|
||||||
(RoomNameCalculator(widget.room).name),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
topicEditMode
|
||||||
|
? ListTile(
|
||||||
|
title: TextField(
|
||||||
|
textInputAction: TextInputAction.done,
|
||||||
|
onSubmitted: (s) => setTopicAction(context, s),
|
||||||
|
autofocus: true,
|
||||||
|
minLines: 1,
|
||||||
|
maxLines: 4,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: InputBorder.none,
|
||||||
|
labelText: "Group description:",
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
hintText: widget.room.topic ??
|
||||||
|
"Set group description",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: Container(),
|
: ListTile(
|
||||||
|
title: Text("Group description:",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
subtitle: LinkText(
|
||||||
|
text: widget.room.topic?.isEmpty ?? true
|
||||||
|
? "Add a group description"
|
||||||
|
: widget.room.topic,
|
||||||
|
textStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onTap: widget.room.canSendEvent("m.room.topic")
|
||||||
|
? () => setState(() => topicEditMode = true)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
"$actualMembersCount participant" +
|
"$actualMembersCount participant" +
|
||||||
|
Loading…
Reference in New Issue
Block a user