mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Can create conversations
This commit is contained in:
@ -1,11 +1,4 @@
|
||||
import 'package:comunic/helpers/conversations_helper.dart';
|
||||
import 'package:comunic/helpers/users_helper.dart';
|
||||
import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/ui/screens/update_conversation_screen.dart';
|
||||
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Update a conversation route
|
||||
@ -24,69 +17,7 @@ class UpdateConversationRoute extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _UpdateConversationRoute extends State<UpdateConversationRoute> {
|
||||
Conversation _conversation;
|
||||
UsersList _membersInfo;
|
||||
bool _error = false;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_loadConversation();
|
||||
}
|
||||
|
||||
void setError(bool e) => setState(() {
|
||||
_error = e;
|
||||
});
|
||||
|
||||
/// Load information about the being updated conversation
|
||||
Future<void> _loadConversation() async {
|
||||
setError(false);
|
||||
|
||||
try {
|
||||
final conversation = await ConversationsHelper()
|
||||
.getSingle(widget.conversationID, force: true);
|
||||
|
||||
//Load information about the members of the conversation
|
||||
_membersInfo = await UsersHelper().getList(conversation.membersID);
|
||||
|
||||
setState(() => _conversation = conversation);
|
||||
} catch (e, s) {
|
||||
print("Failed to load conversation information! $e=>$s");
|
||||
setError(true);
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the body of this widget
|
||||
Widget _buildBody() {
|
||||
if (_error)
|
||||
return buildErrorCard(
|
||||
tr("Could not load information about the conversation"),
|
||||
actions: [
|
||||
FlatButton(
|
||||
onPressed: _loadConversation,
|
||||
child: Text(
|
||||
tr("Retry").toUpperCase(),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
)
|
||||
]);
|
||||
|
||||
if (_conversation == null) return buildLoadingPage();
|
||||
|
||||
return UpdateConversationScreen(
|
||||
initialUsers: _membersInfo,
|
||||
initialSettings: _conversation,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: ComunicBackButton(),
|
||||
title: Text(tr("Update a conversation")),
|
||||
),
|
||||
body: _buildBody(),
|
||||
);
|
||||
}
|
||||
Widget build(BuildContext context) =>
|
||||
UpdateConversationScreen(convID: widget.conversationID);
|
||||
}
|
||||
|
Reference in New Issue
Block a user