Add ADListTile

This commit is contained in:
Ankit Mahato
2025-03-29 12:20:37 +05:30
parent 632186f73c
commit ed230e40f2
3 changed files with 58 additions and 16 deletions

View File

@ -40,21 +40,21 @@ class SettingsPage extends ConsumerWidget {
child: ListView( child: ListView(
shrinkWrap: true, shrinkWrap: true,
children: [ children: [
SwitchListTile( ADListTile(
hoverColor: kColorTransparent, type: ListTileType.switchOnOff,
title: const Text('Switch Theme Mode'), title: 'Switch Theme Mode',
subtitle: Text( subtitle:
'Current selection: ${settings.isDark ? "Dark Mode" : "Light mode"}'), 'Current selection: ${settings.isDark ? "Dark Mode" : "Light mode"}',
value: settings.isDark, value: settings.isDark,
onChanged: (bool? value) { onChanged: (bool? value) {
ref.read(settingsProvider.notifier).update(isDark: value); ref.read(settingsProvider.notifier).update(isDark: value);
}, },
), ),
SwitchListTile( ADListTile(
hoverColor: kColorTransparent, type: ListTileType.switchOnOff,
title: const Text('Collection Pane Scrollbar Visiblity'), title: 'Collection Pane Scrollbar Visiblity',
subtitle: Text( subtitle:
'Current selection: ${settings.alwaysShowCollectionPaneScrollbar ? "Always show" : "Show only when scrolling"}'), 'Current selection: ${settings.alwaysShowCollectionPaneScrollbar ? "Always show" : "Show only when scrolling"}',
value: settings.alwaysShowCollectionPaneScrollbar, value: settings.alwaysShowCollectionPaneScrollbar,
onChanged: (bool? value) { onChanged: (bool? value) {
ref ref
@ -77,12 +77,11 @@ class SettingsPage extends ConsumerWidget {
), ),
), ),
!kIsWeb !kIsWeb
? SwitchListTile( ? ADListTile(
hoverColor: kColorTransparent, type: ListTileType.switchOnOff,
title: const Text('Disable SSL verification'), title: 'Disable SSL verification',
subtitle: Text( subtitle:
'Current selection: ${settings.isSSLDisabled ? "SSL Verification Disabled" : "SSL Verification Enabled"}', 'Current selection: ${settings.isSSLDisabled ? "SSL Verification Disabled" : "SSL Verification Enabled"}',
),
value: settings.isSSLDisabled, value: settings.isSSLDisabled,
onChanged: (bool? value) { onChanged: (bool? value) {
ref ref

View 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(),
};
}
}

View File

@ -4,6 +4,7 @@ export 'button_text.dart';
export 'checkbox.dart'; export 'checkbox.dart';
export 'decoration_input_textfield.dart'; export 'decoration_input_textfield.dart';
export 'dropdown.dart'; export 'dropdown.dart';
export 'list_tile.dart';
export 'popup_menu.dart'; export 'popup_menu.dart';
export 'snackbar.dart'; export 'snackbar.dart';
export 'textfield_outlined.dart'; export 'textfield_outlined.dart';