Added functionality to create chat

This commit is contained in:
2023-06-08 21:27:51 +02:00
parent 0f3fe75bad
commit 82b10e4eed
4 changed files with 99 additions and 2 deletions

View File

@ -1,8 +1,11 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:marianum_mobile/api/marianumcloud/talk/createRoom/createRoomParams.dart';
import 'package:marianum_mobile/widget/confirmDialog.dart';
import 'package:provider/provider.dart';
import '../../../api/marianumcloud/talk/createRoom/createRoom.dart';
import '../../../model/chatList/chatListProps.dart';
import '../../../storage/base/settingsProvider.dart';
import 'chatTile.dart';
@ -51,8 +54,24 @@ class _ChatListState extends State<ChatList> {
floatingActionButton: FloatingActionButton(
heroTag: "createChat",
backgroundColor: Theme.of(context).primaryColor,
onPressed: () {
showSearch(context: context, delegate: JoinChat());
onPressed: () async {
showSearch(context: context, delegate: JoinChat()).then((username) {
if(username == null) return;
ConfirmDialog(
title: "Chat starten",
content: "Möchtest du einen Chat mit nutzer '$username' starten?",
confirmButton: "Chat starten",
onConfirm: () {
CreateRoom(CreateRoomParams(
roomType: 1,
invite: username,
)).run().then((value) {
_query(renew: true);
});
},
).asDialog(context);
});
},
child: const Icon(Icons.add_comment_outlined),
),