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();
|
||||
|
||||
final Size initialSize =
|
||||
await WindowStateStore.instance.loadWindowSize() ?? const Size(900, 700);
|
||||
|
||||
final WindowOptions windowOptions = WindowOptions(
|
||||
size: initialSize,
|
||||
minimumSize: Size(400, 600),
|
||||
center: true,
|
||||
center: false,
|
||||
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.setMinimumSize(const Size(400, 600));
|
||||
await windowManager.setSize(initialSize);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
@@ -21,7 +23,7 @@ class NoteEditorScreen extends StatefulWidget {
|
||||
return showGeneralDialog<dynamic>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
barrierColor: const Color.fromARGB(127, 0, 0, 0).withValues(alpha: 0.5),
|
||||
barrierColor: Colors.transparent,
|
||||
transitionDuration: const Duration(milliseconds: 200),
|
||||
pageBuilder: (context, animation, secondaryAnimation) {
|
||||
return NoteEditorScreen(note: note);
|
||||
@@ -96,7 +98,10 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
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(
|
||||
'¿Estás seguro de que deseas eliminar esta nota?',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
@@ -104,14 +109,20 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Cancelar', style: TextStyle(color: Colors.white70)),
|
||||
child: const Text(
|
||||
'Cancelar',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
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(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color.fromRGBO(24, 25, 26, 1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
@@ -156,7 +188,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Header con botones y fechas
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
@@ -192,7 +223,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
// Contenido editable
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
@@ -200,7 +230,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Título
|
||||
TextField(
|
||||
controller: _titleController,
|
||||
style: const TextStyle(
|
||||
@@ -216,7 +245,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Cuerpo de la nota
|
||||
TextField(
|
||||
controller: _bodyController,
|
||||
maxLines: null,
|
||||
@@ -237,7 +265,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Footer con botones de acción
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
@@ -248,7 +275,6 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Botón de borrar (izquierda) - solo para notas existentes
|
||||
if (!_isNewNote)
|
||||
IconButton(
|
||||
onPressed: _deleteNote,
|
||||
@@ -256,8 +282,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
tooltip: 'Eliminar nota',
|
||||
)
|
||||
else
|
||||
const SizedBox(width: 48), // Espacio para mantener alineación
|
||||
// Botón de guardar (derecha)
|
||||
const SizedBox(width: 48),
|
||||
FilledButton(
|
||||
onPressed: _saveNote,
|
||||
child: const Text('Guardar'),
|
||||
@@ -268,6 +293,14 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user