Compare commits
No commits in common. "a157596a2eccfe30b33450a5ade64d004c9cda4c" and "53b3cac4ca1291814037d54ab93acd22e2dc6b39" have entirely different histories.
a157596a2e
...
53b3cac4ca
@ -104,6 +104,7 @@ abstract class AppRouter {
|
|||||||
reply: arguments?.reply,
|
reply: arguments?.reply,
|
||||||
repost: arguments?.repost,
|
repost: arguments?.repost,
|
||||||
realm: arguments?.realm,
|
realm: arguments?.realm,
|
||||||
|
postListController: arguments?.postListController,
|
||||||
mode: int.tryParse(state.uri.queryParameters['mode'] ?? '0') ?? 0,
|
mode: int.tryParse(state.uri.queryParameters['mode'] ?? '0') ?? 0,
|
||||||
),
|
),
|
||||||
transitionsBuilder:
|
transitionsBuilder:
|
||||||
|
@ -300,7 +300,6 @@ class _AccountProfilePageState extends State<AccountProfilePage> {
|
|||||||
PostWarpedListWidget(
|
PostWarpedListWidget(
|
||||||
isPinned: false,
|
isPinned: false,
|
||||||
controller: _postController.pagingController,
|
controller: _postController.pagingController,
|
||||||
onUpdate: () => _postController.reloadAllOver(),
|
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
@ -76,8 +76,6 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
|
|||||||
itemBuilder: (context, item, index) {
|
itemBuilder: (context, item, index) {
|
||||||
return PostOwnedListEntry(
|
return PostOwnedListEntry(
|
||||||
item: item,
|
item: item,
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.surfaceContainerLow,
|
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
@ -87,13 +85,7 @@ class _DraftBoxScreenState extends State<DraftBoxScreen> {
|
|||||||
noReact: true,
|
noReact: true,
|
||||||
),
|
),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value is Future) {
|
if (value != null) _pagingController.refresh();
|
||||||
value.then((_) {
|
|
||||||
_pagingController.refresh();
|
|
||||||
});
|
|
||||||
} else if (value != null) {
|
|
||||||
_pagingController.refresh();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
).paddingOnly(left: 12, right: 12, bottom: 4);
|
).paddingOnly(left: 12, right: 12, bottom: 4);
|
||||||
|
@ -77,10 +77,7 @@ class _FeedSearchScreenState extends State<FeedSearchScreen> {
|
|||||||
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
onRefresh: () => Future.sync(() => _pagingController.refresh()),
|
||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
PostWarpedListWidget(
|
PostWarpedListWidget(controller: _pagingController),
|
||||||
controller: _pagingController,
|
|
||||||
onUpdate: () => _pagingController.refresh(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -4,6 +4,7 @@ import 'package:solian/controllers/post_list_controller.dart';
|
|||||||
import 'package:solian/providers/auth.dart';
|
import 'package:solian/providers/auth.dart';
|
||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
import 'package:solian/screens/account/notification.dart';
|
import 'package:solian/screens/account/notification.dart';
|
||||||
|
import 'package:solian/screens/posts/post_editor.dart';
|
||||||
import 'package:solian/theme.dart';
|
import 'package:solian/theme.dart';
|
||||||
import 'package:solian/widgets/app_bar_title.dart';
|
import 'package:solian/widgets/app_bar_title.dart';
|
||||||
import 'package:solian/widgets/current_state_action.dart';
|
import 'package:solian/widgets/current_state_action.dart';
|
||||||
@ -46,20 +47,15 @@ class _HomeScreenState extends State<HomeScreen>
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
onPressed: () async {
|
onPressed: () {
|
||||||
final value = await showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
useRootNavigator: true,
|
useRootNavigator: true,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => const PostCreatePopup(),
|
builder: (context) => PostCreatePopup(
|
||||||
|
controller: _postController,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (value is Future) {
|
|
||||||
value.then((_) {
|
|
||||||
_postController.reloadAllOver();
|
|
||||||
});
|
|
||||||
} else if (value != null) {
|
|
||||||
_postController.reloadAllOver();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
body: NestedScrollView(
|
body: NestedScrollView(
|
||||||
@ -104,7 +100,6 @@ class _HomeScreenState extends State<HomeScreen>
|
|||||||
child: CustomScrollView(slivers: [
|
child: CustomScrollView(slivers: [
|
||||||
PostWarpedListWidget(
|
PostWarpedListWidget(
|
||||||
controller: _postController.pagingController,
|
controller: _postController.pagingController,
|
||||||
onUpdate: () => _postController.reloadAllOver(),
|
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
@ -126,10 +121,12 @@ class _HomeScreenState extends State<HomeScreen>
|
|||||||
|
|
||||||
class PostCreatePopup extends StatelessWidget {
|
class PostCreatePopup extends StatelessWidget {
|
||||||
final bool hideDraftBox;
|
final bool hideDraftBox;
|
||||||
|
final PostListController controller;
|
||||||
|
|
||||||
const PostCreatePopup({
|
const PostCreatePopup({
|
||||||
super.key,
|
super.key,
|
||||||
this.hideDraftBox = false,
|
this.hideDraftBox = false,
|
||||||
|
required this.controller,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -145,14 +142,13 @@ class PostCreatePopup extends StatelessWidget {
|
|||||||
icon: const Icon(Icons.post_add),
|
icon: const Icon(Icons.post_add),
|
||||||
label: 'postEditorModeStory'.tr,
|
label: 'postEditorModeStory'.tr,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(
|
Navigator.pop(context);
|
||||||
context,
|
AppRouter.instance.pushNamed(
|
||||||
AppRouter.instance.pushNamed(
|
'postEditor',
|
||||||
'postEditor',
|
extra: PostPublishArguments(postListController: controller),
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'mode': 0.toString(),
|
'mode': 0.toString(),
|
||||||
},
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -160,14 +156,13 @@ class PostCreatePopup extends StatelessWidget {
|
|||||||
icon: const Icon(Icons.description),
|
icon: const Icon(Icons.description),
|
||||||
label: 'postEditorModeArticle'.tr,
|
label: 'postEditorModeArticle'.tr,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(
|
Navigator.pop(context);
|
||||||
context,
|
AppRouter.instance.pushNamed(
|
||||||
AppRouter.instance.pushNamed(
|
'postEditor',
|
||||||
'postEditor',
|
extra: PostPublishArguments(postListController: controller),
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'mode': 1.toString(),
|
'mode': 1.toString(),
|
||||||
},
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -175,10 +170,8 @@ class PostCreatePopup extends StatelessWidget {
|
|||||||
icon: const Icon(Icons.drafts),
|
icon: const Icon(Icons.drafts),
|
||||||
label: 'draftBoxOpen'.tr,
|
label: 'draftBoxOpen'.tr,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(
|
Navigator.pop(context);
|
||||||
context,
|
AppRouter.instance.pushNamed('draftBox');
|
||||||
AppRouter.instance.pushNamed('draftBox'),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
@ -61,7 +61,6 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
|||||||
item: item!,
|
item: item!,
|
||||||
isClickable: true,
|
isClickable: true,
|
||||||
isFullDate: true,
|
isFullDate: true,
|
||||||
isFullContent: true,
|
|
||||||
isShowReply: false,
|
isShowReply: false,
|
||||||
isContentSelectable: true,
|
isContentSelectable: true,
|
||||||
),
|
),
|
||||||
|
@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:markdown_toolbar/markdown_toolbar.dart';
|
import 'package:markdown_toolbar/markdown_toolbar.dart';
|
||||||
import 'package:solian/controllers/post_editor_controller.dart';
|
import 'package:solian/controllers/post_editor_controller.dart';
|
||||||
|
import 'package:solian/controllers/post_list_controller.dart';
|
||||||
import 'package:solian/exts.dart';
|
import 'package:solian/exts.dart';
|
||||||
import 'package:solian/models/post.dart';
|
import 'package:solian/models/post.dart';
|
||||||
import 'package:solian/models/realm.dart';
|
import 'package:solian/models/realm.dart';
|
||||||
@ -22,12 +23,14 @@ class PostPublishArguments {
|
|||||||
final Post? reply;
|
final Post? reply;
|
||||||
final Post? repost;
|
final Post? repost;
|
||||||
final Realm? realm;
|
final Realm? realm;
|
||||||
|
final PostListController? postListController;
|
||||||
|
|
||||||
PostPublishArguments({
|
PostPublishArguments({
|
||||||
this.edit,
|
this.edit,
|
||||||
this.reply,
|
this.reply,
|
||||||
this.repost,
|
this.repost,
|
||||||
this.realm,
|
this.realm,
|
||||||
|
this.postListController,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +39,7 @@ class PostPublishScreen extends StatefulWidget {
|
|||||||
final Post? reply;
|
final Post? reply;
|
||||||
final Post? repost;
|
final Post? repost;
|
||||||
final Realm? realm;
|
final Realm? realm;
|
||||||
|
final PostListController? postListController;
|
||||||
final int mode;
|
final int mode;
|
||||||
|
|
||||||
const PostPublishScreen({
|
const PostPublishScreen({
|
||||||
@ -44,6 +48,7 @@ class PostPublishScreen extends StatefulWidget {
|
|||||||
this.reply,
|
this.reply,
|
||||||
this.repost,
|
this.repost,
|
||||||
this.realm,
|
this.realm,
|
||||||
|
this.postListController,
|
||||||
required this.mode,
|
required this.mode,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,6 +95,9 @@ class _PostPublishScreenState extends State<PostPublishScreen> {
|
|||||||
context.showErrorDialog(resp.bodyString);
|
context.showErrorDialog(resp.bodyString);
|
||||||
} else {
|
} else {
|
||||||
_editorController.localClear();
|
_editorController.localClear();
|
||||||
|
if (widget.postListController != null) {
|
||||||
|
widget.postListController!.reloadAllOver();
|
||||||
|
}
|
||||||
AppRouter.instance.pop(resp.body);
|
AppRouter.instance.pop(resp.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,5 +361,4 @@ const i18nEnglish = {
|
|||||||
'stickerUploaderName': 'Name',
|
'stickerUploaderName': 'Name',
|
||||||
'stickerUploaderNameHint':
|
'stickerUploaderNameHint':
|
||||||
'A human-friendly name given to the user in the sticker selection interface.',
|
'A human-friendly name given to the user in the sticker selection interface.',
|
||||||
'readMore': 'Read more',
|
|
||||||
};
|
};
|
||||||
|
@ -329,5 +329,4 @@ const i18nSimplifiedChinese = {
|
|||||||
'stickerUploaderAliasHint': '将会在输入时使用和贴图包前缀组成占位符。',
|
'stickerUploaderAliasHint': '将会在输入时使用和贴图包前缀组成占位符。',
|
||||||
'stickerUploaderName': '贴图名称',
|
'stickerUploaderName': '贴图名称',
|
||||||
'stickerUploaderNameHint': '在贴图选择界面提供给用户的人类友好名称。',
|
'stickerUploaderNameHint': '在贴图选择界面提供给用户的人类友好名称。',
|
||||||
'readMore': '阅读更多',
|
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
import 'package:solian/exts.dart';
|
||||||
import 'package:solian/models/account.dart';
|
import 'package:solian/models/account.dart';
|
||||||
import 'package:solian/providers/account_status.dart';
|
import 'package:solian/providers/account_status.dart';
|
||||||
import 'package:solian/router.dart';
|
import 'package:solian/router.dart';
|
||||||
@ -17,38 +18,23 @@ class AccountProfilePopup extends StatefulWidget {
|
|||||||
|
|
||||||
class _AccountProfilePopupState extends State<AccountProfilePopup> {
|
class _AccountProfilePopupState extends State<AccountProfilePopup> {
|
||||||
bool _isBusy = true;
|
bool _isBusy = true;
|
||||||
dynamic _hasError;
|
|
||||||
|
|
||||||
Account? _userinfo;
|
Account? _userinfo;
|
||||||
|
|
||||||
void _getUserinfo() async {
|
void _getUserinfo() async {
|
||||||
setState(() => _isBusy = true);
|
setState(() => _isBusy = true);
|
||||||
|
|
||||||
try {
|
final client = ServiceFinder.configureClient('auth');
|
||||||
final client = ServiceFinder.configureClient('auth');
|
final resp = await client.get('/users/${widget.name}');
|
||||||
final resp = await client.get('/users/${widget.name}');
|
if (resp.statusCode == 200) {
|
||||||
if (resp.statusCode == 200) {
|
_userinfo = Account.fromJson(resp.body);
|
||||||
setState(() {
|
setState(() => _isBusy = false);
|
||||||
_userinfo = Account.fromJson(resp.body);
|
} else {
|
||||||
_isBusy = false;
|
context.showErrorDialog(resp.bodyString);
|
||||||
});
|
Navigator.pop(context);
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
_hasError = resp.bodyString;
|
|
||||||
_isBusy = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
setState(() {
|
|
||||||
_hasError = e;
|
|
||||||
_isBusy = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color get _unFocusColor =>
|
|
||||||
Theme.of(context).colorScheme.onSurface.withOpacity(0.75);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -57,35 +43,13 @@ class _AccountProfilePopupState extends State<AccountProfilePopup> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (_isBusy) {
|
if (_isBusy || _userinfo == null) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.75,
|
height: MediaQuery.of(context).size.height * 0.75,
|
||||||
child: const Center(child: CircularProgressIndicator()),
|
child: const Center(child: CircularProgressIndicator()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_hasError != null) {
|
|
||||||
return SizedBox(
|
|
||||||
height: MediaQuery.of(context).size.height * 0.75,
|
|
||||||
width: double.infinity,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.cancel, size: 24),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
_hasError.toString(),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
color: _unFocusColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.75,
|
height: MediaQuery.of(context).size.height * 0.75,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
@ -97,13 +97,13 @@ class _PostActionState extends State<PostAction> {
|
|||||||
leading: const FaIcon(FontAwesomeIcons.reply, size: 20),
|
leading: const FaIcon(FontAwesomeIcons.reply, size: 20),
|
||||||
title: Text('reply'.tr),
|
title: Text('reply'.tr),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Navigator.pop(
|
final value = await AppRouter.instance.pushNamed(
|
||||||
context,
|
'postEditor',
|
||||||
AppRouter.instance.pushNamed(
|
extra: PostPublishArguments(reply: widget.item),
|
||||||
'postEditor',
|
|
||||||
extra: PostPublishArguments(reply: widget.item),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
if (value != null) {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (!widget.noReact)
|
if (!widget.noReact)
|
||||||
@ -112,13 +112,13 @@ class _PostActionState extends State<PostAction> {
|
|||||||
leading: const FaIcon(FontAwesomeIcons.retweet, size: 20),
|
leading: const FaIcon(FontAwesomeIcons.retweet, size: 20),
|
||||||
title: Text('repost'.tr),
|
title: Text('repost'.tr),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Navigator.pop(
|
final value = await AppRouter.instance.pushNamed(
|
||||||
context,
|
'postEditor',
|
||||||
AppRouter.instance.pushNamed(
|
extra: PostPublishArguments(repost: widget.item),
|
||||||
'postEditor',
|
|
||||||
extra: PostPublishArguments(repost: widget.item),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
if (value != null) {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (_canModifyContent && !widget.noReact)
|
if (_canModifyContent && !widget.noReact)
|
||||||
@ -146,13 +146,13 @@ class _PostActionState extends State<PostAction> {
|
|||||||
leading: const Icon(Icons.edit),
|
leading: const Icon(Icons.edit),
|
||||||
title: Text('edit'.tr),
|
title: Text('edit'.tr),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
Navigator.pop(
|
final value = await AppRouter.instance.pushNamed(
|
||||||
context,
|
'postEditor',
|
||||||
AppRouter.instance.pushNamed(
|
extra: PostPublishArguments(edit: widget.item),
|
||||||
'postEditor',
|
|
||||||
extra: PostPublishArguments(edit: widget.item),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
if (value != null) {
|
||||||
|
Navigator.pop(context, true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (_canModifyContent)
|
if (_canModifyContent)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:animations/animations.dart';
|
import 'package:animations/animations.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get_utils/get_utils.dart';
|
import 'package:get/get_utils/get_utils.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
@ -24,7 +23,6 @@ class PostItem extends StatefulWidget {
|
|||||||
final bool isShowReply;
|
final bool isShowReply;
|
||||||
final bool isShowEmbed;
|
final bool isShowEmbed;
|
||||||
final bool isFullDate;
|
final bool isFullDate;
|
||||||
final bool isFullContent;
|
|
||||||
final bool isContentSelectable;
|
final bool isContentSelectable;
|
||||||
final String? attachmentParent;
|
final String? attachmentParent;
|
||||||
final Color? backgroundColor;
|
final Color? backgroundColor;
|
||||||
@ -38,7 +36,6 @@ class PostItem extends StatefulWidget {
|
|||||||
this.isShowReply = true,
|
this.isShowReply = true,
|
||||||
this.isShowEmbed = true,
|
this.isShowEmbed = true,
|
||||||
this.isFullDate = false,
|
this.isFullDate = false,
|
||||||
this.isFullContent = false,
|
|
||||||
this.isContentSelectable = false,
|
this.isContentSelectable = false,
|
||||||
this.attachmentParent,
|
this.attachmentParent,
|
||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
@ -167,7 +164,6 @@ class _PostItemState extends State<PostItem> {
|
|||||||
|
|
||||||
Widget _buildReply(BuildContext context) {
|
Widget _buildReply(BuildContext context) {
|
||||||
return OpenContainer(
|
return OpenContainer(
|
||||||
tappable: widget.isClickable,
|
|
||||||
closedBuilder: (_, openContainer) => Column(
|
closedBuilder: (_, openContainer) => Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@ -206,15 +202,13 @@ class _PostItemState extends State<PostItem> {
|
|||||||
),
|
),
|
||||||
closedElevation: 0,
|
closedElevation: 0,
|
||||||
openElevation: 0,
|
openElevation: 0,
|
||||||
closedColor:
|
closedColor: widget.backgroundColor ?? Theme.of(context).colorScheme.surface,
|
||||||
widget.backgroundColor ?? Theme.of(context).colorScheme.surface,
|
|
||||||
openColor: Theme.of(context).colorScheme.surface,
|
openColor: Theme.of(context).colorScheme.surface,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildRepost(BuildContext context) {
|
Widget _buildRepost(BuildContext context) {
|
||||||
return OpenContainer(
|
return OpenContainer(
|
||||||
tappable: widget.isClickable,
|
|
||||||
closedBuilder: (_, openContainer) => Column(
|
closedBuilder: (_, openContainer) => Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@ -253,14 +247,11 @@ class _PostItemState extends State<PostItem> {
|
|||||||
),
|
),
|
||||||
closedElevation: 0,
|
closedElevation: 0,
|
||||||
openElevation: 0,
|
openElevation: 0,
|
||||||
closedColor:
|
closedColor: widget.backgroundColor ?? Theme.of(context).colorScheme.surface,
|
||||||
widget.backgroundColor ?? Theme.of(context).colorScheme.surface,
|
|
||||||
openColor: Theme.of(context).colorScheme.surface,
|
openColor: Theme.of(context).colorScheme.surface,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
double _contentHeight = 0;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final List<int> attachments = item.body['attachments'] is List
|
final List<int> attachments = item.body['attachments'] is List
|
||||||
@ -304,7 +295,6 @@ class _PostItemState extends State<PostItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return OpenContainer(
|
return OpenContainer(
|
||||||
tappable: widget.isClickable,
|
|
||||||
closedBuilder: (_, openContainer) => Column(
|
closedBuilder: (_, openContainer) => Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -332,31 +322,11 @@ class _PostItemState extends State<PostItem> {
|
|||||||
_buildHeader(),
|
_buildHeader(),
|
||||||
SizedContainer(
|
SizedContainer(
|
||||||
maxWidth: 640,
|
maxWidth: 640,
|
||||||
maxHeight: widget.isFullContent ? double.infinity : 320,
|
child: MarkdownTextContent(
|
||||||
child: _MeasureSize(
|
content: item.body['content'],
|
||||||
onChange: (size) {
|
isSelectable: widget.isContentSelectable,
|
||||||
_contentHeight = size.height;
|
).paddingOnly(left: 12, right: 8),
|
||||||
},
|
|
||||||
child: MarkdownTextContent(
|
|
||||||
content: item.body['content'],
|
|
||||||
isSelectable: widget.isContentSelectable,
|
|
||||||
).paddingOnly(left: 12, right: 8),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (_contentHeight >= 320 &&
|
|
||||||
widget.isClickable &&
|
|
||||||
!widget.isFullContent)
|
|
||||||
InkWell(
|
|
||||||
child: Text(
|
|
||||||
'readMore'.tr,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
openContainer();
|
|
||||||
},
|
|
||||||
).paddingOnly(left: 12, top: 4),
|
|
||||||
if (widget.item.replyTo != null && widget.isShowEmbed)
|
if (widget.item.replyTo != null && widget.isShowEmbed)
|
||||||
_buildReply(context).paddingOnly(top: 4),
|
_buildReply(context).paddingOnly(top: 4),
|
||||||
if (widget.item.repostTo != null && widget.isShowEmbed)
|
if (widget.item.repostTo != null && widget.isShowEmbed)
|
||||||
@ -407,52 +377,8 @@ class _PostItemState extends State<PostItem> {
|
|||||||
),
|
),
|
||||||
closedElevation: 0,
|
closedElevation: 0,
|
||||||
openElevation: 0,
|
openElevation: 0,
|
||||||
closedColor:
|
closedColor: widget.backgroundColor ?? Theme.of(context).colorScheme.surface,
|
||||||
widget.backgroundColor ?? Theme.of(context).colorScheme.surface,
|
|
||||||
openColor: Theme.of(context).colorScheme.surface,
|
openColor: Theme.of(context).colorScheme.surface,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef _OnWidgetSizeChange = void Function(Size size);
|
|
||||||
|
|
||||||
class _MeasureSizeRenderObject extends RenderProxyBox {
|
|
||||||
Size? oldSize;
|
|
||||||
_OnWidgetSizeChange onChange;
|
|
||||||
|
|
||||||
_MeasureSizeRenderObject(this.onChange);
|
|
||||||
|
|
||||||
@override
|
|
||||||
void performLayout() {
|
|
||||||
super.performLayout();
|
|
||||||
|
|
||||||
Size newSize = child!.size;
|
|
||||||
if (oldSize == newSize) return;
|
|
||||||
|
|
||||||
oldSize = newSize;
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
onChange(newSize);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MeasureSize extends SingleChildRenderObjectWidget {
|
|
||||||
final _OnWidgetSizeChange onChange;
|
|
||||||
|
|
||||||
const _MeasureSize({
|
|
||||||
super.key,
|
|
||||||
required this.onChange,
|
|
||||||
required Widget super.child,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
RenderObject createRenderObject(BuildContext context) {
|
|
||||||
return _MeasureSizeRenderObject(onChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void updateRenderObject(
|
|
||||||
BuildContext context, covariant _MeasureSizeRenderObject renderObject) {
|
|
||||||
renderObject.onChange = onChange;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -85,13 +85,7 @@ class PostListEntryWidget extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) => PostAction(item: item),
|
builder: (context) => PostAction(item: item),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value is Future) {
|
if (value != null) onUpdate();
|
||||||
value.then((_) {
|
|
||||||
onUpdate();
|
|
||||||
});
|
|
||||||
} else if (value != null) {
|
|
||||||
onUpdate();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -6,19 +6,18 @@ import 'package:solian/widgets/posts/post_item.dart';
|
|||||||
class PostOwnedListEntry extends StatelessWidget {
|
class PostOwnedListEntry extends StatelessWidget {
|
||||||
final Post item;
|
final Post item;
|
||||||
final Function onTap;
|
final Function onTap;
|
||||||
final Color? backgroundColor;
|
|
||||||
|
|
||||||
const PostOwnedListEntry({
|
const PostOwnedListEntry({
|
||||||
super.key,
|
super.key,
|
||||||
required this.item,
|
required this.item,
|
||||||
required this.onTap,
|
required this.onTap,
|
||||||
this.backgroundColor,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Card(
|
return Card(
|
||||||
child: GestureDetector(
|
child: InkWell(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -29,7 +28,6 @@ class PostOwnedListEntry extends StatelessWidget {
|
|||||||
isClickable: false,
|
isClickable: false,
|
||||||
isShowReply: false,
|
isShowReply: false,
|
||||||
isReactable: false,
|
isReactable: false,
|
||||||
backgroundColor: backgroundColor,
|
|
||||||
).paddingSymmetric(vertical: 8),
|
).paddingSymmetric(vertical: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -9,7 +9,6 @@ class PostWarpedListWidget extends StatelessWidget {
|
|||||||
final bool isNestedClickable;
|
final bool isNestedClickable;
|
||||||
final bool isPinned;
|
final bool isPinned;
|
||||||
final PagingController<int, Post> controller;
|
final PagingController<int, Post> controller;
|
||||||
final Function? onUpdate;
|
|
||||||
|
|
||||||
const PostWarpedListWidget({
|
const PostWarpedListWidget({
|
||||||
super.key,
|
super.key,
|
||||||
@ -18,7 +17,6 @@ class PostWarpedListWidget extends StatelessWidget {
|
|||||||
this.isClickable = true,
|
this.isClickable = true,
|
||||||
this.isNestedClickable = true,
|
this.isNestedClickable = true,
|
||||||
this.isPinned = true,
|
this.isPinned = true,
|
||||||
this.onUpdate,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -37,7 +35,9 @@ class PostWarpedListWidget extends StatelessWidget {
|
|||||||
isNestedClickable: isNestedClickable,
|
isNestedClickable: isNestedClickable,
|
||||||
isClickable: isClickable,
|
isClickable: isClickable,
|
||||||
item: item,
|
item: item,
|
||||||
onUpdate: onUpdate ?? () {},
|
onUpdate: () {
|
||||||
|
controller.refresh();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -3,13 +3,11 @@ import 'package:flutter/material.dart';
|
|||||||
class SizedContainer extends StatelessWidget {
|
class SizedContainer extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
final double maxWidth;
|
final double maxWidth;
|
||||||
final double maxHeight;
|
|
||||||
|
|
||||||
const SizedContainer({
|
const SizedContainer({
|
||||||
super.key,
|
super.key,
|
||||||
required this.child,
|
required this.child,
|
||||||
this.maxWidth = 720,
|
this.maxWidth = 720,
|
||||||
this.maxHeight = double.infinity,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -17,7 +15,7 @@ class SizedContainer extends StatelessWidget {
|
|||||||
return Align(
|
return Align(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: BoxConstraints(maxWidth: maxWidth, maxHeight: maxHeight),
|
constraints: BoxConstraints(maxWidth: maxWidth),
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
16
pubspec.lock
16
pubspec.lock
@ -385,14 +385,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
field_suggestion:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: field_suggestion
|
|
||||||
sha256: "596362ed67a661a18e01e4f51b8b92424f333baf37cebd48cc647a4c82c858d5"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.5"
|
|
||||||
file:
|
file:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -744,14 +736,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.2"
|
version: "2.3.2"
|
||||||
highlightable:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: highlightable
|
|
||||||
sha256: "526793e148c91977b694d75d99cd34401ea3b65efd223e7b539c76916af86ffd"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.5"
|
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -66,7 +66,6 @@ dependencies:
|
|||||||
animations: ^2.0.11
|
animations: ^2.0.11
|
||||||
avatar_stack: ^1.2.0
|
avatar_stack: ^1.2.0
|
||||||
async: ^2.11.0
|
async: ^2.11.0
|
||||||
field_suggestion: ^0.2.5
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user