mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Collection pane scrollbar visibility added to settings
This commit is contained in:
@ -5,12 +5,14 @@ import 'package:apidash/consts.dart';
|
|||||||
class SettingsModel {
|
class SettingsModel {
|
||||||
const SettingsModel(
|
const SettingsModel(
|
||||||
{this.isDark = false,
|
{this.isDark = false,
|
||||||
|
this.alwaysShowCollectionPaneScrollbar = true,
|
||||||
this.size,
|
this.size,
|
||||||
this.offset,
|
this.offset,
|
||||||
this.defaultUriScheme = kDefaultUriScheme,
|
this.defaultUriScheme = kDefaultUriScheme,
|
||||||
this.saveResponses = true});
|
this.saveResponses = true});
|
||||||
|
|
||||||
final bool isDark;
|
final bool isDark;
|
||||||
|
final bool alwaysShowCollectionPaneScrollbar;
|
||||||
final Size? size;
|
final Size? size;
|
||||||
final Offset? offset;
|
final Offset? offset;
|
||||||
final String defaultUriScheme;
|
final String defaultUriScheme;
|
||||||
@ -18,6 +20,7 @@ class SettingsModel {
|
|||||||
|
|
||||||
SettingsModel copyWith({
|
SettingsModel copyWith({
|
||||||
bool? isDark,
|
bool? isDark,
|
||||||
|
bool? alwaysShowCollectionPaneScrollbar,
|
||||||
Size? size,
|
Size? size,
|
||||||
Offset? offset,
|
Offset? offset,
|
||||||
String? defaultUriScheme,
|
String? defaultUriScheme,
|
||||||
@ -25,6 +28,8 @@ class SettingsModel {
|
|||||||
}) {
|
}) {
|
||||||
return SettingsModel(
|
return SettingsModel(
|
||||||
isDark: isDark ?? this.isDark,
|
isDark: isDark ?? this.isDark,
|
||||||
|
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar ??
|
||||||
|
this.alwaysShowCollectionPaneScrollbar,
|
||||||
size: size ?? this.size,
|
size: size ?? this.size,
|
||||||
defaultUriScheme: defaultUriScheme ?? this.defaultUriScheme,
|
defaultUriScheme: defaultUriScheme ?? this.defaultUriScheme,
|
||||||
offset: offset ?? this.offset,
|
offset: offset ?? this.offset,
|
||||||
@ -34,6 +39,8 @@ class SettingsModel {
|
|||||||
|
|
||||||
factory SettingsModel.fromJson(Map<dynamic, dynamic> data) {
|
factory SettingsModel.fromJson(Map<dynamic, dynamic> data) {
|
||||||
final isDark = data["isDark"] as bool?;
|
final isDark = data["isDark"] as bool?;
|
||||||
|
final alwaysShowCollectionPaneScrollbar =
|
||||||
|
data["alwaysShowCollectionPaneScrollbar"] as bool?;
|
||||||
final width = data["width"] as double?;
|
final width = data["width"] as double?;
|
||||||
final height = data["height"] as double?;
|
final height = data["height"] as double?;
|
||||||
final dx = data["dx"] as double?;
|
final dx = data["dx"] as double?;
|
||||||
@ -53,6 +60,7 @@ class SettingsModel {
|
|||||||
|
|
||||||
return sm.copyWith(
|
return sm.copyWith(
|
||||||
isDark: isDark,
|
isDark: isDark,
|
||||||
|
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
|
||||||
size: size,
|
size: size,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
defaultUriScheme: defaultUriScheme,
|
defaultUriScheme: defaultUriScheme,
|
||||||
@ -63,6 +71,7 @@ class SettingsModel {
|
|||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
"isDark": isDark,
|
"isDark": isDark,
|
||||||
|
"alwaysShowCollectionPaneScrollbar": alwaysShowCollectionPaneScrollbar,
|
||||||
"width": size?.width,
|
"width": size?.width,
|
||||||
"height": size?.height,
|
"height": size?.height,
|
||||||
"dx": offset?.dx,
|
"dx": offset?.dx,
|
||||||
|
@ -15,6 +15,7 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
|
|||||||
|
|
||||||
Future<void> update({
|
Future<void> update({
|
||||||
bool? isDark,
|
bool? isDark,
|
||||||
|
bool? alwaysShowCollectionPaneScrollbar,
|
||||||
Size? size,
|
Size? size,
|
||||||
Offset? offset,
|
Offset? offset,
|
||||||
String? defaultUriScheme,
|
String? defaultUriScheme,
|
||||||
@ -22,6 +23,7 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
|
|||||||
}) async {
|
}) async {
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
isDark: isDark,
|
isDark: isDark,
|
||||||
|
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
|
||||||
size: size,
|
size: size,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
defaultUriScheme: defaultUriScheme,
|
defaultUriScheme: defaultUriScheme,
|
||||||
|
@ -110,10 +110,12 @@ class _RequestListState extends ConsumerState<RequestList> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final requestItems = ref.watch(collectionStateNotifierProvider)!;
|
final requestItems = ref.watch(collectionStateNotifierProvider)!;
|
||||||
|
final alwaysShowCollectionPaneScrollbar = ref.watch(settingsProvider
|
||||||
|
.select((value) => value.alwaysShowCollectionPaneScrollbar));
|
||||||
|
|
||||||
return Scrollbar(
|
return Scrollbar(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
thumbVisibility: true,
|
thumbVisibility: alwaysShowCollectionPaneScrollbar ? true : null,
|
||||||
radius: const Radius.circular(12),
|
radius: const Radius.circular(12),
|
||||||
child: ReorderableListView.builder(
|
child: ReorderableListView.builder(
|
||||||
padding: kPr8CollectionPane,
|
padding: kPr8CollectionPane,
|
||||||
|
@ -41,6 +41,19 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
|
|||||||
ref.read(settingsProvider.notifier).update(isDark: value);
|
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(
|
ListTile(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
hoverColor: kColorTransparent,
|
hoverColor: kColorTransparent,
|
||||||
|
Reference in New Issue
Block a user