💄 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,7 +82,8 @@ class _AccountScreenState extends State<AccountScreen> {
|
|||||||
return CenteredContainer(
|
return CenteredContainer(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
const AccountHeading().paddingOnly(bottom: 8, top: 8),
|
if (auth.userProfile.value != null)
|
||||||
|
const AccountHeading().paddingOnly(bottom: 8, top: 8),
|
||||||
...(actionItems.map(
|
...(actionItems.map(
|
||||||
(x) => ListTile(
|
(x) => ListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 34),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 34),
|
||||||
@ -134,7 +135,7 @@ class _AccountHeadingState extends State<AccountHeading> {
|
|||||||
final AuthProvider auth = Get.find();
|
final AuthProvider auth = Get.find();
|
||||||
|
|
||||||
final prof = auth.userProfile.value!;
|
final prof = auth.userProfile.value!;
|
||||||
|
|
||||||
return AccountHeadingWidget(
|
return AccountHeadingWidget(
|
||||||
avatar: prof['avatar'],
|
avatar: prof['avatar'],
|
||||||
banner: prof['banner'],
|
banner: prof['banner'],
|
||||||
|
@ -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,
|
||||||
@ -251,16 +255,15 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
final element = _attachmentsMeta[idx];
|
final element = _attachmentsMeta[idx];
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border:
|
border:
|
||||||
Border.all(color: Theme.of(context).dividerColor, width: 1),
|
Border.all(color: Theme.of(context).dividerColor, width: 1),
|
||||||
borderRadius: radius,
|
borderRadius: radius,
|
||||||
),
|
),
|
||||||
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,20 +24,14 @@ class FeedListWidget extends StatelessWidget {
|
|||||||
pagingController: controller,
|
pagingController: controller,
|
||||||
builderDelegate: PagedChildBuilderDelegate<Post>(
|
builderDelegate: PagedChildBuilderDelegate<Post>(
|
||||||
itemBuilder: (context, item, index) {
|
itemBuilder: (context, item, index) {
|
||||||
return SizedContainer(
|
return PostListEntryWidget(
|
||||||
child: Builder(
|
isShowEmbed: isShowEmbed,
|
||||||
builder: (context) {
|
isNestedClickable: isNestedClickable,
|
||||||
return PostListEntryWidget(
|
isClickable: isClickable,
|
||||||
isShowEmbed: isShowEmbed,
|
item: item,
|
||||||
isNestedClickable: isNestedClickable,
|
onUpdate: () {
|
||||||
isClickable: isClickable,
|
controller.refresh();
|
||||||
item: item,
|
},
|
||||||
onUpdate: () {
|
|
||||||
controller.refresh();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -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(
|
||||||
content: item.body['content'],
|
maxWidth: 640,
|
||||||
isSelectable: widget.isContentSelectable,
|
child: MarkdownTextContent(
|
||||||
).paddingOnly(left: 12, right: 8),
|
content: item.body['content'],
|
||||||
|
isSelectable: widget.isContentSelectable,
|
||||||
|
).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(
|
||||||
key: Key('p${element.id}'),
|
child: PostSingleDisplay(
|
||||||
item: element,
|
key: Key('p${element.id}'),
|
||||||
onUpdate: () {
|
item: element,
|
||||||
widget.controller.reloadAllOver();
|
onUpdate: () {
|
||||||
},
|
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(
|
||||||
alignment: Alignment.center,
|
child: Container(
|
||||||
child: Card(
|
alignment: Alignment.center,
|
||||||
child: SingleChildScrollView(
|
child: Card(
|
||||||
child: PostListEntryWidget(
|
child: PostListEntryWidget(
|
||||||
item: item,
|
item: item,
|
||||||
isClickable: true,
|
isClickable: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user