mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-19 10:39:26 +01:00
fix: Popup menu without elevation
This commit is contained in:
parent
0b90e1ff88
commit
7f6c914fca
@ -10,6 +10,7 @@ import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../widgets/m2_popup_menu_button.dart';
|
||||
import 'chat.dart';
|
||||
import 'input_bar.dart';
|
||||
|
||||
@ -89,7 +90,7 @@ class ChatInputRow extends StatelessWidget {
|
||||
alignment: Alignment.center,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: const BoxDecoration(),
|
||||
child: PopupMenuButton<String>(
|
||||
child: M2PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.add_outlined),
|
||||
onSelected: controller.onAddPopupMenuButtonSelected,
|
||||
itemBuilder: (BuildContext context) =>
|
||||
@ -295,7 +296,7 @@ class _ChatAccountPicker extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: FutureBuilder<Profile>(
|
||||
future: controller.sendingClient!.fetchOwnProfile(),
|
||||
builder: (context, snapshot) => PopupMenuButton<String>(
|
||||
builder: (context, snapshot) => M2PopupMenuButton<String>(
|
||||
onSelected: _popupMenuButtonSelected,
|
||||
itemBuilder: (BuildContext context) => clients
|
||||
.map((client) => PopupMenuItem<String>(
|
||||
|
@ -21,6 +21,7 @@ import 'package:fluffychat/widgets/connection_status_header.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/unread_badge_back_button.dart';
|
||||
import '../../utils/stream_extension.dart';
|
||||
import '../../widgets/m2_popup_menu_button.dart';
|
||||
import 'chat_emoji_picker.dart';
|
||||
import 'chat_input_row.dart';
|
||||
|
||||
@ -65,7 +66,7 @@ class ChatView extends StatelessWidget {
|
||||
tooltip: L10n.of(context)!.pinMessage,
|
||||
),
|
||||
if (controller.selectedEvents.length == 1)
|
||||
PopupMenuButton<_EventContextAction>(
|
||||
M2PopupMenuButton<_EventContextAction>(
|
||||
onSelected: (action) {
|
||||
switch (action) {
|
||||
case _EventContextAction.info:
|
||||
|
@ -16,6 +16,7 @@ import 'package:fluffychat/widgets/content_banner.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../utils/url_launcher.dart';
|
||||
import '../../widgets/m2_popup_menu_button.dart';
|
||||
|
||||
class ChatDetailsView extends StatelessWidget {
|
||||
final ChatDetailsController controller;
|
||||
@ -197,7 +198,7 @@ class ChatDetailsView extends StatelessWidget {
|
||||
Text(L10n.of(context)!.setCustomEmotes),
|
||||
onTap: controller.goToEmoteSettings,
|
||||
),
|
||||
PopupMenuButton(
|
||||
M2PopupMenuButton(
|
||||
onSelected: controller.setJoinRulesAction,
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<JoinRules>>[
|
||||
@ -231,7 +232,7 @@ class ChatDetailsView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
PopupMenuButton(
|
||||
M2PopupMenuButton(
|
||||
onSelected:
|
||||
controller.setHistoryVisibilityAction,
|
||||
itemBuilder: (BuildContext context) =>
|
||||
@ -284,7 +285,7 @@ class ChatDetailsView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
if (room.joinRules == JoinRules.public)
|
||||
PopupMenuButton(
|
||||
M2PopupMenuButton(
|
||||
onSelected: controller.setGuestAccessAction,
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<GuestAccess>>[
|
||||
|
@ -9,6 +9,7 @@ import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../utils/matrix_sdk_extensions.dart/device_extension.dart';
|
||||
import '../../widgets/m2_popup_menu_button.dart';
|
||||
|
||||
class ChatEncryptionSettingsView extends StatelessWidget {
|
||||
final ChatEncryptionSettingsController controller;
|
||||
@ -73,7 +74,7 @@ class ChatEncryptionSettingsView extends StatelessWidget {
|
||||
deviceKeys[i].userId !=
|
||||
deviceKeys[i - 1].userId) ...{
|
||||
const Divider(height: 1, thickness: 1),
|
||||
PopupMenuButton(
|
||||
M2PopupMenuButton(
|
||||
onSelected: (dynamic action) => controller
|
||||
.onSelected(context, action, deviceKeys[i]),
|
||||
itemBuilder: (c) {
|
||||
@ -115,7 +116,7 @@ class ChatEncryptionSettingsView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
},
|
||||
PopupMenuButton(
|
||||
M2PopupMenuButton(
|
||||
onSelected: (dynamic action) => controller
|
||||
.onSelected(context, action, deviceKeys[i]),
|
||||
itemBuilder: (c) {
|
||||
|
@ -9,6 +9,7 @@ import 'package:vrouter/vrouter.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../utils/fluffy_share.dart';
|
||||
import '../../widgets/m2_popup_menu_button.dart';
|
||||
import 'chat_list.dart';
|
||||
|
||||
class ClientChooserButton extends StatelessWidget {
|
||||
@ -191,12 +192,7 @@ class ClientChooserButton extends StatelessWidget {
|
||||
onKeysPressed: () => _previousAccount(matrix, context),
|
||||
child: Container(),
|
||||
),
|
||||
Theme(
|
||||
data: Theme.of(context),
|
||||
child: PopupMenuButton<Object>(
|
||||
shape: Border.all(
|
||||
color: Theme.of(context).dividerColor,
|
||||
),
|
||||
M2PopupMenuButton<Object>(
|
||||
onSelected: (o) => _clientSelected(o, context),
|
||||
itemBuilder: _bundleMenuItems,
|
||||
child: Material(
|
||||
@ -211,7 +207,6 @@ class ClientChooserButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -14,6 +14,7 @@ import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/utils/string_color.dart';
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import '../../widgets/m2_popup_menu_button.dart';
|
||||
|
||||
class StoryView extends StatelessWidget {
|
||||
final StoryPageController controller;
|
||||
@ -101,7 +102,7 @@ class StoryView extends StatelessWidget {
|
||||
icon: Icon(Icons.adaptive.share_outlined),
|
||||
onPressed: controller.share,
|
||||
),
|
||||
PopupMenuButton<PopupStoryAction>(
|
||||
M2PopupMenuButton<PopupStoryAction>(
|
||||
color: Colors.white,
|
||||
onSelected: controller.onPopupStoryAction,
|
||||
itemBuilder: (context) => [
|
||||
|
@ -9,6 +9,7 @@ import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/utils/fluffy_share.dart';
|
||||
import '../../utils/matrix_sdk_extensions.dart/presence_extension.dart';
|
||||
import '../../widgets/content_banner.dart';
|
||||
import '../../widgets/m2_popup_menu_button.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
import 'user_bottom_sheet.dart';
|
||||
|
||||
@ -43,7 +44,7 @@ class UserBottomSheetView extends StatelessWidget {
|
||||
title: Text(user.calcDisplayname()),
|
||||
actions: [
|
||||
if (user.id != client.userID)
|
||||
PopupMenuButton(
|
||||
M2PopupMenuButton(
|
||||
itemBuilder: (_) => [
|
||||
if (controller.widget.onMention != null)
|
||||
PopupMenuItem(
|
||||
|
@ -14,6 +14,7 @@ import 'package:vrouter/vrouter.dart';
|
||||
import 'package:fluffychat/pages/chat/cupertino_widgets_bottom_sheet.dart';
|
||||
import 'package:fluffychat/pages/chat/edit_widgets_dialog.dart';
|
||||
import 'package:fluffychat/pages/chat/widgets_bottom_sheet.dart';
|
||||
import 'm2_popup_menu_button.dart';
|
||||
import 'matrix.dart';
|
||||
|
||||
class ChatSettingsPopupMenu extends StatefulWidget {
|
||||
@ -125,7 +126,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
||||
onKeysPressed: _showWidgets,
|
||||
child: Container(),
|
||||
),
|
||||
PopupMenuButton(
|
||||
M2PopupMenuButton(
|
||||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
case 'widgets':
|
||||
|
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'm2_popup_menu_button.dart';
|
||||
|
||||
class LogViewer extends StatefulWidget {
|
||||
const LogViewer({Key? key}) : super(key: key);
|
||||
|
||||
@ -32,7 +34,7 @@ class LogViewerState extends State<LogViewer> {
|
||||
icon: const Icon(Icons.zoom_out_outlined),
|
||||
onPressed: () => setState(() => fontSize--),
|
||||
),
|
||||
PopupMenuButton<Level>(
|
||||
M2PopupMenuButton<Level>(
|
||||
itemBuilder: (context) => Level.values
|
||||
.map((level) => PopupMenuItem(
|
||||
value: level,
|
||||
|
46
lib/widgets/m2_popup_menu_button.dart
Normal file
46
lib/widgets/m2_popup_menu_button.dart
Normal file
@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class M2PopupMenuButton<T> extends StatelessWidget {
|
||||
final List<PopupMenuEntry<T>> Function(BuildContext) itemBuilder;
|
||||
final T? initialValue;
|
||||
final void Function(T)? onSelected;
|
||||
final void Function()? onCanceled;
|
||||
final Widget? icon;
|
||||
final Color? color;
|
||||
final Widget? child;
|
||||
|
||||
const M2PopupMenuButton({
|
||||
Key? key,
|
||||
required this.itemBuilder,
|
||||
this.initialValue,
|
||||
this.onSelected,
|
||||
this.onCanceled,
|
||||
this.icon,
|
||||
this.color,
|
||||
this.child,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return Theme(
|
||||
data: theme.copyWith(
|
||||
useMaterial3: false,
|
||||
popupMenuTheme: PopupMenuThemeData(
|
||||
color: theme.colorScheme.surface,
|
||||
elevation: theme.appBarTheme.scrolledUnderElevation,
|
||||
textStyle: theme.textTheme.bodyText1,
|
||||
),
|
||||
),
|
||||
child: PopupMenuButton<T>(
|
||||
itemBuilder: itemBuilder,
|
||||
initialValue: initialValue,
|
||||
onSelected: onSelected,
|
||||
onCanceled: onCanceled,
|
||||
icon: icon,
|
||||
color: color,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user