🐛 Bug fixes
This commit is contained in:
		@@ -192,11 +192,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 +199,11 @@ 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: [
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user