💄 Optimize unauthorized status

This commit is contained in:
2026-01-02 14:33:41 +08:00
parent 3b13a63e7b
commit 800815c721
4 changed files with 84 additions and 34 deletions

View File

@@ -358,7 +358,7 @@
"accountSettingsHelp": "Account Settings Help", "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.", "accountSettingsHelpContent": "This page allows you to manage your account security, privacy, and other settings. If you need assistance, please contact support.",
"unauthorized": "Unauthorized", "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 {}", "publisherBelongsTo": "Belongs to {}",
"postContent": "Content", "postContent": "Content",
"postSettings": "Settings", "postSettings": "Settings",

View File

@@ -603,11 +603,13 @@ class ChatListScreen extends HookConsumerWidget {
), ),
), ),
), ),
body: ChatListBodyWidget( body: userInfo.value == null
isFloating: false, ? const ResponseUnauthorizedWidget()
tabController: tabController, : ChatListBodyWidget(
selectedTab: selectedTab, isFloating: false,
), tabController: tabController,
selectedTab: selectedTab,
),
); );
} }
} }

View File

@@ -121,36 +121,38 @@ class RealmListScreen extends HookConsumerWidget {
MediaQuery.of(context).padding.bottom, MediaQuery.of(context).padding.bottom,
) )
: null, : null,
body: ExtendedRefreshIndicator( body: userInfo.value == null
child: realms.when( ? const ResponseUnauthorizedWidget()
data: (value) => Column( : ExtendedRefreshIndicator(
children: [ child: realms.when(
Expanded( data: (value) => Column(
child: ListView.separated( children: [
padding: EdgeInsets.only( Expanded(
top: 8, child: ListView.separated(
bottom: MediaQuery.of(context).padding.bottom + 8, padding: EdgeInsets.only(
), top: 8,
itemCount: value.length, bottom: MediaQuery.of(context).padding.bottom + 8,
itemBuilder: (context, item) { ),
return ConstrainedBox( itemCount: value.length,
constraints: const BoxConstraints(maxWidth: 540), itemBuilder: (context, item) {
child: RealmListTile(realm: value[item]), return ConstrainedBox(
).padding(horizontal: 8).center(); constraints: const BoxConstraints(maxWidth: 540),
}, child: RealmListTile(realm: value[item]),
separatorBuilder: (_, _) => const Gap(8), ).padding(horizontal: 8).center();
},
separatorBuilder: (_, _) => const Gap(8),
),
),
],
),
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, _) => ResponseErrorWidget(
error: e,
onRetry: () => ref.invalidate(realmsJoinedProvider),
), ),
), ),
], onRefresh: () => ref.refresh(realmsJoinedProvider.future),
), ),
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, _) => ResponseErrorWidget(
error: e,
onRetry: () => ref.invalidate(realmsJoinedProvider),
),
),
onRefresh: () => ref.refresh(realmsJoinedProvider.future),
),
); );
} }
} }

View File

@@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:island/screens/auth/login_modal.dart';
import 'package:material_symbols_icons/symbols.dart'; import 'package:material_symbols_icons/symbols.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
@@ -73,3 +74,48 @@ class ResponseLoadingWidget extends StatelessWidget {
return const Center(child: CircularProgressIndicator()); 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(),
],
);
}
}