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(
shrinkWrap: true,
children: [
SwitchListTile(
hoverColor: kColorTransparent,
title: const Text('Switch Theme Mode'),
subtitle: Text(
'Current selection: ${settings.isDark ? "Dark Mode" : "Light mode"}'),
ADListTile(
type: ListTileType.switchOnOff,
title: 'Switch Theme Mode',
subtitle:
'Current selection: ${settings.isDark ? "Dark Mode" : "Light mode"}',
value: settings.isDark,
onChanged: (bool? value) {
ref.read(settingsProvider.notifier).update(isDark: value);
},
),
SwitchListTile(
hoverColor: kColorTransparent,
title: const Text('Collection Pane Scrollbar Visiblity'),
subtitle: Text(
'Current selection: ${settings.alwaysShowCollectionPaneScrollbar ? "Always show" : "Show only when scrolling"}'),
ADListTile(
type: ListTileType.switchOnOff,
title: 'Collection Pane Scrollbar Visiblity',
subtitle:
'Current selection: ${settings.alwaysShowCollectionPaneScrollbar ? "Always show" : "Show only when scrolling"}',
value: settings.alwaysShowCollectionPaneScrollbar,
onChanged: (bool? value) {
ref
@ -77,12 +77,11 @@ class SettingsPage extends ConsumerWidget {
),
),
!kIsWeb
? SwitchListTile(
hoverColor: kColorTransparent,
title: const Text('Disable SSL verification'),
subtitle: Text(
'Current selection: ${settings.isSSLDisabled ? "SSL Verification Disabled" : "SSL Verification Enabled"}',
),
? ADListTile(
type: ListTileType.switchOnOff,
title: 'Disable SSL verification',
subtitle:
'Current selection: ${settings.isSSLDisabled ? "SSL Verification Disabled" : "SSL Verification Enabled"}',
value: settings.isSSLDisabled,
onChanged: (bool? value) {
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 'decoration_input_textfield.dart';
export 'dropdown.dart';
export 'list_tile.dart';
export 'popup_menu.dart';
export 'snackbar.dart';
export 'textfield_outlined.dart';