design: Redesign chat app bar

This commit is contained in:
Christian Pauly 2022-02-17 12:52:58 +01:00
parent c7ebc6d63d
commit 5bd892668a
4 changed files with 46 additions and 44 deletions

View File

@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
@ -21,10 +20,8 @@ import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/pages/chat/chat_view.dart';
import 'package:fluffychat/pages/chat/cupertino_widgets_bottom_sheet.dart';
import 'package:fluffychat/pages/chat/event_info_dialog.dart';
import 'package:fluffychat/pages/chat/recording_dialog.dart';
import 'package:fluffychat/pages/chat/widgets_bottom_sheet.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/ios_badge_client_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
@ -585,17 +582,6 @@ class ChatController extends State<Chat> {
.any((cl) => selectedEvents.first.senderId == cl!.userID);
}
void showWidgetsSheet() => [TargetPlatform.iOS, TargetPlatform.macOS]
.contains(Theme.of(context).platform)
? showCupertinoModalPopup(
context: context,
builder: (context) => CupertinoWidgetsBottomSheet(room: room!),
)
: showModalBottomSheet(
context: context,
builder: (context) => WidgetsBottomSheet(room: room!),
);
void forwardEventsAction() async {
if (selectedEvents.length == 1) {
Matrix.of(context).shareContent = selectedEvents.first.content;

View File

@ -6,10 +6,7 @@ import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pages/user_bottom_sheet/user_bottom_sheet.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
import 'package:fluffychat/utils/room_status_extension.dart';
import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart';
class ChatAppBarTitle extends StatelessWidget {
final ChatController controller;
@ -25,12 +22,9 @@ class ChatAppBarTitle extends StatelessWidget {
return Text(controller.selectedEvents.length.toString());
}
final directChatMatrixID = room.directChatMatrixID;
return ListTile(
leading: Avatar(
mxContent: room.avatar,
name: room.displayname,
),
contentPadding: EdgeInsets.zero,
return InkWell(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
onTap: directChatMatrixID != null
? () => showModalBottomSheet(
context: context,
@ -42,20 +36,22 @@ class ChatAppBarTitle extends StatelessWidget {
),
)
: () => VRouter.of(context).toSegments(['rooms', room.id, 'details']),
title: Text(room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
maxLines: 1),
subtitle: StreamBuilder<Object>(
stream: Matrix.of(context)
.client
.onPresence
.stream
.where((p) => p.senderId == room.directChatMatrixID)
.rateLimit(const Duration(seconds: 1)),
builder: (context, snapshot) => Text(
room.getLocalizedStatus(context),
maxLines: 1,
//overflow: TextOverflow.ellipsis,
child: Row(
children: [
Avatar(
mxContent: room.avatar,
name: room.displayname,
size: 32,
),
const SizedBox(width: 12),
Text(
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
maxLines: 1,
style: const TextStyle(
fontSize: 16,
),
),
],
),
);
}

View File

@ -112,14 +112,7 @@ class ChatView extends StatelessWidget {
),
];
} else {
final widgets = controller.room?.widgets ?? [];
return [
if (widgets.isNotEmpty)
IconButton(
onPressed: controller.showWidgetsSheet,
icon: const Icon(Icons.widgets),
tooltip: L10n.of(context)!.matrixWidgets,
),
IconButton(
onPressed: controller.onPhoneButtonTap,
icon: const Icon(Icons.call_outlined),

View File

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:adaptive_dialog/adaptive_dialog.dart';
@ -8,6 +9,8 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/pages/chat/cupertino_widgets_bottom_sheet.dart';
import 'package:fluffychat/pages/chat/widgets_bottom_sheet.dart';
import 'matrix.dart';
class ChatSettingsPopupMenu extends StatefulWidget {
@ -40,6 +43,17 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
(u) => setState(() {}),
);
final items = <PopupMenuEntry<String>>[
if (widget.room.widgets.isNotEmpty)
PopupMenuItem<String>(
value: 'widgets',
child: Row(
children: [
const Icon(Icons.widgets_outlined),
const SizedBox(width: 12),
Text(L10n.of(context)!.matrixWidgets),
],
),
),
widget.room.pushRuleState == PushRuleState.notify
? PopupMenuItem<String>(
value: 'mute',
@ -90,6 +104,19 @@ class _ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
return PopupMenuButton(
onSelected: (String choice) async {
switch (choice) {
case 'widgets':
[TargetPlatform.iOS, TargetPlatform.macOS]
.contains(Theme.of(context).platform)
? showCupertinoModalPopup(
context: context,
builder: (context) =>
CupertinoWidgetsBottomSheet(room: widget.room),
)
: showModalBottomSheet(
context: context,
builder: (context) => WidgetsBottomSheet(room: widget.room),
);
break;
case 'leave':
final confirmed = await showOkCancelAlertDialog(
useRootNavigator: false,