tv: improved view config dialog in landscape
This commit is contained in:
parent
0e4fbdade2
commit
a1990e44ae
2 changed files with 66 additions and 42 deletions
|
@ -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<MediaQueryData, double>((mq) => mq.size.width / 2),
|
||||
child: DecoratedBox(
|
||||
decoration: contentDecoration(context),
|
||||
child: child,
|
||||
|
|
|
@ -172,19 +172,7 @@ class _TileViewDialogState<S, G, L> extends State<TileViewDialog<S, G, L>> with
|
|||
}) {
|
||||
if (options.isEmpty || !show) return const SizedBox();
|
||||
|
||||
final iconSize = IconTheme.of(context).size! * MediaQuery.textScaleFactorOf(context);
|
||||
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(
|
||||
final label = ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: kMinInteractiveDimension),
|
||||
child: Row(
|
||||
children: [
|
||||
|
@ -199,10 +187,8 @@ class _TileViewDialogState<S, G, L> extends State<TileViewDialog<S, G, L>> with
|
|||
if (trailing != null) trailing,
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: iconSize + 16, end: 12),
|
||||
child: TextDropdownButton<T>(
|
||||
);
|
||||
final selector = TextDropdownButton<T>(
|
||||
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,
|
||||
|
@ -210,7 +196,19 @@ class _TileViewDialogState<S, G, L> extends State<TileViewDialog<S, G, L>> with
|
|||
onChanged: (v) => setState(() => onChanged(v)),
|
||||
isExpanded: true,
|
||||
dropdownColor: Themes.thirdLayerColor(context),
|
||||
),
|
||||
);
|
||||
|
||||
final iconSize = IconTheme.of(context).size! * MediaQuery.textScaleFactorOf(context);
|
||||
final isPortrait = context.select<MediaQueryData, Orientation>((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(
|
||||
|
@ -218,8 +216,33 @@ class _TileViewDialogState<S, G, L> extends State<TileViewDialog<S, G, L>> with
|
|||
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.only(left: 16, top: 8, right: 16),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue