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...
 | 
					  /// This settings should be always true except for the small call window...
 | 
				
			||||||
  final bool floatingButtons;
 | 
					  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({
 | 
					  const CallScreen({
 | 
				
			||||||
    Key key,
 | 
					    Key key,
 | 
				
			||||||
    @required this.convID,
 | 
					    @required this.convID,
 | 
				
			||||||
    this.floatingButtons = true,
 | 
					    this.floatingButtons = true,
 | 
				
			||||||
 | 
					    this.buildCustomAppBar,
 | 
				
			||||||
  })  : assert(convID != null),
 | 
					  })  : assert(convID != null),
 | 
				
			||||||
        assert(convID > 0),
 | 
					        assert(convID > 0),
 | 
				
			||||||
        assert(floatingButtons != null),
 | 
					        assert(floatingButtons != null),
 | 
				
			||||||
@@ -453,22 +458,26 @@ class _CallScreenState extends SafeState<CallScreen> {
 | 
				
			|||||||
    return GestureDetector(
 | 
					    return GestureDetector(
 | 
				
			||||||
      onDoubleTap: () => _toggleMenuBarsVisibility(),
 | 
					      onDoubleTap: () => _toggleMenuBarsVisibility(),
 | 
				
			||||||
      child: Scaffold(
 | 
					      child: Scaffold(
 | 
				
			||||||
        appBar: _canHideMenuBar
 | 
					        appBar: _canHideMenuBar ? null : _buildAppBar(),
 | 
				
			||||||
            ? null
 | 
					 | 
				
			||||||
            : AppBar(
 | 
					 | 
				
			||||||
                leading: IconButton(
 | 
					 | 
				
			||||||
                  icon: Icon(Icons.arrow_back),
 | 
					 | 
				
			||||||
                  onPressed: () => _leaveCall(),
 | 
					 | 
				
			||||||
                ),
 | 
					 | 
				
			||||||
                title: _convName == null
 | 
					 | 
				
			||||||
                    ? CircularProgressIndicator()
 | 
					 | 
				
			||||||
                    : Text(_convName),
 | 
					 | 
				
			||||||
              ),
 | 
					 | 
				
			||||||
        body: _buildBody(),
 | 
					        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),
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Build widget body
 | 
					  /// Build widget body
 | 
				
			||||||
  Widget _buildBody() {
 | 
					  Widget _buildBody() {
 | 
				
			||||||
    // Handle errors
 | 
					    // Handle errors
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,20 +1,25 @@
 | 
				
			|||||||
import 'package:comunic/ui/screens/call_screen.dart';
 | 
					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/ui/widgets/tablet_mode/calls/calls_area.dart';
 | 
				
			||||||
 | 
					import 'package:comunic/utils/intl_utils.dart';
 | 
				
			||||||
import 'package:flutter/material.dart';
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Call window widget
 | 
					/// Call window widget
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
/// @author Pierre HUBERT
 | 
					/// @author Pierre HUBERT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const _WindowSize = Size(500, 200);
 | 
					const _WindowSize = Size(450, 200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CallWindowWidget extends StatefulWidget {
 | 
					class CallWindowWidget extends StatefulWidget {
 | 
				
			||||||
  final int convID;
 | 
					  final int convID;
 | 
				
			||||||
 | 
					  final void Function() onClose;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const CallWindowWidget({
 | 
					  const CallWindowWidget({
 | 
				
			||||||
    Key key,
 | 
					    Key key,
 | 
				
			||||||
    this.convID,
 | 
					    @required this.convID,
 | 
				
			||||||
 | 
					    @required this.onClose,
 | 
				
			||||||
  })  : assert(convID != null),
 | 
					  })  : assert(convID != null),
 | 
				
			||||||
 | 
					        assert(onClose != null),
 | 
				
			||||||
        super(key: key);
 | 
					        super(key: key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
@@ -43,6 +48,19 @@ class _CallWindowWidgetState extends State<CallWindowWidget> {
 | 
				
			|||||||
      child: Draggable(
 | 
					      child: Draggable(
 | 
				
			||||||
        child: Card(
 | 
					        child: Card(
 | 
				
			||||||
          child: CallScreen(
 | 
					          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,
 | 
					            convID: widget.convID,
 | 
				
			||||||
            floatingButtons: false,
 | 
					            floatingButtons: false,
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,8 +19,13 @@ class CallsAreaState extends State<CallsArea> {
 | 
				
			|||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
    return Stack(
 | 
					    return Stack(
 | 
				
			||||||
      children: _openCalls
 | 
					      children: _openCalls
 | 
				
			||||||
          .map((convID, key) =>
 | 
					          .map((convID, key) => MapEntry(
 | 
				
			||||||
              MapEntry(convID, CallWindowWidget(key: key, convID: convID)))
 | 
					              convID,
 | 
				
			||||||
 | 
					              CallWindowWidget(
 | 
				
			||||||
 | 
					                key: key,
 | 
				
			||||||
 | 
					                convID: convID,
 | 
				
			||||||
 | 
					                onClose: () => closeCall(convID),
 | 
				
			||||||
 | 
					              )))
 | 
				
			||||||
          .values
 | 
					          .values
 | 
				
			||||||
          .toList(),
 | 
					          .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