This commit is contained in:
Ashita Prasad
2024-12-21 17:37:21 +05:30
parent 21f8e34212
commit 4ba44b728f
2 changed files with 13 additions and 13 deletions

View File

@ -6,7 +6,6 @@ import 'package:apidash/consts.dart';
class SettingsModel { class SettingsModel {
const SettingsModel({ const SettingsModel({
this.isDark = false, this.isDark = false,
this.isSSLDisabled =false,
this.alwaysShowCollectionPaneScrollbar = true, this.alwaysShowCollectionPaneScrollbar = true,
this.size, this.size,
this.offset, this.offset,
@ -17,10 +16,10 @@ class SettingsModel {
this.activeEnvironmentId, this.activeEnvironmentId,
this.historyRetentionPeriod = HistoryRetentionPeriod.oneWeek, this.historyRetentionPeriod = HistoryRetentionPeriod.oneWeek,
this.workspaceFolderPath, this.workspaceFolderPath,
this.isSSLDisabled = false,
}); });
final bool isDark; final bool isDark;
final bool isSSLDisabled;
final bool alwaysShowCollectionPaneScrollbar; final bool alwaysShowCollectionPaneScrollbar;
final Size? size; final Size? size;
final Offset? offset; final Offset? offset;
@ -31,10 +30,10 @@ class SettingsModel {
final String? activeEnvironmentId; final String? activeEnvironmentId;
final HistoryRetentionPeriod historyRetentionPeriod; final HistoryRetentionPeriod historyRetentionPeriod;
final String? workspaceFolderPath; final String? workspaceFolderPath;
final bool isSSLDisabled;
SettingsModel copyWith({ SettingsModel copyWith({
bool? isDark, bool? isDark,
bool? isSSLDisabled,
bool? alwaysShowCollectionPaneScrollbar, bool? alwaysShowCollectionPaneScrollbar,
Size? size, Size? size,
Offset? offset, Offset? offset,
@ -45,10 +44,10 @@ class SettingsModel {
String? activeEnvironmentId, String? activeEnvironmentId,
HistoryRetentionPeriod? historyRetentionPeriod, HistoryRetentionPeriod? historyRetentionPeriod,
String? workspaceFolderPath, String? workspaceFolderPath,
bool? isSSLDisabled,
}) { }) {
return SettingsModel( return SettingsModel(
isDark: isDark ?? this.isDark, isDark: isDark ?? this.isDark,
isSSLDisabled: isSSLDisabled ?? this.isSSLDisabled,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar ?? alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar ??
this.alwaysShowCollectionPaneScrollbar, this.alwaysShowCollectionPaneScrollbar,
size: size ?? this.size, size: size ?? this.size,
@ -61,6 +60,7 @@ class SettingsModel {
historyRetentionPeriod: historyRetentionPeriod:
historyRetentionPeriod ?? this.historyRetentionPeriod, historyRetentionPeriod ?? this.historyRetentionPeriod,
workspaceFolderPath: workspaceFolderPath ?? this.workspaceFolderPath, workspaceFolderPath: workspaceFolderPath ?? this.workspaceFolderPath,
isSSLDisabled: isSSLDisabled ?? this.isSSLDisabled,
); );
} }
@ -69,7 +69,6 @@ class SettingsModel {
}) { }) {
return SettingsModel( return SettingsModel(
isDark: isDark, isDark: isDark,
isSSLDisabled: isSSLDisabled,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar, alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
size: size, size: size,
defaultUriScheme: defaultUriScheme, defaultUriScheme: defaultUriScheme,
@ -80,12 +79,12 @@ class SettingsModel {
activeEnvironmentId: activeEnvironmentId, activeEnvironmentId: activeEnvironmentId,
historyRetentionPeriod: historyRetentionPeriod, historyRetentionPeriod: historyRetentionPeriod,
workspaceFolderPath: workspaceFolderPath, workspaceFolderPath: workspaceFolderPath,
isSSLDisabled: isSSLDisabled,
); );
} }
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 isSSLDisabled = data["isSSLDisabled"] as bool?;
final alwaysShowCollectionPaneScrollbar = final alwaysShowCollectionPaneScrollbar =
data["alwaysShowCollectionPaneScrollbar"] as bool?; data["alwaysShowCollectionPaneScrollbar"] as bool?;
final width = data["width"] as double?; final width = data["width"] as double?;
@ -134,12 +133,12 @@ class SettingsModel {
} }
} }
final workspaceFolderPath = data["workspaceFolderPath"] as String?; final workspaceFolderPath = data["workspaceFolderPath"] as String?;
final isSSLDisabled = data["isSSLDisabled"] as bool?;
const sm = SettingsModel(); const sm = SettingsModel();
return sm.copyWith( return sm.copyWith(
isDark: isDark, isDark: isDark,
isSSLDisabled: isSSLDisabled,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar, alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
size: size, size: size,
offset: offset, offset: offset,
@ -151,13 +150,13 @@ class SettingsModel {
historyRetentionPeriod: historyRetentionPeriod:
historyRetentionPeriod ?? HistoryRetentionPeriod.oneWeek, historyRetentionPeriod ?? HistoryRetentionPeriod.oneWeek,
workspaceFolderPath: workspaceFolderPath, workspaceFolderPath: workspaceFolderPath,
isSSLDisabled: isSSLDisabled,
); );
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
return { return {
"isDark": isDark, "isDark": isDark,
"isSSLDisabled":isSSLDisabled,
"alwaysShowCollectionPaneScrollbar": alwaysShowCollectionPaneScrollbar, "alwaysShowCollectionPaneScrollbar": alwaysShowCollectionPaneScrollbar,
"width": size?.width, "width": size?.width,
"height": size?.height, "height": size?.height,
@ -170,6 +169,7 @@ class SettingsModel {
"activeEnvironmentId": activeEnvironmentId, "activeEnvironmentId": activeEnvironmentId,
"historyRetentionPeriod": historyRetentionPeriod.name, "historyRetentionPeriod": historyRetentionPeriod.name,
"workspaceFolderPath": workspaceFolderPath, "workspaceFolderPath": workspaceFolderPath,
"isSSLDisabled": isSSLDisabled,
}; };
} }
@ -183,7 +183,6 @@ class SettingsModel {
return other is SettingsModel && return other is SettingsModel &&
other.runtimeType == runtimeType && other.runtimeType == runtimeType &&
other.isDark == isDark && other.isDark == isDark &&
other.isSSLDisabled == isSSLDisabled &&
other.alwaysShowCollectionPaneScrollbar == other.alwaysShowCollectionPaneScrollbar ==
alwaysShowCollectionPaneScrollbar && alwaysShowCollectionPaneScrollbar &&
other.size == size && other.size == size &&
@ -194,7 +193,8 @@ class SettingsModel {
other.promptBeforeClosing == promptBeforeClosing && other.promptBeforeClosing == promptBeforeClosing &&
other.activeEnvironmentId == activeEnvironmentId && other.activeEnvironmentId == activeEnvironmentId &&
other.historyRetentionPeriod == historyRetentionPeriod && other.historyRetentionPeriod == historyRetentionPeriod &&
other.workspaceFolderPath == workspaceFolderPath; other.workspaceFolderPath == workspaceFolderPath &&
other.isSSLDisabled == isSSLDisabled;
} }
@override @override
@ -202,7 +202,6 @@ class SettingsModel {
return Object.hash( return Object.hash(
runtimeType, runtimeType,
isDark, isDark,
isSSLDisabled,
alwaysShowCollectionPaneScrollbar, alwaysShowCollectionPaneScrollbar,
size, size,
offset, offset,
@ -213,6 +212,7 @@ class SettingsModel {
activeEnvironmentId, activeEnvironmentId,
historyRetentionPeriod, historyRetentionPeriod,
workspaceFolderPath, workspaceFolderPath,
isSSLDisabled,
); );
} }
} }

