Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
ad767ac33a | |||
1051805463 | |||
173c4fbee2 | |||
d06a8d6698 | |||
d788c110a7 | |||
41e2922bfb | |||
a07ba1109c |
@@ -7,7 +7,12 @@ import 'package:system_tray/system_tray.dart';
|
|||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
import 'package:audioplayers/audioplayers.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
|
||||||
|
|
||||||
|
const Duration popupInterval = Duration(minutes: 20);
|
||||||
const String notificationSound = 'MeetTheSniper.mp3';
|
const String notificationSound = 'MeetTheSniper.mp3';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
@@ -116,16 +121,18 @@ class MainPage extends StatefulWidget {
|
|||||||
const MainPage({super.key});
|
const MainPage({super.key});
|
||||||
|
|
||||||
@override
|
@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 SystemTray _systemTray = SystemTray();
|
||||||
|
final Menu _menu = Menu();
|
||||||
final AudioPlayer _audioPlayer = AudioPlayer();
|
final AudioPlayer _audioPlayer = AudioPlayer();
|
||||||
|
|
||||||
final TextEditingController _previousEntryController =
|
final TextEditingController _previousEntryController =
|
||||||
TextEditingController();
|
TextEditingController();
|
||||||
final TextEditingController _currentEntryController = TextEditingController();
|
final TextEditingController _currentEntryController = TextEditingController();
|
||||||
|
final FocusNode _currentEntryFocusNode = FocusNode();
|
||||||
final TextEditingController _todoController = TextEditingController();
|
final TextEditingController _todoController = TextEditingController();
|
||||||
|
|
||||||
Note? previousNote;
|
Note? previousNote;
|
||||||
@@ -151,6 +158,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
_debounceTimer?.cancel();
|
_debounceTimer?.cancel();
|
||||||
_previousEntryController.dispose();
|
_previousEntryController.dispose();
|
||||||
_currentEntryController.dispose();
|
_currentEntryController.dispose();
|
||||||
|
_currentEntryFocusNode.dispose();
|
||||||
_todoController.dispose();
|
_todoController.dispose();
|
||||||
_audioPlayer.dispose();
|
_audioPlayer.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -172,9 +180,22 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
|
|
||||||
await _systemTray.initSystemTray(iconPath: iconPath, toolTip: "Journaler");
|
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) {
|
_systemTray.registerSystemTrayEventHandler((eventName) {
|
||||||
debugPrint("System Tray Event: $eventName");
|
debugPrint("System Tray Event: $eventName");
|
||||||
|
if (eventName == kSystemTrayEventClick) {
|
||||||
_showWindow();
|
_showWindow();
|
||||||
|
} else if (eventName == kSystemTrayEventRightClick) {
|
||||||
|
_systemTray.popUpContextMenu();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,9 +213,11 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
await windowManager.center();
|
await windowManager.center();
|
||||||
await windowManager.show();
|
await windowManager.show();
|
||||||
await windowManager.focus();
|
await windowManager.focus();
|
||||||
|
_currentEntryFocusNode.requestFocus();
|
||||||
await _playSound();
|
await _playSound();
|
||||||
} else {
|
} else {
|
||||||
await windowManager.focus();
|
await windowManager.focus();
|
||||||
|
_currentEntryFocusNode.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,13 +260,17 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return KeyboardListener(
|
// Wrap Scaffold with RawKeyboardListener as workaround for Escape key
|
||||||
focusNode: FocusNode(),
|
return RawKeyboardListener(
|
||||||
autofocus: true,
|
focusNode: FocusNode(), // Needs its own node
|
||||||
onKeyEvent: (event) {
|
onKey: (RawKeyEvent event) {
|
||||||
if (event is KeyDownEvent &&
|
if (event is RawKeyDownEvent &&
|
||||||
event.logicalKey == LogicalKeyboardKey.escape) {
|
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();
|
onWindowClose();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -274,6 +301,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _currentEntryController,
|
controller: _currentEntryController,
|
||||||
|
focusNode: _currentEntryFocusNode,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
expands: true,
|
expands: true,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
@@ -312,3 +340,5 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- End Actions and Shortcuts ---
|
||||||
|
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