Allow accessing app-settings even if not logged-in [skip-ci]
All checks were successful
Build Docker and Deploy / Build Docker Container (push) Has been skipped
Build Docker and Deploy / Run Unit-Tests (push) Has been skipped
Build Docker and Deploy / Deploy to Server (push) Has been skipped

This commit is contained in:
2025-11-06 11:12:06 +01:00
parent 31a45bc4c3
commit 521c1e94c0
3 changed files with 23 additions and 11 deletions

View File

@@ -20,20 +20,30 @@ class SCNNavLayout extends StatefulWidget {
}
class _SCNNavLayoutState extends State<SCNNavLayout> {
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<AppAuth>(context, listen: false);
if (!userAcc.isAuth()) _selectedIndex = 2;
if (!userAcc.isAuth()) _selectedIndex = INDEX_ACCOUNT;
super.initState();
}
void _onItemTapped(int index) {
final userAcc = Provider.of<AppAuth>(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<SCNNavLayout> {
}
setState(() {
_selectedIndex = 4;
_selectedIndex = INDEX_SEND;
});
}
@@ -59,17 +69,17 @@ class _SCNNavLayoutState extends State<SCNNavLayout> {
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,
),

View File

@@ -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'