View File

@ -22,7 +22,6 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
Future<void> update({ Future<void> update({
bool? isDark, bool? isDark,
bool? isSSLDisabled,
bool? alwaysShowCollectionPaneScrollbar, bool? alwaysShowCollectionPaneScrollbar,
Size? size, Size? size,
Offset? offset, Offset? offset,
@ -33,10 +32,10 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
String? activeEnvironmentId, String? activeEnvironmentId,
HistoryRetentionPeriod? historyRetentionPeriod, HistoryRetentionPeriod? historyRetentionPeriod,
String? workspaceFolderPath, String? workspaceFolderPath,
bool? isSSLDisabled,
}) async { }) async {
state = state.copyWith( state = state.copyWith(
isDark: isDark, isDark: isDark,
isSSLDisabled: isSSLDisabled,
alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar, alwaysShowCollectionPaneScrollbar: alwaysShowCollectionPaneScrollbar,
size: size, size: size,
offset: offset, offset: offset,
@ -47,6 +46,7 @@ class ThemeStateNotifier extends StateNotifier<SettingsModel> {
activeEnvironmentId: activeEnvironmentId, activeEnvironmentId: activeEnvironmentId,
historyRetentionPeriod: historyRetentionPeriod, historyRetentionPeriod: historyRetentionPeriod,
workspaceFolderPath: workspaceFolderPath, workspaceFolderPath: workspaceFolderPath,
isSSLDisabled: isSSLDisabled,
); );
await setSettingsToSharedPrefs(state); await setSettingsToSharedPrefs(state);
} }