mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Add ADListTile
This commit is contained in:
@ -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
|
||||
|
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