mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +00:00 
			
		
		
		
	Use custom app bar for call windows
This commit is contained in:
		@@ -32,10 +32,15 @@ class CallScreen extends StatefulWidget {
 | 
			
		||||
  /// This settings should be always true except for the small call window...
 | 
			
		||||
  final bool floatingButtons;
 | 
			
		||||
 | 
			
		||||
  /// Use custom application bar. This function takes as parameter a nullable
 | 
			
		||||
  /// String which is the title of the conversation
 | 
			
		||||
  final PreferredSizeWidget Function(String) buildCustomAppBar;
 | 
			
		||||
 | 
			
		||||
  const CallScreen({
 | 
			
		||||
    Key key,
 | 
			
		||||
    @required this.convID,
 | 
			
		||||
    this.floatingButtons = true,
 | 
			
		||||
    this.buildCustomAppBar,
 | 
			
		||||
  })  : assert(convID != null),
 | 
			
		||||
        assert(convID > 0),
 | 
			
		||||
        assert(floatingButtons != null),
 | 
			
		||||
@@ -453,19 +458,23 @@ class _CallScreenState extends SafeState<CallScreen> {
 | 
			
		||||
    return GestureDetector(
 | 
			
		||||
      onDoubleTap: () => _toggleMenuBarsVisibility(),
 | 
			
		||||
      child: Scaffold(
 | 
			
		||||
        appBar: _canHideMenuBar
 | 
			
		||||
            ? null
 | 
			
		||||
            : AppBar(
 | 
			
		||||
        appBar: _canHideMenuBar ? null : _buildAppBar(),
 | 
			
		||||
        body: _buildBody(),
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Build application bar
 | 
			
		||||
  PreferredSizeWidget _buildAppBar() {
 | 
			
		||||
    if (widget.buildCustomAppBar != null)
 | 
			
		||||
      return widget.buildCustomAppBar(_convName);
 | 
			
		||||
 | 
			
		||||
    return AppBar(
 | 
			
		||||
      leading: IconButton(
 | 
			
		||||
        icon: Icon(Icons.arrow_back),
 | 
			
		||||
        onPressed: () => _leaveCall(),
 | 
			
		||||
      ),
 | 
			
		||||
                title: _convName == null
 | 
			
		||||
                    ? CircularProgressIndicator()
 | 
			
		||||
                    : Text(_convName),
 | 
			
		||||
              ),
 | 
			
		||||
        body: _buildBody(),
 | 
			
		||||
      ),
 | 
			
		||||
      title: _convName == null ? CircularProgressIndicator() : Text(_convName),
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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