chore: use fluffychat's function for changing room display names (#3448)
This commit is contained in:
parent
32355ddffd
commit
6809063a81
2 changed files with 31 additions and 87 deletions
|
|
@ -19,9 +19,9 @@ import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
|||
import 'package:fluffychat/pangea/common/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/spaces/utils/set_class_name.dart';
|
||||
import 'package:fluffychat/pangea/spaces/utils/space_code.dart';
|
||||
import 'package:fluffychat/utils/file_selector.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_modal_action_popup.dart';
|
||||
import 'package:fluffychat/widgets/adaptive_dialogs/show_text_input_dialog.dart';
|
||||
|
|
@ -59,33 +59,38 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
bool displayAddStudentOptions = false;
|
||||
void toggleAddStudentOptions() =>
|
||||
setState(() => displayAddStudentOptions = !displayAddStudentOptions);
|
||||
void setDisplaynameAction() => setClassDisplayname(context, roomId);
|
||||
// void setDisplaynameAction() async {
|
||||
// final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
// final input = await showTextInputDialog(
|
||||
// context: context,
|
||||
// title: L10n.of(context).changeTheNameOfTheGroup,
|
||||
// okLabel: L10n.of(context).ok,
|
||||
// cancelLabel: L10n.of(context).cancel,
|
||||
// initialText: room.getLocalizedDisplayname(
|
||||
// MatrixLocals(
|
||||
// L10n.of(context),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// if (input == null) return;
|
||||
// final success = await showFutureLoadingDialog(
|
||||
// context: context,
|
||||
// future: () => room.setName(input),
|
||||
// );
|
||||
// if (success.error == null) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(content: Text(L10n.of(context).displaynameHasBeenChanged)),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// Pangea#
|
||||
|
||||
void setDisplaynameAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
final input = await showTextInputDialog(
|
||||
context: context,
|
||||
// #Pangea
|
||||
// title: L10n.of(context).changeTheNameOfTheGroup,
|
||||
title: room.isSpace
|
||||
? L10n.of(context).changeTheNameOfTheClass
|
||||
: L10n.of(context).changeTheNameOfTheChat,
|
||||
// Pangea#
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
initialText: room.getLocalizedDisplayname(
|
||||
MatrixLocals(
|
||||
L10n.of(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (input == null) return;
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setName(input),
|
||||
);
|
||||
if (success.error == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(L10n.of(context).displaynameHasBeenChanged)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void setTopicAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
final input = await showTextInputDialog(
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../../utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
|
||||
void setClassDisplayname(BuildContext context, String? roomId) async {
|
||||
if (roomId == null) return;
|
||||
final room = Matrix.of(context).client.getRoomById(roomId);
|
||||
if (room == null) return;
|
||||
final TextEditingController textFieldController = TextEditingController(
|
||||
text: room.getLocalizedDisplayname(
|
||||
MatrixLocals(
|
||||
L10n.of(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: Text(
|
||||
room.isSpace
|
||||
? L10n.of(context).changeTheNameOfTheClass
|
||||
: L10n.of(context).changeTheNameOfTheChat,
|
||||
),
|
||||
content: TextField(
|
||||
maxLength: 64,
|
||||
controller: textFieldController,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(L10n.of(context).cancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(L10n.of(context).ok),
|
||||
onPressed: () async {
|
||||
if (textFieldController.text == "") return;
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setName(textFieldController.text),
|
||||
);
|
||||
if (success.error == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(L10n.of(context).displaynameHasBeenChanged),
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue