feat: add setting for auto-lock fix: fix sideswipe
This commit is contained in:
@@ -106,6 +106,9 @@ class AppSettingsTable extends Table {
|
||||
|
||||
BoolColumn get pinRequired => boolean().withDefault(const Constant(false))();
|
||||
|
||||
BoolColumn get autoLockEnabled =>
|
||||
boolean().withDefault(const Constant(true))();
|
||||
|
||||
TextColumn get themeMode => text().withDefault(const Constant('system'))();
|
||||
|
||||
TextColumn get language => text().withDefault(const Constant('system'))();
|
||||
@@ -132,7 +135,7 @@ class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 8;
|
||||
int get schemaVersion => 9;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration {
|
||||
@@ -181,6 +184,13 @@ class AppDatabase extends _$AppDatabase {
|
||||
appSettingsTable.barGridRows,
|
||||
);
|
||||
}
|
||||
|
||||
if (from < 9 && !await hasSettingsColumn('auto_lock_enabled')) {
|
||||
await migrator.addColumn(
|
||||
appSettingsTable,
|
||||
appSettingsTable.autoLockEnabled,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2207,6 +2207,21 @@ class $AppSettingsTableTable extends AppSettingsTable
|
||||
),
|
||||
defaultValue: const Constant(false),
|
||||
);
|
||||
static const VerificationMeta _autoLockEnabledMeta = const VerificationMeta(
|
||||
'autoLockEnabled',
|
||||
);
|
||||
@override
|
||||
late final GeneratedColumn<bool> autoLockEnabled = GeneratedColumn<bool>(
|
||||
'auto_lock_enabled',
|
||||
aliasedName,
|
||||
false,
|
||||
type: DriftSqlType.bool,
|
||||
requiredDuringInsert: false,
|
||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||
'CHECK ("auto_lock_enabled" IN (0, 1))',
|
||||
),
|
||||
defaultValue: const Constant(true),
|
||||
);
|
||||
static const VerificationMeta _themeModeMeta = const VerificationMeta(
|
||||
'themeMode',
|
||||
);
|
||||
@@ -2247,6 +2262,7 @@ class $AppSettingsTableTable extends AppSettingsTable
|
||||
List<GeneratedColumn> get $columns => [
|
||||
id,
|
||||
pinRequired,
|
||||
autoLockEnabled,
|
||||
themeMode,
|
||||
language,
|
||||
barGridRows,
|
||||
@@ -2277,6 +2293,15 @@ class $AppSettingsTableTable extends AppSettingsTable
|
||||
),
|
||||
);
|
||||
}
|
||||
if (data.containsKey('auto_lock_enabled')) {
|
||||
context.handle(
|
||||
_autoLockEnabledMeta,
|
||||
autoLockEnabled.isAcceptableOrUnknown(
|
||||
data['auto_lock_enabled']!,
|
||||
_autoLockEnabledMeta,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (data.containsKey('theme_mode')) {
|
||||
context.handle(
|
||||
_themeModeMeta,
|
||||
@@ -2315,6 +2340,10 @@ class $AppSettingsTableTable extends AppSettingsTable
|
||||
DriftSqlType.bool,
|
||||
data['${effectivePrefix}pin_required'],
|
||||
)!,
|
||||
autoLockEnabled: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.bool,
|
||||
data['${effectivePrefix}auto_lock_enabled'],
|
||||
)!,
|
||||
themeMode: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}theme_mode'],
|
||||
@@ -2339,12 +2368,14 @@ class $AppSettingsTableTable extends AppSettingsTable
|
||||
class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
final String id;
|
||||
final bool pinRequired;
|
||||
final bool autoLockEnabled;
|
||||
final String themeMode;
|
||||
final String language;
|
||||
final int barGridRows;
|
||||
const AppSettingsRow({
|
||||
required this.id,
|
||||
required this.pinRequired,
|
||||
required this.autoLockEnabled,
|
||||
required this.themeMode,
|
||||
required this.language,
|
||||
required this.barGridRows,
|
||||
@@ -2354,6 +2385,7 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<String>(id);
|
||||
map['pin_required'] = Variable<bool>(pinRequired);
|
||||
map['auto_lock_enabled'] = Variable<bool>(autoLockEnabled);
|
||||
map['theme_mode'] = Variable<String>(themeMode);
|
||||
map['language'] = Variable<String>(language);
|
||||
map['bar_grid_rows'] = Variable<int>(barGridRows);
|
||||
@@ -2364,6 +2396,7 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
return AppSettingsTableCompanion(
|
||||
id: Value(id),
|
||||
pinRequired: Value(pinRequired),
|
||||
autoLockEnabled: Value(autoLockEnabled),
|
||||
themeMode: Value(themeMode),
|
||||
language: Value(language),
|
||||
barGridRows: Value(barGridRows),
|
||||
@@ -2378,6 +2411,7 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
return AppSettingsRow(
|
||||
id: serializer.fromJson<String>(json['id']),
|
||||
pinRequired: serializer.fromJson<bool>(json['pinRequired']),
|
||||
autoLockEnabled: serializer.fromJson<bool>(json['autoLockEnabled']),
|
||||
themeMode: serializer.fromJson<String>(json['themeMode']),
|
||||
language: serializer.fromJson<String>(json['language']),
|
||||
barGridRows: serializer.fromJson<int>(json['barGridRows']),
|
||||
@@ -2389,6 +2423,7 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<String>(id),
|
||||
'pinRequired': serializer.toJson<bool>(pinRequired),
|
||||
'autoLockEnabled': serializer.toJson<bool>(autoLockEnabled),
|
||||
'themeMode': serializer.toJson<String>(themeMode),
|
||||
'language': serializer.toJson<String>(language),
|
||||
'barGridRows': serializer.toJson<int>(barGridRows),
|
||||
@@ -2398,12 +2433,14 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
AppSettingsRow copyWith({
|
||||
String? id,
|
||||
bool? pinRequired,
|
||||
bool? autoLockEnabled,
|
||||
String? themeMode,
|
||||
String? language,
|
||||
int? barGridRows,
|
||||
}) => AppSettingsRow(
|
||||
id: id ?? this.id,
|
||||
pinRequired: pinRequired ?? this.pinRequired,
|
||||
autoLockEnabled: autoLockEnabled ?? this.autoLockEnabled,
|
||||
themeMode: themeMode ?? this.themeMode,
|
||||
language: language ?? this.language,
|
||||
barGridRows: barGridRows ?? this.barGridRows,
|
||||
@@ -2414,6 +2451,9 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
pinRequired: data.pinRequired.present
|
||||
? data.pinRequired.value
|
||||
: this.pinRequired,
|
||||
autoLockEnabled: data.autoLockEnabled.present
|
||||
? data.autoLockEnabled.value
|
||||
: this.autoLockEnabled,
|
||||
themeMode: data.themeMode.present ? data.themeMode.value : this.themeMode,
|
||||
language: data.language.present ? data.language.value : this.language,
|
||||
barGridRows: data.barGridRows.present
|
||||
@@ -2427,6 +2467,7 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
return (StringBuffer('AppSettingsRow(')
|
||||
..write('id: $id, ')
|
||||
..write('pinRequired: $pinRequired, ')
|
||||
..write('autoLockEnabled: $autoLockEnabled, ')
|
||||
..write('themeMode: $themeMode, ')
|
||||
..write('language: $language, ')
|
||||
..write('barGridRows: $barGridRows')
|
||||
@@ -2435,14 +2476,21 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(id, pinRequired, themeMode, language, barGridRows);
|
||||
int get hashCode => Object.hash(
|
||||
id,
|
||||
pinRequired,
|
||||
autoLockEnabled,
|
||||
themeMode,
|
||||
language,
|
||||
barGridRows,
|
||||
);
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
(other is AppSettingsRow &&
|
||||
other.id == this.id &&
|
||||
other.pinRequired == this.pinRequired &&
|
||||
other.autoLockEnabled == this.autoLockEnabled &&
|
||||
other.themeMode == this.themeMode &&
|
||||
other.language == this.language &&
|
||||
other.barGridRows == this.barGridRows);
|
||||
@@ -2451,6 +2499,7 @@ class AppSettingsRow extends DataClass implements Insertable<AppSettingsRow> {
|
||||
class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
final Value<String> id;
|
||||
final Value<bool> pinRequired;
|
||||
final Value<bool> autoLockEnabled;
|
||||
final Value<String> themeMode;
|
||||
final Value<String> language;
|
||||
final Value<int> barGridRows;
|
||||
@@ -2458,6 +2507,7 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
const AppSettingsTableCompanion({
|
||||
this.id = const Value.absent(),
|
||||
this.pinRequired = const Value.absent(),
|
||||
this.autoLockEnabled = const Value.absent(),
|
||||
this.themeMode = const Value.absent(),
|
||||
this.language = const Value.absent(),
|
||||
this.barGridRows = const Value.absent(),
|
||||
@@ -2466,6 +2516,7 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
AppSettingsTableCompanion.insert({
|
||||
required String id,
|
||||
this.pinRequired = const Value.absent(),
|
||||
this.autoLockEnabled = const Value.absent(),
|
||||
this.themeMode = const Value.absent(),
|
||||
this.language = const Value.absent(),
|
||||
this.barGridRows = const Value.absent(),
|
||||
@@ -2474,6 +2525,7 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
static Insertable<AppSettingsRow> custom({
|
||||
Expression<String>? id,
|
||||
Expression<bool>? pinRequired,
|
||||
Expression<bool>? autoLockEnabled,
|
||||
Expression<String>? themeMode,
|
||||
Expression<String>? language,
|
||||
Expression<int>? barGridRows,
|
||||
@@ -2482,6 +2534,7 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
return RawValuesInsertable({
|
||||
if (id != null) 'id': id,
|
||||
if (pinRequired != null) 'pin_required': pinRequired,
|
||||
if (autoLockEnabled != null) 'auto_lock_enabled': autoLockEnabled,
|
||||
if (themeMode != null) 'theme_mode': themeMode,
|
||||
if (language != null) 'language': language,
|
||||
if (barGridRows != null) 'bar_grid_rows': barGridRows,
|
||||
@@ -2492,6 +2545,7 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
AppSettingsTableCompanion copyWith({
|
||||
Value<String>? id,
|
||||
Value<bool>? pinRequired,
|
||||
Value<bool>? autoLockEnabled,
|
||||
Value<String>? themeMode,
|
||||
Value<String>? language,
|
||||
Value<int>? barGridRows,
|
||||
@@ -2500,6 +2554,7 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
return AppSettingsTableCompanion(
|
||||
id: id ?? this.id,
|
||||
pinRequired: pinRequired ?? this.pinRequired,
|
||||
autoLockEnabled: autoLockEnabled ?? this.autoLockEnabled,
|
||||
themeMode: themeMode ?? this.themeMode,
|
||||
language: language ?? this.language,
|
||||
barGridRows: barGridRows ?? this.barGridRows,
|
||||
@@ -2516,6 +2571,9 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
if (pinRequired.present) {
|
||||
map['pin_required'] = Variable<bool>(pinRequired.value);
|
||||
}
|
||||
if (autoLockEnabled.present) {
|
||||
map['auto_lock_enabled'] = Variable<bool>(autoLockEnabled.value);
|
||||
}
|
||||
if (themeMode.present) {
|
||||
map['theme_mode'] = Variable<String>(themeMode.value);
|
||||
}
|
||||
@@ -2536,6 +2594,7 @@ class AppSettingsTableCompanion extends UpdateCompanion<AppSettingsRow> {
|
||||
return (StringBuffer('AppSettingsTableCompanion(')
|
||||
..write('id: $id, ')
|
||||
..write('pinRequired: $pinRequired, ')
|
||||
..write('autoLockEnabled: $autoLockEnabled, ')
|
||||
..write('themeMode: $themeMode, ')
|
||||
..write('language: $language, ')
|
||||
..write('barGridRows: $barGridRows, ')
|
||||
@@ -4125,6 +4184,7 @@ typedef $$AppSettingsTableTableCreateCompanionBuilder =
|
||||
AppSettingsTableCompanion Function({
|
||||
required String id,
|
||||
Value<bool> pinRequired,
|
||||
Value<bool> autoLockEnabled,
|
||||
Value<String> themeMode,
|
||||
Value<String> language,
|
||||
Value<int> barGridRows,
|
||||
@@ -4134,6 +4194,7 @@ typedef $$AppSettingsTableTableUpdateCompanionBuilder =
|
||||
AppSettingsTableCompanion Function({
|
||||
Value<String> id,
|
||||
Value<bool> pinRequired,
|
||||
Value<bool> autoLockEnabled,
|
||||
Value<String> themeMode,
|
||||
Value<String> language,
|
||||
Value<int> barGridRows,
|
||||
@@ -4159,6 +4220,11 @@ class $$AppSettingsTableTableFilterComposer
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<bool> get autoLockEnabled => $composableBuilder(
|
||||
column: $table.autoLockEnabled,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
);
|
||||
|
||||
ColumnFilters<String> get themeMode => $composableBuilder(
|
||||
column: $table.themeMode,
|
||||
builder: (column) => ColumnFilters(column),
|
||||
@@ -4194,6 +4260,11 @@ class $$AppSettingsTableTableOrderingComposer
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<bool> get autoLockEnabled => $composableBuilder(
|
||||
column: $table.autoLockEnabled,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
);
|
||||
|
||||
ColumnOrderings<String> get themeMode => $composableBuilder(
|
||||
column: $table.themeMode,
|
||||
builder: (column) => ColumnOrderings(column),
|
||||
@@ -4227,6 +4298,11 @@ class $$AppSettingsTableTableAnnotationComposer
|
||||
builder: (column) => column,
|
||||
);
|
||||
|
||||
GeneratedColumn<bool> get autoLockEnabled => $composableBuilder(
|
||||
column: $table.autoLockEnabled,
|
||||
builder: (column) => column,
|
||||
);
|
||||
|
||||
GeneratedColumn<String> get themeMode =>
|
||||
$composableBuilder(column: $table.themeMode, builder: (column) => column);
|
||||
|
||||
@@ -4278,6 +4354,7 @@ class $$AppSettingsTableTableTableManager
|
||||
({
|
||||
Value<String> id = const Value.absent(),
|
||||
Value<bool> pinRequired = const Value.absent(),
|
||||
Value<bool> autoLockEnabled = const Value.absent(),
|
||||
Value<String> themeMode = const Value.absent(),
|
||||
Value<String> language = const Value.absent(),
|
||||
Value<int> barGridRows = const Value.absent(),
|
||||
@@ -4285,6 +4362,7 @@ class $$AppSettingsTableTableTableManager
|
||||
}) => AppSettingsTableCompanion(
|
||||
id: id,
|
||||
pinRequired: pinRequired,
|
||||
autoLockEnabled: autoLockEnabled,
|
||||
themeMode: themeMode,
|
||||
language: language,
|
||||
barGridRows: barGridRows,
|
||||
@@ -4294,6 +4372,7 @@ class $$AppSettingsTableTableTableManager
|
||||
({
|
||||
required String id,
|
||||
Value<bool> pinRequired = const Value.absent(),
|
||||
Value<bool> autoLockEnabled = const Value.absent(),
|
||||
Value<String> themeMode = const Value.absent(),
|
||||
Value<String> language = const Value.absent(),
|
||||
Value<int> barGridRows = const Value.absent(),
|
||||
@@ -4301,6 +4380,7 @@ class $$AppSettingsTableTableTableManager
|
||||
}) => AppSettingsTableCompanion.insert(
|
||||
id: id,
|
||||
pinRequired: pinRequired,
|
||||
autoLockEnabled: autoLockEnabled,
|
||||
themeMode: themeMode,
|
||||
language: language,
|
||||
barGridRows: barGridRows,
|
||||
|
||||
Reference in New Issue
Block a user