mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 22:39:22 +00:00
Display the name of the call
This commit is contained in:
parent
0a03f581d1
commit
da641515fa
@ -143,6 +143,19 @@ class ConversationsHelper {
|
|||||||
return _conversationsDatabaseHelper.get(id);
|
return _conversationsDatabaseHelper.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get information about a conversation. The method throws an [Exception] in
|
||||||
|
/// case of failure
|
||||||
|
///
|
||||||
|
/// Return value of this method is never null.
|
||||||
|
Future<Conversation> getSingleOrThrow(int id, {bool force = false}) async {
|
||||||
|
final conv = await this.getSingle(id, force: force);
|
||||||
|
|
||||||
|
if (conv == null)
|
||||||
|
throw Exception("Could not get information about the conversation!");
|
||||||
|
|
||||||
|
return conv;
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the name of a [conversation]. This requires information
|
/// Get the name of a [conversation]. This requires information
|
||||||
/// about the users of this conversation
|
/// about the users of this conversation
|
||||||
static String getConversationName(
|
static String getConversationName(
|
||||||
@ -187,7 +200,7 @@ class ConversationsHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Asynchronously get the name fo the conversation
|
/// Asynchronously get the name of the conversation
|
||||||
///
|
///
|
||||||
/// Unlike the synchronous method, this method does not need information
|
/// Unlike the synchronous method, this method does not need information
|
||||||
/// about the members of the conversation
|
/// about the members of the conversation
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
import 'package:comunic/helpers/conversations_helper.dart';
|
||||||
|
import 'package:comunic/models/conversation.dart';
|
||||||
|
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
||||||
|
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||||
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Call screen
|
/// Call screen
|
||||||
@ -16,9 +22,67 @@ class CallScreen extends StatefulWidget {
|
|||||||
_CallScreenState createState() => _CallScreenState();
|
_CallScreenState createState() => _CallScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CallScreenState extends State<CallScreen> {
|
class _CallScreenState extends SafeState<CallScreen> {
|
||||||
|
// Widget properties
|
||||||
|
int get convID => widget.convID;
|
||||||
|
|
||||||
|
// State properties
|
||||||
|
Conversation _conversation;
|
||||||
|
String _convName;
|
||||||
|
var _error = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_initCall();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_endCall();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initCall() async {
|
||||||
|
try {
|
||||||
|
setState(() => _error = false);
|
||||||
|
|
||||||
|
// First, load information about the conversation
|
||||||
|
_conversation = await ConversationsHelper().getSingleOrThrow(convID);
|
||||||
|
_convName =
|
||||||
|
await ConversationsHelper.getConversationNameAsync(_conversation);
|
||||||
|
assert(_convName != null);
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
} catch (e, stack) {
|
||||||
|
print("Could not initialize call! $e\n$stack");
|
||||||
|
setState(() => _error = true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _endCall() async {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container();
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
leading: ComunicBackButton(),
|
||||||
|
title:
|
||||||
|
_convName == null ? CircularProgressIndicator() : Text(_convName),
|
||||||
|
),
|
||||||
|
body: _buildBody(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build widget body
|
||||||
|
Widget _buildBody() {
|
||||||
|
if (_error)
|
||||||
|
// Handle errors
|
||||||
|
return buildErrorCard(tr("Could not initialize call!"), actions: [
|
||||||
|
MaterialButton(
|
||||||
|
onPressed: () => _initCall(),
|
||||||
|
child: Text(tr("Try again").toUpperCase()),
|
||||||
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user