Channel organize

This commit is contained in:
LittleSheep 2024-05-26 00:11:00 +08:00
parent 9eae49128e
commit 657f36c1f8
24 changed files with 650 additions and 34 deletions

View File

@ -3,7 +3,9 @@ import 'package:get/get.dart';
import 'package:solian/providers/account.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/content/attachment.dart';
import 'package:solian/providers/content/post_explore.dart';
import 'package:solian/providers/content/channel.dart';
import 'package:solian/providers/content/post.dart';
import 'package:solian/providers/content/realm.dart';
import 'package:solian/providers/friend.dart';
import 'package:solian/router.dart';
import 'package:solian/theme.dart';
@ -35,6 +37,8 @@ class SolianApp extends StatelessWidget {
Get.lazyPut(() => PostProvider());
Get.lazyPut(() => AttachmentProvider());
Get.lazyPut(() => AccountProvider());
Get.lazyPut(() => ChannelProvider());
Get.lazyPut(() => RealmProvider());
final AuthProvider auth = Get.find();
auth.isAuthorized.then((value) async {

View File

@ -1,3 +1,5 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:solian/models/account.dart';
class Channel {
@ -60,6 +62,15 @@ class Channel {
'realm_id': realmId,
'is_encrypted': isEncrypted,
};
IconData get icon {
switch (type) {
case 1:
return FontAwesomeIcons.userGroup;
default:
return FontAwesomeIcons.hashtag;
}
}
}
class ChannelMember {

View File

@ -0,0 +1,21 @@
import 'package:get/get.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/services.dart';
class ChannelProvider extends GetxController {
Future<Response> listAvailableChannel({String realm = 'global'}) async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = GetConnect();
client.httpClient.baseUrl = ServiceFinder.services['messaging'];
client.httpClient.addAuthenticator(auth.requestAuthenticator);
final resp = await client.get('/api/channels/$realm/me/available');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
return resp;
}
}

View File

@ -0,0 +1,21 @@
import 'package:get/get.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/services.dart';
class RealmProvider extends GetxController {
Future<Response> listAvailableRealm() async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) throw Exception('unauthorized');
final client = GetConnect();
client.httpClient.baseUrl = ServiceFinder.services['passport'];
client.httpClient.addAuthenticator(auth.requestAuthenticator);
final resp = await client.get('/realms/me/available');
if (resp.statusCode != 200) {
throw Exception(resp.bodyString);
}
return resp;
}
}

View File

@ -14,6 +14,9 @@ class FriendProvider extends GetConnect {
Future<Response> listFriendship() => get('/api/users/me/friends');
Future<Response> listFriendshipWithStatus(int status) =>
get('/api/users/me/friends?status=$status');
Future<Response> createFriendship(String username) async {
final resp = await post('/api/users/me/friends?related=$username', {});
if (resp.statusCode != 200) {

View File

@ -2,10 +2,11 @@ import 'package:go_router/go_router.dart';
import 'package:solian/screens/account.dart';
import 'package:solian/screens/account/friend.dart';
import 'package:solian/screens/account/personalize.dart';
import 'package:solian/screens/channel/channel_organize.dart';
import 'package:solian/screens/contact.dart';
import 'package:solian/screens/posts/post_detail.dart';
import 'package:solian/screens/social.dart';
import 'package:solian/screens/posts/publish.dart';
import 'package:solian/screens/posts/post_publish.dart';
import 'package:solian/shells/basic_shell.dart';
import 'package:solian/shells/nav_shell.dart';
@ -75,6 +76,17 @@ abstract class AppRouter {
);
},
),
GoRoute(
path: '/chat/organize',
name: 'channelOrganizing',
builder: (context, state) {
final arguments = state.extra as ChannelOrganizeArguments?;
return ChannelOrganizeScreen(
edit: arguments?.edit,
realm: state.uri.queryParameters['realm'],
);
},
),
],
);
}

