mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-11-04 00:33:12 +00:00
fix: align request approval menu layout and icons
This commit is contained in:
1 parent
3a2e1b3e58
commit
76dacea54b
4 files changed
+42
-35
No files matched your search
@@ -751,6 +751,10 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.edit),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: kMinInteractiveDimension - 8,
|
||||
minHeight: kMinInteractiveDimension,
|
||||
),
|
||||
onPressed: () {
|
||||
if (Navigator.canPop(context)) {
|
||||
Navigator.pop(context);
|
||||
|
||||
@@ -7,27 +7,18 @@ class RequestApprovalMenu extends MenuEntryBase<String> {
|
||||
final String title;
|
||||
final List<MenuEntryButton<String>> entries;
|
||||
final EdgeInsets? padding;
|
||||
final double arrowScale;
|
||||
|
||||
RequestApprovalMenu(
|
||||
{required this.title, required this.entries, this.padding});
|
||||
{required this.title,
|
||||
required this.entries,
|
||||
this.padding,
|
||||
this.arrowScale = 1.0});
|
||||
|
||||
@override
|
||||
List<mod_menu.PopupMenuEntry<String>> build(
|
||||
BuildContext context, MenuConfig conf) {
|
||||
final theme = Theme.of(context);
|
||||
final buttonPadding =
|
||||
(TextButtonTheme.of(context).style?.padding?.resolve({}) ??
|
||||
ButtonStyleButton.scaledPadding(
|
||||
theme.useMaterial3
|
||||
? const EdgeInsets.symmetric(horizontal: 12, vertical: 8)
|
||||
: const EdgeInsets.all(8),
|
||||
const EdgeInsets.symmetric(horizontal: 8),
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
MediaQuery.textScalerOf(context)
|
||||
.scale(theme.textTheme.labelLarge?.fontSize ?? 14) /
|
||||
14,
|
||||
))
|
||||
.resolve(Directionality.of(context));
|
||||
final checkboxTheme = CheckboxTheme.of(context);
|
||||
final checkboxWidth =
|
||||
((checkboxTheme.materialTapTargetSize ?? theme.materialTapTargetSize) ==
|
||||
@@ -41,14 +32,9 @@ class RequestApprovalMenu extends MenuEntryBase<String> {
|
||||
return MenuEntrySubMenu<String>(
|
||||
text: title,
|
||||
dismissParentOnCanceled: true,
|
||||
// Normal entries contain two TextButtons; the submenu adds a leading gap.
|
||||
arrowScale: arrowScale,
|
||||
padding: (padding ?? EdgeInsets.zero)
|
||||
.add(EdgeInsets.only(
|
||||
left: buttonPadding.left * 2,
|
||||
right: buttonPadding.right * 2 + arrowInset))
|
||||
.subtract(
|
||||
const EdgeInsetsDirectional.only(start: MenuConfig.midPadding))
|
||||
.resolve(Directionality.of(context)),
|
||||
.copyWith(right: (padding?.right ?? 0) + arrowInset),
|
||||
entries: entries
|
||||
.map((entry) => MenuEntryButton<String>(
|
||||
childBuilder: entry.childBuilder,
|
||||
|
||||
@@ -362,6 +362,7 @@ class _ConnectionPageState extends State<ConnectionPage>
|
||||
return RequestApprovalMenu(
|
||||
title: translate('Request approval'),
|
||||
padding: EdgeInsets.symmetric(horizontal: kDesktopMenuPadding.left),
|
||||
arrowScale: MenuConfig.iconScale,
|
||||
entries: [
|
||||
action('Connect'),
|
||||
action('Transfer file', isFileTransfer: true),
|
||||
|
||||
@@ -16,6 +16,7 @@ class PopupMenuChildrenItem<T> extends mod_menu.PopupMenuEntry<T> {
|
||||
this.textStyle,
|
||||
this.onTap,
|
||||
this.dismissParentOnCanceled = false,
|
||||
this.useButtonLayout = false,
|
||||
this.position = mod_menu.PopupMenuPosition.overSide,
|
||||
this.offset = Offset.zero,
|
||||
required this.itemBuilder,
|
||||
@@ -29,6 +30,7 @@ class PopupMenuChildrenItem<T> extends mod_menu.PopupMenuEntry<T> {
|
||||
final RxBool? enabled;
|
||||
final void Function()? onTap;
|
||||
final bool dismissParentOnCanceled;
|
||||
final bool useButtonLayout;
|
||||
final List<mod_menu.PopupMenuEntry<T>> Function(BuildContext) itemBuilder;
|
||||
final Widget child;
|
||||
|
||||
@@ -80,18 +82,30 @@ class MyPopupMenuItemState<T, W extends PopupMenuChildrenItem<T>>
|
||||
: null,
|
||||
itemBuilder: widget.itemBuilder,
|
||||
padding: EdgeInsets.zero,
|
||||
child: AnimatedDefaultTextStyle(
|
||||
style: style,
|
||||
duration: kThemeChangeDuration,
|
||||
child: Container(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: widget.height, maxHeight: widget.height),
|
||||
padding:
|
||||
widget.padding ?? const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: widget.child,
|
||||
),
|
||||
),
|
||||
child: Builder(builder: (context) {
|
||||
final child = AnimatedDefaultTextStyle(
|
||||
style: style,
|
||||
duration: kThemeChangeDuration,
|
||||
child: Container(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: widget.height, maxHeight: widget.height),
|
||||
padding: widget.padding ??
|
||||
const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: widget.child,
|
||||
),
|
||||
);
|
||||
if (!widget.useButtonLayout) return child;
|
||||
final onPressed = enabled.value
|
||||
? () => context
|
||||
.findAncestorStateOfType<mod_menu.PopupMenuButtonState<T>>()
|
||||
?.showButtonMenu()
|
||||
: null;
|
||||
return TextButton(
|
||||
onPressed: onPressed,
|
||||
child: TextButton(onPressed: onPressed, child: child),
|
||||
);
|
||||
}),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -655,12 +669,14 @@ class MenuEntrySubMenu<T> extends MenuEntryBase<T> {
|
||||
final List<MenuEntryBase<T>> entries;
|
||||
final EdgeInsets? padding;
|
||||
final bool dismissParentOnCanceled;
|
||||
final double arrowScale;
|
||||
|
||||
MenuEntrySubMenu({
|
||||
required this.text,
|
||||
required this.entries,
|
||||
this.padding,
|
||||
this.dismissParentOnCanceled = false,
|
||||
this.arrowScale = MenuConfig.iconScale,
|
||||
RxBool? enabled,
|
||||
}) : super(enabled: enabled);
|
||||
|
||||
@@ -674,13 +690,13 @@ class MenuEntrySubMenu<T> extends MenuEntryBase<T> {
|
||||
height: conf.height,
|
||||
padding: padding,
|
||||
dismissParentOnCanceled: dismissParentOnCanceled,
|
||||
useButtonLayout: true,
|
||||
position: mod_menu.PopupMenuPosition.overSide,
|
||||
itemBuilder: (BuildContext context) => entries
|
||||
.map((entry) => entry.build(context, conf))
|
||||
.expand((i) => i)
|
||||
.toList(),
|
||||
child: Row(children: [
|
||||
const SizedBox(width: MenuConfig.midPadding),
|
||||
Obx(() => Text(
|
||||
text,
|
||||
style: super.enabled!.value
|
||||
@@ -691,7 +707,7 @@ class MenuEntrySubMenu<T> extends MenuEntryBase<T> {
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Transform.scale(
|
||||
scale: MenuConfig.iconScale,
|
||||
scale: arrowScale,
|
||||
child: Obx(() => Icon(
|
||||
Icons.keyboard_arrow_right,
|
||||
color: super.enabled!.value
|
||||
|
||||
Reference in new issue
Block a user