Compare commits

..

No commits in common. "82fc191bad667118e1badf8387d085bb40843065" and "b257378a82735e77c283949fda2cfc57518fded4" have entirely different histories.

9 changed files with 51 additions and 161 deletions

View File

@ -5,7 +5,6 @@
"account": "Account",
"signIn": "Sign In",
"signInCaption": "Sign in to create post, start a realm, message your friend and more!",
"signInRequired": "Sign in required",
"signUp": "Sign Up",
"signUpCaption": "Create an account on Solarpass and then get the access of entire Solar Networks!",
"confirmation": "Confirmation",

View File

@ -5,7 +5,6 @@
"account": "账号",
"signIn": "登陆",
"signInCaption": "登陆以发表帖子、文章、创建领域、和你的朋友聊天,以及获取更多功能!",
"signInRequired": "请先登陆",
"signUp": "注册",
"signUpCaption": "在 Solarpass 注册一个账号以获得整个 Solar Networks 的存取权!",
"confirmation": "确认",

View File

@ -8,7 +8,6 @@ import 'package:solian/router.dart';
import 'package:solian/utils/service_url.dart';
import 'package:solian/widgets/indent_wrapper.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:solian/widgets/signin_required.dart';
class ChatIndexScreen extends StatefulWidget {
const ChatIndexScreen({super.key});
@ -51,43 +50,33 @@ class _ChatIndexScreenState extends State<ChatIndexScreen> {
@override
Widget build(BuildContext context) {
final auth = context.read<AuthProvider>();
return IndentWrapper(
title: AppLocalizations.of(context)!.chat,
child: FutureBuilder(
future: auth.isAuthorized(),
builder: (context, snapshot) {
if (!snapshot.hasData || !snapshot.data!) {
return const SignInRequiredScreen();
}
return RefreshIndicator(
onRefresh: () => fetchChannels(context),
child: ListView.builder(
itemCount: _channels.length,
itemBuilder: (context, index) {
final element = _channels[index];
return ListTile(
leading: const CircleAvatar(
backgroundColor: Colors.indigo,
child: Icon(Icons.tag, color: Colors.white),
),
title: Text(element.name),
subtitle: Text(element.description),
onTap: () {
router.pushNamed(
'chat.channel',
pathParameters: {
'channel': element.alias,
},
);
},
);
},
child: RefreshIndicator(
onRefresh: () => fetchChannels(context),
child: ListView.builder(
itemCount: _channels.length,
itemBuilder: (context, index) {
final element = _channels[index];
return ListTile(
leading: const CircleAvatar(
backgroundColor: Colors.indigo,
child: Icon(Icons.tag, color: Colors.white),
),
title: Text(element.name),
subtitle: Text(element.description),
onTap: () {
router.pushNamed(
'chat.channel',
pathParameters: {
'channel': element.alias,
},
);
},
);
}),
},
),
),
);
}
}

View File

@ -1,10 +1,8 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:solian/models/pagination.dart';
import 'package:solian/models/post.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/router.dart';
import 'package:solian/utils/service_url.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
@ -56,24 +54,13 @@ class _ExploreScreenState extends State<ExploreScreen> {
@override
Widget build(BuildContext context) {
final auth = context.read<AuthProvider>();
return IndentWrapper(
noSafeArea: true,
floatingActionButton: FutureBuilder(
future: auth.isAuthorized(),
builder: (context, snapshot) {
if (snapshot.hasData && snapshot.data!) {
return FloatingActionButton(
child: const Icon(Icons.edit),
onPressed: () async {
final did = await router.pushNamed("posts.moments.editor");
if (did == true) _pagingController.refresh();
},
);
} else {
return Container();
}
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.edit),
onPressed: () async {
final did = await router.pushNamed("posts.moments.editor");
if (did == true) _pagingController.refresh();
},
),
title: AppLocalizations.of(context)!.explore,
@ -84,8 +71,9 @@ class _ExploreScreenState extends State<ExploreScreen> {
child: Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 640),
child: PagedListView<int, Post>(
child: PagedListView<int, Post>.separated(
pagingController: _pagingController,
separatorBuilder: (context, index) => const Divider(thickness: 0.3),
builderDelegate: PagedChildBuilderDelegate<Post>(
itemBuilder: (context, item, index) => PostItem(
item: item,

View File

@ -11,6 +11,7 @@ class ChatMessageContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Markdown(
selectable: true,
data: item.content,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),

View File

@ -1,11 +1,8 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:solian/models/message.dart';
import 'package:solian/widgets/chat/content.dart';
import 'package:solian/widgets/posts/content/attachment.dart';
import 'package:timeago/timeago.dart' as timeago;
import 'dart:math' as math;
class ChatMessage extends StatelessWidget {
final Message item;
@ -24,49 +21,6 @@ class ChatMessage extends StatelessWidget {
}
}
Widget renderReply() {
final padding =
underMerged ? const EdgeInsets.only(left: 14, right: 8, top: 4) : const EdgeInsets.only(left: 8, right: 8);
if (item.replyTo != null) {
return Row(
children: [
Container(
padding: padding,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Transform(
alignment: Alignment.center,
transform: Matrix4.rotationY(math.pi),
child: const Icon(Icons.reply, size: 16),
),
const SizedBox(width: 8),
CircleAvatar(
radius: 10,
backgroundImage: NetworkImage(item.replyTo!.sender.account.avatar),
),
]),
),
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(right: 12, top: 2),
child: ChatMessageContent(item: item.replyTo!),
),
renderAttachment()
],
),
),
],
);
} else {
return Container();
}
}
@override
Widget build(BuildContext context) {
final contentPart = Padding(
@ -94,32 +48,27 @@ class ChatMessage extends StatelessWidget {
const SizedBox(width: 40),
Expanded(
child: Column(
children: [renderReply(), contentPart, renderAttachment()],
children: [contentPart, renderAttachment()],
),
),
],
);
} else {
return Column(
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
renderReply(),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
backgroundImage: NetworkImage(item.sender.account.avatar),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
userinfoPart,
contentPart,
renderAttachment(),
],
),
),
],
CircleAvatar(
backgroundImage: NetworkImage(item.sender.account.avatar),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
userinfoPart,
contentPart,
renderAttachment(),
],
),
),
],
);

View File

@ -1,9 +1,13 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:solian/models/message.dart';
import 'package:solian/models/post.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/router.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:solian/screens/posts/comment_editor.dart';
import 'package:solian/widgets/chat/message_deletion.dart';
import 'package:solian/widgets/posts/item_deletion.dart';
class ChatMessageAction extends StatelessWidget {
final String channel;

View File

@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:solian/models/message.dart';
import 'package:solian/models/post.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/utils/service_url.dart';

View File

@ -1,40 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:solian/router.dart';
class SignInRequiredScreen extends StatelessWidget {
const SignInRequiredScreen({super.key});
@override
Widget build(BuildContext context) {
return GestureDetector(
child: Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 340),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.login, size: 40),
const SizedBox(height: 20),
Text(
AppLocalizations.of(context)!.signInRequired,
style: Theme.of(context).textTheme.headlineSmall,
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
Text(
AppLocalizations.of(context)!.signInCaption,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
)
],
),
),
),
onTap: () {
router.goNamed('account');
},
);
}
}