refactor: Remove AppTitleBar widget and its references from various screens
This commit is contained in:
@@ -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<NotesApp>
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
AppTitleBar(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Column(
|
||||
@@ -868,7 +866,6 @@ class _NotesAppState extends State<NotesApp>
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const AppTitleBar(),
|
||||
Expanded(
|
||||
child: AnimatedSwitcher(
|
||||
duration: _screenTransitionDuration,
|
||||
|
||||
@@ -16,7 +16,7 @@ Future<void> bootstrapWindow() async {
|
||||
size: initialSize,
|
||||
minimumSize: Size(400, 600),
|
||||
center: false,
|
||||
titleBarStyle: TitleBarStyle.hidden,
|
||||
titleBarStyle: TitleBarStyle.normal,
|
||||
);
|
||||
|
||||
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<BiometricGateScreen> {
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const AppTitleBar(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
|
||||
@@ -485,20 +485,17 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
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,
|
||||
|
||||
@@ -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<VaultAccessScreen> {
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const AppTitleBar(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export 'app_title_bar_stub.dart' if (dart.library.io) 'app_title_bar_io.dart';
|
||||
@@ -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<void> _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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user