Login hint

This commit is contained in:
LittleSheep 2024-05-28 20:13:36 +08:00
parent 9aceabd83c
commit 99f3211151
4 changed files with 161 additions and 78 deletions

View File

@ -8,6 +8,7 @@ import 'package:solian/providers/content/channel.dart';
import 'package:solian/router.dart'; import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart'; import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart'; import 'package:solian/theme.dart';
import 'package:solian/widgets/account/signin_required_overlay.dart';
class ContactScreen extends StatefulWidget { class ContactScreen extends StatefulWidget {
const ContactScreen({super.key}); const ContactScreen({super.key});
@ -48,90 +49,108 @@ class _ContactScreenState extends State<ContactScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final AuthProvider auth = Get.find(); final AuthProvider auth = Get.find();
// TODO Un signed in tip
return Material( return Material(
color: Theme.of(context).colorScheme.surface, color: Theme.of(context).colorScheme.surface,
child: SafeArea( child: FutureBuilder(
child: NestedScrollView( future: auth.isAuthorized,
headerSliverBuilder: (context, innerBoxIsScrolled) { builder: (context, snapshot) {
return [ if (!snapshot.hasData) {
SliverOverlapAbsorber( return const Center(
handle: child: CircularProgressIndicator(),
NestedScrollView.sliverOverlapAbsorberHandleFor(context), );
sliver: SliverAppBar( } else if (snapshot.data == false) {
title: Text('contact'.tr), return SigninRequiredOverlay(
centerTitle: false, onSignedIn: () {
titleSpacing: SolianTheme.isLargeScreen(context) ? null : 24, getChannels();
forceElevated: innerBoxIsScrolled, },
actions: [ );
const NotificationButton(), }
IconButton(
icon: const Icon(Icons.add_circle), return SafeArea(
onPressed: () { child: NestedScrollView(
AppRouter.instance.pushNamed('channelOrganizing').then( headerSliverBuilder: (context, innerBoxIsScrolled) {
(value) { return [
if (value != null) { SliverOverlapAbsorber(
getChannels(); handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
} context),
}, sliver: SliverAppBar(
); title: Text('contact'.tr),
}, centerTitle: false,
), titleSpacing:
SizedBox( SolianTheme.isLargeScreen(context) ? null : 24,
width: SolianTheme.isLargeScreen(context) ? 8 : 16, forceElevated: innerBoxIsScrolled,
), actions: [
], const NotificationButton(),
), IconButton(
), icon: const Icon(Icons.add_circle),
]; onPressed: () {
}, AppRouter.instance
body: MediaQuery.removePadding( .pushNamed('channelOrganizing')
removeTop: true, .then(
context: context, (value) {
child: Column( if (value != null) {
children: [ getChannels();
if (_isBusy) const LinearProgressIndicator().animate().scaleX(), }
Expanded( },
child: RefreshIndicator( );
onRefresh: () => getChannels(), },
child: ListView.builder(
itemCount: _channels.length,
itemBuilder: (context, index) {
final element = _channels[index];
return ListTile(
leading: CircleAvatar(
backgroundColor: Colors.indigo,
child: FaIcon(
element.icon,
color: Colors.white,
size: 16,
),
), ),
contentPadding: SizedBox(
const EdgeInsets.symmetric(horizontal: 24), width: SolianTheme.isLargeScreen(context) ? 8 : 16,
title: Text(element.name), ),
subtitle: Text(element.description), ],
onTap: () { ),
AppRouter.instance.pushNamed(
'channelChat',
pathParameters: {'alias': element.alias},
queryParameters: {
if (element.realmId != null)
'realm': element.realm!.alias,
},
);
},
);
},
), ),
];
},
body: MediaQuery.removePadding(
removeTop: true,
context: context,
child: Column(
children: [
if (_isBusy)
const LinearProgressIndicator().animate().scaleX(),
Expanded(
child: RefreshIndicator(
onRefresh: () => getChannels(),
child: ListView.builder(
itemCount: _channels.length,
itemBuilder: (context, index) {
final element = _channels[index];
return ListTile(
leading: CircleAvatar(
backgroundColor: Colors.indigo,
child: FaIcon(
element.icon,
color: Colors.white,
size: 16,
),
),
contentPadding:
const EdgeInsets.symmetric(horizontal: 24),
title: Text(element.name),
subtitle: Text(element.description),
onTap: () {
AppRouter.instance.pushNamed(
'channelChat',
pathParameters: {'alias': element.alias},
queryParameters: {
if (element.realmId != null)
'realm': element.realm!.alias,
},
);
},
);
},
),
),
),
],
), ),
), ),
], ),
), );
), }),
),
),
); );
} }
} }

10
lib/screens/realms.dart Normal file
View File

@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class RealmListScreen extends StatelessWidget {
const RealmListScreen({super.key});
@override
Widget build(BuildContext context) {
throw UnimplementedError();
}
}

View File

@ -48,6 +48,8 @@ class SolianMessages extends Translations {
'aspectRatioPortrait': 'Portrait', 'aspectRatioPortrait': 'Portrait',
'aspectRatioLandscape': 'Landscape', 'aspectRatioLandscape': 'Landscape',
'signin': 'Sign in', 'signin': 'Sign in',
'signinRequired': 'Sign in',
'signinRequiredHint': 'Sign in to get full access of Solar Network',
'signinGreeting': 'Welcome back\nSolar Network', 'signinGreeting': 'Welcome back\nSolar Network',
'signinCaption': 'signinCaption':
'Sign in to create post, start a realm, message your friend and more!', 'Sign in to create post, start a realm, message your friend and more!',
@ -160,6 +162,8 @@ class SolianMessages extends Translations {
'aspectRatioPortrait': '竖型', 'aspectRatioPortrait': '竖型',
'aspectRatioLandscape': '横型', 'aspectRatioLandscape': '横型',
'signin': '登录', 'signin': '登录',
'signinRequired': '需要登录',
'signinRequiredHint': '登陆以获得 Solar Network 的全部功能使用权。',
'signinGreeting': '欢迎回来\nSolar Network', 'signinGreeting': '欢迎回来\nSolar Network',
'signinCaption': '登录以发表帖子、文章、创建领域、和你的朋友聊天,以及获取更多功能!', 'signinCaption': '登录以发表帖子、文章、创建领域、和你的朋友聊天,以及获取更多功能!',
'signinRiskDetected': '检测到风险,点击下一步按钮来打开一个网页,并通过在其上面登录来通过安全检查。', 'signinRiskDetected': '检测到风险,点击下一步按钮来打开一个网页,并通过在其上面登录来通过安全检查。',

View File

@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:solian/screens/auth/signin.dart';
class SigninRequiredOverlay extends StatelessWidget {
final Function onSignedIn;
const SigninRequiredOverlay({super.key, required this.onSignedIn});
@override
Widget build(BuildContext context) {
return GestureDetector(
child: Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 280),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.login,
size: 48,
),
const SizedBox(height: 8),
Text(
'signinRequired'.tr,
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
Text(
'signinRequiredHint'.tr,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
),
],
),
),
),
onTap: () {
showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: true,
context: context,
builder: (context) => const SignInPopup(),
).then((value) {
if (value != null) onSignedIn();
});
},
);
}
}