✨ 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);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user