Skip to content

Commit a9832c7

Browse files
committed
[411] fix: remove AppLock widget when lock is disabled
1 parent f5938a8 commit a9832c7

File tree

2 files changed

+68
-62
lines changed

2 files changed

+68
-62
lines changed

lib/app.dart

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class _AppState extends ConsumerState<App> {
9898
final useWhiteTextDarkMode = ref.watch(
9999
preferencesProvider.select((preferences) => preferences.useWhiteTextDarkMode),
100100
);
101-
final lock = PreferenceKey.lockApp.preferenceOrDefault;
102-
final lockDelay = PreferenceKey.lockAppDelay.preferenceOrDefault;
101+
final lockApp = PreferenceKey.lockApp.preferenceOrDefault;
102+
final lockAppDelay = PreferenceKey.lockAppDelay.preferenceOrDefault;
103103

104104
return DynamicColorBuilder(
105105
builder: (lightDynamicColorScheme, darkDynamicColorScheme) {
@@ -134,24 +134,26 @@ class _AppState extends ConsumerState<App> {
134134

135135
return Directionality(
136136
textDirection: SystemUtils().deviceLocale.textDirection,
137-
child: AppLock(
138-
initiallyEnabled: lock,
139-
initialBackgroundLockLatency: Duration(seconds: lockDelay),
140-
builder: (BuildContext context, Object? launchArg) {
141-
SystemUtils().setQuickActions(context, ref);
142-
143-
return child;
144-
},
145-
lockScreenBuilder: (BuildContext context) {
146-
final l = AppLocalizations.of(context);
147-
148-
return LockPage(
149-
back: false,
150-
description: l.lock_page_description_app,
151-
reason: l.lock_page_reason_app,
152-
);
153-
},
154-
),
137+
child: lockApp
138+
? AppLock(
139+
initiallyEnabled: lockApp,
140+
initialBackgroundLockLatency: Duration(seconds: lockAppDelay),
141+
builder: (BuildContext context, Object? launchArg) {
142+
SystemUtils().setQuickActions(context, ref);
143+
144+
return child;
145+
},
146+
lockScreenBuilder: (BuildContext context) {
147+
final l = AppLocalizations.of(context);
148+
149+
return LockPage(
150+
back: false,
151+
description: l.lock_page_description_app,
152+
reason: l.lock_page_reason_app,
153+
);
154+
},
155+
)
156+
: child,
155157
);
156158
},
157159
theme: lightTheme,

lib/pages/editor/editor_page.dart

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -119,52 +119,56 @@ class _EditorState extends ConsumerState<NotesEditorPage> {
119119
);
120120
}
121121

122-
return AppLock(
123-
initiallyEnabled: lockNote,
124-
initialBackgroundLockLatency: Duration(seconds: lockDelay),
125-
builder: (BuildContext context, Object? launchArg) {
126-
return Scaffold(
127-
appBar: const TopNavigation(
128-
appbar: EditorAppBar(),
129-
notesStatus: NoteStatus.available,
130-
),
131-
body: Column(
132-
children: [
133-
Expanded(
134-
child: Column(
135-
children: [
136-
TitleEditor(
137-
readOnly: widget.readOnly,
138-
isNewNote: widget.isNewNote,
139-
onSubmitted: requestEditorFocus,
140-
),
141-
Gap(8.0),
142-
Expanded(
143-
child: contentEditor,
144-
),
145-
],
122+
final editor = Scaffold(
123+
appBar: const TopNavigation(
124+
appbar: EditorAppBar(),
125+
notesStatus: NoteStatus.available,
126+
),
127+
body: Column(
128+
children: [
129+
Expanded(
130+
child: Column(
131+
children: [
132+
TitleEditor(
133+
readOnly: widget.readOnly,
134+
isNewNote: widget.isNewNote,
135+
onSubmitted: requestEditorFocus,
146136
),
147-
),
148-
SafeArea(
149-
child: Column(
150-
children: [
151-
if (showLabelsList) EditorLabelsList(readOnly: widget.readOnly),
152-
if (toolbar != null && isEditorInEditMode && !currentNote.deleted) toolbar,
153-
],
137+
Gap(8.0),
138+
Expanded(
139+
child: contentEditor,
154140
),
155-
),
156-
],
141+
],
142+
),
157143
),
158-
);
159-
},
160-
lockScreenBuilder: (BuildContext context) {
161-
return LockPage(
162-
back: true,
163-
description: l.lock_page_description_note,
164-
reason: l.lock_page_reason_note,
165-
);
166-
},
144+
SafeArea(
145+
child: Column(
146+
children: [
147+
if (showLabelsList) EditorLabelsList(readOnly: widget.readOnly),
148+
if (toolbar != null && isEditorInEditMode && !currentNote.deleted) toolbar,
149+
],
150+
),
151+
),
152+
],
153+
),
167154
);
155+
156+
return lockNote
157+
? AppLock(
158+
initiallyEnabled: lockNote,
159+
initialBackgroundLockLatency: Duration(seconds: lockDelay),
160+
builder: (BuildContext context, Object? launchArg) {
161+
return editor;
162+
},
163+
lockScreenBuilder: (BuildContext context) {
164+
return LockPage(
165+
back: true,
166+
description: l.lock_page_description_note,
167+
reason: l.lock_page_reason_note,
168+
);
169+
},
170+
)
171+
: editor;
168172
},
169173
);
170174
},

0 commit comments

Comments
 (0)