Compare commits

..

No commits in common. "f0a3bbe02346a90bbc71119aadc554ff70d04df0" and "8b12395fca6e0b4d61b91bffbd1b8c47ff3ae9f8" have entirely different histories.

4 changed files with 39 additions and 40 deletions

View File

@ -192,6 +192,11 @@ 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',
@ -199,11 +204,6 @@ final _appRoutes = [
editingRealmAlias: state.uri.queryParameters['editing'], editingRealmAlias: state.uri.queryParameters['editing'],
), ),
), ),
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: [

View File

@ -1,4 +1,3 @@
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';
@ -18,7 +17,6 @@ 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
@ -35,8 +33,6 @@ 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 {
@ -45,9 +41,6 @@ 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 {
@ -55,6 +48,8 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
} }
} }
SnChannel? _editingChannel;
Future<void> _fetchChannel() async { Future<void> _fetchChannel() async {
setState(() => _isBusy = true); setState(() => _isBusy = true);
@ -129,7 +124,9 @@ 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 ? Text('screenChatManage').tr() : Text('screenChatNew').tr(), title: widget.editingChannelAlias != null
? Text('screenChatManage').tr()
: Text('screenChatNew').tr(),
), ),
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
@ -141,7 +138,8 @@ 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'.tr(args: ['#${_editingChannel!.alias}']), 'channelEditingNotice'
.tr(args: ['#${_editingChannel!.alias}']),
), ),
actions: [ actions: [
TextButton( TextButton(
@ -164,7 +162,6 @@ 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: [
@ -182,12 +179,15 @@ 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).textTheme.bodyMedium!), Text(item.name).textStyle(Theme.of(context)
.textTheme
.bodyMedium!),
Text( Text(
item.description, item.description,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
).textStyle(Theme.of(context).textTheme.bodySmall!), ).textStyle(
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: Theme.of(context).colorScheme.onSurface, foregroundColor:
Theme.of(context).colorScheme.onSurface,
child: const Icon(Symbols.clear), child: const Icon(Symbols.clear),
), ),
const Gap(12), const Gap(12),
@ -213,7 +213,9 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text('fieldChatBelongToRealmUnset').tr().textStyle( Text('fieldChatBelongToRealmUnset')
.tr()
.textStyle(
Theme.of(context).textTheme.bodyMedium!, Theme.of(context).textTheme.bodyMedium!,
), ),
], ],
@ -229,10 +231,10 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
}, },
buttonStyleData: const ButtonStyleData( buttonStyleData: const ButtonStyleData(
padding: EdgeInsets.only(right: 16), padding: EdgeInsets.only(right: 16),
height: 48, height: 60,
), ),
menuItemStyleData: const MenuItemStyleData( menuItemStyleData: const MenuItemStyleData(
height: 48, height: 60,
), ),
), ),
), ),
@ -248,7 +250,8 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
helperText: 'fieldChatAliasHint'.tr(), helperText: 'fieldChatAliasHint'.tr(),
helperMaxLines: 2, helperMaxLines: 2,
), ),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
), ),
const Gap(4), const Gap(4),
TextField( TextField(
@ -257,7 +260,8 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
border: const UnderlineInputBorder(), border: const UnderlineInputBorder(),
labelText: 'fieldChatName'.tr(), labelText: 'fieldChatName'.tr(),
), ),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
), ),
const Gap(4), const Gap(4),
TextField( TextField(
@ -268,7 +272,8 @@ class _ChatManageScreenState extends State<ChatManageScreen> {
border: const UnderlineInputBorder(), border: const UnderlineInputBorder(),
labelText: 'fieldChatDescription'.tr(), labelText: 'fieldChatDescription'.tr(),
), ),
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), onTapOutside: (_) =>
FocusManager.instance.primaryFocus?.unfocus(),
), ),
const Gap(12), const Gap(12),
Row( Row(

View File

@ -6,7 +6,6 @@ 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';
@ -50,19 +49,10 @@ 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) { resp.data?.map((e) => SnRelationship.fromJson(e)) ?? [],
final rel = SnRelationship.fromJson(e);
if (rel.relatedId == ua.user?.id) {
return rel.account!;
} else {
return rel.related!;
}
}).cast<SnAccount>(),
); );
}); });
} }
@ -133,9 +123,13 @@ class _AccountSelectState extends State<AccountSelect> {
), ),
Expanded( Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: _pendingUsers.isEmpty ? _relativeUsers.length : _pendingUsers.length, itemCount: _pendingUsers.isEmpty
? _relativeUsers.length
: _pendingUsers.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
var user = _pendingUsers.isEmpty ? _relativeUsers[index] : _pendingUsers[index]; var user = _pendingUsers.isEmpty
? _relativeUsers[index]
: _pendingUsers[index];
return ListTile( return ListTile(
title: Text(user.nick), title: Text(user.nick),
subtitle: Text(user.name), subtitle: Text(user.name),
@ -154,7 +148,8 @@ class _AccountSelectState extends State<AccountSelect> {
} }
setState(() { setState(() {
final idx = _selectedUsers.indexWhere((x) => x.id == user.id); final idx = _selectedUsers
.indexWhere((x) => x.id == user.id);
if (idx != -1) { if (idx != -1) {
_selectedUsers.removeAt(idx); _selectedUsers.removeAt(idx);
} else { } else {

View File

@ -203,7 +203,6 @@ 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();
} }