Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
0a381ef09b | |||
9b84e912b2 | |||
b3254e0f2f | |||
f0a3bbe023 | |||
df81c84438 | |||
8b12395fca |
@ -27,6 +27,7 @@
|
|||||||
"screenChatNew": "New Channel",
|
"screenChatNew": "New Channel",
|
||||||
"screenRealm": "Realm",
|
"screenRealm": "Realm",
|
||||||
"screenRealmManage": "Edit Realm",
|
"screenRealmManage": "Edit Realm",
|
||||||
|
"screenRealmDiscovery": "Realm Discovery",
|
||||||
"screenRealmNew": "New Realm",
|
"screenRealmNew": "New Realm",
|
||||||
"screenNotification": "Notification",
|
"screenNotification": "Notification",
|
||||||
"screenPostSearch": "Search Posts",
|
"screenPostSearch": "Search Posts",
|
||||||
@ -619,5 +620,10 @@
|
|||||||
"postQuestionAnswered": "Answered Question",
|
"postQuestionAnswered": "Answered Question",
|
||||||
"postQuestionAnswerSelect": "Select as Answer",
|
"postQuestionAnswerSelect": "Select as Answer",
|
||||||
"postQuestionAnswerSelected": "Answer has been selected, reward has been applied.",
|
"postQuestionAnswerSelected": "Answer has been selected, reward has been applied.",
|
||||||
"postVideoUpload": "Upload Video"
|
"postVideoUpload": "Upload Video",
|
||||||
|
"realmJoin": "Join Realm",
|
||||||
|
"realmCommunityHint": "This realm is a community realm, you can freely join.",
|
||||||
|
"realmCommunityPublicChannelsHint": "The public channels in this realm",
|
||||||
|
"realmJoined": "Joined realm {}.",
|
||||||
|
"join": "Join"
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"screenChatNew": "新建聊天频道",
|
"screenChatNew": "新建聊天频道",
|
||||||
"screenRealm": "领域",
|
"screenRealm": "领域",
|
||||||
"screenRealmManage": "编辑领域",
|
"screenRealmManage": "编辑领域",
|
||||||
|
"screenRealmDiscovery": "发现领域",
|
||||||
"screenRealmNew": "新建领域",
|
"screenRealmNew": "新建领域",
|
||||||
"screenNotification": "通知",
|
"screenNotification": "通知",
|
||||||
"screenPostSearch": "搜索帖子",
|
"screenPostSearch": "搜索帖子",
|
||||||
@ -618,5 +619,10 @@
|
|||||||
"postQuestionAnswerTitle": "精选解答",
|
"postQuestionAnswerTitle": "精选解答",
|
||||||
"postQuestionAnswerSelect": "选择解答",
|
"postQuestionAnswerSelect": "选择解答",
|
||||||
"postQuestionAnswerSelected": "解答已选择,奖励已发放。",
|
"postQuestionAnswerSelected": "解答已选择,奖励已发放。",
|
||||||
"postVideoUpload": "上传视频"
|
"postVideoUpload": "上传视频",
|
||||||
|
"realmJoin": "加入领域",
|
||||||
|
"realmCommunityHint": "该领域是一个社区领域,你可以自由加入。",
|
||||||
|
"realmCommunityPublicChannelsHint": "该领域包含的公共频道",
|
||||||
|
"realmJoined": "已加入领域 {}。",
|
||||||
|
"join": "加入"
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"screenChatNew": "新建聊天頻道",
|
"screenChatNew": "新建聊天頻道",
|
||||||
"screenRealm": "領域",
|
"screenRealm": "領域",
|
||||||
"screenRealmManage": "編輯領域",
|
"screenRealmManage": "編輯領域",
|
||||||
|
"screenRealmDiscovery": "發現領域",
|
||||||
"screenRealmNew": "新建領域",
|
"screenRealmNew": "新建領域",
|
||||||
"screenNotification": "通知",
|
"screenNotification": "通知",
|
||||||
"screenPostSearch": "搜索帖子",
|
"screenPostSearch": "搜索帖子",
|
||||||
@ -139,6 +140,7 @@
|
|||||||
"writePostTypeStory": "發動態",
|
"writePostTypeStory": "發動態",
|
||||||
"writePostTypeArticle": "寫文章",
|
"writePostTypeArticle": "寫文章",
|
||||||
"writePostTypeQuestion": "提問題",
|
"writePostTypeQuestion": "提問題",
|
||||||
|
"writePostTypeVideo": "發視頻",
|
||||||
"fieldPostPublisher": "帖子發佈者",
|
"fieldPostPublisher": "帖子發佈者",
|
||||||
"fieldPostContent": "發生什麼事了?!",
|
"fieldPostContent": "發生什麼事了?!",
|
||||||
"fieldPostTitle": "標題",
|
"fieldPostTitle": "標題",
|
||||||
@ -616,5 +618,11 @@
|
|||||||
"postQuestionAnswered": "已解答的問題",
|
"postQuestionAnswered": "已解答的問題",
|
||||||
"postQuestionAnswerTitle": "精選解答",
|
"postQuestionAnswerTitle": "精選解答",
|
||||||
"postQuestionAnswerSelect": "選擇解答",
|
"postQuestionAnswerSelect": "選擇解答",
|
||||||
"postQuestionAnswerSelected": "解答已選擇,獎勵已發放。"
|
"postQuestionAnswerSelected": "解答已選擇,獎勵已發放。",
|
||||||
|
"postVideoUpload": "上傳視頻",
|
||||||
|
"realmJoin": "加入領域",
|
||||||
|
"realmCommunityHint": "該領域是一個社區領域,你可以自由加入。",
|
||||||
|
"realmCommunityPublicChannelsHint": "該領域包含的公共頻道",
|
||||||
|
"realmJoined": "已加入領域 {}。",
|
||||||
|
"join": "加入"
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
"screenChatNew": "新建聊天頻道",
|
"screenChatNew": "新建聊天頻道",
|
||||||
"screenRealm": "領域",
|
"screenRealm": "領域",
|
||||||
"screenRealmManage": "編輯領域",
|
"screenRealmManage": "編輯領域",
|
||||||
|
"screenRealmDiscovery": "發現領域",
|
||||||
"screenRealmNew": "新建領域",
|
"screenRealmNew": "新建領域",
|
||||||
"screenNotification": "通知",
|
"screenNotification": "通知",
|
||||||
"screenPostSearch": "搜索帖子",
|
"screenPostSearch": "搜索帖子",
|
||||||
@ -139,6 +140,7 @@
|
|||||||
"writePostTypeStory": "發動態",
|
"writePostTypeStory": "發動態",
|
||||||
"writePostTypeArticle": "寫文章",
|
"writePostTypeArticle": "寫文章",
|
||||||
"writePostTypeQuestion": "提問題",
|
"writePostTypeQuestion": "提問題",
|
||||||
|
"writePostTypeVideo": "發視頻",
|
||||||
"fieldPostPublisher": "帖子發佈者",
|
"fieldPostPublisher": "帖子發佈者",
|
||||||
"fieldPostContent": "發生什麼事了?!",
|
"fieldPostContent": "發生什麼事了?!",
|
||||||
"fieldPostTitle": "標題",
|
"fieldPostTitle": "標題",
|
||||||
@ -616,5 +618,11 @@
|
|||||||
"postQuestionAnswered": "已解答的問題",
|
"postQuestionAnswered": "已解答的問題",
|
||||||
"postQuestionAnswerTitle": "精選解答",
|
"postQuestionAnswerTitle": "精選解答",
|
||||||
"postQuestionAnswerSelect": "選擇解答",
|
"postQuestionAnswerSelect": "選擇解答",
|
||||||
"postQuestionAnswerSelected": "解答已選擇,獎勵已發放。"
|
"postQuestionAnswerSelected": "解答已選擇,獎勵已發放。",
|
||||||
|
"postVideoUpload": "上傳視頻",
|
||||||
|
"realmJoin": "加入領域",
|
||||||
|
"realmCommunityHint": "該領域是一個社區領域,你可以自由加入。",
|
||||||
|
"realmCommunityPublicChannelsHint": "該領域包含的公共頻道",
|
||||||
|
"realmJoined": "已加入領域 {}。",
|
||||||
|
"join": "加入"
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,7 @@ class PostWriteController extends ChangeNotifier {
|
|||||||
contentController.text = post.body['content'] ?? '';
|
contentController.text = post.body['content'] ?? '';
|
||||||
aliasController.text = post.alias ?? '';
|
aliasController.text = post.alias ?? '';
|
||||||
rewardController.text = post.body['reward']?.toString() ?? '';
|
rewardController.text = post.body['reward']?.toString() ?? '';
|
||||||
|
videoAttachment = post.preload?.video;
|
||||||
publishedAt = post.publishedAt;
|
publishedAt = post.publishedAt;
|
||||||
publishedUntil = post.publishedUntil;
|
publishedUntil = post.publishedUntil;
|
||||||
visibleUsers = List.from(post.visibleUsersList ?? [], growable: true);
|
visibleUsers = List.from(post.visibleUsersList ?? [], growable: true);
|
||||||
|
@ -31,6 +31,7 @@ import 'package:surface/screens/post/post_search.dart';
|
|||||||
import 'package:surface/screens/realm.dart';
|
import 'package:surface/screens/realm.dart';
|
||||||
import 'package:surface/screens/realm/manage.dart';
|
import 'package:surface/screens/realm/manage.dart';
|
||||||
import 'package:surface/screens/realm/realm_detail.dart';
|
import 'package:surface/screens/realm/realm_detail.dart';
|
||||||
|
import 'package:surface/screens/realm/realm_discovery.dart';
|
||||||
import 'package:surface/screens/settings.dart';
|
import 'package:surface/screens/settings.dart';
|
||||||
import 'package:surface/screens/sharing.dart';
|
import 'package:surface/screens/sharing.dart';
|
||||||
import 'package:surface/screens/wallet.dart';
|
import 'package:surface/screens/wallet.dart';
|
||||||
@ -192,11 +193,6 @@ final _appRoutes = [
|
|||||||
child: const RealmScreen(),
|
child: const RealmScreen(),
|
||||||
),
|
),
|
||||||
routes: [
|
routes: [
|
||||||
GoRoute(
|
|
||||||
path: '/:alias',
|
|
||||||
name: 'realmDetail',
|
|
||||||
builder: (context, state) => RealmDetailScreen(alias: state.pathParameters['alias']!),
|
|
||||||
),
|
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/manage',
|
path: '/manage',
|
||||||
name: 'realmManage',
|
name: 'realmManage',
|
||||||
@ -204,6 +200,16 @@ final _appRoutes = [
|
|||||||
editingRealmAlias: state.uri.queryParameters['editing'],
|
editingRealmAlias: state.uri.queryParameters['editing'],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/discovery',
|
||||||
|
name: 'realmDiscovery',
|
||||||
|
builder: (context, state) => const RealmDiscoveryScreen(),
|
||||||
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/:alias',
|
||||||
|
name: 'realmDetail',
|
||||||
|
builder: (context, state) => RealmDetailScreen(alias: state.pathParameters['alias']!),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
GoRoute(path: '/news', name: 'news', builder: (context, state) => const NewsScreen(), routes: [
|
GoRoute(path: '/news', name: 'news', builder: (context, state) => const NewsScreen(), routes: [
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
@ -17,6 +18,7 @@ import 'package:uuid/uuid.dart';
|
|||||||
|
|
||||||
class ChatManageScreen extends StatefulWidget {
|
class ChatManageScreen extends StatefulWidget {
|
||||||
final String? editingChannelAlias;
|
final String? editingChannelAlias;
|
||||||
|
|
||||||
const ChatManageScreen({super.key, this.editingChannelAlias});
|
const ChatManageScreen({super.key, this.editingChannelAlias});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -33,6 +35,8 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
List<SnRealm>? _realms;
|
List<SnRealm>? _realms;
|
||||||
SnRealm? _belongToRealm;
|
SnRealm? _belongToRealm;
|
||||||
|
|
||||||
|
SnChannel? _editingChannel;
|
||||||
|
|
||||||
Future<void> _fetchRealms() async {
|
Future<void> _fetchRealms() async {
|
||||||
setState(() => _isBusy = true);
|
setState(() => _isBusy = true);
|
||||||
try {
|
try {
|
||||||
@ -41,6 +45,9 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
_realms = List<SnRealm>.from(
|
_realms = List<SnRealm>.from(
|
||||||
resp.data?.map((e) => SnRealm.fromJson(e)) ?? [],
|
resp.data?.map((e) => SnRealm.fromJson(e)) ?? [],
|
||||||
);
|
);
|
||||||
|
if (_editingChannel != null) {
|
||||||
|
_belongToRealm = _realms?.firstWhereOrNull((e) => e.id == _editingChannel!.realmId);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (mounted) context.showErrorDialog(err);
|
if (mounted) context.showErrorDialog(err);
|
||||||
} finally {
|
} finally {
|
||||||
@ -48,8 +55,6 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SnChannel? _editingChannel;
|
|
||||||
|
|
||||||
Future<void> _fetchChannel() async {
|
Future<void> _fetchChannel() async {
|
||||||
setState(() => _isBusy = true);
|
setState(() => _isBusy = true);
|
||||||
|
|
||||||
@ -124,9 +129,7 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AppScaffold(
|
return AppScaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: widget.editingChannelAlias != null
|
title: widget.editingChannelAlias != null ? Text('screenChatManage').tr() : Text('screenChatNew').tr(),
|
||||||
? Text('screenChatManage').tr()
|
|
||||||
: Text('screenChatNew').tr(),
|
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -138,8 +141,7 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
|
leadingPadding: const EdgeInsets.only(left: 10, right: 20),
|
||||||
dividerColor: Colors.transparent,
|
dividerColor: Colors.transparent,
|
||||||
content: Text(
|
content: Text(
|
||||||
'channelEditingNotice'
|
'channelEditingNotice'.tr(args: ['#${_editingChannel!.alias}']),
|
||||||
.tr(args: ['#${_editingChannel!.alias}']),
|
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
@ -162,6 +164,7 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
items: [
|
items: [
|
||||||
...(_realms?.map(
|
...(_realms?.map(
|
||||||
(SnRealm item) => DropdownMenuItem<SnRealm>(
|
(SnRealm item) => DropdownMenuItem<SnRealm>(
|
||||||
|
enabled: _editingChannel == null || _editingChannel?.realmId == item.id,
|
||||||
value: item,
|
value: item,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@ -179,15 +182,12 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(item.name).textStyle(Theme.of(context)
|
Text(item.name).textStyle(Theme.of(context).textTheme.bodyMedium!),
|
||||||
.textTheme
|
|
||||||
.bodyMedium!),
|
|
||||||
Text(
|
Text(
|
||||||
item.description,
|
item.description,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
).textStyle(
|
).textStyle(Theme.of(context).textTheme.bodySmall!),
|
||||||
Theme.of(context).textTheme.bodySmall!),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -197,14 +197,14 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
) ??
|
) ??
|
||||||
[]),
|
[]),
|
||||||
DropdownMenuItem<SnRealm>(
|
DropdownMenuItem<SnRealm>(
|
||||||
|
enabled: _editingChannel == null,
|
||||||
value: null,
|
value: null,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
radius: 16,
|
radius: 16,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
foregroundColor:
|
foregroundColor: Theme.of(context).colorScheme.onSurface,
|
||||||
Theme.of(context).colorScheme.onSurface,
|
|
||||||
child: const Icon(Symbols.clear),
|
child: const Icon(Symbols.clear),
|
||||||
),
|
),
|
||||||
const Gap(12),
|
const Gap(12),
|
||||||
@ -213,9 +213,7 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('fieldChatBelongToRealmUnset')
|
Text('fieldChatBelongToRealmUnset').tr().textStyle(
|
||||||
.tr()
|
|
||||||
.textStyle(
|
|
||||||
Theme.of(context).textTheme.bodyMedium!,
|
Theme.of(context).textTheme.bodyMedium!,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -231,10 +229,10 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
},
|
},
|
||||||
buttonStyleData: const ButtonStyleData(
|
buttonStyleData: const ButtonStyleData(
|
||||||
padding: EdgeInsets.only(right: 16),
|
padding: EdgeInsets.only(right: 16),
|
||||||
height: 60,
|
height: 48,
|
||||||
),
|
),
|
||||||
menuItemStyleData: const MenuItemStyleData(
|
menuItemStyleData: const MenuItemStyleData(
|
||||||
height: 60,
|
height: 48,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -250,8 +248,7 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
helperText: 'fieldChatAliasHint'.tr(),
|
helperText: 'fieldChatAliasHint'.tr(),
|
||||||
helperMaxLines: 2,
|
helperMaxLines: 2,
|
||||||
),
|
),
|
||||||
onTapOutside: (_) =>
|
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
),
|
||||||
const Gap(4),
|
const Gap(4),
|
||||||
TextField(
|
TextField(
|
||||||
@ -260,8 +257,7 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
border: const UnderlineInputBorder(),
|
border: const UnderlineInputBorder(),
|
||||||
labelText: 'fieldChatName'.tr(),
|
labelText: 'fieldChatName'.tr(),
|
||||||
),
|
),
|
||||||
onTapOutside: (_) =>
|
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
),
|
||||||
const Gap(4),
|
const Gap(4),
|
||||||
TextField(
|
TextField(
|
||||||
@ -272,8 +268,7 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
|
|||||||
border: const UnderlineInputBorder(),
|
border: const UnderlineInputBorder(),
|
||||||
labelText: 'fieldChatDescription'.tr(),
|
labelText: 'fieldChatDescription'.tr(),
|
||||||
),
|
),
|
||||||
onTapOutside: (_) =>
|
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
),
|
||||||
const Gap(12),
|
const Gap(12),
|
||||||
Row(
|
Row(
|
||||||
|
@ -261,17 +261,15 @@ class _ExploreScreenState extends State<ExploreScreen> {
|
|||||||
hasReachedMax: _postCount != null && _posts.length >= _postCount!,
|
hasReachedMax: _postCount != null && _posts.length >= _postCount!,
|
||||||
onFetchData: _fetchPosts,
|
onFetchData: _fetchPosts,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
return Center(
|
return OpenablePostItem(
|
||||||
child: OpenablePostItem(
|
data: _posts[idx],
|
||||||
data: _posts[idx],
|
maxWidth: 640,
|
||||||
maxWidth: 640,
|
onChanged: (data) {
|
||||||
onChanged: (data) {
|
setState(() => _posts[idx] = data);
|
||||||
setState(() => _posts[idx] = data);
|
},
|
||||||
},
|
onDeleted: () {
|
||||||
onDeleted: () {
|
_refreshPosts();
|
||||||
_refreshPosts();
|
},
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
separatorBuilder: (_, __) => const Gap(8),
|
separatorBuilder: (_, __) => const Gap(8),
|
||||||
|
@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_context_menu/flutter_context_menu.dart';
|
||||||
import 'package:gap/gap.dart';
|
import 'package:gap/gap.dart';
|
||||||
import 'package:hotkey_manager/hotkey_manager.dart';
|
import 'package:hotkey_manager/hotkey_manager.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
@ -14,11 +15,14 @@ import 'package:responsive_framework/responsive_framework.dart';
|
|||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:surface/controllers/post_write_controller.dart';
|
import 'package:surface/controllers/post_write_controller.dart';
|
||||||
import 'package:surface/providers/config.dart';
|
import 'package:surface/providers/config.dart';
|
||||||
|
import 'package:surface/providers/sn_attachment.dart';
|
||||||
import 'package:surface/providers/sn_network.dart';
|
import 'package:surface/providers/sn_network.dart';
|
||||||
import 'package:surface/types/attachment.dart';
|
import 'package:surface/types/attachment.dart';
|
||||||
import 'package:surface/types/post.dart';
|
import 'package:surface/types/post.dart';
|
||||||
import 'package:surface/widgets/account/account_image.dart';
|
import 'package:surface/widgets/account/account_image.dart';
|
||||||
import 'package:surface/widgets/attachment/attachment_item.dart';
|
import 'package:surface/widgets/attachment/attachment_item.dart';
|
||||||
|
import 'package:surface/widgets/attachment/pending_attachment_alt.dart';
|
||||||
|
import 'package:surface/widgets/attachment/pending_attachment_boost.dart';
|
||||||
import 'package:surface/widgets/loading_indicator.dart';
|
import 'package:surface/widgets/loading_indicator.dart';
|
||||||
import 'package:surface/widgets/markdown_content.dart';
|
import 'package:surface/widgets/markdown_content.dart';
|
||||||
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
||||||
@ -716,6 +720,74 @@ class _PostVideoEditor extends StatelessWidget {
|
|||||||
controller.setVideoAttachment(video);
|
controller.setVideoAttachment(video);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _setAlt(BuildContext context) async {
|
||||||
|
if (controller.videoAttachment == null) return;
|
||||||
|
|
||||||
|
final result = await showDialog<SnAttachment?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => PendingAttachmentAltDialog(media: PostWriteMedia(controller.videoAttachment)),
|
||||||
|
);
|
||||||
|
if (result == null) return;
|
||||||
|
|
||||||
|
controller.setVideoAttachment(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _createBoost(BuildContext context) async {
|
||||||
|
if (controller.videoAttachment == null) return;
|
||||||
|
|
||||||
|
final result = await showDialog<SnAttachmentBoost?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => PendingAttachmentBoostDialog(media: PostWriteMedia(controller.videoAttachment)),
|
||||||
|
);
|
||||||
|
if (result == null) return;
|
||||||
|
|
||||||
|
final newAttach = controller.videoAttachment!.copyWith(
|
||||||
|
boosts: [...controller.videoAttachment!.boosts, result],
|
||||||
|
);
|
||||||
|
|
||||||
|
controller.setVideoAttachment(newAttach);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _setThumbnail(BuildContext context) async {
|
||||||
|
if (controller.videoAttachment == null) return;
|
||||||
|
|
||||||
|
final thumbnail = await showDialog<SnAttachment?>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AttachmentInputDialog(
|
||||||
|
title: 'attachmentSetThumbnail'.tr(),
|
||||||
|
pool: 'interactive',
|
||||||
|
analyzeNow: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (thumbnail == null) return;
|
||||||
|
if (!context.mounted) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final attach = context.read<SnAttachmentProvider>();
|
||||||
|
final newAttach = await attach.updateOne(
|
||||||
|
controller.videoAttachment!,
|
||||||
|
thumbnailId: thumbnail.id,
|
||||||
|
);
|
||||||
|
controller.setVideoAttachment(newAttach);
|
||||||
|
} catch (err) {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _deleteAttachment(BuildContext context) async {
|
||||||
|
if (controller.videoAttachment == null) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
await sn.client.delete('/cgi/uc/attachments/${controller.videoAttachment!.id}');
|
||||||
|
controller.setVideoAttachment(null);
|
||||||
|
} catch (err) {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
@ -772,35 +844,78 @@ class _PostVideoEditor extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(color: Theme.of(context).dividerColor),
|
border: Border.all(color: Theme.of(context).dividerColor),
|
||||||
),
|
),
|
||||||
child: InkWell(
|
child: ContextMenuRegion(
|
||||||
borderRadius: BorderRadius.circular(16),
|
contextMenu: ContextMenu(
|
||||||
child: AspectRatio(
|
entries: [
|
||||||
aspectRatio: 16 / 9,
|
MenuItem(
|
||||||
child: controller.videoAttachment == null
|
label: 'attachmentSetAlt'.tr(),
|
||||||
? Center(
|
icon: Symbols.description,
|
||||||
child: Row(
|
onSelected: () {
|
||||||
mainAxisSize: MainAxisSize.min,
|
_setAlt(context);
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
},
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
),
|
||||||
children: [
|
MenuItem(
|
||||||
const Icon(Icons.add),
|
label: 'attachmentBoost'.tr(),
|
||||||
const Gap(4),
|
icon: Symbols.bolt,
|
||||||
Text('postVideoUpload'.tr()),
|
onSelected: () {
|
||||||
],
|
_createBoost(context);
|
||||||
),
|
},
|
||||||
)
|
),
|
||||||
: ClipRRect(
|
MenuItem(
|
||||||
borderRadius: BorderRadius.circular(16),
|
label: 'attachmentSetThumbnail'.tr(),
|
||||||
child: AttachmentItem(
|
icon: Symbols.image,
|
||||||
data: controller.videoAttachment!,
|
onSelected: () {
|
||||||
heroTag: const Uuid().v4(),
|
_setThumbnail(context);
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
|
MenuItem(
|
||||||
|
label: 'attachmentCopyRandomId'.tr(),
|
||||||
|
icon: Symbols.content_copy,
|
||||||
|
onSelected: () {
|
||||||
|
Clipboard.setData(ClipboardData(text: controller.videoAttachment!.rid));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
MenuItem(
|
||||||
|
label: 'delete'.tr(),
|
||||||
|
icon: Symbols.delete,
|
||||||
|
onSelected: () => _deleteAttachment(context),
|
||||||
|
),
|
||||||
|
MenuItem(
|
||||||
|
label: 'unlink'.tr(),
|
||||||
|
icon: Symbols.link_off,
|
||||||
|
onSelected: () {
|
||||||
|
controller.setVideoAttachment(null);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
onTap: controller.videoAttachment != null ? () => _selectVideo(context) : null,
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
child: controller.videoAttachment == null
|
||||||
|
? Center(
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.add),
|
||||||
|
const Gap(4),
|
||||||
|
Text('postVideoUpload'.tr()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
child: AttachmentItem(
|
||||||
|
data: controller.videoAttachment!,
|
||||||
|
heroTag: const Uuid().v4(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
|
||||||
if (controller.videoAttachment != null) return;
|
|
||||||
_selectVideo(context);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -100,6 +100,12 @@ class _RealmScreenState extends State<RealmScreen> {
|
|||||||
leading: AutoAppBarLeading(),
|
leading: AutoAppBarLeading(),
|
||||||
title: Text('screenRealm').tr(),
|
title: Text('screenRealm').tr(),
|
||||||
actions: [
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Symbols.globe),
|
||||||
|
onPressed: () {
|
||||||
|
GoRouter.of(context).pushNamed('realmDiscovery');
|
||||||
|
},
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: !_isCompactView ? const Icon(Symbols.view_list) : const Icon(Symbols.view_module),
|
icon: !_isCompactView ? const Icon(Symbols.view_list) : const Icon(Symbols.view_module),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
291
lib/screens/realm/realm_discovery.dart
Normal file
291
lib/screens/realm/realm_discovery.dart
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:surface/providers/sn_network.dart';
|
||||||
|
import 'package:surface/providers/userinfo.dart';
|
||||||
|
import 'package:surface/types/chat.dart';
|
||||||
|
import 'package:surface/types/realm.dart';
|
||||||
|
import 'package:surface/widgets/account/account_image.dart';
|
||||||
|
import 'package:surface/widgets/dialog.dart';
|
||||||
|
import 'package:surface/widgets/loading_indicator.dart';
|
||||||
|
import 'package:surface/widgets/navigation/app_scaffold.dart';
|
||||||
|
import 'package:surface/widgets/universal_image.dart';
|
||||||
|
|
||||||
|
class RealmDiscoveryScreen extends StatefulWidget {
|
||||||
|
const RealmDiscoveryScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RealmDiscoveryScreen> createState() => _RealmDiscoveryScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RealmDiscoveryScreenState extends State<RealmDiscoveryScreen> {
|
||||||
|
List<SnRealm>? _realms;
|
||||||
|
bool _isBusy = false;
|
||||||
|
|
||||||
|
Future<void> _fetchRealms() async {
|
||||||
|
try {
|
||||||
|
setState(() => _isBusy = true);
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
final resp = await sn.client.get('/cgi/id/realms');
|
||||||
|
_realms = List<SnRealm>.from(
|
||||||
|
resp.data?.map((e) => SnRealm.fromJson(e)) ?? [],
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
if (mounted) context.showErrorDialog(err);
|
||||||
|
rethrow;
|
||||||
|
} finally {
|
||||||
|
setState(() => _isBusy = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_fetchRealms();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
|
||||||
|
return AppScaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('screenRealmDiscovery').tr(),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
LoadingIndicator(isActive: _isBusy),
|
||||||
|
Expanded(
|
||||||
|
child: RefreshIndicator(
|
||||||
|
onRefresh: _fetchRealms,
|
||||||
|
child: ListView.builder(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
itemCount: _realms?.length ?? 0,
|
||||||
|
itemBuilder: (context, idx) {
|
||||||
|
final realm = _realms![idx];
|
||||||
|
return Container(
|
||||||
|
constraints: BoxConstraints(maxWidth: 640),
|
||||||
|
child: Card(
|
||||||
|
margin: const EdgeInsets.all(12),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
AspectRatio(
|
||||||
|
aspectRatio: 16 / 7,
|
||||||
|
child: Stack(
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
child: Container(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: (realm.banner?.isEmpty ?? true)
|
||||||
|
? const SizedBox.shrink()
|
||||||
|
: AutoResizeUniversalImage(
|
||||||
|
sn.getAttachmentUrl(realm.banner!),
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: -30,
|
||||||
|
left: 18,
|
||||||
|
child: AccountImage(
|
||||||
|
content: realm.avatar,
|
||||||
|
radius: 24,
|
||||||
|
fallbackWidget: const Icon(Symbols.group, size: 24),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Gap(20 + 12),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(realm.name).textStyle(Theme.of(context).textTheme.titleMedium!),
|
||||||
|
Text(realm.description).textStyle(Theme.of(context).textTheme.bodySmall!),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, bottom: 14),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => _RealmJoinPopup(realm: realm),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).center();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RealmJoinPopup extends StatefulWidget {
|
||||||
|
final SnRealm realm;
|
||||||
|
|
||||||
|
const _RealmJoinPopup({required this.realm});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_RealmJoinPopup> createState() => _RealmJoinPopupState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RealmJoinPopupState extends State<_RealmJoinPopup> {
|
||||||
|
final List<String> _planJoinChannels = List.empty(growable: true);
|
||||||
|
|
||||||
|
List<SnChannel>? _channels;
|
||||||
|
bool _isBusy = false;
|
||||||
|
bool _isJoining = false;
|
||||||
|
|
||||||
|
Future<void> _fetchPublicChannels() async {
|
||||||
|
try {
|
||||||
|
setState(() => _isBusy = true);
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
final resp = await sn.client.get('/cgi/im/channels/${widget.realm.alias}');
|
||||||
|
final out = List<SnChannel>.from(
|
||||||
|
resp.data.map((e) => SnChannel.fromJson(e)).cast<SnChannel>(),
|
||||||
|
);
|
||||||
|
setState(() => _channels = out);
|
||||||
|
} catch (err) {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
} finally {
|
||||||
|
setState(() => _isBusy = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _joinRealm() async {
|
||||||
|
try {
|
||||||
|
setState(() => _isJoining = true);
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
final ua = context.read<UserProvider>();
|
||||||
|
await sn.client.post('/cgi/id/realms/${widget.realm.alias}/members', data: {
|
||||||
|
'related': ua.user?.name,
|
||||||
|
});
|
||||||
|
await _joinSelectedChannels();
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showSnackbar('realmJoined'.tr(args: [widget.realm.name]));
|
||||||
|
Navigator.pop(context);
|
||||||
|
} catch (err) {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
} finally {
|
||||||
|
setState(() => _isJoining = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _joinSelectedChannels() async {
|
||||||
|
if (_planJoinChannels.isEmpty) return;
|
||||||
|
for (final channel in _planJoinChannels) {
|
||||||
|
try {
|
||||||
|
final sn = context.read<SnNetworkProvider>();
|
||||||
|
final ua = context.read<UserProvider>();
|
||||||
|
await sn.client.post('/cgi/im/channels/${widget.realm.alias}/$channel/members', data: {
|
||||||
|
'related': ua.user?.name,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
if (!mounted) return;
|
||||||
|
context.showErrorDialog(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_fetchPublicChannels();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Symbols.group_add, size: 24),
|
||||||
|
const Gap(16),
|
||||||
|
Text('realmJoin', style: Theme.of(context).textTheme.titleLarge).tr(),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 20, top: 16, bottom: 12),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.realm.name,
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.realm.description,
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _isJoining ? null : () => _joinRealm(),
|
||||||
|
child: Text('join'.tr()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).padding(horizontal: 24, bottom: 12),
|
||||||
|
const Divider(height: 1),
|
||||||
|
LoadingIndicator(isActive: _isBusy),
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||||
|
child: Text('realmCommunityPublicChannelsHint'.tr(), style: Theme.of(context).textTheme.bodyMedium)
|
||||||
|
.padding(horizontal: 24, vertical: 8),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: _channels?.length ?? 0,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final channel = _channels![index];
|
||||||
|
return CheckboxListTile(
|
||||||
|
value: _planJoinChannels.contains(channel.alias) ?? false,
|
||||||
|
title: Text(channel.name),
|
||||||
|
subtitle: Text(
|
||||||
|
channel.description,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
secondary: AccountImage(
|
||||||
|
content: null,
|
||||||
|
fallbackWidget: const Icon(Symbols.chat, size: 20),
|
||||||
|
),
|
||||||
|
onChanged: (value) {
|
||||||
|
value ??= false;
|
||||||
|
if (value) {
|
||||||
|
setState(() => _planJoinChannels.add(channel.alias));
|
||||||
|
} else {
|
||||||
|
setState(() => _planJoinChannels.remove(channel.alias));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'package:surface/providers/sn_network.dart';
|
import 'package:surface/providers/sn_network.dart';
|
||||||
import 'package:surface/providers/user_directory.dart';
|
import 'package:surface/providers/user_directory.dart';
|
||||||
|
import 'package:surface/providers/userinfo.dart';
|
||||||
import 'package:surface/types/account.dart';
|
import 'package:surface/types/account.dart';
|
||||||
import 'package:surface/widgets/account/account_image.dart';
|
import 'package:surface/widgets/account/account_image.dart';
|
||||||
|
|
||||||
@ -49,10 +50,19 @@ class _AccountSelectState extends State<AccountSelect> {
|
|||||||
Future<void> _getFriends() async {
|
Future<void> _getFriends() async {
|
||||||
final sn = context.read<SnNetworkProvider>();
|
final sn = context.read<SnNetworkProvider>();
|
||||||
final resp = await sn.client.get('/cgi/id/users/me/relations?status=1');
|
final resp = await sn.client.get('/cgi/id/users/me/relations?status=1');
|
||||||
|
if (!mounted) return;
|
||||||
|
final ua = context.read<UserProvider>();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_relativeUsers.addAll(
|
_relativeUsers.addAll(
|
||||||
resp.data?.map((e) => SnRelationship.fromJson(e)) ?? [],
|
resp.data?.map((e) {
|
||||||
|
final rel = SnRelationship.fromJson(e);
|
||||||
|
if (rel.relatedId == ua.user?.id) {
|
||||||
|
return rel.account!;
|
||||||
|
} else {
|
||||||
|
return rel.related!;
|
||||||
|
}
|
||||||
|
}).cast<SnAccount>(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -123,13 +133,9 @@ class _AccountSelectState extends State<AccountSelect> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: _pendingUsers.isEmpty
|
itemCount: _pendingUsers.isEmpty ? _relativeUsers.length : _pendingUsers.length,
|
||||||
? _relativeUsers.length
|
|
||||||
: _pendingUsers.length,
|
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var user = _pendingUsers.isEmpty
|
var user = _pendingUsers.isEmpty ? _relativeUsers[index] : _pendingUsers[index];
|
||||||
? _relativeUsers[index]
|
|
||||||
: _pendingUsers[index];
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(user.nick),
|
title: Text(user.nick),
|
||||||
subtitle: Text(user.name),
|
subtitle: Text(user.name),
|
||||||
@ -148,8 +154,7 @@ class _AccountSelectState extends State<AccountSelect> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
final idx = _selectedUsers
|
final idx = _selectedUsers.indexWhere((x) => x.id == user.id);
|
||||||
.indexWhere((x) => x.id == user.id);
|
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
_selectedUsers.removeAt(idx);
|
_selectedUsers.removeAt(idx);
|
||||||
} else {
|
} else {
|
||||||
|
@ -203,6 +203,7 @@ class ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_contentController.dispose();
|
_contentController.dispose();
|
||||||
_focusNode.dispose();
|
_focusNode.dispose();
|
||||||
|
_dismissEmojiPicker();
|
||||||
if (!kIsWeb && !(Platform.isAndroid || Platform.isIOS)) hotKeyManager.unregister(_pasteHotKey);
|
if (!kIsWeb && !(Platform.isAndroid || Platform.isIOS)) hotKeyManager.unregister(_pasteHotKey);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ class AppScaffold extends StatelessWidget {
|
|||||||
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
||||||
body: SizedBox.expand(
|
body: SizedBox.expand(
|
||||||
child: AppBackground(
|
child: AppBackground(
|
||||||
|
isRoot: true,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
IgnorePointer(child: SizedBox(height: appBar != null ? appBarHeight + safeTop : 0)),
|
IgnorePointer(child: SizedBox(height: appBar != null ? appBarHeight + safeTop : 0)),
|
||||||
|
@ -69,32 +69,34 @@ class OpenablePostItem extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cfg = context.read<ConfigProvider>();
|
final cfg = context.read<ConfigProvider>();
|
||||||
|
|
||||||
return OpenContainer(
|
return Center(
|
||||||
closedBuilder: (_, __) => Container(
|
child: OpenContainer(
|
||||||
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
closedBuilder: (_, __) => Container(
|
||||||
child: PostItem(
|
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
||||||
data: data,
|
child: PostItem(
|
||||||
maxWidth: maxWidth,
|
data: data,
|
||||||
showComments: showComments,
|
maxWidth: maxWidth,
|
||||||
showFullPost: showFullPost,
|
showComments: showComments,
|
||||||
onChanged: onChanged,
|
showFullPost: showFullPost,
|
||||||
onDeleted: onDeleted,
|
onChanged: onChanged,
|
||||||
onSelectAnswer: onSelectAnswer,
|
onDeleted: onDeleted,
|
||||||
),
|
onSelectAnswer: onSelectAnswer,
|
||||||
),
|
|
||||||
openBuilder: (_, close) => PostDetailScreen(
|
|
||||||
slug: data.id.toString(),
|
|
||||||
preload: data,
|
|
||||||
onBack: close,
|
|
||||||
),
|
|
||||||
openColor: Colors.transparent,
|
|
||||||
openElevation: 0,
|
|
||||||
transitionType: ContainerTransitionType.fade,
|
|
||||||
closedColor: Theme.of(context).colorScheme.surfaceContainerLow.withOpacity(
|
|
||||||
cfg.prefs.getBool(kAppBackgroundStoreKey) == true ? 0.75 : 1,
|
|
||||||
),
|
),
|
||||||
closedShape: const RoundedRectangleBorder(
|
),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(16)),
|
openBuilder: (_, close) => PostDetailScreen(
|
||||||
|
slug: data.id.toString(),
|
||||||
|
preload: data,
|
||||||
|
onBack: close,
|
||||||
|
),
|
||||||
|
openColor: Colors.transparent,
|
||||||
|
openElevation: 0,
|
||||||
|
transitionType: ContainerTransitionType.fade,
|
||||||
|
closedColor: Theme.of(context).colorScheme.surfaceContainerLow.withOpacity(
|
||||||
|
cfg.prefs.getBool(kAppBackgroundStoreKey) == true ? 0.75 : 1,
|
||||||
|
),
|
||||||
|
closedShape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(16)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 2.3.2+65
|
version: 2.3.2+66
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.4
|
sdk: ^3.5.4
|
||||||
|
Reference in New Issue
Block a user