diff --git a/lib/providers/auth.dart b/lib/providers/auth.dart index de57dfb..67cfd67 100644 --- a/lib/providers/auth.dart +++ b/lib/providers/auth.dart @@ -175,10 +175,10 @@ class AuthProvider extends GetConnect { value: jsonEncode(credentials!.toJson()), ); - await refreshUserProfile(); - Get.find().connect(); Get.find().notifyPrefetch(); + await refreshAuthorizeStatus(); + await refreshUserProfile(); return credentials!; } diff --git a/lib/screens/account.dart b/lib/screens/account.dart index 553a89a..6319c2c 100644 --- a/lib/screens/account.dart +++ b/lib/screens/account.dart @@ -82,7 +82,8 @@ class _AccountScreenState extends State { return CenteredContainer( child: ListView( children: [ - const AccountHeading().paddingOnly(bottom: 8, top: 8), + if (auth.userProfile.value != null) + const AccountHeading().paddingOnly(bottom: 8, top: 8), ...(actionItems.map( (x) => ListTile( contentPadding: const EdgeInsets.symmetric(horizontal: 34), @@ -134,7 +135,7 @@ class _AccountHeadingState extends State { final AuthProvider auth = Get.find(); final prof = auth.userProfile.value!; - + return AccountHeadingWidget( avatar: prof['avatar'], banner: prof['banner'], diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 37df5dd..0ed8009 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -25,9 +25,8 @@ class _HomeScreenState extends State @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 onRefresh: () => _postController.reloadAllOver(), child: CustomScrollView(slivers: [ FeedListWidget( - controller: _postController.pagingController), + controller: _postController.pagingController, + ), ]), ), PostShuffleSwiper(controller: _postController), diff --git a/lib/widgets/attachments/attachment_list.dart b/lib/widgets/attachments/attachment_list.dart index 2d5a186..f74d3b9 100644 --- a/lib/widgets/attachments/attachment_list.dart +++ b/lib/widgets/attachments/attachment_list.dart @@ -13,6 +13,7 @@ class AttachmentList extends StatefulWidget { final String parentId; final List 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 { ); } - 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, @@ -251,16 +255,15 @@ class _AttachmentListState extends State { itemBuilder: (context, idx) { final element = _attachmentsMeta[idx]; return Container( - decoration: BoxDecoration( - border: - Border.all(color: Theme.of(context).dividerColor, width: 1), - borderRadius: radius, - ), - child: ClipRRect( - borderRadius: radius, - child: _buildEntry(element, idx), - ) - ); + decoration: BoxDecoration( + border: + Border.all(color: Theme.of(context).dividerColor, width: 1), + borderRadius: radius, + ), + child: ClipRRect( + borderRadius: radius, + child: _buildEntry(element, idx), + )); }, ).paddingSymmetric(horizontal: 24); } diff --git a/lib/widgets/feed/feed_list.dart b/lib/widgets/feed/feed_list.dart index c90b614..dd4643a 100644 --- a/lib/widgets/feed/feed_list.dart +++ b/lib/widgets/feed/feed_list.dart @@ -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,20 +24,14 @@ class FeedListWidget extends StatelessWidget { pagingController: controller, builderDelegate: PagedChildBuilderDelegate( itemBuilder: (context, item, index) { - return SizedContainer( - child: Builder( - builder: (context) { - return PostListEntryWidget( - isShowEmbed: isShowEmbed, - isNestedClickable: isNestedClickable, - isClickable: isClickable, - item: item, - onUpdate: () { - controller.refresh(); - }, - ); - }, - ), + return PostListEntryWidget( + isShowEmbed: isShowEmbed, + isNestedClickable: isNestedClickable, + isClickable: isClickable, + item: item, + onUpdate: () { + controller.refresh(); + }, ); }, ), diff --git a/lib/widgets/navigation/app_navigation_drawer.dart b/lib/widgets/navigation/app_navigation_drawer.dart index 182f2e9..1e26ee3 100644 --- a/lib/widgets/navigation/app_navigation_drawer.dart +++ b/lib/widgets/navigation/app_navigation_drawer.dart @@ -82,7 +82,7 @@ class _AppNavigationDrawerState extends State { }, 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 { top: 12, ), Obx(() { - if (auth.isAuthorized.isFalse) { + if (auth.isAuthorized.isFalse || auth.userProfile.value == null) { return const SizedBox(); } diff --git a/lib/widgets/posts/post_item.dart b/lib/widgets/posts/post_item.dart index 5c4bae6..41feaca 100644 --- a/lib/widgets/posts/post_item.dart +++ b/lib/widgets/posts/post_item.dart @@ -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 { crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildHeader(), - MarkdownTextContent( - content: item.body['content'], - isSelectable: widget.isContentSelectable, - ).paddingOnly(left: 12, right: 8), + 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 { width: MediaQuery.of(context).size.width, constraints: const BoxConstraints( maxHeight: 720, - maxWidth: 640, ), child: AttachmentList( parentId: widget.item.id.toString(), diff --git a/lib/widgets/posts/post_shuffle_swiper.dart b/lib/widgets/posts/post_shuffle_swiper.dart index f50605a..aed14bc 100644 --- a/lib/widgets/posts/post_shuffle_swiper.dart +++ b/lib/widgets/posts/post_shuffle_swiper.dart @@ -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 { ); } final element = widget.controller.postList[index]; - return PostSingleDisplay( - key: Key('p${element.id}'), - item: element, - onUpdate: () { - widget.controller.reloadAllOver(); - }, + return CenteredContainer( + child: PostSingleDisplay( + key: Key('p${element.id}'), + item: element, + onUpdate: () { + widget.controller.reloadAllOver(); + }, + ), ); }, padding: const EdgeInsets.all(24), diff --git a/lib/widgets/posts/post_single_display.dart b/lib/widgets/posts/post_single_display.dart index db6055f..9571fe5 100644 --- a/lib/widgets/posts/post_single_display.dart +++ b/lib/widgets/posts/post_single_display.dart @@ -14,10 +14,10 @@ class PostSingleDisplay extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - alignment: Alignment.center, - child: Card( - child: SingleChildScrollView( + return SingleChildScrollView( + child: Container( + alignment: Alignment.center, + child: Card( child: PostListEntryWidget( item: item, isClickable: true,