feat: Update window bootstrap logic and improve note editor UI layout
This commit is contained in:
@@ -9,18 +9,21 @@ Future<void> bootstrapWindow() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
|
|
||||||
final Size initialSize =
|
final Size initialSize =
|
||||||
await WindowStateStore.instance.loadWindowSize() ?? const Size(900, 700);
|
await WindowStateStore.instance.loadWindowSize() ?? const Size(900, 700);
|
||||||
|
|
||||||
final WindowOptions windowOptions = WindowOptions(
|
final WindowOptions windowOptions = WindowOptions(
|
||||||
size: initialSize,
|
size: initialSize,
|
||||||
minimumSize: Size(400, 600),
|
minimumSize: Size(400, 600),
|
||||||
center: true,
|
center: false,
|
||||||
titleBarStyle: TitleBarStyle.hidden,
|
titleBarStyle: TitleBarStyle.hidden,
|
||||||
);
|
);
|
||||||
|
|
||||||
windowManager.waitUntilReadyToShow(windowOptions, () async {
|
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||||
|
// Re-apply size after the window is ready to ensure it takes effect.
|
||||||
|
try {
|
||||||
|
await windowManager.setSize(initialSize);
|
||||||
|
} catch (_) {}
|
||||||
await windowManager.show();
|
await windowManager.show();
|
||||||
await windowManager.setMinimumSize(const Size(400, 600));
|
await windowManager.setMinimumSize(const Size(400, 600));
|
||||||
await windowManager.setSize(initialSize);
|
await windowManager.setSize(initialSize);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
@@ -21,7 +23,7 @@ class NoteEditorScreen extends StatefulWidget {
|
|||||||
return showGeneralDialog<dynamic>(
|
return showGeneralDialog<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
barrierColor: const Color.fromARGB(127, 0, 0, 0).withValues(alpha: 0.5),
|
barrierColor: Colors.transparent,
|
||||||
transitionDuration: const Duration(milliseconds: 200),
|
transitionDuration: const Duration(milliseconds: 200),
|
||||||
pageBuilder: (context, animation, secondaryAnimation) {
|
pageBuilder: (context, animation, secondaryAnimation) {
|
||||||
return NoteEditorScreen(note: note);
|
return NoteEditorScreen(note: note);
|
||||||
@@ -96,7 +98,10 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
backgroundColor: const Color(0xFF303134),
|
backgroundColor: const Color(0xFF303134),
|
||||||
title: const Text('Eliminar nota', style: TextStyle(color: Colors.white)),
|
title: const Text(
|
||||||
|
'Eliminar nota',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
content: const Text(
|
content: const Text(
|
||||||
'¿Estás seguro de que deseas eliminar esta nota?',
|
'¿Estás seguro de que deseas eliminar esta nota?',
|
||||||
style: TextStyle(color: Colors.white70),
|
style: TextStyle(color: Colors.white70),
|
||||||
@@ -104,14 +109,20 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: const Text('Cancelar', style: TextStyle(color: Colors.white70)),
|
child: const Text(
|
||||||
|
'Cancelar',
|
||||||
|
style: TextStyle(color: Colors.white70),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop('delete');
|
Navigator.of(context).pop('delete');
|
||||||
},
|
},
|
||||||
child: const Text('Eliminar', style: TextStyle(color: Colors.red)),
|
child: const Text(
|
||||||
|
'Eliminar',
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -136,11 +147,32 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Dialog(
|
return Material(
|
||||||
backgroundColor: Colors.transparent,
|
color: Colors.transparent,
|
||||||
elevation: 0,
|
child: LayoutBuilder(
|
||||||
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
|
final double maxWidth = math.min(600, constraints.maxWidth - 48);
|
||||||
|
final double maxHeight = math.min(constraints.maxHeight * 0.88, 720);
|
||||||
|
final double overlayTop = MediaQuery.paddingOf(context).top + 32;
|
||||||
|
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
Positioned.fill(
|
||||||
|
top: overlayTop,
|
||||||
|
child: Container(
|
||||||
|
color: const Color.fromARGB(127, 0, 0, 0).withValues(alpha: 0.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SafeArea(
|
||||||
|
child: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.only(top: overlayTop),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: maxWidth,
|
||||||
|
maxHeight: maxHeight,
|
||||||
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: const BoxConstraints(maxWidth: 600),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color.fromRGBO(24, 25, 26, 1),
|
color: const Color.fromRGBO(24, 25, 26, 1),
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
@@ -156,7 +188,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
// Header con botones y fechas
|
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -192,7 +223,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Contenido editable
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -200,7 +230,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Título
|
|
||||||
TextField(
|
TextField(
|
||||||
controller: _titleController,
|
controller: _titleController,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -216,7 +245,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// Cuerpo de la nota
|
|
||||||
TextField(
|
TextField(
|
||||||
controller: _bodyController,
|
controller: _bodyController,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
@@ -237,7 +265,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Footer con botones de acción
|
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -248,7 +275,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
// Botón de borrar (izquierda) - solo para notas existentes
|
|
||||||
if (!_isNewNote)
|
if (!_isNewNote)
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _deleteNote,
|
onPressed: _deleteNote,
|
||||||
@@ -256,8 +282,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
tooltip: 'Eliminar nota',
|
tooltip: 'Eliminar nota',
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
const SizedBox(width: 48), // Espacio para mantener alineación
|
const SizedBox(width: 48),
|
||||||
// Botón de guardar (derecha)
|
|
||||||
FilledButton(
|
FilledButton(
|
||||||
onPressed: _saveNote,
|
onPressed: _saveNote,
|
||||||
child: const Text('Guardar'),
|
child: const Text('Guardar'),
|
||||||
@@ -268,6 +293,14 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user