✨ Channel organize
This commit is contained in:
@ -15,7 +15,8 @@ class AccountAvatar extends StatelessWidget {
|
||||
bool isEmpty = content == null;
|
||||
if (content is String) {
|
||||
direct = content.startsWith('http');
|
||||
isEmpty = content.endsWith('/api/attachments/0');
|
||||
if (!isEmpty) isEmpty = content.isEmpty;
|
||||
if (!isEmpty) isEmpty = content.endsWith('/api/attachments/0');
|
||||
}
|
||||
|
||||
return CircleAvatar(
|
||||
|
81
lib/widgets/account/friend_select.dart
Normal file
81
lib/widgets/account/friend_select.dart
Normal file
@ -0,0 +1,81 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/account.dart';
|
||||
import 'package:solian/models/friendship.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/providers/friend.dart';
|
||||
import 'package:solian/widgets/account/account_avatar.dart';
|
||||
|
||||
class FriendSelect extends StatefulWidget {
|
||||
final String title;
|
||||
final Widget? Function(Account item)? trailingBuilder;
|
||||
|
||||
const FriendSelect({super.key, required this.title, this.trailingBuilder});
|
||||
|
||||
@override
|
||||
State<FriendSelect> createState() => _FriendSelectState();
|
||||
}
|
||||
|
||||
class _FriendSelectState extends State<FriendSelect> {
|
||||
int _accountId = 0;
|
||||
|
||||
List<Friendship> _friends = List.empty(growable: true);
|
||||
|
||||
getFriends() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
final prof = await auth.getProfile();
|
||||
_accountId = prof.body['id'];
|
||||
|
||||
final FriendProvider provider = Get.find();
|
||||
final resp = await provider.listFriendshipWithStatus(1);
|
||||
|
||||
setState(() {
|
||||
_friends.addAll(resp.body
|
||||
.map((e) => Friendship.fromJson(e))
|
||||
.toList()
|
||||
.cast<Friendship>());
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
getFriends();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.85,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.title,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
).paddingOnly(left: 24, right: 24, top: 32, bottom: 16),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: _friends.length,
|
||||
itemBuilder: (context, index) {
|
||||
var element = _friends[index].getOtherside(_accountId);
|
||||
return ListTile(
|
||||
title: Text(element.nick),
|
||||
subtitle: Text(element.name),
|
||||
leading: AccountAvatar(content: element.avatar),
|
||||
trailing: widget.trailingBuilder != null
|
||||
? widget.trailingBuilder!(element)
|
||||
: null,
|
||||
onTap: () {
|
||||
Navigator.pop(context, element);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/services.dart';
|
||||
|
||||
class AttachmentItem extends StatelessWidget {
|
||||
final String parentId;
|
||||
final Attachment item;
|
||||
final bool showBadge;
|
||||
final bool showHideButton;
|
||||
@ -13,6 +14,7 @@ class AttachmentItem extends StatelessWidget {
|
||||
|
||||
const AttachmentItem({
|
||||
super.key,
|
||||
required this.parentId,
|
||||
required this.item,
|
||||
this.badge,
|
||||
this.fit = BoxFit.cover,
|
||||
@ -24,7 +26,7 @@ class AttachmentItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Hero(
|
||||
tag: Key('a${item.uuid}'),
|
||||
tag: Key('a${item.uuid}p$parentId'),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
@ -48,8 +50,10 @@ class AttachmentItem extends StatelessWidget {
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: ActionChip(
|
||||
visualDensity: const VisualDensity(vertical: -4, horizontal: -4),
|
||||
avatar: Icon(Icons.visibility_off, color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
visualDensity:
|
||||
const VisualDensity(vertical: -4, horizontal: -4),
|
||||
avatar: Icon(Icons.visibility_off,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant),
|
||||
label: Text('hide'.tr),
|
||||
onPressed: () {
|
||||
if (onHide != null) onHide!();
|
||||
|
@ -9,9 +9,11 @@ import 'package:solian/providers/content/attachment.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_list_fullscreen.dart';
|
||||
|
||||
class AttachmentList extends StatefulWidget {
|
||||
final String parentId;
|
||||
final List<int> attachmentsId;
|
||||
|
||||
const AttachmentList({super.key, required this.attachmentsId});
|
||||
const AttachmentList(
|
||||
{super.key, required this.parentId, required this.attachmentsId});
|
||||
|
||||
@override
|
||||
State<AttachmentList> createState() => _AttachmentListState();
|
||||
@ -126,6 +128,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
AttachmentItem(
|
||||
parentId: widget.parentId,
|
||||
key: Key('a${element!.uuid}'),
|
||||
item: element,
|
||||
badge: _attachmentsMeta.length > 1
|
||||
@ -180,7 +183,8 @@ class _AttachmentListState extends State<AttachmentList> {
|
||||
} else {
|
||||
Navigator.of(context, rootNavigator: true).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AttachmentListFullscreen(
|
||||
builder: (context) => AttachmentListFullScreen(
|
||||
parentId: widget.parentId,
|
||||
attachment: element,
|
||||
),
|
||||
),
|
||||
|
@ -2,17 +2,19 @@ import 'package:flutter/material.dart';
|
||||
import 'package:solian/models/attachment.dart';
|
||||
import 'package:solian/widgets/attachments/attachment_item.dart';
|
||||
|
||||
class AttachmentListFullscreen extends StatefulWidget {
|
||||
class AttachmentListFullScreen extends StatefulWidget {
|
||||
final String parentId;
|
||||
final Attachment attachment;
|
||||
|
||||
const AttachmentListFullscreen({super.key, required this.attachment});
|
||||
const AttachmentListFullScreen(
|
||||
{super.key, required this.parentId, required this.attachment});
|
||||
|
||||
@override
|
||||
State<AttachmentListFullscreen> createState() =>
|
||||
_AttachmentListFullscreenState();
|
||||
State<AttachmentListFullScreen> createState() =>
|
||||
_AttachmentListFullScreenState();
|
||||
}
|
||||
|
||||
class _AttachmentListFullscreenState extends State<AttachmentListFullscreen> {
|
||||
class _AttachmentListFullScreenState extends State<AttachmentListFullScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -33,6 +35,7 @@ class _AttachmentListFullscreenState extends State<AttachmentListFullscreen> {
|
||||
panEnabled: true,
|
||||
scaleEnabled: true,
|
||||
child: AttachmentItem(
|
||||
parentId: widget.parentId,
|
||||
showHideButton: false,
|
||||
item: widget.attachment,
|
||||
fit: BoxFit.contain,
|
||||
|
@ -8,7 +8,7 @@ import 'package:solian/exts.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/posts/publish.dart';
|
||||
import 'package:solian/screens/posts/post_publish.dart';
|
||||
import 'package:solian/services.dart';
|
||||
|
||||
class PostAction extends StatefulWidget {
|
||||
|
@ -17,6 +17,7 @@ class PostItem extends StatefulWidget {
|
||||
final bool isReactable;
|
||||
final bool isShowReply;
|
||||
final bool isShowEmbed;
|
||||
final String? overrideAttachmentParent;
|
||||
|
||||
const PostItem({
|
||||
super.key,
|
||||
@ -26,6 +27,7 @@ class PostItem extends StatefulWidget {
|
||||
this.isReactable = true,
|
||||
this.isShowReply = true,
|
||||
this.isShowEmbed = true,
|
||||
this.overrideAttachmentParent,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -53,7 +55,7 @@ class _PostItemState extends State<PostItem> {
|
||||
),
|
||||
Text(
|
||||
'postRepliedNotify'.trParams(
|
||||
{'username': '@${widget.item.author.name}'},
|
||||
{'username': '@${widget.item.replyTo!.author.name}'},
|
||||
),
|
||||
style: TextStyle(
|
||||
color:
|
||||
@ -67,6 +69,7 @@ class _PostItemState extends State<PostItem> {
|
||||
child: PostItem(
|
||||
item: widget.item.replyTo!,
|
||||
isCompact: true,
|
||||
overrideAttachmentParent: widget.item.alias,
|
||||
).paddingSymmetric(vertical: 8),
|
||||
),
|
||||
],
|
||||
@ -85,7 +88,7 @@ class _PostItemState extends State<PostItem> {
|
||||
),
|
||||
Text(
|
||||
'postRepostedNotify'.trParams(
|
||||
{'username': '@${widget.item.author.name}'},
|
||||
{'username': '@${widget.item.repostTo!.author.name}'},
|
||||
),
|
||||
style: TextStyle(
|
||||
color:
|
||||
@ -99,6 +102,7 @@ class _PostItemState extends State<PostItem> {
|
||||
child: PostItem(
|
||||
item: widget.item.repostTo!,
|
||||
isCompact: true,
|
||||
overrideAttachmentParent: widget.item.alias,
|
||||
).paddingSymmetric(vertical: 8),
|
||||
),
|
||||
],
|
||||
@ -134,7 +138,10 @@ class _PostItemState extends State<PostItem> {
|
||||
top: 2,
|
||||
bottom: hasAttachment ? 4 : 0,
|
||||
),
|
||||
AttachmentList(attachmentsId: item.attachments ?? List.empty()),
|
||||
AttachmentList(
|
||||
parentId: widget.overrideAttachmentParent ?? widget.item.alias,
|
||||
attachmentsId: item.attachments ?? List.empty(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -200,7 +207,10 @@ class _PostItemState extends State<PostItem> {
|
||||
right: 16,
|
||||
left: 16,
|
||||
),
|
||||
AttachmentList(attachmentsId: item.attachments ?? List.empty()),
|
||||
AttachmentList(
|
||||
parentId: widget.item.alias,
|
||||
attachmentsId: item.attachments ?? List.empty(),
|
||||
),
|
||||
PostQuickAction(
|
||||
isShowReply: widget.isShowReply,
|
||||
isReactable: widget.isReactable,
|
||||
|
@ -3,7 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/models/pagination.dart';
|
||||
import 'package:solian/models/post.dart';
|
||||
import 'package:solian/providers/content/post_explore.dart';
|
||||
import 'package:solian/providers/content/post.dart';
|
||||
import 'package:solian/widgets/posts/post_list.dart';
|
||||
|
||||
class PostReplyList extends StatefulWidget {
|
||||
|
Reference in New Issue
Block a user