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