Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[411] Label lock #423

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ class _AppState extends ConsumerState<App> {
final useWhiteTextDarkMode = ref.watch(
preferencesProvider.select((preferences) => preferences.useWhiteTextDarkMode),
);
final lock = PreferenceKey.lockApp.preferenceOrDefault;
final lockDelay = PreferenceKey.lockAppDelay.preferenceOrDefault;
final lockApp = PreferenceKey.lockApp.preferenceOrDefault;
final lockAppDelay = PreferenceKey.lockAppDelay.preferenceOrDefault;

return DynamicColorBuilder(
builder: (lightDynamicColorScheme, darkDynamicColorScheme) {
Expand Down Expand Up @@ -134,24 +134,26 @@ class _AppState extends ConsumerState<App> {

return Directionality(
textDirection: SystemUtils().deviceLocale.textDirection,
child: AppLock(
initiallyEnabled: lock,
initialBackgroundLockLatency: Duration(seconds: lockDelay),
builder: (BuildContext context, Object? launchArg) {
SystemUtils().setQuickActions(context, ref);

return child;
},
lockScreenBuilder: (BuildContext context) {
final l = AppLocalizations.of(context);

return LockPage(
back: false,
description: l.lock_page_description_app,
reason: l.lock_page_reason_app,
);
},
),
child: lockApp
? AppLock(
initiallyEnabled: lockApp,
initialBackgroundLockLatency: Duration(seconds: lockAppDelay),
builder: (BuildContext context, Object? launchArg) {
SystemUtils().setQuickActions(context, ref);

return child;
},
lockScreenBuilder: (BuildContext context) {
final l = AppLocalizations.of(context);

return LockPage(
back: false,
description: l.lock_page_description_app,
reason: l.lock_page_reason_app,
);
},
)
: child,
);
},
theme: lightTheme,
Expand Down
88 changes: 46 additions & 42 deletions lib/pages/editor/editor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,52 +119,56 @@ class _EditorState extends ConsumerState<NotesEditorPage> {
);
}

return AppLock(
initiallyEnabled: lockNote,
initialBackgroundLockLatency: Duration(seconds: lockDelay),
builder: (BuildContext context, Object? launchArg) {
return Scaffold(
appBar: const TopNavigation(
appbar: EditorAppBar(),
notesStatus: NoteStatus.available,
),
body: Column(
children: [
Expanded(
child: Column(
children: [
TitleEditor(
readOnly: widget.readOnly,
isNewNote: widget.isNewNote,
onSubmitted: requestEditorFocus,
),
Gap(8.0),
Expanded(
child: contentEditor,
),
],
final editor = Scaffold(
appBar: const TopNavigation(
appbar: EditorAppBar(),
notesStatus: NoteStatus.available,
),
body: Column(
children: [
Expanded(
child: Column(
children: [
TitleEditor(
readOnly: widget.readOnly,
isNewNote: widget.isNewNote,
onSubmitted: requestEditorFocus,
),
),
SafeArea(
child: Column(
children: [
if (showLabelsList) EditorLabelsList(readOnly: widget.readOnly),
if (toolbar != null && isEditorInEditMode && !currentNote.deleted) toolbar,
],
Gap(8.0),
Expanded(
child: contentEditor,
),
),
],
],
),
),
);
},
lockScreenBuilder: (BuildContext context) {
return LockPage(
back: true,
description: l.lock_page_description_note,
reason: l.lock_page_reason_note,
);
},
SafeArea(
child: Column(
children: [
if (showLabelsList) EditorLabelsList(readOnly: widget.readOnly),
if (toolbar != null && isEditorInEditMode && !currentNote.deleted) toolbar,
],
),
),
],
),
);

return lockNote
? AppLock(
initiallyEnabled: lockNote,
initialBackgroundLockLatency: Duration(seconds: lockDelay),
builder: (BuildContext context, Object? launchArg) {
return editor;
},
lockScreenBuilder: (BuildContext context) {
return LockPage(
back: true,
description: l.lock_page_description_note,
reason: l.lock_page_reason_note,
);
},
)
: editor;
},
);
},
Expand Down