mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 05:32:26 +08:00
Add ADListTile
This commit is contained in:
42
packages/apidash_design_system/lib/widgets/list_tile.dart
Normal file
42
packages/apidash_design_system/lib/widgets/list_tile.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../tokens/colors.dart';
|
||||
|
||||
enum ListTileType { switchOnOff, checkbox, button }
|
||||
|
||||
class ADListTile extends StatelessWidget {
|
||||
const ADListTile({
|
||||
super.key,
|
||||
required this.type,
|
||||
this.hoverColor = kColorTransparent,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.value,
|
||||
this.onChanged,
|
||||
});
|
||||
|
||||
final ListTileType type;
|
||||
final Color hoverColor;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
// For Switch and checkbox tiles
|
||||
final bool? value;
|
||||
// For Switch and checkbox tiles
|
||||
final Function(bool?)? onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return switch (type) {
|
||||
ListTileType.switchOnOff => SwitchListTile(
|
||||
hoverColor: hoverColor,
|
||||
title: Text(title),
|
||||
subtitle: subtitle == null ? null : Text(subtitle ?? ''),
|
||||
value: value ?? false,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
// TODO: Handle this case.
|
||||
ListTileType.checkbox => throw UnimplementedError(),
|
||||
// TODO: Handle this case.
|
||||
ListTileType.button => throw UnimplementedError(),
|
||||
};
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ export 'button_text.dart';
|
||||
export 'checkbox.dart';
|
||||
export 'decoration_input_textfield.dart';
|
||||
export 'dropdown.dart';
|
||||
export 'list_tile.dart';
|
||||
export 'popup_menu.dart';
|
||||
export 'snackbar.dart';
|
||||
export 'textfield_outlined.dart';
|
||||
|
Reference in New Issue
Block a user