💄 Better posting page

This commit is contained in:
LittleSheep 2024-07-07 03:02:10 +08:00
parent b2a2d38c3d
commit f8bed6946e
2 changed files with 128 additions and 131 deletions

View File

@ -68,7 +68,11 @@ class _FeedScreenState extends State<FeedScreen> {
actions: [
const BackgroundStateWidget(),
const NotificationButton(),
const FeedCreationButton(),
FeedCreationButton(
onCreated: () {
_pagingController.refresh();
},
),
SizedBox(
width: SolianTheme.isLargeScreen(context) ? 8 : 16,
),
@ -84,7 +88,9 @@ class _FeedScreenState extends State<FeedScreen> {
}
class FeedCreationButton extends StatelessWidget {
const FeedCreationButton({super.key});
final Function? onCreated;
const FeedCreationButton({super.key, this.onCreated});
@override
Widget build(BuildContext context) {
@ -97,7 +103,11 @@ class FeedCreationButton extends StatelessWidget {
return IconButton(
icon: const Icon(Icons.add_circle),
onPressed: () {
AppRouter.instance.pushNamed('postPublishing');
AppRouter.instance.pushNamed('postPublishing').then((val) {
if (val == true && onCreated != null) {
onCreated!();
}
});
},
);
}

View File

@ -137,91 +137,65 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
),
body: SafeArea(
top: false,
child: Column(
child: Stack(
children: [
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
ListView(
children: [
if (_isBusy)
const LinearProgressIndicator().animate().scaleX(),
if (widget.edit != null)
MaterialBanner(
leading: const Icon(Icons.edit),
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
leadingPadding:
const EdgeInsets.only(left: 10, right: 20),
dividerColor: Colors.transparent,
content: Text('postEditingNotify'.tr),
actions: notifyBannerActions,
),
if (widget.reply != null)
Container(
color: Theme.of(context).colorScheme.surfaceContainerLow,
child: Column(
children: [
MaterialBanner(
ExpansionTile(
leading: const FaIcon(
FontAwesomeIcons.reply,
size: 18,
),
leadingPadding:
const EdgeInsets.only(left: 10, right: 20),
backgroundColor: Colors.transparent,
dividerColor: Colors.transparent,
content: Text(
'postReplyingNotify'.trParams(
).paddingOnly(left: 2),
title: Text('postReplyingNotify'.trParams(
{'username': '@${widget.reply!.author.name}'},
),
),
actions: notifyBannerActions,
),
const Divider(thickness: 0.3, height: 0.3),
Container(
constraints: const BoxConstraints(maxHeight: 280),
child: SingleChildScrollView(
child: PostItem(
)),
collapsedBackgroundColor:
Theme.of(context).colorScheme.surfaceContainer,
children: [
PostItem(
item: widget.reply!,
isReactable: false,
),
),
),
).paddingOnly(bottom: 8),
],
),
),
if (widget.repost != null)
Container(
color: Theme.of(context).colorScheme.surfaceContainerLow,
child: Column(
children: [
MaterialBanner(
ExpansionTile(
leading: const FaIcon(
FontAwesomeIcons.retweet,
size: 18,
),
leadingPadding:
const EdgeInsets.only(left: 10, right: 20),
dividerColor: Colors.transparent,
content: Text(
'postRepostingNotify'.trParams(
).paddingOnly(left: 2),
title: Text('postRepostingNotify'.trParams(
{'username': '@${widget.repost!.author.name}'},
),
),
actions: notifyBannerActions,
),
const Divider(thickness: 0.3, height: 0.3),
Container(
constraints: const BoxConstraints(maxHeight: 280),
child: SingleChildScrollView(
child: PostItem(
)),
collapsedBackgroundColor:
Theme.of(context).colorScheme.surfaceContainer,
children: [
PostItem(
item: widget.repost!,
isReactable: false,
),
),
),
).paddingOnly(bottom: 8),
],
),
),
FutureBuilder(
future: auth.getProfile(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListTile(
leading: AccountAvatar(
content: snapshot.data?.body!['avatar'], radius: 22),
content: snapshot.data?.body!['avatar'],
radius: 22),
title: Text(snapshot.data?.body!['nick']),
subtitle: Text('postIdentityNotify'.tr),
);
@ -233,7 +207,8 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
if (widget.realm != null)
MaterialBanner(
leading: const Icon(Icons.group),
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
leadingPadding:
const EdgeInsets.only(left: 10, right: 20),
dividerColor: Colors.transparent,
content: Text(
'postInRealmNotify'
@ -241,9 +216,9 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
),
actions: notifyBannerActions,
),
const Divider(thickness: 0.3, height: 0.3).paddingOnly(bottom: 8),
Expanded(
child: Container(
const Divider(thickness: 0.3, height: 0.3)
.paddingOnly(bottom: 8),
Container(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: TextField(
@ -259,14 +234,23 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
FocusManager.instance.primaryFocus?.unfocus(),
),
),
],
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Column(
children: [
const Divider(thickness: 0.3, height: 0.3),
SizedBox(
height: 56,
child: Row(
children: [
TextButton(
style: TextButton.styleFrom(shape: const CircleBorder()),
style: TextButton.styleFrom(
shape: const CircleBorder(),
),
child: const Icon(Icons.camera_alt),
onPressed: () => showAttachments(),
)
@ -276,6 +260,9 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
],
),
),
],
),
),
),
);
}