Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
5ea62a1216 | |||
c457b5cd5b | |||
722aa34fdf | |||
68c6dd1a95 | |||
5a27ac75c7 | |||
900bcd866c | |||
963f7271a2 | |||
442403b5b9 | |||
ad767ac33a | |||
1051805463 | |||
173c4fbee2 | |||
d06a8d6698 | |||
d788c110a7 | |||
41e2922bfb | |||
a07ba1109c |
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
(Stored with Git LFS)
BIN
android/app/src/main/res/mipmap-hdpi/ic_launcher.png
(Stored with Git LFS)
Binary file not shown.
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
(Stored with Git LFS)
BIN
android/app/src/main/res/mipmap-mdpi/ic_launcher.png
(Stored with Git LFS)
Binary file not shown.
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
(Stored with Git LFS)
BIN
android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
(Stored with Git LFS)
Binary file not shown.
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
(Stored with Git LFS)
BIN
android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
(Stored with Git LFS)
Binary file not shown.
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
(Stored with Git LFS)
BIN
android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
(Stored with Git LFS)
Binary file not shown.
@@ -427,7 +427,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@@ -484,7 +484,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png
(Stored with Git LFS)
Normal file
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png
(Stored with Git LFS)
Normal file
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png
(Stored with Git LFS)
Normal file
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png
(Stored with Git LFS)
Normal file
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png
(Stored with Git LFS)
Normal file
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png
(Stored with Git LFS)
Normal file
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
(Stored with Git LFS)
Binary file not shown.
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
(Stored with Git LFS)
BIN
ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
(Stored with Git LFS)
Binary file not shown.
34
lib/db.dart
34
lib/db.dart
@@ -21,13 +21,18 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_notes_date_unique ON notes (date);
|
|||||||
-- ie. they're not really a list but instead a string
|
-- ie. they're not really a list but instead a string
|
||||||
-- But we will also keep a history of all todos
|
-- But we will also keep a history of all todos
|
||||||
-- Because we might as well
|
-- Because we might as well
|
||||||
CREATE TABLE IF NOT EXISTS todos (
|
CREATE TABLE IF NOT EXISTS scratches (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
date TEXT DEFAULT CURRENT_TIMESTAMP,
|
date TEXT DEFAULT CURRENT_TIMESTAMP,
|
||||||
content TEXT NOT NULL
|
content TEXT NOT NULL
|
||||||
);
|
);
|
||||||
CREATE INDEX IF NOT EXISTS idx_todos_date ON todos (date);
|
CREATE INDEX IF NOT EXISTS idx_scratches_date ON scratches (date);
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_todos_date_unique ON todos (date);
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_scratches_date_unique ON scratches (date);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS settings (
|
||||||
|
key TEXT PRIMARY KEY NOT NULL,
|
||||||
|
value TEXT NOT NULL
|
||||||
|
);
|
||||||
''';
|
''';
|
||||||
|
|
||||||
static Future<String> _getDatabasePath() async {
|
static Future<String> _getDatabasePath() async {
|
||||||
@@ -83,4 +88,27 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_todos_date_unique ON todos (date);
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Settings Management
|
||||||
|
static Future<String?> getSetting(String key) async {
|
||||||
|
final List<Map<String, dynamic>> maps = await db.query(
|
||||||
|
'settings',
|
||||||
|
columns: ['value'],
|
||||||
|
where: 'key = ?',
|
||||||
|
whereArgs: [key],
|
||||||
|
);
|
||||||
|
if (maps.isNotEmpty) {
|
||||||
|
return maps.first['value'] as String?;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> setSetting(String key, String value) async {
|
||||||
|
await db.insert(
|
||||||
|
'settings',
|
||||||
|
{'key': key, 'value': value},
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
|
);
|
||||||
|
debugPrint("Setting updated: $key = $value");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
302
lib/main.dart
302
lib/main.dart
@@ -6,9 +6,13 @@ import 'package:journaler/notes.dart';
|
|||||||
import 'package:system_tray/system_tray.dart';
|
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';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
|
||||||
const Duration popupInterval = Duration(hours: 1);
|
// TODO: Sound does not play when ran from a different workdir? Weird
|
||||||
const String notificationSound = 'MeetTheSniper.mp3';
|
|
||||||
|
// Default values - will be replaced by DB values if they exist
|
||||||
|
const Duration _defaultPopupInterval = Duration(minutes: 20);
|
||||||
|
const String _defaultNotificationSound = 'MeetTheSniper.mp3';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
await DB.init();
|
await DB.init();
|
||||||
@@ -116,19 +120,29 @@ 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 TextEditingController _todoController = TextEditingController();
|
final FocusNode _currentEntryFocusNode = FocusNode();
|
||||||
|
final TextEditingController _scratchController = TextEditingController();
|
||||||
|
final TextEditingController _intervalController = TextEditingController();
|
||||||
|
final TextEditingController _soundController = TextEditingController();
|
||||||
|
|
||||||
Note? previousNote;
|
Note? previousNote;
|
||||||
|
Note? _currentlyDisplayedNote;
|
||||||
|
Duration _currentPopupInterval = _defaultPopupInterval;
|
||||||
|
String _currentNotificationSound = _defaultNotificationSound;
|
||||||
|
|
||||||
|
bool _canGoPrevious = false;
|
||||||
|
bool _canGoNext = false;
|
||||||
|
|
||||||
Timer? _popupTimer;
|
Timer? _popupTimer;
|
||||||
Timer? _debounceTimer;
|
Timer? _debounceTimer;
|
||||||
@@ -139,7 +153,6 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
windowManager.addListener(this);
|
windowManager.addListener(this);
|
||||||
_initSystemTray();
|
_initSystemTray();
|
||||||
_loadData();
|
_loadData();
|
||||||
_startPopupTimer();
|
|
||||||
windowManager.setPreventClose(true);
|
windowManager.setPreventClose(true);
|
||||||
_setWindowConfig();
|
_setWindowConfig();
|
||||||
}
|
}
|
||||||
@@ -151,7 +164,10 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
_debounceTimer?.cancel();
|
_debounceTimer?.cancel();
|
||||||
_previousEntryController.dispose();
|
_previousEntryController.dispose();
|
||||||
_currentEntryController.dispose();
|
_currentEntryController.dispose();
|
||||||
_todoController.dispose();
|
_currentEntryFocusNode.dispose();
|
||||||
|
_scratchController.dispose();
|
||||||
|
_intervalController.dispose();
|
||||||
|
_soundController.dispose();
|
||||||
_audioPlayer.dispose();
|
_audioPlayer.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -172,16 +188,31 @@ 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();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startPopupTimer() {
|
void _startPopupTimer() {
|
||||||
_popupTimer = Timer.periodic(popupInterval, (timer) {
|
_popupTimer?.cancel();
|
||||||
|
_popupTimer = Timer.periodic(_currentPopupInterval, (timer) {
|
||||||
_showWindow();
|
_showWindow();
|
||||||
});
|
});
|
||||||
|
debugPrint("Popup timer started with interval: ${_currentPopupInterval.inMinutes} minutes");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _showWindow() async {
|
Future<void> _showWindow() async {
|
||||||
@@ -192,42 +223,128 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _playSound() async {
|
Future<void> _playSound() async {
|
||||||
await _audioPlayer.stop();
|
await _audioPlayer.stop();
|
||||||
await _audioPlayer.play(AssetSource('sounds/$notificationSound'));
|
try {
|
||||||
debugPrint("Played sound: $notificationSound");
|
await _audioPlayer.play(AssetSource('sounds/$_currentNotificationSound'));
|
||||||
|
debugPrint("Played sound: $_currentNotificationSound");
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint("Error playing sound $_currentNotificationSound: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _checkNavigation() async {
|
||||||
|
if (_currentlyDisplayedNote == null) {
|
||||||
|
setState(() {
|
||||||
|
_canGoPrevious = false;
|
||||||
|
_canGoNext = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final prev = await getPreviousNote(_currentlyDisplayedNote!.date);
|
||||||
|
final bool isLatest = _currentlyDisplayedNote!.date == previousNote?.date;
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_canGoPrevious = prev != null;
|
||||||
|
_canGoNext = !isLatest;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _goToPreviousNote() async {
|
||||||
|
if (!_canGoPrevious || _currentlyDisplayedNote == null) return;
|
||||||
|
|
||||||
|
final prevNote = await getPreviousNote(_currentlyDisplayedNote!.date);
|
||||||
|
if (prevNote != null) {
|
||||||
|
setState(() {
|
||||||
|
_currentlyDisplayedNote = prevNote;
|
||||||
|
_previousEntryController.text = prevNote.content;
|
||||||
|
});
|
||||||
|
await _checkNavigation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _goToNextNote() async {
|
||||||
|
if (!_canGoNext || _currentlyDisplayedNote == null) return;
|
||||||
|
|
||||||
|
final nextNote = await getNextNote(_currentlyDisplayedNote!.date);
|
||||||
|
if (nextNote != null) {
|
||||||
|
setState(() {
|
||||||
|
_currentlyDisplayedNote = nextNote;
|
||||||
|
_previousEntryController.text = nextNote.content;
|
||||||
|
});
|
||||||
|
await _checkNavigation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _loadData() async {
|
void _loadData() async {
|
||||||
|
String? intervalMinutesStr = await DB.getSetting('popupIntervalMinutes');
|
||||||
|
String? soundFileStr = await DB.getSetting('notificationSound');
|
||||||
|
|
||||||
|
int intervalMinutes = int.tryParse(intervalMinutesStr ?? '') ?? _defaultPopupInterval.inMinutes;
|
||||||
|
_currentPopupInterval = Duration(minutes: intervalMinutes);
|
||||||
|
_currentNotificationSound = soundFileStr ?? _defaultNotificationSound;
|
||||||
|
|
||||||
|
_intervalController.text = intervalMinutes.toString();
|
||||||
|
_soundController.text = _currentNotificationSound;
|
||||||
|
|
||||||
|
_startPopupTimer();
|
||||||
|
|
||||||
final note = await getLatestNote();
|
final note = await getLatestNote();
|
||||||
previousNote = note;
|
previousNote = note;
|
||||||
_previousEntryController.text = note?.content ?? "";
|
_currentlyDisplayedNote = note;
|
||||||
|
_previousEntryController.text = _currentlyDisplayedNote?.content ?? "";
|
||||||
|
|
||||||
final todo = await getLatestTodo();
|
final scratch = await getLatestScratch();
|
||||||
_todoController.text = todo?.content ?? "";
|
_scratchController.text = scratch?.content ?? "";
|
||||||
_currentEntryController.text = "";
|
_currentEntryController.text = "";
|
||||||
|
|
||||||
debugPrint("Data loaded (placeholder).");
|
await _checkNavigation();
|
||||||
|
|
||||||
|
debugPrint("Data loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void _saveData() async {
|
void _saveData() async {
|
||||||
String previousEntry = _previousEntryController.text;
|
String previousEntry = _previousEntryController.text;
|
||||||
String currentEntry = _currentEntryController.text;
|
String currentEntry = _currentEntryController.text;
|
||||||
String todoList = _todoController.text;
|
String scratchContent = _scratchController.text;
|
||||||
|
String intervalStr = _intervalController.text;
|
||||||
|
String soundStr = _soundController.text;
|
||||||
|
|
||||||
await createNote(currentEntry);
|
await createNote(currentEntry);
|
||||||
await createTodo(todoList);
|
await createScratch(scratchContent);
|
||||||
|
if (previousNote != null) {
|
||||||
previousNote!.content = previousEntry;
|
previousNote!.content = previousEntry;
|
||||||
await updateNote(previousNote!);
|
await updateNote(previousNote!);
|
||||||
|
}
|
||||||
|
|
||||||
|
int newIntervalMinutes = int.tryParse(intervalStr) ?? _currentPopupInterval.inMinutes;
|
||||||
|
Duration newInterval = Duration(minutes: newIntervalMinutes);
|
||||||
|
if (newInterval != _currentPopupInterval) {
|
||||||
|
_currentPopupInterval = newInterval;
|
||||||
|
DB.setSetting('popupIntervalMinutes', newIntervalMinutes.toString());
|
||||||
|
_startPopupTimer();
|
||||||
|
} else {
|
||||||
|
DB.setSetting('popupIntervalMinutes', newIntervalMinutes.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (soundStr != _currentNotificationSound) {
|
||||||
|
_currentNotificationSound = soundStr;
|
||||||
|
DB.setSetting('notificationSound', soundStr);
|
||||||
|
} else {
|
||||||
|
DB.setSetting('notificationSound', soundStr);
|
||||||
|
}
|
||||||
|
|
||||||
debugPrint(
|
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,18 +354,87 @@ 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();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(title: const Text('Journaler'), actions: const []),
|
appBar: AppBar(
|
||||||
|
title: const Text('Journaler'),
|
||||||
|
actions: <Widget>[
|
||||||
|
// Group Label and Input for Interval
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0).copyWith(left: 8.0), // Add padding
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min, // Use minimum space
|
||||||
|
children: [
|
||||||
|
const Text("Interval (m):"),
|
||||||
|
const SizedBox(width: 4), // Space between label and input
|
||||||
|
SizedBox(
|
||||||
|
width: 60, // Constrain width
|
||||||
|
child: TextField(
|
||||||
|
controller: _intervalController,
|
||||||
|
// textAlignVertical: TextAlignVertical.center, // Let default alignment handle it
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
isDense: true,
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
inputFormatters: <TextInputFormatter>[
|
||||||
|
FilteringTextInputFormatter.digitsOnly
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Group Label and Input for Sound
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 8.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text("Sound:"),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
SizedBox(
|
||||||
|
width: 150, // Constrain width
|
||||||
|
child: TextField(
|
||||||
|
controller: _soundController,
|
||||||
|
// textAlignVertical: TextAlignVertical.center,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
isDense: true,
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
|
||||||
|
hintText: 'sound.mp3',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Test Sound Button
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||||
|
child: IconButton(
|
||||||
|
icon: const Icon(Icons.volume_up),
|
||||||
|
tooltip: 'Test Sound',
|
||||||
|
onPressed: _playSound,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
],
|
||||||
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -256,17 +442,63 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 9,
|
flex: 9,
|
||||||
|
child: Listener(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onPointerSignal: (pointerSignal) {
|
||||||
|
if (pointerSignal is PointerScrollEvent) {
|
||||||
|
if (pointerSignal.scrollDelta.dy < 0) {
|
||||||
|
if (_canGoPrevious) {
|
||||||
|
_goToPreviousNote();
|
||||||
|
}
|
||||||
|
} else if (pointerSignal.scrollDelta.dy > 0) {
|
||||||
|
if (_canGoNext) {
|
||||||
|
_goToNextNote();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
|
// Combine Label, Buttons, and TextField for Previous Entry
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
_currentlyDisplayedNote?.date == previousNote?.date
|
||||||
|
? 'Previous Entry (Latest)'
|
||||||
|
: 'Entry: ${_currentlyDisplayedNote?.date ?? 'N/A'}',
|
||||||
|
style: TextStyle(fontSize: 18, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
tooltip: 'Previous Note',
|
||||||
|
onPressed: _canGoPrevious ? _goToPreviousNote : null,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_forward),
|
||||||
|
tooltip: 'Next Note',
|
||||||
|
onPressed: _canGoNext ? _goToNextNote : null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _previousEntryController,
|
controller: _previousEntryController,
|
||||||
|
readOnly: _currentlyDisplayedNote?.date != previousNote?.date,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
expands: true,
|
expands: true,
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: 'Previous Entry',
|
hintText: _currentlyDisplayedNote?.date != previousNote?.date
|
||||||
|
? 'Viewing note from ${_currentlyDisplayedNote?.date} (Read-Only)'
|
||||||
|
: 'Latest Note',
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
filled: _currentlyDisplayedNote?.date != previousNote?.date,
|
||||||
|
fillColor: _currentlyDisplayedNote?.date != previousNote?.date
|
||||||
|
? Colors.grey.withOpacity(0.1)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -274,6 +506,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,
|
||||||
@@ -281,27 +514,22 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Current Entry (What\'s on your mind?)',
|
labelText: 'Current Entry (What\'s on your mind?)',
|
||||||
),
|
),
|
||||||
onChanged: (text) {},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 4, // Adjust flex factor as needed
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _todoController,
|
controller: _scratchController,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
expands: true,
|
expands: true,
|
||||||
style:
|
style: Theme.of(context).textTheme.bodyMedium, // Apply theme text style
|
||||||
Theme.of(
|
|
||||||
context,
|
|
||||||
).textTheme.bodyMedium, // Apply theme text style
|
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Todo',
|
labelText: 'Scratch',
|
||||||
// border: OutlineInputBorder(), // Handled by theme
|
|
||||||
// contentPadding: EdgeInsets.all(8.0), // Handled by theme or default
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -312,3 +540,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});
|
Note({required this.date, required this.content});
|
||||||
}
|
}
|
||||||
|
|
||||||
class Todo {
|
class Scratch {
|
||||||
final String date;
|
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 {
|
Future<Note?> getLatestNote() async {
|
||||||
@@ -43,22 +43,60 @@ Future<void> updateNote(Note note) async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Todo?> getLatestTodo() async {
|
Future<Scratch?> getLatestScratch() async {
|
||||||
final todo = await DB.db.rawQuery(
|
final scratch = await DB.db.rawQuery(
|
||||||
'SELECT content, date FROM todos ORDER BY date DESC LIMIT 1',
|
'SELECT content, date FROM scratches ORDER BY date DESC LIMIT 1',
|
||||||
);
|
);
|
||||||
if (todo.isEmpty) {
|
|
||||||
|
if (scratch.isEmpty) {
|
||||||
return null;
|
return null;
|
||||||
}
|
} else {
|
||||||
return Todo(
|
return Scratch(
|
||||||
date: todo[0]['date'] as String,
|
date: scratch[0]['date'] as String,
|
||||||
content: todo[0]['content'] as String,
|
content: scratch[0]['content'] as String,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> createTodo(String content) async {
|
Future<void> createScratch(String content) async {
|
||||||
if (content.isEmpty) {
|
await DB.db.insert('scratches', {'content': content});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
await DB.db.insert('todos', {'content': content});
|
|
||||||
|
// Get the note immediately older than the given date
|
||||||
|
Future<Note?> getPreviousNote(String currentDate) async {
|
||||||
|
final List<Map<String, dynamic>> notes = await DB.db.query(
|
||||||
|
'notes',
|
||||||
|
where: 'date < ?',
|
||||||
|
whereArgs: [currentDate],
|
||||||
|
orderBy: 'date DESC',
|
||||||
|
limit: 1,
|
||||||
|
);
|
||||||
|
if (notes.isNotEmpty) {
|
||||||
|
return Note(
|
||||||
|
date: notes.first['date'] as String,
|
||||||
|
content: notes.first['content'] as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the note immediately newer than the given date
|
||||||
|
Future<Note?> getNextNote(String currentDate) async {
|
||||||
|
final List<Map<String, dynamic>> notes = await DB.db.query(
|
||||||
|
'notes',
|
||||||
|
where: 'date > ?',
|
||||||
|
whereArgs: [currentDate],
|
||||||
|
orderBy: 'date ASC',
|
||||||
|
limit: 1,
|
||||||
|
);
|
||||||
|
if (notes.isNotEmpty) {
|
||||||
|
return Note(
|
||||||
|
date: notes.first['date'] as String,
|
||||||
|
content: notes.first['content'] as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// If there's no newer note, it means we might be at the latest
|
||||||
|
// but let's double-check by explicitly getting the latest again.
|
||||||
|
// This handles the case where the `currentDate` might not be the absolute latest.
|
||||||
|
return getLatestNote();
|
||||||
}
|
}
|
||||||
|
80
pubspec.lock
80
pubspec.lock
@@ -1,6 +1,22 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
archive:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: archive
|
||||||
|
sha256: a7f37ff061d7abc2fcf213554b9dcaca713c5853afa5c065c44888bc9ccaf813
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.6"
|
||||||
|
args:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: args
|
||||||
|
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.7.0"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -81,6 +97,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.0"
|
||||||
|
checked_yaml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: checked_yaml
|
||||||
|
sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.3"
|
||||||
|
cli_util:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cli_util
|
||||||
|
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.2"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -142,6 +174,14 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_launcher_icons:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: flutter_launcher_icons
|
||||||
|
sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.13.1"
|
||||||
flutter_lints:
|
flutter_lints:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
@@ -176,6 +216,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.2"
|
version: "4.1.2"
|
||||||
|
image:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image
|
||||||
|
sha256: "4e973fcf4caae1a4be2fa0a13157aa38a8f9cb049db6529aa00b4d71abc4d928"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.5.4"
|
||||||
json_annotation:
|
json_annotation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -296,6 +344,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.0"
|
version: "2.3.0"
|
||||||
|
petitparser:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: petitparser
|
||||||
|
sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.1.0"
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -312,6 +368,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.8"
|
version: "2.1.8"
|
||||||
|
posix:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: posix
|
||||||
|
sha256: f0d7856b6ca1887cfa6d1d394056a296ae33489db914e365e2044fdada449e62
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.2"
|
||||||
screen_retriever:
|
screen_retriever:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -501,6 +565,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
|
xml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xml
|
||||||
|
sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.5.0"
|
||||||
|
yaml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: yaml
|
||||||
|
sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.3"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.7.2 <4.0.0"
|
dart: ">=3.7.2 <4.0.0"
|
||||||
flutter: ">=3.27.0"
|
flutter: ">=3.27.0"
|
||||||
|
10
pubspec.yaml
10
pubspec.yaml
@@ -42,6 +42,7 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_launcher_icons: ^0.13.1
|
||||||
|
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
# The "flutter_lints" package below contains a set of recommended lints to
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
# encourage good coding practices. The lint set provided by the package is
|
||||||
@@ -93,3 +94,12 @@ flutter:
|
|||||||
#
|
#
|
||||||
# For details regarding fonts from package dependencies,
|
# For details regarding fonts from package dependencies,
|
||||||
# see https://flutter.dev/to/font-from-package
|
# see https://flutter.dev/to/font-from-package
|
||||||
|
|
||||||
|
flutter_launcher_icons:
|
||||||
|
android: true
|
||||||
|
ios: true
|
||||||
|
image_path: "assets/app_icon.ico"
|
||||||
|
windows:
|
||||||
|
generate: true
|
||||||
|
image_path: "assets/app_icon.ico"
|
||||||
|
icon_size: 256 # min: 48, max: 256, default: 48
|
||||||
|
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"
|
BIN
windows/runner/resources/app_icon.ico
(Stored with Git LFS)
BIN
windows/runner/resources/app_icon.ico
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user