💄 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,139 +137,126 @@ 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(
if (widget.edit != null) children: [
MaterialBanner( if (_isBusy)
leading: const Icon(Icons.edit), const LinearProgressIndicator().animate().scaleX(),
leadingPadding: const EdgeInsets.only(left: 10, right: 20), if (widget.edit != null)
dividerColor: Colors.transparent, MaterialBanner(
content: Text('postEditingNotify'.tr), leading: const Icon(Icons.edit),
actions: notifyBannerActions, leadingPadding:
), const EdgeInsets.only(left: 10, right: 20),
if (widget.reply != null) dividerColor: Colors.transparent,
Container( content: Text('postEditingNotify'.tr),
color: Theme.of(context).colorScheme.surfaceContainerLow, actions: notifyBannerActions,
child: Column(
children: [
MaterialBanner(
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(
{'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(
item: widget.reply!,
isReactable: false,
),
),
),
],
),
),
if (widget.repost != null)
Container(
color: Theme.of(context).colorScheme.surfaceContainerLow,
child: Column(
children: [
MaterialBanner(
leading: const FaIcon(
FontAwesomeIcons.retweet,
size: 18,
),
leadingPadding:
const EdgeInsets.only(left: 10, right: 20),
dividerColor: Colors.transparent,
content: 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(
item: widget.repost!,
isReactable: false,
),
),
),
],
),
),
FutureBuilder(
future: auth.getProfile(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return ListTile(
leading: AccountAvatar(
content: snapshot.data?.body!['avatar'], radius: 22),
title: Text(snapshot.data?.body!['nick']),
subtitle: Text('postIdentityNotify'.tr),
);
} else {
return Container();
}
},
),
if (widget.realm != null)
MaterialBanner(
leading: const Icon(Icons.group),
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
dividerColor: Colors.transparent,
content: Text(
'postInRealmNotify'
.trParams({'realm': '#${widget.realm!.alias}'}),
),
actions: notifyBannerActions,
),
const Divider(thickness: 0.3, height: 0.3).paddingOnly(bottom: 8),
Expanded(
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: TextField(
maxLines: null,
autofocus: true,
autocorrect: true,
keyboardType: TextInputType.multiline,
controller: _contentController,
decoration: InputDecoration.collapsed(
hintText: 'postContentPlaceholder'.tr,
), ),
onTapOutside: (_) => if (widget.reply != null)
FocusManager.instance.primaryFocus?.unfocus(), ExpansionTile(
leading: const FaIcon(
FontAwesomeIcons.reply,
size: 18,
).paddingOnly(left: 2),
title: Text('postReplyingNotify'.trParams(
{'username': '@${widget.reply!.author.name}'},
)),
collapsedBackgroundColor:
Theme.of(context).colorScheme.surfaceContainer,
children: [
PostItem(
item: widget.reply!,
isReactable: false,
).paddingOnly(bottom: 8),
],
),
if (widget.repost != null)
ExpansionTile(
leading: const FaIcon(
FontAwesomeIcons.retweet,
size: 18,
).paddingOnly(left: 2),
title: Text('postRepostingNotify'.trParams(
{'username': '@${widget.repost!.author.name}'},
)),
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),
title: Text(snapshot.data?.body!['nick']),
subtitle: Text('postIdentityNotify'.tr),
);
} else {
return Container();
}
},
), ),
), if (widget.realm != null)
MaterialBanner(
leading: const Icon(Icons.group),
leadingPadding:
const EdgeInsets.only(left: 10, right: 20),
dividerColor: Colors.transparent,
content: Text(
'postInRealmNotify'
.trParams({'realm': '#${widget.realm!.alias}'}),
),
actions: notifyBannerActions,
),
const Divider(thickness: 0.3, height: 0.3)
.paddingOnly(bottom: 8),
Container(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: TextField(
maxLines: null,
autofocus: true,
autocorrect: true,
keyboardType: TextInputType.multiline,
controller: _contentController,
decoration: InputDecoration.collapsed(
hintText: 'postContentPlaceholder'.tr,
),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
),
],
), ),
const Divider(thickness: 0.3, height: 0.3), Positioned(
SizedBox( bottom: 0,
height: 56, left: 0,
child: Row( right: 0,
child: Column(
children: [ children: [
TextButton( const Divider(thickness: 0.3, height: 0.3),
style: TextButton.styleFrom(shape: const CircleBorder()), SizedBox(
child: const Icon(Icons.camera_alt), height: 56,
onPressed: () => showAttachments(), child: Row(
) children: [
TextButton(
style: TextButton.styleFrom(
shape: const CircleBorder(),
),
child: const Icon(Icons.camera_alt),
onPressed: () => showAttachments(),
)
],
),
),
], ],
), ),
), ),