View File

@ -0,0 +1,292 @@
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:get/get.dart';
import 'package:solian/exts.dart';
import 'package:solian/models/account.dart';
import 'package:solian/models/channel.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/router.dart';
import 'package:solian/services.dart';
import 'package:solian/widgets/account/friend_select.dart';
import 'package:solian/widgets/prev_page.dart';
import 'package:uuid/uuid.dart';
class ChannelOrganizeArguments {
final Channel? edit;
ChannelOrganizeArguments({this.edit});
}
class ChannelOrganizeScreen extends StatefulWidget {
final Channel? edit;
final String? realm;
const ChannelOrganizeScreen({super.key, this.edit, this.realm});
@override
State<ChannelOrganizeScreen> createState() => _ChannelOrganizeScreenState();
}
class _ChannelOrganizeScreenState extends State<ChannelOrganizeScreen> {
static Map<int, String> channelTypes = {
0: 'channelTypeCommon'.tr,
1: 'channelTypeDirect'.tr,
};
bool _isBusy = false;
final _aliasController = TextEditingController();
final _nameController = TextEditingController();
final _descriptionController = TextEditingController();
bool _isEncrypted = false;
int _channelType = 0;
List<Account> _initialMembers = List.empty(growable: true);
void selectInitialMembers() async {
final input = await showModalBottomSheet(
useRootNavigator: true,
isScrollControlled: true,
context: context,
builder: (context) => FriendSelect(
title: 'channelMember'.tr,
trailingBuilder: (item) {
if (_initialMembers.any((e) => e.id == item.id)) {
return const Icon(Icons.check);
} else {
return null;
}
},
),
);
if (input == null) return;
setState(() {
if (_initialMembers.any((e) => e.id == input.id)) {
_initialMembers = _initialMembers
.where((e) => e.id != input.id)
.toList(growable: true);
} else {
_initialMembers.add(input as Account);
}
});
}
void applyChannel() async {
final AuthProvider auth = Get.find();
if (!await auth.isAuthorized) return;
if (_aliasController.value.text.isEmpty) randomizeAlias();
setState(() => _isBusy = true);
final client = GetConnect();
client.httpClient.baseUrl = ServiceFinder.services['messaging'];
client.httpClient.addAuthenticator(auth.requestAuthenticator);
final scope = (widget.realm?.isNotEmpty ?? false) ? widget.realm : 'global';
final payload = {
'alias': _aliasController.value.text.toLowerCase(),
'name': _nameController.value.text,
'description': _descriptionController.value.text,
'is_encrypted': _isEncrypted,
if (_channelType == 1)
'members': _initialMembers.map((e) => e.id).toList(),
};
Response resp;
if (widget.edit != null) {
resp = await client.put(
'/api/channels/$scope/${widget.edit!.id}',
payload,
);
} else if (_channelType == 1) {
resp = await client.post('/api/channels/$scope/dm', payload);
} else {
resp = await client.post('/api/channels/$scope', payload);
}
if (resp.statusCode != 200) {
context.showErrorDialog(resp.bodyString);
} else {
AppRouter.instance.pop(resp.body);
}
setState(() => _isBusy = false);
}
void randomizeAlias() {
_aliasController.text =
const Uuid().v4().replaceAll('-', '').substring(0, 12);
}
void syncWidget() {
if (widget.edit != null) {
_aliasController.text = widget.edit!.alias;
_nameController.text = widget.edit!.name;
_descriptionController.text = widget.edit!.description;
_isEncrypted = widget.edit!.isEncrypted;
_channelType = widget.edit!.type;
}
}
void cancelAction() {
AppRouter.instance.pop();
}
@override
void initState() {
syncWidget();
super.initState();
}
@override
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: Scaffold(
appBar: AppBar(
title: Text('channelOrganizing'.tr),
leading: const PrevPageButton(),
actions: [
TextButton(
onPressed: _isBusy ? null : () => applyChannel(),
child: Text('apply'.tr.toUpperCase()),
)
],
),
body: SafeArea(
top: false,
child: Column(
children: [
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
if (widget.edit != null)
MaterialBanner(
leading: const Icon(Icons.edit),
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
dividerColor: Colors.transparent,
content: Text(
'channelEditingNotify'
.trParams({'channel': '#${widget.edit!.alias}'}),
),
actions: [
TextButton(
onPressed: cancelAction,
child: Text('cancel'.tr),
),
],
),
Row(
children: [
Expanded(
child: TextField(
autofocus: true,
controller: _aliasController,
decoration: InputDecoration.collapsed(
hintText: 'channelAlias'.tr,
),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
),
),
TextButton(
style: TextButton.styleFrom(
shape: const CircleBorder(),
visualDensity:
const VisualDensity(horizontal: -2, vertical: -2),
),
onPressed: () => randomizeAlias(),
child: const Icon(Icons.refresh),
)
],
).paddingSymmetric(horizontal: 16, vertical: 2),
const Divider(thickness: 0.3),
TextField(
autocorrect: true,
controller: _nameController,
decoration: InputDecoration.collapsed(
hintText: 'channelName'.tr,
),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
).paddingSymmetric(horizontal: 16, vertical: 8),
const Divider(thickness: 0.3),
Expanded(
child: TextField(
minLines: 5,
maxLines: null,
autocorrect: true,
keyboardType: TextInputType.multiline,
controller: _descriptionController,
decoration: InputDecoration.collapsed(
hintText: 'channelDescription'.tr,
),
onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
).paddingSymmetric(horizontal: 16, vertical: 12),
),
const Divider(thickness: 0.3),
if (_channelType == 1)
ListTile(
leading: const Icon(Icons.supervisor_account)
.paddingSymmetric(horizontal: 8),
title: Text('channelMember'.tr),
subtitle: _initialMembers.isNotEmpty
? Text(_initialMembers.map((e) => e.name).join(' '))
: null,
trailing: const Icon(Icons.chevron_right),
onTap: () => selectInitialMembers(),
).animate().fadeIn().slideY(
begin: 1,
end: 0,
curve: Curves.fastEaseInToSlowEaseOut,
),
ListTile(
leading: const Icon(Icons.mode).paddingSymmetric(horizontal: 8),
title: Text('channelType'.tr),
trailing: DropdownButtonHideUnderline(
child: DropdownButton2<int>(
isExpanded: true,
items: channelTypes.entries
.map((item) => DropdownMenuItem<int>(
value: item.key,
child: Text(
item.value,
style: const TextStyle(
fontSize: 14,
),
),
))
.toList(),
value: _channelType,
onChanged: (int? value) {
setState(() => _channelType = value ?? 0);
},
buttonStyleData: const ButtonStyleData(
padding: EdgeInsets.only(left: 16, right: 1),
height: 40,
width: 140,
),
menuItemStyleData: const MenuItemStyleData(
height: 40,
),
),
),
),
CheckboxListTile(
title: Text('channelEncrypted'.tr),
value: _isEncrypted,
onChanged: (widget.edit?.isEncrypted ?? false)
? null
: (newValue) =>
setState(() => _isEncrypted = newValue ?? false),
controlAffinity: ListTileControlAffinity.leading,
),
],
),
),
),
);
}
}

View File

@ -1,12 +1,127 @@
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
import 'package:solian/models/channel.dart';
import 'package:solian/providers/auth.dart';
import 'package:solian/providers/content/channel.dart';
import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
class ContactScreen extends StatelessWidget {
class ContactScreen extends StatefulWidget {
const ContactScreen({super.key});
@override
State<ContactScreen> createState() => _ContactScreenState();
}
class _ContactScreenState extends State<ContactScreen> {
bool _isBusy = true;
final List<Channel> _channels = List.empty(growable: true);
getChannels() async {
setState(() => _isBusy = true);
final ChannelProvider provider = Get.find();
final resp = await provider.listAvailableChannel();
setState(() {
_channels.clear();
_channels.addAll(
resp.body.map((e) => Channel.fromJson(e)).toList().cast<Channel>(),
);
});
setState(() => _isBusy = false);
}
@override
void initState() {
super.initState();
getChannels();
}
@override
Widget build(BuildContext context) {
final AuthProvider auth = Get.find();
// TODO Un signed in tip
return Material(
color: Theme.of(context).colorScheme.surface,
child: SafeArea(
child: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) {
return [
SliverOverlapAbsorber(
handle:
NestedScrollView.sliverOverlapAbsorberHandleFor(context),
sliver: SliverAppBar(
title: Text('contact'.tr),
centerTitle: false,
titleSpacing: SolianTheme.isLargeScreen(context) ? null : 24,
forceElevated: innerBoxIsScrolled,
actions: [
const NotificationButton(),
IconButton(
icon: const Icon(Icons.add_circle),
onPressed: () {
AppRouter.instance.pushNamed('channelOrganizing').then(
(value) {
if (value != null) {
getChannels();
}
},
);
},
),
if (!SolianTheme.isLargeScreen(context))
const SizedBox(width: 16),
],
),
),
];
},
body: MediaQuery.removePadding(
removeTop: true,
context: context,
child: Column(
children: [
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
Expanded(
child: RefreshIndicator(
onRefresh: () => getChannels(),
child: ListView.builder(
itemCount: _channels.length,
itemBuilder: (context, index) {
final element = _channels[index];
return ListTile(
leading: CircleAvatar(
backgroundColor: Colors.indigo,
child: FaIcon(
element.icon,
color: Colors.white,
size: 16,
),
),
contentPadding:
const EdgeInsets.symmetric(horizontal: 24),
title: Text(element.name),
subtitle: Text(element.description),
onTap: () {},
);
},
),
),
),
],
),
),
),
),
);
}
}

View File

@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:solian/exts.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_item.dart';
import 'package:solian/widgets/posts/post_replies.dart';

View File

@ -41,7 +41,7 @@ class PostPublishingScreen extends StatefulWidget {
class _PostPublishingScreenState extends State<PostPublishingScreen> {
final _contentController = TextEditingController();
bool _isSubmitting = false;
bool _isBusy = false;
List<int> _attachments = List.empty();
@ -61,7 +61,7 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
if (!await auth.isAuthorized) return;
if (_contentController.value.text.isEmpty) return;
setState(() => _isSubmitting = true);
setState(() => _isBusy = true);
final client = GetConnect();
client.httpClient.baseUrl = ServiceFinder.services['interactive'];
@ -87,7 +87,7 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
AppRouter.instance.pop(resp.body);
}
setState(() => _isSubmitting = false);
setState(() => _isBusy = false);
}
void syncWidget() {
@ -126,8 +126,8 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
leading: const PrevPageButton(),
actions: [
TextButton(
onPressed: _isBusy ? null : () => applyPost(),
child: Text('postAction'.tr.toUpperCase()),
onPressed: () => applyPost(),
)
],
),
@ -135,8 +135,7 @@ class _PostPublishingScreenState extends State<PostPublishingScreen> {
top: false,
child: Column(
children: [
if (_isSubmitting)
const LinearProgressIndicator().animate().scaleX(),
if (_isBusy) const LinearProgressIndicator().animate().scaleX(),
if (widget.edit != null)
MaterialBanner(
leading: const Icon(Icons.edit),

View File

@ -4,7 +4,7 @@ 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/auth.dart';
import 'package:solian/providers/content/post_explore.dart';
import 'package:solian/providers/content/post.dart';
import 'package:solian/router.dart';
import 'package:solian/screens/account/notification.dart';
import 'package:solian/theme.dart';
@ -85,8 +85,10 @@ class _SocialScreenState extends State<SocialScreen> {
titleSpacing:
SolianTheme.isLargeScreen(context) ? null : 24,
forceElevated: innerBoxIsScrolled,
actions: const [
NotificationButton(),
actions: [
const NotificationButton(),
if (!SolianTheme.isLargeScreen(context))
const SizedBox(width: 16),
],
),
),

View File

@ -2,9 +2,11 @@ abstract class ServiceFinder {
static const bool devFlag = true;
static Map<String, String> services = {
'paperclip': devFlag ? 'http://localhost:8443' : 'https://usercontent.solsynth.dev',
'paperclip':
devFlag ? 'http://localhost:8443' : 'https://usercontent.solsynth.dev',
'passport': devFlag ? 'http://localhost:8444' : 'https://id.solsynth.dev',
'interactive': devFlag ? 'http://localhost:8445' : 'https://co.solsynth.dev',
'messaging': devFlag ? 'http://localhost:8446' : 'https://im.solsynth.dev',
'interactive':
devFlag ? 'http://localhost:8445' : 'https://co.solsynth.dev',
'messaging': devFlag ? 'http://localhost:8447' : 'https://im.solsynth.dev',
};
}

View File

@ -16,6 +16,7 @@ class SolianMessages extends Translations {
'confirm': 'Confirm',
'edit': 'Edit',
'delete': 'Delete',
'search': 'Search',
'reply': 'Reply',
'repost': 'Repost',
'notification': 'Notification',
@ -89,6 +90,16 @@ class SolianMessages extends Translations {
'attachmentAddFile': 'Attach file',
'attachmentSetting': 'Adjust attachment',
'attachmentAlt': 'Alternative text',
'channelOrganizing': 'Organize a channel',
'channelEditingNotify': 'You\'re editing channel @channel',
'channelAlias': 'Alias (Identifier)',
'channelName': 'Name',
'channelDescription': 'Description',
'channelEncrypted': 'Encrypted Channel',
'channelMember': 'Channel member',
'channelType': 'Channel type',
'channelTypeCommon': 'Regular',
'channelTypeDirect': 'DM',
},
'zh_CN': {
'hide': '隐藏',
@ -103,6 +114,7 @@ class SolianMessages extends Translations {
'social': '社交',
'contact': '联系',
'apply': '应用',
'search': '搜索',
'reply': '回复',
'repost': '转帖',
'notification': '通知',
@ -169,6 +181,16 @@ class SolianMessages extends Translations {
'attachmentAddFile': '附加文件',
'attachmentSetting': '调整附件',
'attachmentAlt': '替代文字',
'channelOrganizing': '组织频道',
'channelEditingNotify': '你正在编辑频道 @channel',
'channelAlias': '别称(标识符)',
'channelName': '显示名称',
'channelDescription': '频道简介',
'channelEncrypted': '加密频道',
'channelMember': '频道成员',
'channelType': '频道类型',
'channelTypeCommon': '普通频道',
'channelTypeDirect': '私信聊天',
}
};
}

View File

@ -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(

View 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);
},
);
},
),
),
],
),
);
}
}

View File

@ -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!();

View File

@ -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,
),
),

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 {

View File

@ -97,6 +97,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.10"
dropdown_button2:
dependency: "direct main"
description:
name: dropdown_button2
sha256: b0fe8d49a030315e9eef6c7ac84ca964250155a6224d491c1365061bc974a9e1
url: "https://pub.dev"
source: hosted
version: "2.3.9"
fake_async:
dependency: transitive
description:

View File

@ -56,6 +56,7 @@ dependencies:
flutter_local_notifications: ^17.1.2
permission_handler: ^11.3.1
uuid: ^4.4.0
dropdown_button2: ^2.3.9
dev_dependencies:
flutter_test: