💄 Better attachments in posts
This commit is contained in:
parent
0237409d27
commit
6e3d0f9787
@ -175,10 +175,10 @@ class AuthProvider extends GetConnect {
|
||||
value: jsonEncode(credentials!.toJson()),
|
||||
);
|
||||
|
||||
await refreshUserProfile();
|
||||
|
||||
Get.find<WebSocketProvider>().connect();
|
||||
Get.find<WebSocketProvider>().notifyPrefetch();
|
||||
await refreshAuthorizeStatus();
|
||||
await refreshUserProfile();
|
||||
|
||||
return credentials!;
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ class _AccountScreenState extends State<AccountScreen> {
|
||||
return CenteredContainer(
|
||||
child: ListView(
|
||||
children: [
|
||||
if (auth.userProfile.value != null)
|
||||
const AccountHeading().paddingOnly(bottom: 8, top: 8),
|
||||
...(actionItems.map(
|
||||
(x) => ListTile(
|
||||
|
@ -25,9 +25,8 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
Get.lazyPut(() => PostListController());
|
||||
super.initState();
|
||||
_postController = Get.find();
|
||||
_postController = PostListController();
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
_tabController.addListener(() {
|
||||
switch (_tabController.index) {
|
||||
@ -97,7 +96,8 @@ class _HomeScreenState extends State<HomeScreen>
|
||||
onRefresh: () => _postController.reloadAllOver(),
|
||||
child: CustomScrollView(slivers: [
|
||||
FeedListWidget(
|
||||
controller: _postController.pagingController),
|
||||
controller: _postController.pagingController,
|
||||
),
|
||||
]),
|
||||
),
|
||||
PostShuffleSwiper(controller: _postController),
|
||||
|
@ -13,6 +13,7 @@ class AttachmentList extends StatefulWidget {
|
||||
final String parentId;
|
||||
final List<int> attachmentsId;
|
||||
final bool isGrid;
|
||||
final bool isForceGrid;
|
||||
|
||||
final double? width;
|
||||
final double? viewport;
|
||||
@ -22,6 +23,7 @@ class AttachmentList extends StatefulWidget {
|
||||
required this.parentId,
|
||||
required this.attachmentsId,
|
||||
this.isGrid = false,
|
||||
this.isForceGrid = false,
|
||||
this.width,
|
||||
this.viewport,
|
||||
});
|
||||
@ -235,7 +237,9 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
);
|
||||
}
|
||||
|
||||
if (widget.isGrid) {
|
||||
final isNotPureImage = _attachmentsMeta
|
||||
.any((x) => x?.mimetype.split('/').firstOrNull != 'image');
|
||||
if (widget.isGrid && (widget.isForceGrid || !isNotPureImage)) {
|
||||
const radius = BorderRadius.all(Radius.circular(8));
|
||||
return GridView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
@ -259,8 +263,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
child: ClipRRect(
|
||||
borderRadius: radius,
|
||||
child: _buildEntry(element, idx),
|
||||
)
|
||||
);
|
||||
));
|
||||
},
|
||||
).paddingSymmetric(horizontal: 24);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
import 'package:solian/widgets/posts/post_list.dart';
|
||||
|
||||
class FeedListWidget extends StatelessWidget {
|
||||
@ -25,9 +24,6 @@ class FeedListWidget extends StatelessWidget {
|
||||
pagingController: controller,
|
||||
builderDelegate: PagedChildBuilderDelegate<Post>(
|
||||
itemBuilder: (context, item, index) {
|
||||
return SizedContainer(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return PostListEntryWidget(
|
||||
isShowEmbed: isShowEmbed,
|
||||
isNestedClickable: isNestedClickable,
|
||||
@ -39,9 +35,6 @@ class FeedListWidget extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
separatorBuilder: (_, __) => const Divider(thickness: 0.3, height: 0.3),
|
||||
);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
},
|
||||
children: [
|
||||
Obx(() {
|
||||
if (auth.isAuthorized.isFalse) {
|
||||
if (auth.isAuthorized.isFalse || auth.userProfile.value == null) {
|
||||
return ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 28),
|
||||
leading: const Icon(Icons.account_circle),
|
||||
@ -172,7 +172,7 @@ class _AppNavigationDrawerState extends State<AppNavigationDrawer> {
|
||||
top: 12,
|
||||
),
|
||||
Obx(() {
|
||||
if (auth.isAuthorized.isFalse) {
|
||||
if (auth.isAuthorized.isFalse || auth.userProfile.value == null) {
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import 'package:solian/widgets/attachments/attachment_list.dart';
|
||||
import 'package:solian/widgets/markdown_text_content.dart';
|
||||
import 'package:solian/widgets/feed/feed_tags.dart';
|
||||
import 'package:solian/widgets/posts/post_quick_action.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
import 'package:timeago/timeago.dart' show format;
|
||||
|
||||
class PostItem extends StatefulWidget {
|
||||
@ -253,10 +254,13 @@ class _PostItemState extends State<PostItem> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildHeader(),
|
||||
MarkdownTextContent(
|
||||
SizedContainer(
|
||||
maxWidth: 640,
|
||||
child: MarkdownTextContent(
|
||||
content: item.body['content'],
|
||||
isSelectable: widget.isContentSelectable,
|
||||
).paddingOnly(left: 12, right: 8),
|
||||
),
|
||||
if (widget.item.replyTo != null && widget.isShowEmbed)
|
||||
GestureDetector(
|
||||
child: _buildReply(context).paddingOnly(top: 4),
|
||||
@ -298,7 +302,6 @@ class _PostItemState extends State<PostItem> {
|
||||
width: MediaQuery.of(context).size.width,
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 720,
|
||||
maxWidth: 640,
|
||||
),
|
||||
child: AttachmentList(
|
||||
parentId: widget.item.id.toString(),
|
||||
|
@ -3,6 +3,7 @@ import 'package:flutter_card_swiper/flutter_card_swiper.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/controllers/post_list_controller.dart';
|
||||
import 'package:solian/widgets/posts/post_single_display.dart';
|
||||
import 'package:solian/widgets/sized_container.dart';
|
||||
|
||||
class PostShuffleSwiper extends StatefulWidget {
|
||||
final PostListController controller;
|
||||
@ -37,12 +38,14 @@ class _PostShuffleSwiperState extends State<PostShuffleSwiper> {
|
||||
);
|
||||
}
|
||||
final element = widget.controller.postList[index];
|
||||
return PostSingleDisplay(
|
||||
return CenteredContainer(
|
||||
child: PostSingleDisplay(
|
||||
key: Key('p${element.id}'),
|
||||
item: element,
|
||||
onUpdate: () {
|
||||
widget.controller.reloadAllOver();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
padding: const EdgeInsets.all(24),
|
||||
|
@ -14,10 +14,10 @@ class PostSingleDisplay extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
return SingleChildScrollView(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Card(
|
||||
child: SingleChildScrollView(
|
||||
child: PostListEntryWidget(
|
||||
item: item,
|
||||
isClickable: true,
|
||||
|
Loading…
Reference in New Issue
Block a user