switch to fluffy's room description details with smaller button (#1055)
This commit is contained in:
parent
e441137159
commit
130a011fad
2 changed files with 65 additions and 142 deletions
|
|
@ -2,9 +2,7 @@ import 'package:adaptive_dialog/adaptive_dialog.dart';
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:fluffychat/pages/settings/settings.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/pages/chat_details/pangea_chat_details.dart';
|
||||
import 'package:fluffychat/pangea/pages/class_settings/p_class_widgets/class_description_button.dart';
|
||||
import 'package:fluffychat/pangea/utils/set_class_name.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:fluffychat/widgets/app_lock.dart';
|
||||
|
|
@ -81,31 +79,30 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
|
||||
void setTopicAction() async {
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!)!;
|
||||
final input = await showTextInputDialog(
|
||||
context: context,
|
||||
title: L10n.of(context)!.setChatDescription,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
hintText: L10n.of(context)!.noChatDescriptionYet,
|
||||
initialText: room.topic,
|
||||
minLines: 4,
|
||||
maxLines: 8,
|
||||
),
|
||||
],
|
||||
);
|
||||
if (input == null) return;
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setDescription(input.single),
|
||||
);
|
||||
// #Pangea
|
||||
setClassTopic(room, context);
|
||||
// final input = await showTextInputDialog(
|
||||
// context: context,
|
||||
// title: L10n.of(context)!.setChatDescription,
|
||||
// okLabel: L10n.of(context)!.ok,
|
||||
// cancelLabel: L10n.of(context)!.cancel,
|
||||
// textFields: [
|
||||
// DialogTextField(
|
||||
// hintText: L10n.of(context)!.noChatDescriptionYet,
|
||||
// initialText: room.topic,
|
||||
// minLines: 4,
|
||||
// maxLines: 8,
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// if (input == null) return;
|
||||
// final success = await showFutureLoadingDialog(
|
||||
// context: context,
|
||||
// future: () => room.setDescription(input.single),
|
||||
// );
|
||||
// if (success.error == null) {
|
||||
// ScaffoldMessenger.of(context).showSnackBar(
|
||||
// SnackBar(
|
||||
// content: Text(L10n.of(context)!.chatDescriptionHasBeenChanged),
|
||||
// content: Text(L10n.of(context).chatDescriptionHasBeenChanged),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
|
@ -247,102 +244,6 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
final TextEditingController _descriptionController = TextEditingController();
|
||||
|
||||
Future<void> setChatDescription() async {
|
||||
if (roomId == null) return;
|
||||
final room = Matrix.of(context).client.getRoomById(roomId!);
|
||||
if (room == null) return;
|
||||
|
||||
if (room.topic.isNotEmpty) {
|
||||
_descriptionController.text = room.topic;
|
||||
}
|
||||
|
||||
final response = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 400,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12,
|
||||
),
|
||||
child: Text(
|
||||
room.isSpace
|
||||
? L10n.of(context)!.spaceDescription
|
||||
: L10n.of(context)!.chatDescription,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.of(context).pop(null),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextFormField(
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
decoration: InputDecoration(
|
||||
hintText: room.isSpace
|
||||
? L10n.of(context)!.addSpaceDescription
|
||||
: L10n.of(context)!.addGroupDescription,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 28.0,
|
||||
vertical: 12.0,
|
||||
),
|
||||
),
|
||||
controller: _descriptionController,
|
||||
enabled: room.isRoomAdmin,
|
||||
minLines: 1, // Minimum number of lines
|
||||
maxLines:
|
||||
null, // Allow the field to expand based on content
|
||||
keyboardType: TextInputType.multiline,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(null),
|
||||
child: Text(L10n.of(context)!.cancel),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(
|
||||
room.isRoomAdmin ? _descriptionController.text : null,
|
||||
),
|
||||
child: Text(L10n.of(context)!.confirm),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (response == null) return;
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.setDescription(response),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -351,7 +252,6 @@ class ChatDetailsController extends State<ChatDetails> {
|
|||
|
||||
@override
|
||||
void dispose() {
|
||||
_descriptionController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
// Pangea#
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ import 'package:fluffychat/pangea/widgets/chat/visibility_toggle.dart';
|
|||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_settings.dart';
|
||||
import 'package:fluffychat/utils/fluffy_share.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -202,34 +204,55 @@ class PangeaChatDetailsView extends StatelessWidget {
|
|||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
TextButton.icon(
|
||||
onPressed: controller.setChatDescription,
|
||||
icon: const Icon(
|
||||
Icons.description_outlined,
|
||||
size: 14,
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor:
|
||||
theme.colorScheme.secondary,
|
||||
),
|
||||
label: Text(
|
||||
room.topic.isEmpty
|
||||
? room.isSpace
|
||||
? L10n.of(context)!
|
||||
.spaceDescription
|
||||
: L10n.of(context)!
|
||||
.chatDescription
|
||||
: room.topic,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(color: theme.dividerColor, height: 1),
|
||||
Stack(
|
||||
children: [
|
||||
if (room.isRoomAdmin)
|
||||
Positioned(
|
||||
right: 4,
|
||||
top: 4,
|
||||
child: IconButton(
|
||||
onPressed: controller.setTopicAction,
|
||||
icon: const Icon(Icons.edit_outlined),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 24.0,
|
||||
right: 24.0,
|
||||
top: 16.0,
|
||||
bottom: 16.0,
|
||||
),
|
||||
child: SelectableLinkify(
|
||||
text: room.topic.isEmpty
|
||||
? L10n.of(context)!.noChatDescriptionYet
|
||||
: room.topic,
|
||||
options: const LinkifyOptions(humanize: false),
|
||||
linkStyle: const TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
decorationColor: Colors.blueAccent,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontStyle: room.topic.isEmpty
|
||||
? FontStyle.italic
|
||||
: FontStyle.normal,
|
||||
color: theme.textTheme.bodyMedium!.color,
|
||||
decorationColor:
|
||||
theme.textTheme.bodyMedium!.color,
|
||||
),
|
||||
onOpen: (url) =>
|
||||
UrlLauncher(context, url.url).launchUrl(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(color: theme.dividerColor, height: 1),
|
||||
if (isGroupChat && room.canInvite)
|
||||
ConversationBotSettings(
|
||||
key: controller.addConversationBotKey,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue