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:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:fladder/screens/shared/flat_button.dart';
|
||||||
|
|
||||||
class SettingsListTile extends StatelessWidget {
|
class SettingsListTile extends StatelessWidget {
|
||||||
final Widget label;
|
final Widget label;
|
||||||
final Widget? subLabel;
|
final Widget? subLabel;
|
||||||
|
|
@ -24,48 +26,86 @@ class SettingsListTile extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final iconWidget = icon != null ? Icon(icon) : null;
|
final iconWidget = icon != null ? Icon(icon) : null;
|
||||||
|
|
||||||
|
final leadingWidget = (suffix ?? iconWidget) != null
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 8, right: 16.0),
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 125),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.primaryContainer.withValues(alpha: selected ? 1 : 0),
|
||||||
|
borderRadius: BorderRadius.circular(selected ? 5 : 20),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 12),
|
||||||
|
child: (suffix ?? iconWidget),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: suffix ?? const SizedBox();
|
||||||
return Card(
|
return Card(
|
||||||
elevation: selected ? 2 : 0,
|
elevation: selected ? 2 : 0,
|
||||||
color: selected ? null : Colors.transparent,
|
color: selected ? Theme.of(context).colorScheme.surfaceContainerLow : Colors.transparent,
|
||||||
shadowColor: Colors.transparent,
|
shadowColor: Colors.transparent,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8))),
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8))),
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
child: ListTile(
|
child: FlatButton(
|
||||||
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
|
|
||||||
? Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 8.0, right: 16.0),
|
|
||||||
child: AnimatedContainer(
|
|
||||||
duration: const Duration(milliseconds: 125),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).colorScheme.primaryContainer.withValues(alpha: selected ? 1 : 0),
|
|
||||||
borderRadius: BorderRadius.circular(selected ? 5 : 20),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 12),
|
|
||||||
child: (suffix ?? iconWidget),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: suffix ?? const SizedBox(),
|
|
||||||
title: label,
|
|
||||||
titleTextStyle: Theme.of(context).textTheme.titleLarge,
|
|
||||||
trailing: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16),
|
|
||||||
child: trailing,
|
|
||||||
),
|
|
||||||
selected: selected,
|
|
||||||
textColor: contentColor,
|
|
||||||
iconColor: contentColor,
|
|
||||||
subtitle: subLabel,
|
|
||||||
onTap: onTap,
|
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,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,13 @@ class FlatButton extends ConsumerWidget {
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bool get _hasInteraction => onTap != null || onLongPress != null || onDoubleTap != null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
if (!_hasInteraction) {
|
||||||
|
return child ?? Container();
|
||||||
|
}
|
||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.passthrough,
|
fit: StackFit.passthrough,
|
||||||
children: [
|
children: [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue