mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-24 04:59:26 +01:00
feat: implement pinned messages
- render pinned events on the chat top - support scroll up for several pinned messages - ask to unpin messages - add button to pin message - fix some null-safety issues - fix the Linux database directly for debug builds Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
parent
849f401dbb
commit
8d1e27a0bf
@ -2723,5 +2723,7 @@
|
|||||||
"@bubbleSize": {
|
"@bubbleSize": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
}
|
},
|
||||||
|
"pinMessage": "An Raum anheften",
|
||||||
|
"pinnedEventsError": "Angeheftete Nachrichten nicht gefunden"
|
||||||
}
|
}
|
||||||
|
@ -2722,5 +2722,8 @@
|
|||||||
"sender": {},
|
"sender": {},
|
||||||
"reaction": {}
|
"reaction": {}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"pinMessage": "Pin to room",
|
||||||
|
"pinnedEventsError": "Error loading pinned messages",
|
||||||
|
"confirmEventUnpin": "Are you sure to permanently unpin the event?"
|
||||||
}
|
}
|
||||||
|
@ -823,6 +823,30 @@ class ChatController extends State<Chat> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unpinEvent(String eventId) async {
|
||||||
|
final response = await showOkCancelAlertDialog(
|
||||||
|
context: context,
|
||||||
|
title: L10n.of(context)!.unpin,
|
||||||
|
message: L10n.of(context)!.confirmEventUnpin,
|
||||||
|
okLabel: L10n.of(context)!.unpin,
|
||||||
|
cancelLabel: L10n.of(context)!.cancel,
|
||||||
|
);
|
||||||
|
if (response == OkCancelResult.ok) {
|
||||||
|
final events = room!.pinnedEventIds
|
||||||
|
..removeWhere((oldEvent) => oldEvent == eventId);
|
||||||
|
room!.setPinnedEvents(events);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pinEvent() {
|
||||||
|
room!.setPinnedEvents(
|
||||||
|
<String>{
|
||||||
|
...room!.pinnedEventIds,
|
||||||
|
...selectedEvents.map((e) => e.eventId),
|
||||||
|
}.toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void onInputBarChanged(String text) {
|
void onInputBarChanged(String text) {
|
||||||
if (text.endsWith(' ') && matrix!.hasComplexBundles) {
|
if (text.endsWith(' ') && matrix!.hasComplexBundles) {
|
||||||
final clients = currentRoomBundle;
|
final clients = currentRoomBundle;
|
||||||
|
@ -12,6 +12,7 @@ import 'package:fluffychat/config/app_config.dart';
|
|||||||
import 'package:fluffychat/config/themes.dart';
|
import 'package:fluffychat/config/themes.dart';
|
||||||
import 'package:fluffychat/pages/chat/chat.dart';
|
import 'package:fluffychat/pages/chat/chat.dart';
|
||||||
import 'package:fluffychat/pages/chat/chat_app_bar_title.dart';
|
import 'package:fluffychat/pages/chat/chat_app_bar_title.dart';
|
||||||
|
import 'package:fluffychat/pages/chat/pinned_events.dart';
|
||||||
import 'package:fluffychat/pages/chat/reactions_picker.dart';
|
import 'package:fluffychat/pages/chat/reactions_picker.dart';
|
||||||
import 'package:fluffychat/pages/chat/reply_display.dart';
|
import 'package:fluffychat/pages/chat/reply_display.dart';
|
||||||
import 'package:fluffychat/pages/chat/seen_by_row.dart';
|
import 'package:fluffychat/pages/chat/seen_by_row.dart';
|
||||||
@ -62,6 +63,11 @@ class ChatView extends StatelessWidget {
|
|||||||
tooltip: L10n.of(context)!.redactMessage,
|
tooltip: L10n.of(context)!.redactMessage,
|
||||||
onPressed: controller.redactEventsAction,
|
onPressed: controller.redactEventsAction,
|
||||||
),
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.push_pin),
|
||||||
|
onPressed: controller.pinEvent,
|
||||||
|
tooltip: L10n.of(context)!.pinMessage,
|
||||||
|
),
|
||||||
if (controller.selectedEvents.length == 1)
|
if (controller.selectedEvents.length == 1)
|
||||||
PopupMenuButton<_EventContextAction>(
|
PopupMenuButton<_EventContextAction>(
|
||||||
onSelected: (action) {
|
onSelected: (action) {
|
||||||
@ -208,6 +214,7 @@ class ChatView extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TombstoneDisplay(controller),
|
TombstoneDisplay(controller),
|
||||||
|
PinnedEvents(controller),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: controller.clearSingleSelectedEvent,
|
onTap: controller.clearSingleSelectedEvent,
|
||||||
|
@ -22,19 +22,19 @@ class Message extends StatelessWidget {
|
|||||||
final void Function(Event)? onInfoTab;
|
final void Function(Event)? onInfoTab;
|
||||||
final void Function(String)? scrollToEventId;
|
final void Function(String)? scrollToEventId;
|
||||||
final void Function(String) unfold;
|
final void Function(String) unfold;
|
||||||
final bool? longPressSelect;
|
final bool longPressSelect;
|
||||||
final bool? selected;
|
final bool selected;
|
||||||
final Timeline timeline;
|
final Timeline timeline;
|
||||||
|
|
||||||
const Message(this.event,
|
const Message(this.event,
|
||||||
{this.nextEvent,
|
{this.nextEvent,
|
||||||
this.longPressSelect,
|
this.longPressSelect = false,
|
||||||
this.onSelect,
|
this.onSelect,
|
||||||
this.onInfoTab,
|
this.onInfoTab,
|
||||||
this.onAvatarTab,
|
this.onAvatarTab,
|
||||||
this.scrollToEventId,
|
this.scrollToEventId,
|
||||||
required this.unfold,
|
required this.unfold,
|
||||||
this.selected,
|
this.selected = false,
|
||||||
required this.timeline,
|
required this.timeline,
|
||||||
Key? key})
|
Key? key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
@ -152,11 +152,10 @@ class Message extends StatelessWidget {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onHover: (b) => useMouse = true,
|
onHover: (b) => useMouse = true,
|
||||||
onTap: !useMouse && longPressSelect!
|
onTap: !useMouse && longPressSelect
|
||||||
? () {}
|
? () {}
|
||||||
: () => onSelect!(event),
|
: () => onSelect!(event),
|
||||||
onLongPress:
|
onLongPress: !longPressSelect ? null : () => onSelect!(event),
|
||||||
!longPressSelect! ? null : () => onSelect!(event),
|
|
||||||
borderRadius: borderRadius,
|
borderRadius: borderRadius,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -301,7 +300,7 @@ class Message extends StatelessWidget {
|
|||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: selected!
|
color: selected
|
||||||
? Theme.of(context).primaryColor.withAlpha(100)
|
? Theme.of(context).primaryColor.withAlpha(100)
|
||||||
: Theme.of(context).primaryColor.withAlpha(0),
|
: Theme.of(context).primaryColor.withAlpha(0),
|
||||||
constraints:
|
constraints:
|
||||||
|
@ -22,10 +22,11 @@ import 'sticker.dart';
|
|||||||
|
|
||||||
class MessageContent extends StatelessWidget {
|
class MessageContent extends StatelessWidget {
|
||||||
final Event event;
|
final Event event;
|
||||||
final Color? textColor;
|
final Color textColor;
|
||||||
final void Function(Event)? onInfoTab;
|
final void Function(Event)? onInfoTab;
|
||||||
|
|
||||||
const MessageContent(this.event, {this.onInfoTab, Key? key, this.textColor})
|
const MessageContent(this.event,
|
||||||
|
{this.onInfoTab, Key? key, required this.textColor})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
void _verifyOrRequestKey(BuildContext context) async {
|
void _verifyOrRequestKey(BuildContext context) async {
|
||||||
@ -83,17 +84,17 @@ class MessageContent extends StatelessWidget {
|
|||||||
if (PlatformInfos.isMobile) {
|
if (PlatformInfos.isMobile) {
|
||||||
return AudioPlayerWidget(
|
return AudioPlayerWidget(
|
||||||
event,
|
event,
|
||||||
color: textColor!,
|
color: textColor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return MessageDownloadContent(event, textColor!);
|
return MessageDownloadContent(event, textColor);
|
||||||
case MessageTypes.Video:
|
case MessageTypes.Video:
|
||||||
if (PlatformInfos.isMobile || PlatformInfos.isWeb) {
|
if (PlatformInfos.isMobile || PlatformInfos.isWeb) {
|
||||||
return EventVideoPlayer(event);
|
return EventVideoPlayer(event);
|
||||||
}
|
}
|
||||||
return MessageDownloadContent(event, textColor!);
|
return MessageDownloadContent(event, textColor);
|
||||||
case MessageTypes.File:
|
case MessageTypes.File:
|
||||||
return MessageDownloadContent(event, textColor!);
|
return MessageDownloadContent(event, textColor);
|
||||||
|
|
||||||
case MessageTypes.Text:
|
case MessageTypes.Text:
|
||||||
case MessageTypes.Notice:
|
case MessageTypes.Notice:
|
||||||
@ -115,7 +116,7 @@ class MessageContent extends StatelessWidget {
|
|||||||
fontSize: bigEmotes ? fontSize * 3 : fontSize,
|
fontSize: bigEmotes ? fontSize * 3 : fontSize,
|
||||||
),
|
),
|
||||||
linkStyle: TextStyle(
|
linkStyle: TextStyle(
|
||||||
color: textColor!.withAlpha(150),
|
color: textColor.withAlpha(150),
|
||||||
fontSize: bigEmotes ? fontSize * 3 : fontSize,
|
fontSize: bigEmotes ? fontSize * 3 : fontSize,
|
||||||
decoration: TextDecoration.underline,
|
decoration: TextDecoration.underline,
|
||||||
),
|
),
|
||||||
@ -200,7 +201,7 @@ class MessageContent extends StatelessWidget {
|
|||||||
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
||||||
),
|
),
|
||||||
linkStyle: TextStyle(
|
linkStyle: TextStyle(
|
||||||
color: textColor!.withAlpha(150),
|
color: textColor.withAlpha(150),
|
||||||
fontSize: bigEmotes ? fontSize * 3 : fontSize,
|
fontSize: bigEmotes ? fontSize * 3 : fontSize,
|
||||||
decoration: TextDecoration.underline,
|
decoration: TextDecoration.underline,
|
||||||
),
|
),
|
||||||
|
87
lib/pages/chat/pinned_events.dart
Normal file
87
lib/pages/chat/pinned_events.dart
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
|
import 'package:fluffychat/pages/chat/chat.dart';
|
||||||
|
import 'package:fluffychat/pages/chat/events/message_content.dart';
|
||||||
|
|
||||||
|
class PinnedEvents extends StatelessWidget {
|
||||||
|
final ChatController controller;
|
||||||
|
|
||||||
|
const PinnedEvents(this.controller, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final pinnedEventIds = controller.room!.pinnedEventIds;
|
||||||
|
|
||||||
|
if (pinnedEventIds.isEmpty) {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
final completers = pinnedEventIds.map<Completer<Event?>>((e) {
|
||||||
|
final completer = Completer<Event?>();
|
||||||
|
controller.room!
|
||||||
|
.getEventById(e)
|
||||||
|
.then((value) => completer.complete(value));
|
||||||
|
return completer;
|
||||||
|
});
|
||||||
|
return FutureBuilder<List<Event?>>(
|
||||||
|
future: Future.wait(completers.map((e) => e.future).toList()),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.hasData &&
|
||||||
|
snapshot.data != null &&
|
||||||
|
snapshot.data!.isNotEmpty &&
|
||||||
|
snapshot.data!.first != null) {
|
||||||
|
return Material(
|
||||||
|
color: Theme.of(context).secondaryHeaderColor,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxHeight: 96,
|
||||||
|
),
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
reverse: true,
|
||||||
|
itemBuilder: (c, i) {
|
||||||
|
final event = snapshot.data![i]!;
|
||||||
|
return ListTile(
|
||||||
|
tileColor: Colors.transparent,
|
||||||
|
onTap: () => controller.scrollToEventId(event.eventId),
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.push_pin_outlined),
|
||||||
|
tooltip: L10n.of(context)!.unpin,
|
||||||
|
onPressed: () => controller.unpinEvent(event.eventId),
|
||||||
|
),
|
||||||
|
title: MessageContent(
|
||||||
|
snapshot.data![i]!,
|
||||||
|
textColor:
|
||||||
|
Theme.of(context).brightness == Brightness.dark
|
||||||
|
? Colors.white
|
||||||
|
: Colors.black,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: snapshot.data!.length,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
Logs().e('Error loading pinned events.', snapshot.error);
|
||||||
|
return ListTile(
|
||||||
|
tileColor: Theme.of(context).secondaryHeaderColor,
|
||||||
|
title: Text(L10n.of(context)!.pinnedEventsError));
|
||||||
|
} else {
|
||||||
|
return ListTile(
|
||||||
|
tileColor: Theme.of(context).secondaryHeaderColor,
|
||||||
|
title: const Center(
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: 24,
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
30
pubspec.lock
30
pubspec.lock
@ -755,7 +755,7 @@ packages:
|
|||||||
name: js
|
name: js
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.3"
|
version: "0.6.4"
|
||||||
latlong2:
|
latlong2:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -818,13 +818,15 @@ packages:
|
|||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.3"
|
version: "0.1.4"
|
||||||
matrix:
|
matrix:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: matrix
|
path: "."
|
||||||
url: "https://pub.dartlang.org"
|
ref: main
|
||||||
source: hosted
|
resolved-ref: "788f8ea2a1fc6c3e417e74750c7200504275700f"
|
||||||
|
url: "https://gitlab.com/famedly/company/frontend/famedlysdk.git"
|
||||||
|
source: git
|
||||||
version: "0.8.7"
|
version: "0.8.7"
|
||||||
matrix_api_lite:
|
matrix_api_lite:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
@ -965,7 +967,7 @@ packages:
|
|||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.1"
|
||||||
path_drawing:
|
path_drawing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1355,7 +1357,7 @@ packages:
|
|||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.8.2"
|
||||||
sqflite:
|
sqflite:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1418,21 +1420,21 @@ packages:
|
|||||||
name: test
|
name: test
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.19.5"
|
version: "1.20.1"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.8"
|
version: "0.4.9"
|
||||||
test_core:
|
test_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_core
|
name: test_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.9"
|
version: "0.4.11"
|
||||||
timezone:
|
timezone:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1572,7 +1574,7 @@ packages:
|
|||||||
name: url_launcher_web
|
name: url_launcher_web
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.0.6"
|
||||||
url_launcher_windows:
|
url_launcher_windows:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1600,7 +1602,7 @@ packages:
|
|||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.2"
|
||||||
video_compress:
|
video_compress:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1756,5 +1758,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.0"
|
version: "3.1.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.15.1 <3.0.0"
|
dart: ">=2.16.0-100.0.dev <3.0.0"
|
||||||
flutter: ">=2.10.0"
|
flutter: ">=2.8.0"
|
||||||
|
@ -118,4 +118,8 @@ dependency_overrides:
|
|||||||
hosted:
|
hosted:
|
||||||
name: geolocator_android
|
name: geolocator_android
|
||||||
url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
|
url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
|
||||||
|
matrix:
|
||||||
|
git:
|
||||||
|
url: https://gitlab.com/famedly/company/frontend/famedlysdk.git
|
||||||
|
ref: main
|
||||||
provider: 5.0.0
|
provider: 5.0.0
|
||||||
|
@ -9,6 +9,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||||||
url_launcher_windows
|
url_launcher_windows
|
||||||
)
|
)
|
||||||
|
|
||||||
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
)
|
||||||
|
|
||||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||||
|
|
||||||
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
||||||
@ -17,3 +20,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
|
|||||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
|
||||||
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
|
||||||
endforeach(plugin)
|
endforeach(plugin)
|
||||||
|
|
||||||
|
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
|
||||||
|
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
|
||||||
|
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
|
||||||
|
endforeach(ffi_plugin)
|
||||||
|
Loading…
Reference in New Issue
Block a user