Collection pane scrollbar visibility added to settings

This commit is contained in:
Ashita Prasad
2023-10-08 11:02:49 +05:30
parent 697d737496
commit de6ca5cd8c
4 changed files with 27 additions and 1 deletions

View File

@ -5,12 +5,14 @@ import 'package:apidash/consts.dart';
class SettingsModel {
const SettingsModel(
{this.isDark = false,
this.alwaysShowCollectionPaneScrollbar = true,
this.size,
this.offset,
this.defaultUriScheme = kDefaultUriScheme,
this.saveResponses = true});
final bool isDark;
final bool alwaysShowCollectionPaneScrollbar;
final Size? size;
final Offset? offset;
final String defaultUriScheme;
@ -18,6 +20,7 @@ class SettingsModel {
SettingsModel copyWith({
bool? isDark,
bool? alwaysShowCollectionPaneScrollbar,
Size? size,
Offset? offset,
String? defaultUriScheme,
@ -25,6 +28,8 @@ class SettingsModel {
}) {
return SettingsModel(
isDark: isDark ?? this.isDark,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar ??
this.alwaysShowCollectionPaneScrollbar,
size: size ?? this.size,
defaultUriScheme: defaultUriScheme ?? this.defaultUriScheme,
offset: offset ?? this.offset,
@ -34,6 +39,8 @@ class SettingsModel {
factory SettingsModel.fromJson(Map<dynamic, dynamic> data) {
final isDark = data["isDark"] as bool?;
final alwaysShowCollectionPaneScrollbar =
data["alwaysShowCollectionPaneScrollbar"] as bool?;
final width = data["width"] as double?;
final height = data["height"] as double?;
final dx = data["dx"] as double?;
@ -53,6 +60,7 @@ class SettingsModel {
return sm.copyWith(
isDark: isDark,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
size: size,
offset: offset,
defaultUriScheme: defaultUriScheme,
@ -63,6 +71,7 @@ class SettingsModel {
Map<String, dynamic> toJson() {
return {
"isDark": isDark,
"alwaysShowCollectionPaneScrollbar": alwaysShowCollectionPaneScrollbar,
"width": size?.width,
"height": size?.height,
"dx": offset?.dx,

View File

@ -15,6 +15,7 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
Future<void> update({
bool? isDark,
bool? alwaysShowCollectionPaneScrollbar,
Size? size,
Offset? offset,
String? defaultUriScheme,
@ -22,6 +23,7 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
}) async {
state = state.copyWith(
isDark: isDark,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
size: size,
offset: offset,
defaultUriScheme: defaultUriScheme,

View File

@ -110,10 +110,12 @@ class _RequestListState extends ConsumerState<RequestList> {
@override
Widget build(BuildContext context) {
final requestItems = ref.watch(collectionStateNotifierProvider)!;
final alwaysShowCollectionPaneScrollbar = ref.watch(settingsProvider
.select((value) => value.alwaysShowCollectionPaneScrollbar));
return Scrollbar(
controller: controller,
thumbVisibility: true,
thumbVisibility: alwaysShowCollectionPaneScrollbar ? true : null,
radius: const Radius.circular(12),
child: ReorderableListView.builder(
padding: kPr8CollectionPane,

View File

@ -41,6 +41,19 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
ref.read(settingsProvider.notifier).update(isDark: value);
},
),
SwitchListTile(
contentPadding: EdgeInsets.zero,
hoverColor: kColorTransparent,
title: const Text('Collection Pane Scrollbar Visiblity'),
subtitle: Text(
'Current selection: ${settings.alwaysShowCollectionPaneScrollbar ? "Always show" : "Show only when scrolling"}'),
value: settings.alwaysShowCollectionPaneScrollbar,
onChanged: (bool? value) {
ref
.read(settingsProvider.notifier)
.update(alwaysShowCollectionPaneScrollbar: value);
},
),
ListTile(
contentPadding: EdgeInsets.zero,
hoverColor: kColorTransparent,