From bed34f4cb5b056e6b5c65169f821b53249813163 Mon Sep 17 00:00:00 2001 From: Marcos Date: Wed, 20 May 2026 20:16:57 +0200 Subject: [PATCH] refactor: Remove AppTitleBar widget and its references from various screens --- lib/app.dart | 3 - lib/platform/window_bootstrap_io.dart | 2 +- lib/screens/biometric_choice_screen.dart | 2 - lib/screens/biometric_gate_screen.dart | 2 - lib/screens/note_editor_screen.dart | 5 +- lib/screens/vault_access_screen.dart | 2 - lib/widgets/app_title_bar.dart | 1 - lib/widgets/app_title_bar_io.dart | 241 ----------------------- lib/widgets/app_title_bar_stub.dart | 18 -- 9 files changed, 2 insertions(+), 274 deletions(-) delete mode 100644 lib/widgets/app_title_bar.dart delete mode 100644 lib/widgets/app_title_bar_io.dart delete mode 100644 lib/widgets/app_title_bar_stub.dart diff --git a/lib/app.dart b/lib/app.dart index 577df3a..2af1624 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -15,7 +15,6 @@ import 'package:notas/screens/home_screen.dart'; import 'package:notas/screens/settings_screen.dart'; import 'package:notas/screens/vault_access_screen.dart'; import 'package:notas/theme/app_theme.dart'; -import 'package:notas/widgets/app_title_bar.dart'; import 'package:notas/widgets/sync_status.dart'; import 'package:path/path.dart' as p; import 'package:path_provider/path_provider.dart'; @@ -777,7 +776,6 @@ class _NotesAppState extends State body: SafeArea( child: Column( children: [ - AppTitleBar(), Expanded( child: Center( child: Column( @@ -868,7 +866,6 @@ class _NotesAppState extends State child: SafeArea( child: Column( children: [ - const AppTitleBar(), Expanded( child: AnimatedSwitcher( duration: _screenTransitionDuration, diff --git a/lib/platform/window_bootstrap_io.dart b/lib/platform/window_bootstrap_io.dart index 49d2caa..591e5c1 100644 --- a/lib/platform/window_bootstrap_io.dart +++ b/lib/platform/window_bootstrap_io.dart @@ -16,7 +16,7 @@ Future bootstrapWindow() async { size: initialSize, minimumSize: Size(400, 600), center: false, - titleBarStyle: TitleBarStyle.hidden, + titleBarStyle: TitleBarStyle.normal, ); await windowManager.waitUntilReadyToShow(windowOptions, () async { diff --git a/lib/screens/biometric_choice_screen.dart b/lib/screens/biometric_choice_screen.dart index 615ed2e..d57e3bd 100644 --- a/lib/screens/biometric_choice_screen.dart +++ b/lib/screens/biometric_choice_screen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:notas/widgets/app_title_bar.dart'; class BiometricChoiceScreen extends StatelessWidget { const BiometricChoiceScreen({ @@ -31,7 +30,6 @@ class BiometricChoiceScreen extends StatelessWidget { child: SafeArea( child: Column( children: [ - const AppTitleBar(), Expanded( child: Center( child: SingleChildScrollView( diff --git a/lib/screens/biometric_gate_screen.dart b/lib/screens/biometric_gate_screen.dart index 79b5634..13975a8 100644 --- a/lib/screens/biometric_gate_screen.dart +++ b/lib/screens/biometric_gate_screen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:notas/widgets/app_title_bar.dart'; class BiometricGateScreen extends StatefulWidget { const BiometricGateScreen({ @@ -55,7 +54,6 @@ class _BiometricGateScreenState extends State { child: SafeArea( child: Column( children: [ - const AppTitleBar(), Expanded( child: Center( child: SingleChildScrollView( diff --git a/lib/screens/note_editor_screen.dart b/lib/screens/note_editor_screen.dart index 704c303..658a81b 100644 --- a/lib/screens/note_editor_screen.dart +++ b/lib/screens/note_editor_screen.dart @@ -485,20 +485,17 @@ class _NoteEditorScreenState extends State { return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { 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; + final double maxHeight = math.min(constraints.maxHeight - 32, 720); return Stack( children: [ Positioned.fill( - top: overlayTop, child: ModalBarrier( dismissible: false, color: const Color.fromARGB(54, 0, 0, 0).withValues(alpha: 0.5), ), ), Positioned.fill( - top: overlayTop, child: Center( child: SizedBox( width: maxWidth, diff --git a/lib/screens/vault_access_screen.dart b/lib/screens/vault_access_screen.dart index 72cf239..158b5e2 100644 --- a/lib/screens/vault_access_screen.dart +++ b/lib/screens/vault_access_screen.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:notas/widgets/app_title_bar.dart'; import 'package:notas/data/api_client.dart'; class VaultAccessScreen extends StatefulWidget { @@ -90,7 +89,6 @@ class _VaultAccessScreenState extends State { child: SafeArea( child: Column( children: [ - const AppTitleBar(), Expanded( child: Center( child: SingleChildScrollView( diff --git a/lib/widgets/app_title_bar.dart b/lib/widgets/app_title_bar.dart deleted file mode 100644 index 77391a2..0000000 --- a/lib/widgets/app_title_bar.dart +++ /dev/null @@ -1 +0,0 @@ -export 'app_title_bar_stub.dart' if (dart.library.io) 'app_title_bar_io.dart'; \ No newline at end of file diff --git a/lib/widgets/app_title_bar_io.dart b/lib/widgets/app_title_bar_io.dart deleted file mode 100644 index 51f5eb3..0000000 --- a/lib/widgets/app_title_bar_io.dart +++ /dev/null @@ -1,241 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:notas/platform/app_platform.dart'; -import 'package:window_manager/window_manager.dart'; - -class AppTitleBar extends StatelessWidget { - const AppTitleBar({ - super.key, - }); - - @override - Widget build(BuildContext context) { - if (isAndroid || isIOS) { - return const SizedBox(height: 10); - } - - if (isMacOS) { - return SizedBox( - height: 28, - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'Mis Notas', - style: TextStyle(color: Colors.white70, fontSize: 13), - ), - ], - ), - ), - ); - } - - if (isLinux) { - return const _KdeTitleBar(); - } - - return SizedBox( - height: 40, - child: WindowCaption( - brightness: Brightness.dark, - title: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const Text('Mis Notas', style: TextStyle(color: Colors.white)), - ], - ), - ), - ); - } -} - -class _KdeTitleBar extends StatefulWidget { - const _KdeTitleBar(); - - @override - State<_KdeTitleBar> createState() => _KdeTitleBarState(); -} - -class _KdeTitleBarState extends State<_KdeTitleBar> with WindowListener { - bool _isFullScreen = false; - bool _isMaximized = false; - - @override - void initState() { - super.initState(); - if (isDesktop) { - windowManager.addListener(this); - _refreshWindowState(); - } - } - - @override - void dispose() { - if (isDesktop) { - windowManager.removeListener(this); - } - super.dispose(); - } - - Future _refreshWindowState() async { - final bool isFullScreen = await windowManager.isFullScreen(); - final bool isMaximized = await windowManager.isMaximized(); - - if (!mounted) { - return; - } - - setState(() { - _isFullScreen = isFullScreen; - _isMaximized = isMaximized; - }); - } - - @override - void onWindowEnterFullScreen() { - setState(() { - _isFullScreen = true; - }); - } - - @override - void onWindowLeaveFullScreen() { - setState(() { - _isFullScreen = false; - }); - } - - @override - void onWindowMaximize() { - setState(() { - _isMaximized = true; - }); - } - - @override - void onWindowUnmaximize() { - setState(() { - _isMaximized = false; - }); - } - - @override - Widget build(BuildContext context) { - final IconData maximizeIcon = - (_isFullScreen || _isMaximized) ? Icons.fullscreen_exit : Icons.fullscreen; - - return Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: Colors.white.withValues(alpha: 0.12), - width: 0.5, - ), - ), - ), - child: SizedBox( - height: 32, - child: Stack( - children: [ - const DragToMoveArea( - child: SizedBox.expand(), - ), - const IgnorePointer( - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - 'Mis Notas', - style: TextStyle( - color: Color.fromARGB(255, 163, 163, 163), - fontSize: 14, - fontWeight: FontWeight.w500, - ), - ), - ], - ), - ), - ), - Positioned( - right: 0, - top: 0, - bottom: 0, - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - _KdeButton( - icon: Icons.minimize, - onPressed: () => windowManager.minimize(), - ), - _KdeButton( - icon: maximizeIcon, - onPressed: () async { - if (await windowManager.isFullScreen()) { - await windowManager.setFullScreen(false); - } else if (await windowManager.isMaximized()) { - await windowManager.unmaximize(); - } else { - await windowManager.maximize(); - } - }, - ), - _KdeButton( - icon: Icons.close, - isClose: true, - onPressed: () => windowManager.close(), - ), - ], - ), - ), - ], - ), - ), - ); - } -} - -class _KdeButton extends StatelessWidget { - const _KdeButton({ - required this.icon, - required this.onPressed, - this.isClose = false, - }); - - final IconData icon; - final VoidCallback onPressed; - final bool isClose; - - @override - Widget build(BuildContext context) { - return MouseRegion( - cursor: SystemMouseCursors.click, - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: onPressed, - child: SizedBox( - width: 32, - height: double.infinity, - child: Material( - color: Colors.transparent, - child: InkResponse( - highlightShape: BoxShape.circle, - containedInkWell: false, - radius: 10, - hoverColor: isClose ? Colors.red : Colors.white.withValues(alpha: 0.08), - onTap: onPressed, - child: Center( - child: Icon( - icon, - color: Colors.white70, - size: 16, - ), - ), - ), - ), - ), - ), - ); - } -} diff --git a/lib/widgets/app_title_bar_stub.dart b/lib/widgets/app_title_bar_stub.dart deleted file mode 100644 index 139473c..0000000 --- a/lib/widgets/app_title_bar_stub.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:notas/widgets/sync_status.dart'; - -class AppTitleBar extends StatelessWidget { - const AppTitleBar({ - this.syncStatus = SyncStatus.idle, - this.syncErrorMessage, - super.key, - }); - - final SyncStatus syncStatus; - final String? syncErrorMessage; - - @override - Widget build(BuildContext context) { - return const SizedBox.shrink(); - } -}