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/screens/account/notification.dart';
import 'package:solian/theme.dart';
import 'package:solian/widgets/account/signin_required_overlay.dart';
class ContactScreen extends StatefulWidget {
const ContactScreen({super.key});
@ -48,90 +49,108 @@ class _ContactScreenState extends State<ContactScreen> {
Widget build(BuildContext context) {
final AuthProvider auth = Get.find();
// TODO Un signed in tip
return Material(
color: Theme.of(context).colorScheme.surface,
child: SafeArea(
child: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverOverlapAbsorber(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar(
title: Text('contact'.tr),
centerTitle: false,
titleSpacing: SolianTheme.isLargeScreen(context) ? null : 24,
forceElevated: innerBoxIsScrolled,
actions: [
const NotificationButton(),
IconButton(
icon: const Icon(Icons.add_circle),
onPressed: () {
AppRouter.instance.pushNamed('channelOrganizing').then(
(value) {
if (value != null) {
getChannels();
}
},
);
},
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
),
],
),
),
];
},
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,
),
child: FutureBuilder(
future: auth.isAuthorized,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const Center(
child: CircularProgressIndicator(),
);
} else if (snapshot.data == false) {
return SigninRequiredOverlay(
onSignedIn: () {
getChannels();
},
);
}
return SafeArea(
child: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
sliver: SliverAppBar(
title: Text('contact'.tr),
centerTitle: false,
titleSpacing:
SolianTheme.isLargeScreen(context) ? null : 24,
forceElevated: innerBoxIsScrolled,
actions: [
const NotificationButton(),
IconButton(
icon: const Icon(Icons.add_circle),
onPressed: () {
AppRouter.instance
.pushNamed('channelOrganizing')
.then(
(value) {
if (value != null) {
getChannels();
}
},
);
},
),
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,
},
);
},
);
},
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
),
],
),
),
];
},
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',
'aspectRatioLandscape': 'Landscape',
'signin': 'Sign in',
'signinRequired': 'Sign in',
'signinRequiredHint': 'Sign in to get full access of Solar Network',
'signinGreeting': 'Welcome back\nSolar Network',
'signinCaption':
'Sign in to create post, start a realm, message your friend and more!',
@ -160,6 +162,8 @@ class SolianMessages extends Translations {
'aspectRatioPortrait': '竖型',
'aspectRatioLandscape': '横型',
'signin': '登录',
'signinRequired': '需要登录',
'signinRequiredHint': '登陆以获得 Solar Network 的全部功能使用权。',
'signinGreeting': '欢迎回来\nSolar Network',
'signinCaption': '登录以发表帖子、文章、创建领域、和你的朋友聊天,以及获取更多功能!',
'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();
});
},
);
}
}