mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
fix settings list tile padding
This commit is contained in:
parent
c492e151b3
commit
9bc1463cd5
2 changed files with 80 additions and 35 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fladder/screens/shared/flat_button.dart';
|
||||
|
||||
class SettingsListTile extends StatelessWidget {
|
||||
final Widget label;
|
||||
final Widget? subLabel;
|
||||
|
|
@ -24,24 +26,10 @@ class SettingsListTile extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final iconWidget = icon != null ? Icon(icon) : null;
|
||||
return Card(
|
||||
elevation: selected ? 2 : 0,
|
||||
color: selected ? null : Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8))),
|
||||
margin: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
minVerticalPadding: 12,
|
||||
minLeadingWidth: 16,
|
||||
minTileHeight: 75,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
horizontalTitleGap: 0,
|
||||
titleAlignment: ListTileTitleAlignment.center,
|
||||
contentPadding: const EdgeInsets.only(right: 12, left: 2),
|
||||
leading: (suffix ?? iconWidget) != null
|
||||
|
||||
final leadingWidget = (suffix ?? iconWidget) != null
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 16.0),
|
||||
padding: const EdgeInsets.only(left: 8, right: 16.0),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 125),
|
||||
decoration: BoxDecoration(
|
||||
|
|
@ -54,18 +42,70 @@ class SettingsListTile extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
)
|
||||
: suffix ?? const SizedBox(),
|
||||
title: label,
|
||||
titleTextStyle: Theme.of(context).textTheme.titleLarge,
|
||||
trailing: Padding(
|
||||
: suffix ?? const SizedBox();
|
||||
return Card(
|
||||
elevation: selected ? 2 : 0,
|
||||
color: selected ? Theme.of(context).colorScheme.surfaceContainerLow : Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8))),
|
||||
margin: EdgeInsets.zero,
|
||||
child: FlatButton(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
).copyWith(
|
||||
left: (suffix ?? iconWidget) != null ? 0 : null,
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 50,
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
ColorFiltered(
|
||||
colorFilter: ColorFilter.mode(
|
||||
contentColor ?? Theme.of(context).colorScheme.onSurface,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
child: leadingWidget,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
textStyle: Theme.of(context).textTheme.titleLarge,
|
||||
child: label,
|
||||
),
|
||||
if (subLabel != null)
|
||||
Opacity(
|
||||
opacity: 0.75,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
textStyle: Theme.of(context).textTheme.labelLarge,
|
||||
child: subLabel,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: trailing,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
selected: selected,
|
||||
textColor: contentColor,
|
||||
iconColor: contentColor,
|
||||
subtitle: subLabel,
|
||||
onTap: onTap,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,13 @@ class FlatButton extends ConsumerWidget {
|
|||
super.key,
|
||||
});
|
||||
|
||||
bool get _hasInteraction => onTap != null || onLongPress != null || onDoubleTap != null;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
if (!_hasInteraction) {
|
||||
return child ?? Container();
|
||||
}
|
||||
return Stack(
|
||||
fit: StackFit.passthrough,
|
||||
children: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue