⬆️ Support latest version of server
This commit is contained in:
@ -1,68 +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/providers/content/feed.dart';
|
||||
import 'package:solian/widgets/articles/article_item.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
|
||||
class ArticleDetailScreen extends StatefulWidget {
|
||||
final String alias;
|
||||
|
||||
const ArticleDetailScreen({super.key, required this.alias});
|
||||
|
||||
@override
|
||||
State<ArticleDetailScreen> createState() => _ArticleDetailScreenState();
|
||||
}
|
||||
|
||||
class _ArticleDetailScreenState extends State<ArticleDetailScreen> {
|
||||
Article? item;
|
||||
|
||||
Future<Article?> getDetail() async {
|
||||
final FeedProvider provider = Get.find();
|
||||
|
||||
try {
|
||||
final resp = await provider.getArticle(widget.alias);
|
||||
item = Article.fromJson(resp.body);
|
||||
} catch (e) {
|
||||
context.showErrorDialog(e).then((_) => Navigator.pop(context));
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: FutureBuilder(
|
||||
future: getDetail(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData || snapshot.data == null) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: CenteredContainer(
|
||||
child: ArticleItem(
|
||||
item: item!,
|
||||
isClickable: true,
|
||||
isFullDate: true,
|
||||
isFullContent: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(height: MediaQuery.of(context).padding.bottom),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,298 +0,0 @@
|
||||
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/models/realm.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/app_bar_leading.dart';
|
||||
import 'package:solian/widgets/app_bar_title.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_publish.dart';
|
||||
import 'package:solian/widgets/feed/feed_tags_field.dart';
|
||||
import 'package:textfield_tags/textfield_tags.dart';
|
||||
import 'package:badges/badges.dart' as badges;
|
||||
|
||||
class ArticlePublishArguments {
|
||||
final Article? edit;
|
||||
final Realm? realm;
|
||||
|
||||
ArticlePublishArguments({this.edit, this.realm});
|
||||
}
|
||||
|
||||
class ArticlePublishScreen extends StatefulWidget {
|
||||
final Article? edit;
|
||||
final Realm? realm;
|
||||
|
||||
const ArticlePublishScreen({
|
||||
super.key,
|
||||
this.edit,
|
||||
this.realm,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ArticlePublishScreen> createState() => _ArticlePublishScreenState();
|
||||
}
|
||||
|
||||
class _ArticlePublishScreenState extends State<ArticlePublishScreen> {
|
||||
final _titleController = TextEditingController();
|
||||
final _descriptionController = TextEditingController();
|
||||
final _contentController = TextEditingController();
|
||||
final _tagsController = StringTagController();
|
||||
|
||||
bool _isBusy = false;
|
||||
|
||||
List<int> _attachments = List.empty();
|
||||
|
||||
bool _isDraft = false;
|
||||
|
||||
void showAttachments() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => AttachmentPublishPopup(
|
||||
usage: 'i.attachment',
|
||||
current: _attachments,
|
||||
onUpdate: (value) {
|
||||
setState(() => _attachments = value);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void applyPost() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
if (!await auth.isAuthorized) return;
|
||||
if (_contentController.value.text.isEmpty) return;
|
||||
|
||||
setState(() => _isBusy = true);
|
||||
|
||||
final client = auth.configureClient('interactive');
|
||||
|
||||
final payload = {
|
||||
'title': _titleController.value.text,
|
||||
'description': _descriptionController.value.text,
|
||||
'content': _contentController.value.text,
|
||||
'tags': _tagsController.getTags?.map((x) => {'alias': x}).toList() ??
|
||||
List.empty(),
|
||||
'attachments': _attachments,
|
||||
'is_draft': _isDraft,
|
||||
if (widget.edit != null) 'alias': widget.edit!.alias,
|
||||
if (widget.realm != null) 'realm': widget.realm!.alias,
|
||||
};
|
||||
|
||||
Response resp;
|
||||
if (widget.edit != null) {
|
||||
resp = await client.put('/articles/${widget.edit!.id}', payload);
|
||||
} else {
|
||||
resp = await client.post('/articles', payload);
|
||||
}
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
} else {
|
||||
AppRouter.instance.pop(resp.body);
|
||||
}
|
||||
|
||||
setState(() => _isBusy = false);
|
||||
}
|
||||
|
||||
void syncWidget() {
|
||||
if (widget.edit != null) {
|
||||
_titleController.text = widget.edit!.title;
|
||||
_descriptionController.text = widget.edit!.description;
|
||||
_contentController.text = widget.edit!.content;
|
||||
_attachments = widget.edit!.attachments ?? List.empty();
|
||||
_isDraft = widget.edit!.isDraft ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
void cancelAction() {
|
||||
AppRouter.instance.pop();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
syncWidget();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final notifyBannerActions = [
|
||||
TextButton(
|
||||
onPressed: cancelAction,
|
||||
child: Text('cancel'.tr),
|
||||
)
|
||||
];
|
||||
|
||||
return Material(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: AppBarLeadingButton.adaptive(context),
|
||||
title: AppBarTitle('articlePublish'.tr),
|
||||
centerTitle: false,
|
||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _isBusy ? null : () => applyPost(),
|
||||
child: Text(
|
||||
_isDraft
|
||||
? 'draftSave'.tr.toUpperCase()
|
||||
: 'postAction'.tr.toUpperCase(),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Stack(
|
||||
children: [
|
||||
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),
|
||||
dividerColor: Colors.transparent,
|
||||
content: Text('postEditingNotify'.tr),
|
||||
actions: notifyBannerActions,
|
||||
),
|
||||
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: 6),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: TextField(
|
||||
maxLines: null,
|
||||
autofocus: true,
|
||||
autocorrect: true,
|
||||
controller: _titleController,
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'articleTitlePlaceholder'.tr,
|
||||
),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
const Divider(thickness: 0.3, height: 0.3)
|
||||
.paddingOnly(bottom: 6),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: TextField(
|
||||
minLines: 1,
|
||||
maxLines: 3,
|
||||
autofocus: true,
|
||||
autocorrect: true,
|
||||
keyboardType: TextInputType.multiline,
|
||||
controller: _descriptionController,
|
||||
decoration: InputDecoration.collapsed(
|
||||
hintText: 'articleDescriptionPlaceholder'.tr,
|
||||
),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
const Divider(thickness: 0.3, height: 0.3)
|
||||
.paddingSymmetric(vertical: 6),
|
||||
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: 'articleContentPlaceholder'.tr,
|
||||
),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 120),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Material(
|
||||
elevation: 8,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Column(
|
||||
children: [
|
||||
TagsField(
|
||||
initialTags:
|
||||
widget.edit?.tags?.map((x) => x.alias).toList(),
|
||||
tagsController: _tagsController,
|
||||
hintText: 'postTagsPlaceholder'.tr,
|
||||
),
|
||||
const Divider(thickness: 0.3, height: 0.3),
|
||||
SizedBox(
|
||||
height: 56,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: _isDraft
|
||||
? const Icon(Icons.drive_file_rename_outline)
|
||||
: const Icon(Icons.public),
|
||||
color: _isDraft
|
||||
? Colors.grey.shade600
|
||||
: Colors.green.shade700,
|
||||
onPressed: () {
|
||||
setState(() => _isDraft = !_isDraft);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: badges.Badge(
|
||||
badgeContent: Text(
|
||||
_attachments.length.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
showBadge: _attachments.isNotEmpty,
|
||||
position: badges.BadgePosition.topEnd(
|
||||
top: -12,
|
||||
end: -8,
|
||||
),
|
||||
child: const Icon(Icons.camera_alt),
|
||||
),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
onPressed: () => showAttachments(),
|
||||
),
|
||||
],
|
||||
).paddingSymmetric(horizontal: 6, vertical: 8),
|
||||
),
|
||||
],
|
||||
).paddingOnly(bottom: MediaQuery.of(context).padding.bottom),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_titleController.dispose();
|
||||
_descriptionController.dispose();
|
||||
_contentController.dispose();
|
||||
_tagsController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
@ -1,17 +1,13 @@
|
||||
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/models/feed.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/screens/home.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
import 'package:solian/widgets/app_bar_leading.dart';
|
||||
import 'package:solian/widgets/app_bar_title.dart';
|
||||
import 'package:solian/widgets/articles/article_action.dart';
|
||||
import 'package:solian/widgets/articles/article_owned_list.dart';
|
||||
import 'package:solian/widgets/posts/post_action.dart';
|
||||
import 'package:solian/widgets/posts/post_owned_list.dart';
|
||||
|
||||
@ -23,11 +19,11 @@ class DraftBoxScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DraftBoxScreenState extends State<DraftBoxScreen> {
|
||||
final PagingController<int, FeedRecord> _pagingController =
|
||||
final PagingController<int, Post> _pagingController =
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
getPosts(int pageKey) async {
|
||||
final FeedProvider provider = Get.find();
|
||||
final PostProvider provider = Get.find();
|
||||
|
||||
Response resp;
|
||||
try {
|
||||
@ -43,7 +39,7 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
|
||||
return;
|
||||
}
|
||||
|
||||
final parsed = result.data?.map((e) => FeedRecord.fromJson(e)).toList();
|
||||
final parsed = result.data?.map((e) => Post.fromJson(e)).toList();
|
||||
if (parsed != null && parsed.length >= 10) {
|
||||
_pagingController.appendPage(parsed, pageKey + parsed.length);
|
||||
} else if (parsed != null) {
|
||||
@ -79,45 +75,25 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
||||
child: PagedListView<int, FeedRecord>(
|
||||
child: PagedListView<int, Post>(
|
||||
pagingController: _pagingController,
|
||||
builderDelegate: PagedChildBuilderDelegate(
|
||||
itemBuilder: (context, item, index) {
|
||||
switch (item.type) {
|
||||
case 'post':
|
||||
final data = Post.fromJson(item.data);
|
||||
return PostOwnedListEntry(
|
||||
item: data,
|
||||
onTap: () async {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => PostAction(
|
||||
item: data,
|
||||
noReact: true,
|
||||
),
|
||||
).then((value) {
|
||||
if (value != null) _pagingController.refresh();
|
||||
});
|
||||
},
|
||||
).paddingOnly(left: 12, right: 12, bottom: 4);
|
||||
case 'article':
|
||||
final data = Article.fromJson(item.data);
|
||||
return ArticleOwnedListEntry(
|
||||
item: data,
|
||||
onTap: () async {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => ArticleAction(item: data),
|
||||
).then((value) {
|
||||
if (value != null) _pagingController.refresh();
|
||||
});
|
||||
},
|
||||
).paddingOnly(left: 12, right: 12, bottom: 4);
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
return PostOwnedListEntry(
|
||||
item: item,
|
||||
onTap: () async {
|
||||
showModalBottomSheet(
|
||||
useRootNavigator: true,
|
||||
context: context,
|
||||
builder: (context) => PostAction(
|
||||
item: item,
|
||||
noReact: true,
|
||||
),
|
||||
).then((value) {
|
||||
if (value != null) _pagingController.refresh();
|
||||
});
|
||||
},
|
||||
).paddingOnly(left: 12, right: 12, bottom: 4);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -1,11 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/providers/content/feed.dart';
|
||||
import 'package:solian/providers/content/posts.dart';
|
||||
import 'package:solian/widgets/feed/feed_list.dart';
|
||||
|
||||
import '../../models/post.dart';
|
||||
|
||||
class FeedSearchScreen extends StatefulWidget {
|
||||
final String? tag;
|
||||
final String? category;
|
||||
@ -17,15 +18,15 @@ class FeedSearchScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _FeedSearchScreenState extends State<FeedSearchScreen> {
|
||||
final PagingController<int, FeedRecord> _pagingController =
|
||||
final PagingController<int, Post> _pagingController =
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
getPosts(int pageKey) async {
|
||||
final FeedProvider provider = Get.find();
|
||||
final PostProvider provider = Get.find();
|
||||
|
||||
Response resp;
|
||||
try {
|
||||
resp = await provider.listFeed(
|
||||
resp = await provider.listRecommendations(
|
||||
pageKey,
|
||||
tag: widget.tag,
|
||||
category: widget.category,
|
||||
@ -36,7 +37,7 @@ class _FeedSearchScreenState extends State<FeedSearchScreen> {
|
||||
}
|
||||
|
||||
final PaginationResult result = PaginationResult.fromJson(resp.body);
|
||||
final parsed = result.data?.map((e) => FeedRecord.fromJson(e)).toList();
|
||||
final parsed = result.data?.map((e) => Post.fromJson(e)).toList();
|
||||
if (parsed != null && parsed.length >= 10) {
|
||||
_pagingController.appendPage(parsed, pageKey + parsed.length);
|
||||
} else if (parsed != null) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/feed.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/content/feed.dart';
|
||||
import 'package:solian/providers/content/posts.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/account/notification.dart';
|
||||
import 'package:solian/theme.dart';
|
||||
@ -21,22 +21,22 @@ class HomeScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
final PagingController<int, FeedRecord> _pagingController =
|
||||
final PagingController<int, Post> _pagingController =
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
getPosts(int pageKey) async {
|
||||
final FeedProvider provider = Get.find();
|
||||
final PostProvider provider = Get.find();
|
||||
|
||||
Response resp;
|
||||
try {
|
||||
resp = await provider.listFeed(pageKey);
|
||||
resp = await provider.listRecommendations(pageKey);
|
||||
} catch (e) {
|
||||
_pagingController.error = e;
|
||||
return;
|
||||
}
|
||||
|
||||
final PaginationResult result = PaginationResult.fromJson(resp.body);
|
||||
final parsed = result.data?.map((e) => FeedRecord.fromJson(e)).toList();
|
||||
final parsed = result.data?.map((e) => Post.fromJson(e)).toList();
|
||||
if (parsed != null && parsed.length >= 10) {
|
||||
_pagingController.appendPage(parsed, pageKey + parsed.length);
|
||||
} else if (parsed != null) {
|
||||
@ -128,20 +128,6 @@ class FeedCreationButton extends StatelessWidget {
|
||||
});
|
||||
},
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: ListTile(
|
||||
title: Text('articleEditor'.tr),
|
||||
leading: const Icon(Icons.newspaper),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
),
|
||||
onTap: () {
|
||||
AppRouter.instance.pushNamed('articleEditor').then((val) {
|
||||
if (val != null && onCreated != null) {
|
||||
onCreated!();
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
if (!hideDraftBox)
|
||||
PopupMenuItem(
|
||||
child: ListTile(
|
||||
|
@ -2,15 +2,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/exts.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/sized_container.dart';
|
||||
import 'package:solian/widgets/posts/post_item.dart';
|
||||
import 'package:solian/widgets/posts/post_replies.dart';
|
||||
|
||||
class PostDetailScreen extends StatefulWidget {
|
||||
final String alias;
|
||||
final String id;
|
||||
|
||||
const PostDetailScreen({super.key, required this.alias});
|
||||
const PostDetailScreen({super.key, required this.id});
|
||||
|
||||
@override
|
||||
State<PostDetailScreen> createState() => _PostDetailScreenState();
|
||||
@ -20,10 +20,10 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
Post? item;
|
||||
|
||||
Future<Post?> getDetail() async {
|
||||
final FeedProvider provider = Get.find();
|
||||
final PostProvider provider = Get.find();
|
||||
|
||||
try {
|
||||
final resp = await provider.getPost(widget.alias);
|
||||
final resp = await provider.getPost(widget.id);
|
||||
item = Post.fromJson(resp.body);
|
||||
} catch (e) {
|
||||
context.showErrorDialog(e).then((_) => Navigator.pop(context));
|
||||
|
@ -82,7 +82,6 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
List.empty(),
|
||||
'attachments': _attachments,
|
||||
'is_draft': _isDraft,
|
||||
if (widget.edit != null) 'alias': widget.edit!.alias,
|
||||
if (widget.reply != null) 'reply_to': widget.reply!.id,
|
||||
if (widget.repost != null) 'repost_to': widget.repost!.id,
|
||||
if (widget.realm != null) 'realm': widget.realm!.alias,
|
||||
@ -90,9 +89,9 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
|
||||
Response resp;
|
||||
if (widget.edit != null) {
|
||||
resp = await client.put('/posts/${widget.edit!.id}', payload);
|
||||
resp = await client.put('/stories/${widget.edit!.id}', payload);
|
||||
} else {
|
||||
resp = await client.post('/posts', payload);
|
||||
resp = await client.post('/stories', payload);
|
||||
}
|
||||
if (resp.statusCode != 200) {
|
||||
context.showErrorDialog(resp.bodyString);
|
||||
@ -105,8 +104,8 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
||||
|
||||
void syncWidget() {
|
||||
if (widget.edit != null) {
|
||||
_contentController.text = widget.edit!.content;
|
||||
_attachments = widget.edit!.attachments ?? List.empty();
|
||||
_contentController.text = widget.edit!.body['content'];
|
||||
_attachments = widget.edit!.body['attachments'] ?? List.empty();
|
||||
_isDraft = widget.edit!.isDraft ?? false;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import 'package:solian/models/post.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/content/channel.dart';
|
||||
import 'package:solian/providers/content/feed.dart';
|
||||
import 'package:solian/providers/content/posts.dart';
|
||||
import 'package:solian/providers/content/realm.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/channel/channel_organize.dart';
|
||||
@ -167,7 +167,7 @@ class _RealmPostListWidgetState extends State<RealmPostListWidget> {
|
||||
PagingController(firstPageKey: 0);
|
||||
|
||||
getPosts(int pageKey) async {
|
||||
final FeedProvider provider = Get.find();
|
||||
final PostProvider provider = Get.find();
|
||||
|
||||
Response resp;
|
||||
try {
|
||||
|
Reference in New Issue
Block a user