From 521c1e94c02596aa8b294687fe00509a8c7ef138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Thu, 6 Nov 2025 11:12:06 +0100 Subject: [PATCH] Allow accessing app-settings even if not logged-in [skip-ci] --- flutter/lib/components/layout/nav_layout.dart | 30 ++++++++++++------- flutter/pubspec.yaml | 2 +- scnserver/.gitignore | 2 ++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/flutter/lib/components/layout/nav_layout.dart b/flutter/lib/components/layout/nav_layout.dart index e30598b..7c3c2ba 100644 --- a/flutter/lib/components/layout/nav_layout.dart +++ b/flutter/lib/components/layout/nav_layout.dart @@ -20,20 +20,30 @@ class SCNNavLayout extends StatefulWidget { } class _SCNNavLayoutState extends State { - int _selectedIndex = 0; // 4 == FAB + static const INDEX_MESSAGES = 0; + static const INDEX_CHANNELS = 1; + static const INDEX_ACCOUNT = 2; + static const INDEX_CONFIG = 3; + static const INDEX_SEND = 4; // FAB + + int _selectedIndex = INDEX_MESSAGES; @override initState() { final userAcc = Provider.of(context, listen: false); - if (!userAcc.isAuth()) _selectedIndex = 2; + if (!userAcc.isAuth()) _selectedIndex = INDEX_ACCOUNT; super.initState(); } void _onItemTapped(int index) { final userAcc = Provider.of(context, listen: false); - if (!userAcc.isAuth()) { + + if (!userAcc.isAuth() && [INDEX_MESSAGES, INDEX_CHANNELS, INDEX_SEND].contains(index)) { Toaster.info("Not logged in", "Please login or create a new account first"); + setState(() { + _selectedIndex = INDEX_ACCOUNT; + }); return; } @@ -50,7 +60,7 @@ class _SCNNavLayoutState extends State { } setState(() { - _selectedIndex = 4; + _selectedIndex = INDEX_SEND; }); } @@ -59,17 +69,17 @@ class _SCNNavLayoutState extends State { return Scaffold( appBar: SCNAppBar( title: null, - showSearch: _selectedIndex == 0, + showSearch: _selectedIndex == INDEX_MESSAGES, showShare: false, showThemeSwitch: true, ), body: IndexedStack( children: [ - ExcludeFocus(excluding: _selectedIndex != 0, child: MessageListPage(isVisiblePage: _selectedIndex == 0)), - ExcludeFocus(excluding: _selectedIndex != 1, child: ChannelRootPage(isVisiblePage: _selectedIndex == 1)), - ExcludeFocus(excluding: _selectedIndex != 2, child: AccountRootPage(isVisiblePage: _selectedIndex == 2)), - ExcludeFocus(excluding: _selectedIndex != 3, child: SettingsRootPage(isVisiblePage: _selectedIndex == 3)), - ExcludeFocus(excluding: _selectedIndex != 4, child: SendRootPage(isVisiblePage: _selectedIndex == 4)), + ExcludeFocus(excluding: _selectedIndex != INDEX_MESSAGES, child: MessageListPage(isVisiblePage: _selectedIndex == INDEX_MESSAGES)), + ExcludeFocus(excluding: _selectedIndex != INDEX_CHANNELS, child: ChannelRootPage(isVisiblePage: _selectedIndex == INDEX_CHANNELS)), + ExcludeFocus(excluding: _selectedIndex != INDEX_ACCOUNT, child: AccountRootPage(isVisiblePage: _selectedIndex == INDEX_ACCOUNT)), + ExcludeFocus(excluding: _selectedIndex != INDEX_CONFIG, child: SettingsRootPage(isVisiblePage: _selectedIndex == INDEX_CONFIG)), + ExcludeFocus(excluding: _selectedIndex != INDEX_SEND, child: SendRootPage(isVisiblePage: _selectedIndex == INDEX_SEND)), ], index: _selectedIndex, ), diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml index 5416856..9d8d46b 100644 --- a/flutter/pubspec.yaml +++ b/flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: simplecloudnotifier description: "Receive push messages" publish_to: 'none' -version: 2.0.1+493 +version: 2.0.1+495 environment: sdk: '>=3.2.6 <4.0.0' diff --git a/scnserver/.gitignore b/scnserver/.gitignore index 2385a86..ab9b6fc 100644 --- a/scnserver/.gitignore +++ b/scnserver/.gitignore @@ -18,6 +18,8 @@ identifier.sqlite .idea/dataSources.xml +.idea/copilot* + .swaggobin scn_send.sh