Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
963f7271a2 | |||
442403b5b9 | |||
ad767ac33a | |||
1051805463 | |||
173c4fbee2 | |||
d06a8d6698 | |||
d788c110a7 | |||
41e2922bfb | |||
a07ba1109c |
@@ -21,13 +21,13 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_notes_date_unique ON notes (date);
|
||||
-- ie. they're not really a list but instead a string
|
||||
-- But we will also keep a history of all todos
|
||||
-- Because we might as well
|
||||
CREATE TABLE IF NOT EXISTS todos (
|
||||
CREATE TABLE IF NOT EXISTS scratches (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
date TEXT DEFAULT CURRENT_TIMESTAMP,
|
||||
content TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_todos_date ON todos (date);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_todos_date_unique ON todos (date);
|
||||
CREATE INDEX IF NOT EXISTS idx_scratches_date ON scratches (date);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_scratches_date_unique ON scratches (date);
|
||||
''';
|
||||
|
||||
static Future<String> _getDatabasePath() async {
|
||||
|
@@ -7,7 +7,13 @@ import 'package:system_tray/system_tray.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:audioplayers/audioplayers.dart';
|
||||
|
||||
const Duration popupInterval = Duration(hours: 1);
|
||||
// TODO: Add an icon to the executable, simply use the existing tray icon
|
||||
// TODO: Add an entry field for the duration ie. the interval of apperance
|
||||
// TODO: Also the sound file, if possible...
|
||||
// TODO: Cram the above into the database
|
||||
// TODO: Implement some sort of scroll through notes
|
||||
|
||||
const Duration popupInterval = Duration(minutes: 20);
|
||||
const String notificationSound = 'MeetTheSniper.mp3';
|
||||
|
||||
void main() async {
|
||||
@@ -116,17 +122,19 @@ class MainPage extends StatefulWidget {
|
||||
const MainPage({super.key});
|
||||
|
||||
@override
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
State<MainPage> createState() => MainPageState();
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> with WindowListener {
|
||||
class MainPageState extends State<MainPage> with WindowListener {
|
||||
final SystemTray _systemTray = SystemTray();
|
||||
final Menu _menu = Menu();
|
||||
final AudioPlayer _audioPlayer = AudioPlayer();
|
||||
|
||||
final TextEditingController _previousEntryController =
|
||||
TextEditingController();
|
||||
final TextEditingController _currentEntryController = TextEditingController();
|
||||
final TextEditingController _todoController = TextEditingController();
|
||||
final FocusNode _currentEntryFocusNode = FocusNode();
|
||||
final TextEditingController _scratchController = TextEditingController();
|
||||
|
||||
Note? previousNote;
|
||||
|
||||
@@ -151,7 +159,8 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
_debounceTimer?.cancel();
|
||||
_previousEntryController.dispose();
|
||||
_currentEntryController.dispose();
|
||||
_todoController.dispose();
|
||||
_currentEntryFocusNode.dispose();
|
||||
_scratchController.dispose();
|
||||
_audioPlayer.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -172,9 +181,22 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
|
||||
await _systemTray.initSystemTray(iconPath: iconPath, toolTip: "Journaler");
|
||||
|
||||
await _menu.buildFrom([
|
||||
MenuItemLabel(
|
||||
label: 'Commit Sudoku',
|
||||
onClicked: (menuItem) => windowManager.destroy(),
|
||||
),
|
||||
]);
|
||||
|
||||
await _systemTray.setContextMenu(_menu);
|
||||
|
||||
_systemTray.registerSystemTrayEventHandler((eventName) {
|
||||
debugPrint("System Tray Event: $eventName");
|
||||
if (eventName == kSystemTrayEventClick) {
|
||||
_showWindow();
|
||||
} else if (eventName == kSystemTrayEventRightClick) {
|
||||
_systemTray.popUpContextMenu();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,9 +214,11 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
await windowManager.center();
|
||||
await windowManager.show();
|
||||
await windowManager.focus();
|
||||
_currentEntryFocusNode.requestFocus();
|
||||
await _playSound();
|
||||
} else {
|
||||
await windowManager.focus();
|
||||
_currentEntryFocusNode.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,25 +233,27 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
previousNote = note;
|
||||
_previousEntryController.text = note?.content ?? "";
|
||||
|
||||
final todo = await getLatestTodo();
|
||||
_todoController.text = todo?.content ?? "";
|
||||
final scratch = await getLatestScratch();
|
||||
_scratchController.text = scratch?.content ?? "";
|
||||
_currentEntryController.text = "";
|
||||
|
||||
debugPrint("Data loaded (placeholder).");
|
||||
debugPrint("Data loaded.");
|
||||
}
|
||||
|
||||
void _saveData() async {
|
||||
String previousEntry = _previousEntryController.text;
|
||||
String currentEntry = _currentEntryController.text;
|
||||
String todoList = _todoController.text;
|
||||
String scratchContent = _scratchController.text;
|
||||
|
||||
await createNote(currentEntry);
|
||||
await createTodo(todoList);
|
||||
await createScratch(scratchContent);
|
||||
if (previousNote != null) {
|
||||
previousNote!.content = previousEntry;
|
||||
await updateNote(previousNote!);
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
"Saving data (placeholder)... Current Entry: [${currentEntry.length} chars], Todo: [${todoList.length} chars]",
|
||||
"Saving data... Current Entry: [${currentEntry.length} chars], Scratch: [${scratchContent.length} chars]",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -237,13 +263,17 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return KeyboardListener(
|
||||
focusNode: FocusNode(),
|
||||
autofocus: true,
|
||||
onKeyEvent: (event) {
|
||||
if (event is KeyDownEvent &&
|
||||
// Wrap Scaffold with RawKeyboardListener as workaround for Escape key
|
||||
return RawKeyboardListener(
|
||||
focusNode: FocusNode(), // Needs its own node
|
||||
onKey: (RawKeyEvent event) {
|
||||
if (event is RawKeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
debugPrint("Escape key pressed - hiding window.");
|
||||
debugPrint(
|
||||
"Escape pressed inside MainPage (RawKeyboardListener - Workaround)",
|
||||
);
|
||||
// Call method directly since we are in the state
|
||||
FocusManager.instance.primaryFocus?.unfocus(); // Keep unfocus attempt
|
||||
onWindowClose();
|
||||
}
|
||||
},
|
||||
@@ -274,6 +304,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _currentEntryController,
|
||||
focusNode: _currentEntryFocusNode,
|
||||
maxLines: null,
|
||||
expands: true,
|
||||
autofocus: true,
|
||||
@@ -291,7 +322,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: TextField(
|
||||
controller: _todoController,
|
||||
controller: _scratchController,
|
||||
maxLines: null,
|
||||
expands: true,
|
||||
style:
|
||||
@@ -299,7 +330,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
context,
|
||||
).textTheme.bodyMedium, // Apply theme text style
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Todo',
|
||||
labelText: 'Scratch',
|
||||
// border: OutlineInputBorder(), // Handled by theme
|
||||
// contentPadding: EdgeInsets.all(8.0), // Handled by theme or default
|
||||
),
|
||||
@@ -312,3 +343,5 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// --- End Actions and Shortcuts ---
|
||||
|
@@ -7,11 +7,11 @@ class Note {
|
||||
Note({required this.date, required this.content});
|
||||
}
|
||||
|
||||
class Todo {
|
||||
class Scratch {
|
||||
final String date;
|
||||
final String content;
|
||||
String content;
|
||||
|
||||
Todo({required this.date, required this.content});
|
||||
Scratch({required this.date, required this.content});
|
||||
}
|
||||
|
||||
Future<Note?> getLatestNote() async {
|
||||
@@ -43,22 +43,21 @@ Future<void> updateNote(Note note) async {
|
||||
);
|
||||
}
|
||||
|
||||
Future<Todo?> getLatestTodo() async {
|
||||
final todo = await DB.db.rawQuery(
|
||||
'SELECT content, date FROM todos ORDER BY date DESC LIMIT 1',
|
||||
Future<Scratch?> getLatestScratch() async {
|
||||
final scratch = await DB.db.rawQuery(
|
||||
'SELECT content, date FROM scratches ORDER BY date DESC LIMIT 1',
|
||||
);
|
||||
if (todo.isEmpty) {
|
||||
|
||||
if (scratch.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
return Todo(
|
||||
date: todo[0]['date'] as String,
|
||||
content: todo[0]['content'] as String,
|
||||
} else {
|
||||
return Scratch(
|
||||
date: scratch[0]['date'] as String,
|
||||
content: scratch[0]['content'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> createTodo(String content) async {
|
||||
if (content.isEmpty) {
|
||||
return;
|
||||
}
|
||||
await DB.db.insert('todos', {'content': content});
|
||||
Future<void> createScratch(String content) async {
|
||||
await DB.db.insert('scratches', {'content': content});
|
||||
}
|
||||
|
60
release.sh
Normal file
60
release.sh
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Figuring out the tag..."
|
||||
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
|
||||
if [ -z "$TAG" ]; then
|
||||
# Get the latest tag
|
||||
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
|
||||
# Increment the patch version
|
||||
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG"
|
||||
VERSION_PARTS[2]=$((VERSION_PARTS[2]+1))
|
||||
TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
|
||||
# Create a new tag
|
||||
git tag $TAG
|
||||
git push origin $TAG
|
||||
fi
|
||||
echo "Tag: $TAG"
|
||||
|
||||
echo "Building the thing..."
|
||||
flutter build windows --release
|
||||
flutter build apk --release
|
||||
|
||||
echo "Creating a release..."
|
||||
TOKEN="$GITEA_API_KEY"
|
||||
GITEA="https://git.site.quack-lab.dev"
|
||||
REPO="dave/journaler"
|
||||
ZIP="journaler-${TAG}.zip"
|
||||
APK="journaler-${TAG}.apk"
|
||||
# Create a release
|
||||
RELEASE_RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"tag_name": "'"$TAG"'",
|
||||
"name": "'"$TAG"'",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}' \
|
||||
$GITEA/api/v1/repos/$REPO/releases)
|
||||
|
||||
# Extract the release ID
|
||||
echo $RELEASE_RESPONSE
|
||||
RELEASE_ID=$(echo $RELEASE_RESPONSE | awk -F'"id":' '{print $2+0; exit}')
|
||||
echo "Release ID: $RELEASE_ID"
|
||||
|
||||
echo "Uploading the things..."
|
||||
WINRELEASE="./build/windows/x64/runner/Release/"
|
||||
7z a $WINRELEASE/$ZIP $WINRELEASE/*
|
||||
curl -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$WINRELEASE/$ZIP" \
|
||||
"$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=$ZIP"
|
||||
rm $WINRELEASE/$ZIP
|
||||
|
||||
ANDROIDRELEASE="./build/app/outputs/flutter-apk/"
|
||||
mv $ANDROIDRELEASE/app-release.apk $ANDROIDRELEASE/$APK
|
||||
curl -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$ANDROIDRELEASE/$APK" \
|
||||
"$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=$APK"
|
Reference in New Issue
Block a user