design: Adjust design to new material 3 capabilities of Flutter 3.7
This commit is contained in:
parent
d226bf6020
commit
b176811f7c
10 changed files with 34 additions and 97 deletions
|
|
@ -48,31 +48,25 @@ class Avatar extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
final borderRadius = BorderRadius.circular(size / 2);
|
||||
final container = Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Theme.of(context).dividerColor),
|
||||
borderRadius: borderRadius,
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: borderRadius,
|
||||
child: Container(
|
||||
width: size,
|
||||
height: size,
|
||||
color: noPic
|
||||
? name?.lightColorAvatar
|
||||
: Theme.of(context).secondaryHeaderColor,
|
||||
child: noPic
|
||||
? textWidget
|
||||
: MxcImage(
|
||||
key: Key(mxContent.toString()),
|
||||
uri: mxContent,
|
||||
fit: BoxFit.cover,
|
||||
width: size,
|
||||
height: size,
|
||||
placeholder: (_) => textWidget,
|
||||
cacheKey: mxContent.toString(),
|
||||
),
|
||||
),
|
||||
final container = ClipRRect(
|
||||
borderRadius: borderRadius,
|
||||
child: Container(
|
||||
width: size,
|
||||
height: size,
|
||||
color: noPic
|
||||
? name?.lightColorAvatar
|
||||
: Theme.of(context).secondaryHeaderColor,
|
||||
child: noPic
|
||||
? textWidget
|
||||
: MxcImage(
|
||||
key: Key(mxContent.toString()),
|
||||
uri: mxContent,
|
||||
fit: BoxFit.cover,
|
||||
width: size,
|
||||
height: size,
|
||||
placeholder: (_) => textWidget,
|
||||
cacheKey: mxContent.toString(),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (onTap == null) return container;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ 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 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
|
||||
import 'm2_popup_menu_button.dart';
|
||||
import 'matrix.dart';
|
||||
|
||||
class ChatSettingsPopupMenu extends StatefulWidget {
|
||||
|
|
@ -127,7 +126,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
onKeysPressed: _showWidgets,
|
||||
child: Container(),
|
||||
),
|
||||
M2PopupMenuButton(
|
||||
PopupMenuButton(
|
||||
onSelected: (String choice) async {
|
||||
switch (choice) {
|
||||
case 'widgets':
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ 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);
|
||||
|
||||
|
|
@ -34,7 +32,7 @@ class LogViewerState extends State<LogViewer> {
|
|||
icon: const Icon(Icons.zoom_out_outlined),
|
||||
onPressed: () => setState(() => fontSize--),
|
||||
),
|
||||
M2PopupMenuButton<Level>(
|
||||
PopupMenuButton<Level>(
|
||||
itemBuilder: (context) => Level.values
|
||||
.map((level) => PopupMenuItem(
|
||||
value: level,
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.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,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
),
|
||||
elevation: theme.appBarTheme.scrolledUnderElevation,
|
||||
textStyle: theme.textTheme.bodyLarge,
|
||||
),
|
||||
),
|
||||
child: PopupMenuButton<T>(
|
||||
itemBuilder: itemBuilder,
|
||||
initialValue: initialValue,
|
||||
onSelected: onSelected,
|
||||
onCanceled: onCanceled,
|
||||
icon: icon,
|
||||
color: color,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue