✨ Post alias
This commit is contained in:
		| @@ -238,8 +238,8 @@ class _AttachmentItemVideoState extends State<_AttachmentItemVideo> { | ||||
|  | ||||
|   bool _showContent = false; | ||||
|  | ||||
|   void _startLoad() { | ||||
|     _player.open( | ||||
|   Future<void> _startLoad() async { | ||||
|     await _player.open( | ||||
|       Media(ServiceFinder.buildUrl('files', '/attachments/${widget.item.id}')), | ||||
|       play: false, | ||||
|     ); | ||||
| @@ -249,7 +249,9 @@ class _AttachmentItemVideoState extends State<_AttachmentItemVideo> { | ||||
|   @override | ||||
|   void initState() { | ||||
|     super.initState(); | ||||
|     _showContent = widget.autoload; | ||||
|     if (widget.autoload) { | ||||
|       _startLoad(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   @override | ||||
|   | ||||
| @@ -57,10 +57,12 @@ class _AttachmentListState extends State<AttachmentList> { | ||||
|     } | ||||
|  | ||||
|     attach.listMetadata(widget.attachmentsId).then((result) { | ||||
|       setState(() { | ||||
|         _attachmentsMeta = result; | ||||
|         _isLoading = false; | ||||
|       }); | ||||
|       if (mounted) { | ||||
|         setState(() { | ||||
|           _attachmentsMeta = result; | ||||
|           _isLoading = false; | ||||
|         }); | ||||
|       } | ||||
|       _calculateAspectRatio(); | ||||
|     }); | ||||
|   } | ||||
| @@ -111,6 +113,7 @@ class _AttachmentListState extends State<AttachmentList> { | ||||
|       showBadge: _attachmentsMeta.length > 1 && !widget.isGrid, | ||||
|       showBorder: widget.attachmentsId.length > 1, | ||||
|       showMature: _showMature, | ||||
|       autoload: widget.autoload, | ||||
|       onReveal: (value) { | ||||
|         setState(() => _showMature = value); | ||||
|       }, | ||||
| @@ -138,8 +141,9 @@ class _AttachmentListState extends State<AttachmentList> { | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     final isNotPureImage = _attachmentsMeta | ||||
|         .any((x) => x?.mimetype.split('/').firstOrNull != 'image'); | ||||
|     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( | ||||
| @@ -157,8 +161,10 @@ class _AttachmentListState extends State<AttachmentList> { | ||||
|           final element = _attachmentsMeta[idx]; | ||||
|           return Container( | ||||
|             decoration: BoxDecoration( | ||||
|               border: | ||||
|                   Border.all(color: Theme.of(context).dividerColor, width: 1), | ||||
|               border: Border.all( | ||||
|                 color: Theme.of(context).dividerColor, | ||||
|                 width: 1, | ||||
|               ), | ||||
|               borderRadius: radius, | ||||
|             ), | ||||
|             child: ClipRRect( | ||||
|   | ||||
| @@ -19,7 +19,7 @@ class PostEditorCategoriesDialog extends StatelessWidget { | ||||
|             initialTags: controller.tags, | ||||
|             hintText: 'postTagsPlaceholder'.tr, | ||||
|             onUpdate: (value) { | ||||
|               controller.tags.value = value; | ||||
|               controller.tags.value = List.from(value, growable: true); | ||||
|               controller.tags.refresh(); | ||||
|             }, | ||||
|           ), | ||||
|   | ||||
| @@ -14,12 +14,25 @@ class PostEditorOverviewDialog extends StatelessWidget { | ||||
|       content: Column( | ||||
|         mainAxisSize: MainAxisSize.min, | ||||
|         children: [ | ||||
|           TextField( | ||||
|             autofocus: true, | ||||
|             autocorrect: true, | ||||
|             controller: controller.aliasController, | ||||
|             decoration: InputDecoration( | ||||
|               isDense: true, | ||||
|               border: const OutlineInputBorder(), | ||||
|               hintText: 'alias'.tr, | ||||
|             ), | ||||
|             onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), | ||||
|           ), | ||||
|           const SizedBox(height: 16), | ||||
|           TextField( | ||||
|             autofocus: true, | ||||
|             autocorrect: true, | ||||
|             controller: controller.titleController, | ||||
|             decoration: InputDecoration( | ||||
|               border: const UnderlineInputBorder(), | ||||
|               isDense: true, | ||||
|               border: const OutlineInputBorder(), | ||||
|               hintText: 'title'.tr, | ||||
|             ), | ||||
|             onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), | ||||
| @@ -33,7 +46,8 @@ class PostEditorOverviewDialog extends StatelessWidget { | ||||
|             keyboardType: TextInputType.multiline, | ||||
|             controller: controller.descriptionController, | ||||
|             decoration: InputDecoration( | ||||
|               border: const UnderlineInputBorder(), | ||||
|               isDense: true, | ||||
|               border: const OutlineInputBorder(), | ||||
|               hintText: 'description'.tr, | ||||
|             ), | ||||
|             onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), | ||||
|   | ||||
| @@ -42,10 +42,16 @@ class _PostActionState extends State<PostAction> { | ||||
|  | ||||
|   Future<void> _doShare({bool noUri = false}) async { | ||||
|     ShareResult result; | ||||
|     String id; | ||||
|     final box = context.findRenderObject() as RenderBox?; | ||||
|     if (widget.item.alias?.isNotEmpty ?? false) { | ||||
|       id = '${widget.item.areaAlias}:${widget.item.alias}'; | ||||
|     } else { | ||||
|       id = '${widget.item.id}'; | ||||
|     } | ||||
|     if ((PlatformInfo.isAndroid || PlatformInfo.isIOS) && !noUri) { | ||||
|       result = await Share.shareUri( | ||||
|         Uri.parse('https://solsynth.dev/posts/${widget.item.id}'), | ||||
|         Uri.parse('https://solsynth.dev/posts/$id'), | ||||
|         sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, | ||||
|       ); | ||||
|     } else { | ||||
| @@ -59,7 +65,7 @@ class _PostActionState extends State<PostAction> { | ||||
|           'username': widget.item.author.nick, | ||||
|           'content': | ||||
|               '${extraContent.join('\n')}${isExtraNotEmpty ? '\n\n' : ''}${widget.item.body['content'] ?? 'no content'}', | ||||
|           'link': 'https://solsynth.dev/posts/${widget.item.id}', | ||||
|           'link': 'https://solsynth.dev/posts/$id', | ||||
|         }), | ||||
|         subject: 'postShareSubject'.trParams({ | ||||
|           'username': widget.item.author.nick, | ||||
| @@ -96,9 +102,27 @@ class _PostActionState extends State<PostAction> { | ||||
|                 'postActionList'.tr, | ||||
|                 style: Theme.of(context).textTheme.headlineSmall, | ||||
|               ), | ||||
|               Text( | ||||
|                 '#${widget.item.id.toString().padLeft(8, '0')}', | ||||
|                 style: Theme.of(context).textTheme.bodySmall, | ||||
|               Row( | ||||
|                 children: [ | ||||
|                   Text( | ||||
|                     '#${widget.item.id.toString().padLeft(8, '0')}', | ||||
|                     style: Theme.of(context).textTheme.bodySmall, | ||||
|                   ), | ||||
|                   if (widget.item.alias?.isNotEmpty ?? false) | ||||
|                     Text( | ||||
|                       '·', | ||||
|                       style: Theme.of(context).textTheme.bodySmall, | ||||
|                     ).paddingSymmetric(horizontal: 6), | ||||
|                   if (widget.item.alias?.isNotEmpty ?? false) | ||||
|                     Expanded( | ||||
|                       child: Text( | ||||
|                         '${widget.item.areaAlias}:${widget.item.alias}', | ||||
|                         style: Theme.of(context).textTheme.bodySmall, | ||||
|                         maxLines: 1, | ||||
|                         overflow: TextOverflow.ellipsis, | ||||
|                       ), | ||||
|                     ), | ||||
|                 ], | ||||
|               ), | ||||
|             ], | ||||
|           ).paddingOnly(left: 24, right: 24, top: 32, bottom: 16), | ||||
|   | ||||
| @@ -78,23 +78,17 @@ class _PostItemState extends State<PostItem> { | ||||
|  | ||||
|   Widget _buildThumbnail() { | ||||
|     if (widget.item.body['thumbnail'] == null) return const SizedBox(); | ||||
|     const radius = BorderRadius.all(Radius.circular(8)); | ||||
|     return AspectRatio( | ||||
|       aspectRatio: 16 / 9, | ||||
|       child: Container( | ||||
|         decoration: BoxDecoration( | ||||
|           border: Border.all( | ||||
|             color: Theme.of(context).dividerColor, | ||||
|             width: 0.3, | ||||
|           ), | ||||
|           borderRadius: radius, | ||||
|         ), | ||||
|         child: ClipRRect( | ||||
|           borderRadius: radius, | ||||
|           child: AttachmentSelfContainedEntry( | ||||
|             id: widget.item.body['thumbnail'], | ||||
|             parentId: 'p${item.id}-thumbnail', | ||||
|           ), | ||||
|     final border = BorderSide( | ||||
|       color: Theme.of(context).dividerColor, | ||||
|       width: 0.3, | ||||
|     ); | ||||
|     return Container( | ||||
|       decoration: BoxDecoration(border: Border(top: border, bottom: border)), | ||||
|       child: AspectRatio( | ||||
|         aspectRatio: 16 / 9, | ||||
|         child: AttachmentSelfContainedEntry( | ||||
|           id: widget.item.body['thumbnail'], | ||||
|           parentId: 'p${item.id}-thumbnail', | ||||
|         ), | ||||
|       ), | ||||
|     ); | ||||
| @@ -307,7 +301,7 @@ class _PostItemState extends State<PostItem> { | ||||
|       return Column( | ||||
|         crossAxisAlignment: CrossAxisAlignment.start, | ||||
|         children: [ | ||||
|           _buildThumbnail().paddingSymmetric(horizontal: 12, vertical: 4), | ||||
|           _buildThumbnail(), | ||||
|           _buildHeader().paddingSymmetric(horizontal: 12), | ||||
|           _buildHeaderDivider().paddingSymmetric(horizontal: 12), | ||||
|           Stack( | ||||
| @@ -381,7 +375,7 @@ class _PostItemState extends State<PostItem> { | ||||
|       closedBuilder: (_, openContainer) => Column( | ||||
|         crossAxisAlignment: CrossAxisAlignment.start, | ||||
|         children: [ | ||||
|           _buildThumbnail().paddingSymmetric(horizontal: 12, vertical: 4), | ||||
|           _buildThumbnail().paddingOnly(bottom: 4), | ||||
|           Row( | ||||
|             crossAxisAlignment: CrossAxisAlignment.start, | ||||
|             children: [ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user