mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Display the name of the call
This commit is contained in:
		@@ -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';
 | 
			
		||||
 | 
			
		||||
/// Call screen
 | 
			
		||||
@@ -16,9 +22,67 @@ class CallScreen extends StatefulWidget {
 | 
			
		||||
  _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
 | 
			
		||||
  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()),
 | 
			
		||||
        )
 | 
			
		||||
      ]);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user