diff --git a/assets/i18n/en-US.json b/assets/i18n/en-US.json index 15567bfd..ffa45caa 100644 --- a/assets/i18n/en-US.json +++ b/assets/i18n/en-US.json @@ -358,7 +358,7 @@ "accountSettingsHelp": "Account Settings Help", "accountSettingsHelpContent": "This page allows you to manage your account security, privacy, and other settings. If you need assistance, please contact support.", "unauthorized": "Unauthorized", - "unauthorizedHint": "You're not signed in or session expired, please sign in again.", + "unauthorizedHint": "You're not signed in or session expired, please sign in and try again.", "publisherBelongsTo": "Belongs to {}", "postContent": "Content", "postSettings": "Settings", diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index fbc71442..1f3b20ab 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -603,11 +603,13 @@ class ChatListScreen extends HookConsumerWidget { ), ), ), - body: ChatListBodyWidget( - isFloating: false, - tabController: tabController, - selectedTab: selectedTab, - ), + body: userInfo.value == null + ? const ResponseUnauthorizedWidget() + : ChatListBodyWidget( + isFloating: false, + tabController: tabController, + selectedTab: selectedTab, + ), ); } } diff --git a/lib/screens/realm/realms.dart b/lib/screens/realm/realms.dart index 03871bd5..fe52b78b 100644 --- a/lib/screens/realm/realms.dart +++ b/lib/screens/realm/realms.dart @@ -121,36 +121,38 @@ class RealmListScreen extends HookConsumerWidget { MediaQuery.of(context).padding.bottom, ) : null, - body: ExtendedRefreshIndicator( - child: realms.when( - data: (value) => Column( - children: [ - Expanded( - child: ListView.separated( - padding: EdgeInsets.only( - top: 8, - bottom: MediaQuery.of(context).padding.bottom + 8, - ), - itemCount: value.length, - itemBuilder: (context, item) { - return ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 540), - child: RealmListTile(realm: value[item]), - ).padding(horizontal: 8).center(); - }, - separatorBuilder: (_, _) => const Gap(8), + body: userInfo.value == null + ? const ResponseUnauthorizedWidget() + : ExtendedRefreshIndicator( + child: realms.when( + data: (value) => Column( + children: [ + Expanded( + child: ListView.separated( + padding: EdgeInsets.only( + top: 8, + bottom: MediaQuery.of(context).padding.bottom + 8, + ), + itemCount: value.length, + itemBuilder: (context, item) { + return ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 540), + child: RealmListTile(realm: value[item]), + ).padding(horizontal: 8).center(); + }, + separatorBuilder: (_, _) => const Gap(8), + ), + ), + ], + ), + loading: () => const Center(child: CircularProgressIndicator()), + error: (e, _) => ResponseErrorWidget( + error: e, + onRetry: () => ref.invalidate(realmsJoinedProvider), ), ), - ], - ), - loading: () => const Center(child: CircularProgressIndicator()), - error: (e, _) => ResponseErrorWidget( - error: e, - onRetry: () => ref.invalidate(realmsJoinedProvider), - ), - ), - onRefresh: () => ref.refresh(realmsJoinedProvider.future), - ), + onRefresh: () => ref.refresh(realmsJoinedProvider.future), + ), ); } } diff --git a/lib/widgets/response.dart b/lib/widgets/response.dart index a49963eb..7289bd69 100644 --- a/lib/widgets/response.dart +++ b/lib/widgets/response.dart @@ -2,6 +2,7 @@ import 'package:dio/dio.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; +import 'package:island/screens/auth/login_modal.dart'; import 'package:material_symbols_icons/symbols.dart'; import 'package:styled_widget/styled_widget.dart'; @@ -73,3 +74,48 @@ class ResponseLoadingWidget extends StatelessWidget { return const Center(child: CircularProgressIndicator()); } } + +class ResponseUnauthorizedWidget extends StatelessWidget { + const ResponseUnauthorizedWidget({super.key}); + + @override + Widget build(BuildContext context) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(Symbols.error_outline, size: 48), + const Gap(4), + ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 320), + child: Column( + children: [ + Text( + 'unauthorized'.tr(), + textAlign: TextAlign.center, + style: const TextStyle(color: Color(0xFF757575)), + ).bold(), + Text( + 'unauthorizedHint'.tr(), + textAlign: TextAlign.center, + style: const TextStyle(color: Color(0xFF757575)), + ), + const Gap(8), + TextButton.icon( + onPressed: () { + showModalBottomSheet( + context: context, + useRootNavigator: true, + isScrollControlled: true, + builder: (context) => const LoginModal(), + ); + }, + icon: const Icon(Symbols.login), + label: Text('login').tr(), + ), + ], + ), + ).center(), + ], + ); + } +}