mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Use custom app bar for call windows
This commit is contained in:
		@@ -1,20 +1,25 @@
 | 
			
		||||
import 'package:comunic/ui/screens/call_screen.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/custom_app_bar_size.dart';
 | 
			
		||||
import 'package:comunic/ui/widgets/tablet_mode/calls/calls_area.dart';
 | 
			
		||||
import 'package:comunic/utils/intl_utils.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
/// Call window widget
 | 
			
		||||
///
 | 
			
		||||
/// @author Pierre HUBERT
 | 
			
		||||
 | 
			
		||||
const _WindowSize = Size(500, 200);
 | 
			
		||||
const _WindowSize = Size(450, 200);
 | 
			
		||||
 | 
			
		||||
class CallWindowWidget extends StatefulWidget {
 | 
			
		||||
  final int convID;
 | 
			
		||||
  final void Function() onClose;
 | 
			
		||||
 | 
			
		||||
  const CallWindowWidget({
 | 
			
		||||
    Key key,
 | 
			
		||||
    this.convID,
 | 
			
		||||
    @required this.convID,
 | 
			
		||||
    @required this.onClose,
 | 
			
		||||
  })  : assert(convID != null),
 | 
			
		||||
        assert(onClose != null),
 | 
			
		||||
        super(key: key);
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
@@ -43,6 +48,19 @@ class _CallWindowWidgetState extends State<CallWindowWidget> {
 | 
			
		||||
      child: Draggable(
 | 
			
		||||
        child: Card(
 | 
			
		||||
          child: CallScreen(
 | 
			
		||||
            buildCustomAppBar: (convName) => AppBarWrapper(
 | 
			
		||||
                height: 30,
 | 
			
		||||
                appBar: AppBar(
 | 
			
		||||
                  backgroundColor: Colors.black,
 | 
			
		||||
                  title: Text(convName == null ? tr("Loading...") : convName),
 | 
			
		||||
                  actions: <Widget>[
 | 
			
		||||
                    IconButton(
 | 
			
		||||
                      iconSize: 16,
 | 
			
		||||
                      icon: Icon(Icons.close),
 | 
			
		||||
                      onPressed: widget.onClose,
 | 
			
		||||
                    )
 | 
			
		||||
                  ],
 | 
			
		||||
                )),
 | 
			
		||||
            convID: widget.convID,
 | 
			
		||||
            floatingButtons: false,
 | 
			
		||||
          ),
 | 
			
		||||
 
 | 
			
		||||
@@ -19,8 +19,13 @@ class CallsAreaState extends State<CallsArea> {
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Stack(
 | 
			
		||||
      children: _openCalls
 | 
			
		||||
          .map((convID, key) =>
 | 
			
		||||
              MapEntry(convID, CallWindowWidget(key: key, convID: convID)))
 | 
			
		||||
          .map((convID, key) => MapEntry(
 | 
			
		||||
              convID,
 | 
			
		||||
              CallWindowWidget(
 | 
			
		||||
                key: key,
 | 
			
		||||
                convID: convID,
 | 
			
		||||
                onClose: () => closeCall(convID),
 | 
			
		||||
              )))
 | 
			
		||||
          .values
 | 
			
		||||
          .toList(),
 | 
			
		||||
    );
 | 
			
		||||
@@ -34,4 +39,10 @@ class CallsAreaState extends State<CallsArea> {
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Close a call
 | 
			
		||||
  void closeCall(int convID) {
 | 
			
		||||
    if (_openCalls.containsKey(convID))
 | 
			
		||||
      setState(() => _openCalls.remove(convID));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user