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