Theme configuration
This commit is contained in:
99
lib/widgets/custom_list_tile.dart
Normal file
99
lib/widgets/custom_list_tile.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CustomListTile extends StatelessWidget {
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final Widget? subtitleWidget;
|
||||
final void Function()? onTap;
|
||||
final IconData? icon;
|
||||
final Widget? trailing;
|
||||
final EdgeInsets? padding;
|
||||
final void Function()? onLongPress;
|
||||
final bool? disabled;
|
||||
final void Function(bool)? onHover;
|
||||
final Color? color;
|
||||
|
||||
const CustomListTile({
|
||||
Key? key,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.subtitleWidget,
|
||||
this.onTap,
|
||||
this.icon,
|
||||
this.trailing,
|
||||
this.padding,
|
||||
this.onLongPress,
|
||||
this.disabled,
|
||||
this.onHover,
|
||||
this.color,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: color ?? Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
onHover: onHover,
|
||||
onLongPress: onLongPress,
|
||||
child: Padding(
|
||||
padding: padding ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(
|
||||
icon,
|
||||
size: 24,
|
||||
color: disabled == true
|
||||
? Theme.of(context).colorScheme.onSurface.withOpacity(0.38)
|
||||
: Theme.of(context).listTileTheme.iconColor,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
Flexible(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: disabled == true
|
||||
? Theme.of(context).colorScheme.onSurface.withOpacity(0.38)
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (subtitle != null || subtitleWidget != null) ...[
|
||||
const SizedBox(height: 5),
|
||||
if (subtitle == null && subtitleWidget != null) subtitleWidget!,
|
||||
if (subtitle != null && subtitleWidget == null)
|
||||
Text(
|
||||
subtitle!,
|
||||
style: TextStyle(
|
||||
color: disabled == true
|
||||
? Theme.of(context).colorScheme.onSurfaceVariant.withOpacity(0.38)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400),
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailing != null) ...[const SizedBox(width: 16), trailing!]
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user