Added functionality to create chat
This commit is contained in:
parent
0f3fe75bad
commit
82b10e4eed
24
lib/api/marianumcloud/talk/createRoom/createRoom.dart
Normal file
24
lib/api/marianumcloud/talk/createRoom/createRoom.dart
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
|
import '../talkApi.dart';
|
||||||
|
import 'createRoomParams.dart';
|
||||||
|
class CreateRoom extends TalkApi<void> {
|
||||||
|
CreateRoomParams params;
|
||||||
|
|
||||||
|
CreateRoom(this.params) : super("v4/room", params);
|
||||||
|
|
||||||
|
@override
|
||||||
|
assemble(String raw) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
|
||||||
|
if(body is CreateRoomParams) {
|
||||||
|
return http.post(uri, headers: headers, body: body.toJson().map((key, value) => MapEntry(key, value.toString())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
27
lib/api/marianumcloud/talk/createRoom/createRoomParams.dart
Normal file
27
lib/api/marianumcloud/talk/createRoom/createRoomParams.dart
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:json_annotation/json_annotation.dart';
|
||||||
|
|
||||||
|
import '../../../apiParams.dart';
|
||||||
|
|
||||||
|
part 'createRoomParams.g.dart';
|
||||||
|
|
||||||
|
@JsonSerializable()
|
||||||
|
class CreateRoomParams extends ApiParams {
|
||||||
|
int roomType;
|
||||||
|
String invite;
|
||||||
|
String? source;
|
||||||
|
String? roomName;
|
||||||
|
String? objectType;
|
||||||
|
String? objectId;
|
||||||
|
|
||||||
|
CreateRoomParams({
|
||||||
|
required this.roomType,
|
||||||
|
required this.invite,
|
||||||
|
this.source,
|
||||||
|
this.roomName,
|
||||||
|
this.objectType,
|
||||||
|
this.objectId
|
||||||
|
});
|
||||||
|
|
||||||
|
factory CreateRoomParams.fromJson(Map<String, dynamic> json) => _$CreateRoomParamsFromJson(json);
|
||||||
|
Map<String, dynamic> toJson() => _$CreateRoomParamsToJson(this);
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'createRoomParams.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
CreateRoomParams _$CreateRoomParamsFromJson(Map<String, dynamic> json) =>
|
||||||
|
CreateRoomParams(
|
||||||
|
roomType: json['roomType'] as int,
|
||||||
|
invite: json['invite'] as String,
|
||||||
|
source: json['source'] as String?,
|
||||||
|
roomName: json['roomName'] as String?,
|
||||||
|
objectType: json['objectType'] as String?,
|
||||||
|
objectId: json['objectId'] as String?,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$CreateRoomParamsToJson(CreateRoomParams instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'roomType': instance.roomType,
|
||||||
|
'invite': instance.invite,
|
||||||
|
'source': instance.source,
|
||||||
|
'roomName': instance.roomName,
|
||||||
|
'objectType': instance.objectType,
|
||||||
|
'objectId': instance.objectId,
|
||||||
|
};
|
@ -1,8 +1,11 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
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 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../../api/marianumcloud/talk/createRoom/createRoom.dart';
|
||||||
import '../../../model/chatList/chatListProps.dart';
|
import '../../../model/chatList/chatListProps.dart';
|
||||||
import '../../../storage/base/settingsProvider.dart';
|
import '../../../storage/base/settingsProvider.dart';
|
||||||
import 'chatTile.dart';
|
import 'chatTile.dart';
|
||||||
@ -51,8 +54,24 @@ class _ChatListState extends State<ChatList> {
|
|||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
heroTag: "createChat",
|
heroTag: "createChat",
|
||||||
backgroundColor: Theme.of(context).primaryColor,
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
showSearch(context: context, delegate: JoinChat());
|
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),
|
child: const Icon(Icons.add_comment_outlined),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user