✨ Draft box
This commit is contained in:
@ -1,56 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/widgets/centered_container.dart';
|
||||
import 'package:solian/widgets/posts/post_list.dart';
|
||||
|
||||
class FeedListWidget extends StatelessWidget {
|
||||
final bool isShowEmbed;
|
||||
final bool isClickable;
|
||||
final bool isNestedClickable;
|
||||
final PagingController<int, FeedRecord> controller;
|
||||
|
||||
const FeedListWidget({
|
||||
super.key,
|
||||
required this.controller,
|
||||
this.isShowEmbed = true,
|
||||
this.isClickable = true,
|
||||
this.isNestedClickable = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PagedSliverList<int, FeedRecord>.separated(
|
||||
pagingController: controller,
|
||||
builderDelegate: PagedChildBuilderDelegate<FeedRecord>(
|
||||
itemBuilder: (context, item, index) {
|
||||
return RepaintBoundary(
|
||||
child: CenteredContainer(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
switch (item.type) {
|
||||
case 'post':
|
||||
final data = Post.fromJson(item.data);
|
||||
return PostListEntryWidget(
|
||||
isShowEmbed: isShowEmbed,
|
||||
isNestedClickable: isNestedClickable,
|
||||
isClickable: isClickable,
|
||||
item: data,
|
||||
onUpdate: () {
|
||||
controller.refresh();
|
||||
},
|
||||
);
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
separatorBuilder: (_, __) => const Divider(thickness: 0.3, height: 0.3),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/router.dart';
|
||||
|
||||
class FeedTagsList extends StatelessWidget {
|
||||
final List<Tag> tags;
|
||||
|
||||
const FeedTagsList({
|
||||
super.key,
|
||||
required this.tags,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
spacing: 6,
|
||||
children: tags
|
||||
.map(
|
||||
(x) => InkWell(
|
||||
child: Text(
|
||||
'#${x.alias}',
|
||||
style: TextStyle(
|
||||
color:
|
||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.8),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
AppRouter.instance.pushNamed('feedSearch', queryParameters: {
|
||||
'tag': x.alias,
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
@ -12,8 +12,9 @@ import 'package:solian/screens/posts/post_publish.dart';
|
||||
|
||||
class PostAction extends StatefulWidget {
|
||||
final Post item;
|
||||
final bool noReact;
|
||||
|
||||
const PostAction({super.key, required this.item});
|
||||
const PostAction({super.key, required this.item, this.noReact = false});
|
||||
|
||||
@override
|
||||
State<PostAction> createState() => _PostActionState();
|
||||
@ -39,7 +40,6 @@ class _PostActionState extends State<PostAction> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
checkAbleToModifyContent();
|
||||
}
|
||||
|
||||
@ -66,35 +66,37 @@ class _PostActionState extends State<PostAction> {
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: const FaIcon(FontAwesomeIcons.reply, size: 20),
|
||||
title: Text('reply'.tr),
|
||||
onTap: () async {
|
||||
final value = await AppRouter.instance.pushNamed(
|
||||
'postCreate',
|
||||
extra: PostPublishArguments(reply: widget.item),
|
||||
);
|
||||
if (value != null) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: const FaIcon(FontAwesomeIcons.retweet, size: 20),
|
||||
title: Text('repost'.tr),
|
||||
onTap: () async {
|
||||
final value = await AppRouter.instance.pushNamed(
|
||||
'postCreate',
|
||||
extra: PostPublishArguments(repost: widget.item),
|
||||
);
|
||||
if (value != null) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (_canModifyContent)
|
||||
if (!widget.noReact)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: const FaIcon(FontAwesomeIcons.reply, size: 20),
|
||||
title: Text('reply'.tr),
|
||||
onTap: () async {
|
||||
final value = await AppRouter.instance.pushNamed(
|
||||
'postCreate',
|
||||
extra: PostPublishArguments(reply: widget.item),
|
||||
);
|
||||
if (value != null) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (!widget.noReact)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: const FaIcon(FontAwesomeIcons.retweet, size: 20),
|
||||
title: Text('repost'.tr),
|
||||
onTap: () async {
|
||||
final value = await AppRouter.instance.pushNamed(
|
||||
'postCreate',
|
||||
extra: PostPublishArguments(repost: widget.item),
|
||||
);
|
||||
if (value != null) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (_canModifyContent && !widget.noReact)
|
||||
const Divider(thickness: 0.3, height: 0.3)
|
||||
.paddingSymmetric(vertical: 16),
|
||||
if (_canModifyContent)
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@ -8,11 +7,10 @@ import 'package:solian/router.dart';
|
||||
import 'package:solian/widgets/account/account_avatar.dart';
|
||||
import 'package:solian/widgets/account/account_profile_popup.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_list.dart';
|
||||
import 'package:solian/widgets/posts/feed_tags.dart';
|
||||
import 'package:solian/widgets/feed/feed_content.dart';
|
||||
import 'package:solian/widgets/feed/feed_tags.dart';
|
||||
import 'package:solian/widgets/posts/post_quick_action.dart';
|
||||
import 'package:timeago/timeago.dart' show format;
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
import 'package:markdown/markdown.dart' as markdown;
|
||||
|
||||
class PostItem extends StatefulWidget {
|
||||
final Post item;
|
||||
@ -74,30 +72,6 @@ class _PostItemState extends State<PostItem> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildBody() {
|
||||
return Markdown(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
data: item.content,
|
||||
padding: const EdgeInsets.all(0),
|
||||
extensionSet: markdown.ExtensionSet(
|
||||
markdown.ExtensionSet.gitHubFlavored.blockSyntaxes,
|
||||
<markdown.InlineSyntax>[
|
||||
markdown.EmojiSyntax(),
|
||||
markdown.AutolinkExtensionSyntax(),
|
||||
...markdown.ExtensionSet.gitHubFlavored.inlineSyntaxes
|
||||
],
|
||||
),
|
||||
onTapLink: (text, href, title) async {
|
||||
if (href == null) return;
|
||||
await launchUrlString(
|
||||
href,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildFooter() {
|
||||
List<String> labels = List.empty(growable: true);
|
||||
if (widget.item.createdAt != widget.item.updatedAt) {
|
||||
@ -216,7 +190,7 @@ class _PostItemState extends State<PostItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildHeader().paddingSymmetric(horizontal: 12),
|
||||
buildBody().paddingOnly(
|
||||
FeedContent(content: item.content).paddingOnly(
|
||||
left: 16,
|
||||
right: 12,
|
||||
top: 2,
|
||||
@ -257,7 +231,8 @@ class _PostItemState extends State<PostItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildHeader(),
|
||||
buildBody().paddingOnly(left: 12, right: 8),
|
||||
FeedContent(content: item.content)
|
||||
.paddingOnly(left: 12, right: 8),
|
||||
if (widget.item.replyTo != null && widget.isShowEmbed)
|
||||
GestureDetector(
|
||||
child: buildReply(context).paddingOnly(top: 4),
|
||||
|
93
lib/widgets/posts/post_owned_list.dart
Normal file
93
lib/widgets/posts/post_owned_list.dart
Normal file
@ -0,0 +1,93 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/widgets/feed/feed_content.dart';
|
||||
import 'package:solian/widgets/feed/feed_tags.dart';
|
||||
|
||||
class PostOwnedListEntry extends StatelessWidget {
|
||||
final Post item;
|
||||
final Function onTap;
|
||||
|
||||
const PostOwnedListEntry({
|
||||
super.key,
|
||||
required this.item,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
Widget buildFooter(BuildContext context) {
|
||||
List<String> labels = List.empty(growable: true);
|
||||
if (item.createdAt == item.updatedAt) {
|
||||
labels.add('postNewCreated'.trParams({
|
||||
'date': DateFormat('yyyy/MM/dd HH:mm').format(item.updatedAt.toLocal()),
|
||||
}));
|
||||
} else {
|
||||
labels.add('postEdited'.trParams({
|
||||
'date': DateFormat('yyyy/MM/dd HH:mm').format(item.updatedAt.toLocal()),
|
||||
}));
|
||||
}
|
||||
if (item.realm != null) {
|
||||
labels.add('postInRealm'.trParams({
|
||||
'realm': '#${item.realm!.alias}',
|
||||
}));
|
||||
}
|
||||
|
||||
final color = Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
||||
|
||||
List<Widget> widgets = List.from([
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'post'.tr,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
Icon(Icons.text_snippet, size: 14, color: color).paddingOnly(left: 4),
|
||||
],
|
||||
),
|
||||
], growable: true);
|
||||
|
||||
if (item.tags?.isNotEmpty ?? false) {
|
||||
widgets.add(FeedTagsList(tags: item.tags!));
|
||||
}
|
||||
if (labels.isNotEmpty) {
|
||||
widgets.add(Text(
|
||||
labels.join(' · '),
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: color,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: widgets,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
FeedContent(content: item.content).paddingOnly(
|
||||
left: 12,
|
||||
right: 12,
|
||||
top: 8,
|
||||
),
|
||||
buildFooter(context).paddingOnly(left: 12, top: 6, bottom: 8),
|
||||
],
|
||||
),
|
||||
onTap: () => onTap(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/providers/content/post.dart';
|
||||
import 'package:solian/providers/content/feed.dart';
|
||||
import 'package:solian/widgets/posts/post_list.dart';
|
||||
|
||||
class PostReplyList extends StatefulWidget {
|
||||
@ -23,7 +23,7 @@ class _PostReplyListState extends State<PostReplyList> {
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
Future<void> getReplies(int pageKey) async {
|
||||
final PostProvider provider = Get.find();
|
||||
final FeedProvider provider = Get.find();
|
||||
|
||||
Response resp;
|
||||
try {
|
||||
|
@ -1,95 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:textfield_tags/textfield_tags.dart';
|
||||
|
||||
class TagsField extends StatelessWidget {
|
||||
final List<String>? initialTags;
|
||||
final String hintText;
|
||||
|
||||
const TagsField({
|
||||
super.key,
|
||||
this.initialTags,
|
||||
required this.hintText,
|
||||
required StringTagController<String> tagsController,
|
||||
}) : _tagsController = tagsController;
|
||||
|
||||
final StringTagController<String> _tagsController;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 8,
|
||||
),
|
||||
child: TextFieldTags<String>(
|
||||
initialTags: initialTags,
|
||||
letterCase: LetterCase.small,
|
||||
textfieldTagsController: _tagsController,
|
||||
textSeparators: const [' ', ','],
|
||||
inputFieldBuilder: (context, inputFieldValues) {
|
||||
return TextField(
|
||||
controller: inputFieldValues.textEditingController,
|
||||
focusNode: inputFieldValues.focusNode,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
hintText: hintText,
|
||||
border: InputBorder.none,
|
||||
prefixIconConstraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.of(context).size.width * 0.8,
|
||||
),
|
||||
prefixIcon: inputFieldValues.tags.isNotEmpty
|
||||
? SingleChildScrollView(
|
||||
controller: inputFieldValues.tagScrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: inputFieldValues.tags.map((String tag) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(20.0),
|
||||
),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
margin: const EdgeInsets.only(right: 10.0),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10.0, vertical: 4.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InkWell(
|
||||
child: Text(
|
||||
'#$tag',
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
onTap: () {
|
||||
//print("$tag selected");
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 4.0),
|
||||
InkWell(
|
||||
child: const Icon(
|
||||
Icons.cancel,
|
||||
size: 14.0,
|
||||
color: Color.fromARGB(255, 233, 233, 233),
|
||||
),
|
||||
onTap: () {
|
||||
inputFieldValues.onTagRemoved(tag);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onChanged: inputFieldValues.onTagChanged,
|
||||
onSubmitted: inputFieldValues.onTagSubmitted,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user