diff --git a/lib/widgets/dialogs/aves_dialog.dart b/lib/widgets/dialogs/aves_dialog.dart index c6c135bdf..c19c0fe5a 100644 --- a/lib/widgets/dialogs/aves_dialog.dart +++ b/lib/widgets/dialogs/aves_dialog.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:aves/model/settings/settings.dart'; import 'package:aves/widgets/common/extensions/build_context.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; class AvesDialog extends StatelessWidget { static const confirmationRouteName = '/dialog/confirmation'; @@ -103,7 +104,7 @@ class AvesDialog extends StatelessWidget { // workaround because the dialog tries // to size itself to the content intrinsic size, // but the `ListView` viewport does not have one - width: 1, + width: context.select((mq) => mq.size.width / 2), child: DecoratedBox( decoration: contentDecoration(context), child: child, diff --git a/lib/widgets/dialogs/tile_view_dialog.dart b/lib/widgets/dialogs/tile_view_dialog.dart index 09d3e2b65..077cedee1 100644 --- a/lib/widgets/dialogs/tile_view_dialog.dart +++ b/lib/widgets/dialogs/tile_view_dialog.dart @@ -172,53 +172,76 @@ class _TileViewDialogState extends State> with }) { if (options.isEmpty || !show) return const SizedBox(); + final label = ConstrainedBox( + constraints: const BoxConstraints(minHeight: kMinInteractiveDimension), + child: Row( + children: [ + Icon(icon), + const SizedBox(width: 16), + Expanded( + child: HighlightTitle( + title: title, + showHighlight: false, + ), + ), + if (trailing != null) trailing, + ], + ), + ); + final selector = TextDropdownButton( + values: options.map((v) => v.value).toList(), + valueText: (v) => options.firstWhere((option) => option.value == v).title, + valueIcon: (v) => options.firstWhere((option) => option.value == v).icon, + value: value, + onChanged: (v) => setState(() => onChanged(v)), + isExpanded: true, + dropdownColor: Themes.thirdLayerColor(context), + ); + final iconSize = IconTheme.of(context).size! * MediaQuery.textScaleFactorOf(context); + final isPortrait = context.select((mq) => mq.orientation) == Orientation.portrait; + final child = isPortrait + ? Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + label, + Padding( + padding: EdgeInsetsDirectional.only(start: iconSize + 16, end: 12), + child: selector, + ), + if (bottom != null) + Padding( + padding: EdgeInsetsDirectional.only(start: iconSize + 16), + child: bottom, + ), + ], + ) + : Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: label), + const SizedBox(width: 8), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + selector, + if (bottom != null) bottom, + ], + ), + ), + ], + ); + return TooltipTheme( data: TooltipTheme.of(context).copyWith( preferBelow: false, ), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 8), - ConstrainedBox( - constraints: const BoxConstraints(minHeight: kMinInteractiveDimension), - child: Row( - children: [ - Icon(icon), - const SizedBox(width: 16), - Expanded( - child: HighlightTitle( - title: title, - showHighlight: false, - ), - ), - if (trailing != null) trailing, - ], - ), - ), - Padding( - padding: EdgeInsetsDirectional.only(start: iconSize + 16, end: 12), - child: TextDropdownButton( - values: options.map((v) => v.value).toList(), - valueText: (v) => options.firstWhere((option) => option.value == v).title, - valueIcon: (v) => options.firstWhere((option) => option.value == v).icon, - value: value, - onChanged: (v) => setState(() => onChanged(v)), - isExpanded: true, - dropdownColor: Themes.thirdLayerColor(context), - ), - ), - if (bottom != null) - Padding( - padding: EdgeInsetsDirectional.only(start: iconSize + 16), - child: bottom, - ), - ], - ), + padding: const EdgeInsets.only(left: 16, top: 8, right: 16), + child: child, ), ); }