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

Enhance welcome note #73

Merged
merged 6 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
30 changes: 10 additions & 20 deletions lib/core/databases/sqflite_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:dairy_app/core/logger/logger.dart';
import 'package:path_provider/path_provider.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
import 'welcome_note.dart';

final log = printer("SQLTableSetup");

Expand Down Expand Up @@ -60,29 +61,18 @@ class DBProvider {
${NoteDependencies.ASSET_PATH} TEXT
)
""");
log.i("All create queries executed successfully");
log.i("Inserting welcome note");
//as soon as the tables are created, insert a welcome note

String body =
"""[{\"insert\":\"Welcome to DiaryVault!\\n\\nKey Features:\\n\\n-Rich text editor with support for images and videos.\\n\\n-Your data is securely preserved on your Google Drive / Dropbox account, ensuring complete ownership and privacy\\r.\\n\\n-Sync data between multiple devices.\\r\\n\\n-Fingerprint login on supported devices.\\r\\n\\n-Multiple Themes.\\n\\n\\nHappy notemaking!\\nThe DiaryVault team.\\n\\n\"}]""";

Map<String, Object> notemap = {
Notes.ID: "f773a170-6447-11ee-9a76-c314b6be99a3",
Notes.CREATED_AT: DateTime.now().millisecondsSinceEpoch,
Notes.TITLE: "Welcome to DiaryVault",
Notes.BODY: body,
Notes.HASH: "welcome_note_hash",
Notes.LAST_MODIFIED: DateTime.now().millisecondsSinceEpoch,
Notes.PLAIN_TEXT: "Read me to get started!",
Notes.DELETED: 0,
Notes.AUTHOR_ID: "guest_user_id",
};
await db.insert(Notes.TABLE_NAME, notemap);

log.i("All create queries executed successfully");
// As soon as the tables are created, insert a welcome note
// Check if there are no records in the notes table before inserting the initial data
final count = Sqflite.firstIntValue(
await db.rawQuery('SELECT COUNT(*) FROM ${Notes.TABLE_NAME}'));
if (count == 0) {
await db.insert(Notes.TABLE_NAME, welcomeNote);
}
log.i("Welcome Note inserted into table: ${Notes.TABLE_NAME}");
// print note
await db.query(Notes.TABLE_NAME).then((value) => log.i(value));

} catch (e) {
log.e(e);
rethrow;
Expand Down
12 changes: 12 additions & 0 deletions lib/core/databases/welcome_note.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
final welcomeNote = {
"id": "f773a170-6447-11ee-9a76-c314b6be99a3",
"created_at": 1696597075215,
"title": "Welcome to DiaryVault",
"body":
"[{\"insert\":\"Welcome to DiaryVault\"},{\"insert\":\": \",\"attributes\":{\"color\":\"#FF8E24AA\"}},{\"insert\":\"Your Personal Journaling Companion\"},{\"insert\":\"\\n\\n\",\"attributes\":{\"header\":2}},{\"insert\":\"We're \"},{\"insert\":\"delighted\",\"attributes\":{\"bold\":true,\"color\":\"#FF00ACC1\"}},{\"insert\":\" \",\"attributes\":{\"bold\":true}},{\"insert\":\"to have you onboard., and we're \"},{\"insert\":\"excited \",\"attributes\":{\"italic\":true,\"color\":\"#FF03A9F4\"}},{\"insert\":\"to be your trusted partner in capturing your thoughts, memories and moments 📝\",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\"\\n\\nExpress Yourself with Rich Text:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"Our powerful rich text editor allows you to \"},{\"insert\":\"craft your entries \",\"attributes\":{\"bold\":true}},{\"insert\":\"just the way you envision them. Add \"},{\"insert\":\"images \",\"attributes\":{\"italic\":true,\"color\":\"#FF039BE5\",\"bold\":true}},{\"insert\":\"and \",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\"videos \",\"attributes\":{\"italic\":true,\"color\":\"#FF039BE5\",\"bold\":true}},{\"insert\":\"📸\",\"attributes\":{\"color\":\"#FF039BE5\"}},{\"insert\":\" \",\"attributes\":{\"italic\":true,\"color\":\"#FF039BE5\",\"bold\":true}},{\"insert\":\"to give life to your words and relive your memories.\",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\"\\n\\nYour Data, Your Control:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"Your privacy 🔏 matters to us. With DiaryVault your journal entries are securely stored in your own \"},{\"insert\":\"Google Drive \",\"attributes\":{\"color\":\"#FF00897B\",\"bold\":true}},{\"insert\":\"or \",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\"Dropbox \",\"attributes\":{\"color\":\"#FF00897B\",\"bold\":true}},{\"insert\":\"account\",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\". \",\"attributes\":{\"color\":\"#FF00897B\",\"bold\":true}},{\"insert\":\"You retain complete ownership and over your data. \",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\"\\n\\nSay Goodbye to Lost Notes:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"We've got your back. DiaryVault automatically saves your notes, so you don't have to worry about losing your precious thoughts. Write freely and we'll ensure your words are safe 💜.\\n\\nSeemless Cross-Device Sync: \"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"Whether you're using DiaryVault on one phone or multiple devices. Your data is always kept in sync 🔃. You can fully restore your data on a new device.\\n \\nQuick and Secure Access:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"DiaryVault ensures the safety and security of your notes with \"},{\"insert\":\"fingerprint \",\"attributes\":{\"color\":\"#FF2962FF\",\"bold\":true}},{\"insert\":\"and \",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\"PIN\",\"attributes\":{\"color\":\"#FF2962FF\",\"bold\":true}},{\"insert\":\" based authentication 🔐, providing you with peace of mind and safeguarding your personal thoughts from prying eyes\\n\\nExport your Notes:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"DiaryVault allows you to export your entries in the form of \"},{\"insert\":\"text files \",\"attributes\":{\"color\":\"#FF00ACC1\",\"bold\":true}},{\"insert\":\"and\",\"attributes\":{\"color\":\"#FFFFFFFF\"}},{\"insert\":\" PDF\",\"attributes\":{\"color\":\"#FF00ACC1\",\"bold\":true}},{\"insert\":\". Share your thoughts easily with your friends or keep an offline copy for yourself.\\n\\nNever Miss a Day with Daily Reminders:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"You can setup daily reminder \"},{\"insert\":\"notifications\",\"attributes\":{\"bold\":true,\"color\":\"#FFD500F9\"}},{\"insert\":\" to ensure you never miss a day of journaling. Stay commited to your writing routine effortlessly 🔔✍️.\\n\\nPersonalize Your Experience:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"Explore multiple themes, fonts, pen-colors to make your journal uniquely yours 🎠..\\n\\nListen to Your Notes:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"DiaryVault offers Text-to-speech, enabling you to transform your written words into spoken ones. Sit back, relax and let your words come to life as you listen to your journals 🔊.\\n\\nYour Ad-free and Free of Cost Writing Journey:\"},{\"insert\":\"\\n\",\"attributes\":{\"header\":3}},{\"insert\":\"We're dedicated to providing you with a precious writing journey that's entirely ad-free and free of cost. Our focus is on preserving the sanctity of your writing experience, ensuring no interruptions or hidden fees 💎🚫✍️.\\n\\n\"},{\"insert\":\"Happy Journaling 🎉\",\"attributes\":{\"italic\":true}},{\"insert\":\"\\nThe DiaryVault Team\\n\\n\"},{\"insert\":{\"image\":\"https://imgur.com/PumJ9nC.png\"}},{\"insert\":\"\\n\\n\\n\\n\"}]",
"hash": "29d508083d4238085e2c114b2148c995cbce9d78",
"last_modified": 1696705796903,
"plain_text": "Open this note to get started",
"deleted": 0,
"author_id": "guest_user_id"
};
Loading