⬆️ Support latest version of server
This commit is contained in:
@ -1,157 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/articles.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/articles/article_editor.dart';
|
||||
|
||||
class ArticleAction extends StatefulWidget {
|
||||
final Article item;
|
||||
|
||||
const ArticleAction({super.key, required this.item});
|
||||
|
||||
@override
|
||||
State<ArticleAction> createState() => _ArticleActionState();
|
||||
}
|
||||
|
||||
class _ArticleActionState extends State<ArticleAction> {
|
||||
bool _isBusy = true;
|
||||
bool _canModifyContent = false;
|
||||
|
||||
void checkAbleToModifyContent() async {
|
||||
final AuthProvider provider = Get.find();
|
||||
if (!await provider.isAuthorized) return;
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final prof = await provider.getProfile();
|
||||
setState(() {
|
||||
_canModifyContent = prof.body?['id'] == widget.item.author.externalId;
|
||||
_isBusy = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
checkAbleToModifyContent();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'postActionList'.tr,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
Text(
|
||||
'#${widget.item.id.toString().padLeft(8, '0')}',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
).paddingOnly(left: 24, right: 24, top: 32, bottom: 16),
|
||||
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
if (_canModifyContent)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: const Icon(Icons.edit),
|
||||
title: Text('edit'.tr),
|
||||
onTap: () async {
|
||||
final value = await AppRouter.instance.pushNamed(
|
||||
'articleEditor',
|
||||
extra: ArticlePublishArguments(edit: widget.item),
|
||||
);
|
||||
if (value != null) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (_canModifyContent)
|
||||
ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text('delete'.tr),
|
||||
onTap: () async {
|
||||
final value = await showDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
ArticleDeletionDialog(item: widget.item),
|
||||
);
|
||||
if (value != null) {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ArticleDeletionDialog extends StatefulWidget {
|
||||
final Article item;
|
||||
|
||||
const ArticleDeletionDialog({super.key, required this.item});
|
||||
|
||||
@override
|
||||
State<ArticleDeletionDialog> createState() => _ArticleDeletionDialogState();
|
||||
}
|
||||
|
||||
class _ArticleDeletionDialogState extends State<ArticleDeletionDialog> {
|
||||
bool _isBusy = false;
|
||||
|
||||
void performAction() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
|
||||
final client = auth.configureClient('interactive');
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
final resp = await client.delete('/articles/${widget.item.id}');
|
||||
setState(() => _isBusy = false);
|
||||
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
} else {
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text('postDeletionConfirm'.tr),
|
||||
content: Text('postDeletionConfirmCaption'.trParams({
|
||||
'content': widget.item.content
|
||||
.substring(0, min(widget.item.content.length, 60))
|
||||
.trim(),
|
||||
})),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: _isBusy ? null : () => Navigator.pop(context),
|
||||
child: Text('cancel'.tr),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: _isBusy ? null : () => performAction(),
|
||||
child: Text('confirm'.tr),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,210 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get_utils/get_utils.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:solian/models/articles.dart';
|
||||
import 'package:solian/widgets/account/account_avatar.dart';
|
||||
import 'package:solian/widgets/account/account_profile_popup.dart';
|
||||
import 'package:solian/widgets/articles/article_quick_action.dart';
|
||||
import 'package:solian/widgets/markdown_text_content.dart';
|
||||
import 'package:solian/widgets/feed/feed_tags.dart';
|
||||
import 'package:timeago/timeago.dart' show format;
|
||||
|
||||
class ArticleItem extends StatefulWidget {
|
||||
final Article item;
|
||||
final bool isClickable;
|
||||
final bool isReactable;
|
||||
final bool isFullDate;
|
||||
final bool isFullContent;
|
||||
final String? overrideAttachmentParent;
|
||||
|
||||
const ArticleItem({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.isClickable = false,
|
||||
this.isReactable = true,
|
||||
this.isFullDate = false,
|
||||
this.isFullContent = false,
|
||||
this.overrideAttachmentParent,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ArticleItem> createState() => _ArticleItemState();
|
||||
}
|
||||
|
||||
class _ArticleItemState extends State<ArticleItem> {
|
||||
late final Article item;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
item = widget.item;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget buildDate() {
|
||||
if (widget.isFullDate) {
|
||||
return Text(DateFormat('y/M/d H:m').format(item.createdAt.toLocal()));
|
||||
} else {
|
||||
return Text(format(item.createdAt.toLocal(), locale: 'en_short'));
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildHeader() {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
item.author.nick,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
buildDate().paddingOnly(left: 4),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildFooter() {
|
||||
List<String> labels = List.from(['article'.tr], growable: true);
|
||||
if (widget.item.createdAt != widget.item.updatedAt) {
|
||||
labels.add('postEdited'.trParams({
|
||||
'date': DateFormat('yy/M/d H:m').format(item.updatedAt.toLocal()),
|
||||
}));
|
||||
}
|
||||
if (widget.item.realm != null) {
|
||||
labels.add('postInRealm'.trParams({
|
||||
'realm': '#${widget.item.realm!.alias}',
|
||||
}));
|
||||
}
|
||||
|
||||
List<Widget> widgets = List.empty(growable: true);
|
||||
|
||||
if (widget.item.tags?.isNotEmpty ?? false) {
|
||||
widgets.add(FeedTagsList(tags: widget.item.tags!));
|
||||
}
|
||||
if (labels.isNotEmpty) {
|
||||
widgets.add(Text(
|
||||
labels.join(' · '),
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.75),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
if (widgets.isEmpty) {
|
||||
return const SizedBox();
|
||||
} else {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: widgets,
|
||||
).paddingOnly(top: 4);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!widget.isFullContent) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AccountAvatar(content: item.author.avatar.toString()),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildHeader(),
|
||||
Text(item.title, style: const TextStyle(fontSize: 15)),
|
||||
Text(
|
||||
item.description,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withOpacity(0.8),
|
||||
),
|
||||
),
|
||||
buildFooter(),
|
||||
],
|
||||
).paddingOnly(left: 12),
|
||||
),
|
||||
],
|
||||
).paddingOnly(
|
||||
top: 10,
|
||||
bottom: 10,
|
||||
right: 16,
|
||||
left: 16,
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
GestureDetector(
|
||||
child: AccountAvatar(content: item.author.avatar.toString()),
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
context: context,
|
||||
builder: (context) => AccountProfilePopup(
|
||||
account: item.author,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildHeader(),
|
||||
Text(item.title),
|
||||
Text(
|
||||
item.description,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onSurface
|
||||
.withOpacity(0.8),
|
||||
),
|
||||
),
|
||||
],
|
||||
).paddingOnly(left: 12),
|
||||
)
|
||||
],
|
||||
).paddingOnly(
|
||||
top: 10,
|
||||
right: 16,
|
||||
left: 16,
|
||||
),
|
||||
MarkdownTextContent(content: item.content).paddingOnly(
|
||||
left: 20,
|
||||
right: 20,
|
||||
top: 10,
|
||||
bottom: 8,
|
||||
),
|
||||
buildFooter().paddingOnly(left: 20),
|
||||
if (widget.isReactable)
|
||||
ArticleQuickAction(
|
||||
isReactable: widget.isReactable,
|
||||
item: widget.item,
|
||||
onReact: (symbol, changes) {
|
||||
setState(() {
|
||||
item.metric!.reactionList[symbol] =
|
||||
(item.metric!.reactionList[symbol] ?? 0) + changes;
|
||||
});
|
||||
},
|
||||
).paddingOnly(
|
||||
top: 6,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 10,
|
||||
)
|
||||
else
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/articles.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/widgets/articles/article_action.dart';
|
||||
import 'package:solian/widgets/articles/article_item.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
|
||||
class ArticleListWidget extends StatelessWidget {
|
||||
final bool isShowEmbed;
|
||||
final bool isClickable;
|
||||
final bool isNestedClickable;
|
||||
final PagingController<int, Article> controller;
|
||||
|
||||
const ArticleListWidget({
|
||||
super.key,
|
||||
required this.controller,
|
||||
this.isShowEmbed = true,
|
||||
this.isClickable = true,
|
||||
this.isNestedClickable = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PagedSliverList<int, Article>.separated(
|
||||
addRepaintBoundaries: true,
|
||||
pagingController: controller,
|
||||
builderDelegate: PagedChildBuilderDelegate<Article>(
|
||||
itemBuilder: (context, item, index) {
|
||||
return CenteredContainer(
|
||||
child: ArticleListEntryWidget(
|
||||
isClickable: isClickable,
|
||||
item: item,
|
||||
onUpdate: () {
|
||||
controller.refresh();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
separatorBuilder: (_, __) => const Divider(thickness: 0.3, height: 0.3),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ArticleListEntryWidget extends StatelessWidget {
|
||||
final bool isClickable;
|
||||
final Article item;
|
||||
final Function onUpdate;
|
||||
|
||||
const ArticleListEntryWidget({
|
||||
super.key,
|
||||
required this.isClickable,
|
||||
required this.item,
|
||||
required this.onUpdate,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
child: ArticleItem(
|
||||
key: Key('a${item.alias}'),
|
||||
item: item,
|
||||
).paddingSymmetric(vertical: 8),
|
||||
onTap: () {
|
||||
if (!isClickable) return;
|
||||
AppRouter.instance.pushNamed(
|
||||
'articleDetail',
|
||||
pathParameters: {'alias': item.alias},
|
||||
);
|
||||
},
|
||||
onLongPress: () {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => ArticleAction(item: item),
|
||||
).then((value) {
|
||||
if (value != null) onUpdate();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:solian/models/articles.dart';
|
||||
import 'package:solian/widgets/articles/article_item.dart';
|
||||
|
||||
class ArticleOwnedListEntry extends StatelessWidget {
|
||||
final Article item;
|
||||
final Function onTap;
|
||||
|
||||
const ArticleOwnedListEntry({
|
||||
super.key,
|
||||
required this.item,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ArticleItem(
|
||||
key: Key('a${item.alias}'),
|
||||
item: item,
|
||||
isClickable: false,
|
||||
isReactable: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () => onTap(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/articles.dart';
|
||||
import 'package:solian/models/reaction.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/widgets/posts/post_reaction.dart';
|
||||
|
||||
class ArticleQuickAction extends StatefulWidget {
|
||||
final Article item;
|
||||
final bool isReactable;
|
||||
final void Function(String symbol, int num) onReact;
|
||||
|
||||
const ArticleQuickAction({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.isReactable = true,
|
||||
required this.onReact,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ArticleQuickAction> createState() => _ArticleQuickActionState();
|
||||
}
|
||||
|
||||
class _ArticleQuickActionState extends State<ArticleQuickAction> {
|
||||
bool _isSubmitting = false;
|
||||
|
||||
void showReactMenu() {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => PostReactionPopup(
|
||||
reactionList: widget.item.metric!.reactionList,
|
||||
onReact: (key, value) {
|
||||
doWidgetReact(key, value.attitude);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> doWidgetReact(String symbol, int attitude) async {
|
||||
if (!widget.isReactable) return;
|
||||
|
||||
final AuthProvider auth = Get.find();
|
||||
|
||||
if (_isSubmitting) return;
|
||||
if (!await auth.isAuthorized) return;
|
||||
|
||||
final client = auth.configureClient('interactive');
|
||||
|
||||
setState(() => _isSubmitting = true);
|
||||
|
||||
final resp = await client.post('/articles/${widget.item.alias}/react', {
|
||||
'symbol': symbol,
|
||||
'attitude': attitude,
|
||||
});
|
||||
if (resp.statusCode == 201) {
|
||||
widget.onReact(symbol, 1);
|
||||
context.showSnackbar('reactCompleted'.tr);
|
||||
} else if (resp.statusCode == 204) {
|
||||
widget.onReact(symbol, -1);
|
||||
context.showSnackbar('reactUncompleted'.tr);
|
||||
} else {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
}
|
||||
|
||||
setState(() => _isSubmitting = false);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
if (!widget.isReactable && widget.item.metric!.reactionList.isEmpty) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
widget.onReact('thumb_up', 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const density = VisualDensity(horizontal: -4, vertical: -3);
|
||||
|
||||
return SizedBox(
|
||||
height: 32,
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
...widget.item.metric!.reactionList.entries.map((x) {
|
||||
final info = reactions[x.key];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: ActionChip(
|
||||
avatar: Text(info!.icon),
|
||||
label: Text(x.value.toString()),
|
||||
tooltip: ':${x.key}:',
|
||||
visualDensity: density,
|
||||
onPressed: _isSubmitting
|
||||
? null
|
||||
: () => doWidgetReact(x.key, info.attitude),
|
||||
),
|
||||
);
|
||||
}),
|
||||
if (widget.isReactable)
|
||||
ActionChip(
|
||||
avatar: const Icon(Icons.add_reaction, color: Colors.teal),
|
||||
label: Text('reactAdd'.tr),
|
||||
visualDensity: density,
|
||||
onPressed: () => showReactMenu(),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/articles.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/widgets/articles/article_list.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
import 'package:solian/widgets/posts/post_list.dart';
|
||||
|
||||
@ -11,7 +8,7 @@ class FeedListWidget extends StatelessWidget {
|
||||
final bool isShowEmbed;
|
||||
final bool isClickable;
|
||||
final bool isNestedClickable;
|
||||
final PagingController<int, FeedRecord> controller;
|
||||
final PagingController<int, Post> controller;
|
||||
|
||||
const FeedListWidget({
|
||||
super.key,
|
||||
@ -23,38 +20,23 @@ class FeedListWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PagedSliverList<int, FeedRecord>.separated(
|
||||
return PagedSliverList<int, Post>.separated(
|
||||
addRepaintBoundaries: true,
|
||||
pagingController: controller,
|
||||
builderDelegate: PagedChildBuilderDelegate<FeedRecord>(
|
||||
builderDelegate: PagedChildBuilderDelegate<Post>(
|
||||
itemBuilder: (context, item, index) {
|
||||
return SizedContainer(
|
||||
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();
|
||||
},
|
||||
);
|
||||
case 'article':
|
||||
final data = Article.fromJson(item.data);
|
||||
return ArticleListEntryWidget(
|
||||
isClickable: isClickable,
|
||||
item: data,
|
||||
onUpdate: () {
|
||||
controller.refresh();
|
||||
},
|
||||
);
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
return PostListEntryWidget(
|
||||
isShowEmbed: isShowEmbed,
|
||||
isNestedClickable: isNestedClickable,
|
||||
isClickable: isClickable,
|
||||
item: item,
|
||||
onUpdate: () {
|
||||
controller.refresh();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
@ -173,8 +173,8 @@ class _PostDeletionDialogState extends State<PostDeletionDialog> {
|
||||
return AlertDialog(
|
||||
title: Text('postDeletionConfirm'.tr),
|
||||
content: Text('postDeletionConfirmCaption'.trParams({
|
||||
'content': widget.item.content
|
||||
.substring(0, min(widget.item.content.length, 60))
|
||||
'content': widget.item.body['content']
|
||||
.substring(0, min<int>(widget.item.body['content'].length, 60))
|
||||
.trim(),
|
||||
})),
|
||||
actions: <Widget>[
|
||||
|
@ -86,7 +86,7 @@ class _PostItemState extends State<PostItem> {
|
||||
}
|
||||
if (widget.item.realm != null) {
|
||||
labels.add('postInRealm'.trParams({
|
||||
'realm': '#${widget.item.realm!.alias}',
|
||||
'realm': '#${widget.item.realm!.id}',
|
||||
}));
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ class _PostItemState extends State<PostItem> {
|
||||
child: PostItem(
|
||||
item: widget.item.replyTo!,
|
||||
isCompact: true,
|
||||
overrideAttachmentParent: widget.item.alias,
|
||||
overrideAttachmentParent: widget.item.id.toString(),
|
||||
).paddingSymmetric(vertical: 8),
|
||||
),
|
||||
],
|
||||
@ -173,7 +173,7 @@ class _PostItemState extends State<PostItem> {
|
||||
child: PostItem(
|
||||
item: widget.item.repostTo!,
|
||||
isCompact: true,
|
||||
overrideAttachmentParent: widget.item.alias,
|
||||
overrideAttachmentParent: widget.item.id.toString(),
|
||||
).paddingSymmetric(vertical: 8),
|
||||
),
|
||||
],
|
||||
@ -182,7 +182,7 @@ class _PostItemState extends State<PostItem> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasAttachment = item.attachments?.isNotEmpty ?? false;
|
||||
final hasAttachment = item.body['attachments']?.isNotEmpty ?? false;
|
||||
|
||||
if (widget.isCompact) {
|
||||
return Column(
|
||||
@ -190,7 +190,7 @@ class _PostItemState extends State<PostItem> {
|
||||
children: [
|
||||
buildHeader().paddingSymmetric(horizontal: 12),
|
||||
MarkdownTextContent(
|
||||
content: item.content,
|
||||
content: item.body['content'],
|
||||
isSelectable: widget.isContentSelectable,
|
||||
).paddingOnly(
|
||||
left: 16,
|
||||
@ -199,7 +199,7 @@ class _PostItemState extends State<PostItem> {
|
||||
bottom: hasAttachment ? 4 : 0,
|
||||
),
|
||||
buildFooter().paddingOnly(left: 16),
|
||||
if (item.attachments?.isNotEmpty ?? false)
|
||||
if (item.body['attachments']?.isNotEmpty ?? false)
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
@ -209,7 +209,7 @@ class _PostItemState extends State<PostItem> {
|
||||
).paddingOnly(right: 6),
|
||||
Text(
|
||||
'postAttachmentTip'.trParams(
|
||||
{'count': item.attachments!.length.toString()},
|
||||
{'count': item.body['attachments']!.length.toString()},
|
||||
),
|
||||
style: TextStyle(color: _unFocusColor),
|
||||
)
|
||||
@ -245,7 +245,7 @@ class _PostItemState extends State<PostItem> {
|
||||
children: [
|
||||
buildHeader(),
|
||||
MarkdownTextContent(
|
||||
content: item.content,
|
||||
content: item.body['content'],
|
||||
isSelectable: widget.isContentSelectable,
|
||||
).paddingOnly(left: 12, right: 8),
|
||||
if (widget.item.replyTo != null && widget.isShowEmbed)
|
||||
@ -256,7 +256,7 @@ class _PostItemState extends State<PostItem> {
|
||||
AppRouter.instance.pushNamed(
|
||||
'postDetail',
|
||||
pathParameters: {
|
||||
'alias': widget.item.replyTo!.alias,
|
||||
'id': widget.item.replyTo!.id.toString(),
|
||||
},
|
||||
);
|
||||
},
|
||||
@ -269,7 +269,7 @@ class _PostItemState extends State<PostItem> {
|
||||
AppRouter.instance.pushNamed(
|
||||
'postDetail',
|
||||
pathParameters: {
|
||||
'alias': widget.item.repostTo!.alias,
|
||||
'alias': widget.item.repostTo!.id.toString(),
|
||||
},
|
||||
);
|
||||
},
|
||||
@ -292,8 +292,8 @@ class _PostItemState extends State<PostItem> {
|
||||
maxWidth: 640,
|
||||
),
|
||||
child: AttachmentList(
|
||||
parentId: widget.item.alias,
|
||||
attachmentsId: item.attachments ?? List.empty(),
|
||||
parentId: widget.item.id.toString(),
|
||||
attachmentsId: item.body['attachments'].cast<int>() ?? List.empty(),
|
||||
divided: true,
|
||||
),
|
||||
),
|
||||
|
@ -66,7 +66,7 @@ class PostListEntryWidget extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
child: PostItem(
|
||||
key: Key('p${item.alias}'),
|
||||
key: Key('p${item.id}'),
|
||||
item: item,
|
||||
isShowEmbed: isShowEmbed,
|
||||
isClickable: isNestedClickable,
|
||||
@ -75,7 +75,7 @@ class PostListEntryWidget extends StatelessWidget {
|
||||
if (!isClickable) return;
|
||||
AppRouter.instance.pushNamed(
|
||||
'postDetail',
|
||||
pathParameters: {'alias': item.alias},
|
||||
pathParameters: {'id': item.id.toString()},
|
||||
);
|
||||
},
|
||||
onLongPress: () {
|
||||
|
@ -22,7 +22,7 @@ class PostOwnedListEntry extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
PostItem(
|
||||
key: Key('p${item.alias}'),
|
||||
key: Key('p${item.id}'),
|
||||
item: item,
|
||||
isShowEmbed: false,
|
||||
isClickable: false,
|
||||
|
@ -53,7 +53,7 @@ class _PostQuickActionState extends State<PostQuickAction> {
|
||||
|
||||
setState(() => _isSubmitting = true);
|
||||
|
||||
final resp = await client.post('/posts/${widget.item.alias}/react', {
|
||||
final resp = await client.post('/posts/${widget.item.id}/react', {
|
||||
'symbol': symbol,
|
||||
'attitude': attitude,
|
||||
});
|
||||
|
@ -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/feed.dart';
|
||||
import 'package:solian/providers/content/posts.dart';
|
||||
import 'package:solian/widgets/posts/post_list.dart';
|
||||
|
||||
class PostReplyList extends StatefulWidget {
|
||||
@ -23,11 +23,11 @@ class _PostReplyListState extends State<PostReplyList> {
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
Future<void> getReplies(int pageKey) async {
|
||||
final FeedProvider provider = Get.find();
|
||||
final PostProvider provider = Get.find();
|
||||
|
||||
Response resp;
|
||||
try {
|
||||
resp = await provider.listPostReplies(widget.item.alias, pageKey);
|
||||
resp = await provider.listPostReplies(widget.item.id.toString(), pageKey);
|
||||
} catch (e) {
|
||||
_pagingController.error = e;
|
||||
return;
|
||||
|
Reference in New Issue
Block a user