From 59a5229e46b0d717bfd6bbfce552cdb3e43ddebd Mon Sep 17 00:00:00 2001 From: Marcos Date: Tue, 19 May 2026 17:55:16 +0200 Subject: [PATCH] feat: Refactor NoteEditorScreen for improved mobile layout handling and UI consistency --- lib/screens/note_editor_screen.dart | 73 ++++++++++++++--------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/lib/screens/note_editor_screen.dart b/lib/screens/note_editor_screen.dart index adf74b1..84bb7de 100644 --- a/lib/screens/note_editor_screen.dart +++ b/lib/screens/note_editor_screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:notas/models/note.dart'; +import 'package:notas/platform/app_platform.dart'; // NoteEditorScreen: unified UI for creating and editing notes. // - Use `NoteEditorScreen.showDialog(context, note: existing)` to edit. @@ -22,7 +23,7 @@ class NoteEditorScreen extends StatefulWidget { State createState() => _NoteEditorScreenState(); static Future showDialog(BuildContext context, {Note? note}) { - if (MediaQuery.sizeOf(context).width < 600) { + if (isAndroid || isIOS) { return showGeneralDialog( context: context, barrierDismissible: false, @@ -81,7 +82,7 @@ class _NoteEditorScreenState extends State { late Note _currentNote; late bool _isNewNote; - bool get _isCompactLayout => MediaQuery.sizeOf(context).width < 600; + bool get _isMobileLayout => isAndroid || isIOS; @override void initState() { @@ -203,7 +204,7 @@ class _NoteEditorScreenState extends State { @override Widget build(BuildContext context) { - if (_isCompactLayout) { + if (_isMobileLayout) { return Material( color: Colors.transparent, child: SafeArea( @@ -338,23 +339,17 @@ class _NoteEditorScreenState extends State { return 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 maxWidth = math.min(constraints.maxWidth - 32, 600); + final double maxHeight = math.min(constraints.maxHeight - 64, 720); final double overlayTop = MediaQuery.paddingOf(context).top + 32; return Stack( children: [ Positioned.fill( top: overlayTop, - child: IgnorePointer( - child: Container( - color: const Color.fromARGB( - 54, - 0, - 0, - 0, - ).withValues(alpha: 0.5), - ), + child: ModalBarrier( + dismissible: false, + color: const Color.fromARGB(54, 0, 0, 0).withValues(alpha: 0.5), ), ), Positioned.fill( @@ -425,32 +420,32 @@ class _NoteEditorScreenState extends State { ), ), Expanded( - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextField( - controller: _titleController, - style: const TextStyle( - color: Colors.white, - fontSize: 28, - fontWeight: FontWeight.bold, - ), - decoration: const InputDecoration( - hintText: 'Título', - hintStyle: TextStyle( - color: Colors.white30, - ), - border: InputBorder.none, - contentPadding: EdgeInsets.zero, - ), + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: _titleController, + style: const TextStyle( + color: Colors.white, + fontSize: 28, + fontWeight: FontWeight.bold, ), - const SizedBox(height: 16), - TextField( + decoration: const InputDecoration( + hintText: 'Título', + hintStyle: TextStyle(color: Colors.white30), + border: InputBorder.none, + contentPadding: EdgeInsets.zero, + ), + ), + const SizedBox(height: 8), + Expanded( + child: TextField( controller: _bodyController, + keyboardType: TextInputType.multiline, maxLines: null, + expands: true, style: const TextStyle( color: Colors.white, fontSize: 16, @@ -465,8 +460,8 @@ class _NoteEditorScreenState extends State { contentPadding: EdgeInsets.zero, ), ), - ], - ), + ), + ], ), ), ),