Enhance navigation and structure: integrate SettingsScreen into main app flow, update HomeScreen to open settings, and improve UI elements for better user experience.
This commit is contained in:
+92
-6
@@ -7,6 +7,7 @@ import 'package:notas/data/note_repository.dart';
|
||||
import 'package:notas/platform/app_platform.dart';
|
||||
import 'package:notas/platform/window_state.dart';
|
||||
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';
|
||||
@@ -14,6 +15,11 @@ import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
enum _AppSection {
|
||||
home,
|
||||
settings,
|
||||
}
|
||||
|
||||
class NotesApp extends StatefulWidget {
|
||||
const NotesApp({super.key});
|
||||
|
||||
@@ -22,6 +28,8 @@ class NotesApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NotesAppState extends State<NotesApp> with WindowListener {
|
||||
static const Duration _screenTransitionDuration = Duration(milliseconds: 280);
|
||||
|
||||
final LocalVaultService _vaultService = LocalVaultService.instance;
|
||||
final GlobalKey<ScaffoldMessengerState> _scaffoldMessengerKey =
|
||||
GlobalKey<ScaffoldMessengerState>();
|
||||
@@ -30,6 +38,7 @@ class _NotesAppState extends State<NotesApp> with WindowListener {
|
||||
NoteRepository? _repository;
|
||||
bool _isBootstrapping = true;
|
||||
bool _isUnlocking = false;
|
||||
_AppSection _currentSection = _AppSection.home;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -80,6 +89,26 @@ class _NotesAppState extends State<NotesApp> with WindowListener {
|
||||
});
|
||||
}
|
||||
|
||||
void _openSettings() {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_currentSection = _AppSection.settings;
|
||||
});
|
||||
}
|
||||
|
||||
void _openHome() {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_currentSection = _AppSection.home;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _resetLocalVaultData() async {
|
||||
final AppDatabase? database = _database;
|
||||
|
||||
@@ -207,6 +236,68 @@ class _NotesAppState extends State<NotesApp> with WindowListener {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainShell(NoteRepository repository) {
|
||||
final Widget activeScreen = _currentSection == _AppSection.home
|
||||
? HomeScreen(
|
||||
key: const ValueKey<String>('home-screen'),
|
||||
repository: repository,
|
||||
onOpenSettings: _openSettings,
|
||||
)
|
||||
: SettingsScreen(
|
||||
key: const ValueKey<String>('settings-screen'),
|
||||
onDeleteAllData: _resetLocalVaultData,
|
||||
onBackToHome: _openHome,
|
||||
);
|
||||
|
||||
return MaterialApp(
|
||||
title: 'Mis Notas',
|
||||
debugShowCheckedModeBanner: false,
|
||||
scaffoldMessengerKey: _scaffoldMessengerKey,
|
||||
theme: AppTheme.theme,
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
Color(0xFF191A1D),
|
||||
Color(0xFF222326),
|
||||
Color(0xFF101114),
|
||||
],
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
const AppTitleBar(),
|
||||
Expanded(
|
||||
child: AnimatedSwitcher(
|
||||
duration: _screenTransitionDuration,
|
||||
switchInCurve: Curves.easeOutCubic,
|
||||
switchOutCurve: Curves.easeInCubic,
|
||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
||||
final Animation<Offset> offsetAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.08, 0.0),
|
||||
end: Offset.zero,
|
||||
).animate(animation);
|
||||
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: SlideTransition(position: offsetAnimation, child: child),
|
||||
);
|
||||
},
|
||||
child: activeScreen,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowResize() {
|
||||
_saveWindowSize();
|
||||
@@ -226,12 +317,7 @@ class _NotesAppState extends State<NotesApp> with WindowListener {
|
||||
final NoteRepository? repository = _repository;
|
||||
|
||||
if (repository != null) {
|
||||
return _buildAppShell(
|
||||
home: HomeScreen(
|
||||
repository: repository,
|
||||
onDeleteAllData: _resetLocalVaultData,
|
||||
),
|
||||
);
|
||||
return _buildMainShell(repository);
|
||||
}
|
||||
|
||||
return _buildAppShell(
|
||||
|
||||
Reference in New Issue
Block a user