Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions commet/lib/ui/atoms/room_text_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RoomTextButton extends StatefulWidget {
});
final bool highlight;
final Room room;
final Function(Room room)? onTap;
final Function(Room room, {bool bypassSpecialRoomType})? onTap;

@override
State<RoomTextButton> createState() => _RoomTextButtonState();
Expand Down Expand Up @@ -173,7 +173,15 @@ class _RoomTextButtonState extends State<RoomTextButton> {

var items = [
ContextMenuItem(
text: "Mark as Read", onPressed: () => widget.room.markAsRead()),
text: "Mark as Read",
icon: Icons.visibility,
onPressed: () => widget.room.markAsRead()),
if (widget.room.isSpecialRoomType)
ContextMenuItem(
text: "Open as Text Chat",
icon: Icons.tag,
onPressed: () =>
widget.onTap?.call(widget.room, bypassSpecialRoomType: true)),
if (voipRoom != null && preferences.developerMode)
ContextMenuItem(
text: "Clear Membership Status",
Expand Down
2 changes: 1 addition & 1 deletion commet/lib/ui/atoms/space_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:tiamat/tiamat.dart' as tiamat;
class SpaceList extends StatefulWidget {
const SpaceList(this.space,
{this.onRoomSelected, this.isTopLevel = true, super.key});
final Function(Room room)? onRoomSelected;
final Function(Room room, {bool bypassSpecialRoomType})? onRoomSelected;

final bool isTopLevel;

Expand Down
2 changes: 1 addition & 1 deletion commet/lib/ui/molecules/space_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SpaceViewer extends StatefulWidget {
this.onRoomSelected,
});
final Space space;
final void Function(Room)? onRoomSelected;
final void Function(Room, {bool bypassSpecialRoomType})? onRoomSelected;

@override
State<SpaceViewer> createState() => _SpaceViewerState();
Expand Down
6 changes: 4 additions & 2 deletions commet/lib/ui/pages/main/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum MainPageSubView {
class MainPageState extends State<MainPage> {
Space? _currentSpace;
Room? _currentRoom;
bool showAsTextRoom = false;
Client? filterClient;

MainPageSubView _currentView = MainPageSubView.home;
Expand Down Expand Up @@ -168,13 +169,14 @@ class MainPageState extends State<MainPage> {
EventBus.onSelectedSpaceChanged.add(space);
}

void selectRoom(Room room) {
if (room == currentRoom) return;
void selectRoom(Room room, {bool bypassSpecialRoomType = false}) {
if (room == currentRoom && bypassSpecialRoomType == showAsTextRoom) return;

onRoomUpdateSubscription?.cancel();

setState(() {
_currentRoom = room;
showAsTextRoom = bypassSpecialRoomType;
});

EventBus.onSelectedRoomChanged.add(room);
Expand Down
8 changes: 5 additions & 3 deletions commet/lib/ui/pages/main/main_page_view_desktop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ class MainPageViewDesktop extends StatelessWidget {
key: ValueKey(
"space-view-key-${state.currentSpace!.localId}",
),
onRoomSelected: (room) {
state.selectRoom(room);
onRoomSelected: (room, {bool bypassSpecialRoomType = false}) {
state.selectRoom(room,
bypassSpecialRoomType: bypassSpecialRoomType);
},
),
),
Expand Down Expand Up @@ -336,7 +337,8 @@ class MainPageViewDesktop extends StatelessWidget {
caulkClipBottomLeft: true,
caulkClipBottomRight: true,
caulkBorderLeft: true,
child: RoomPrimaryView(state.currentRoom!),
child: RoomPrimaryView(state.currentRoom!,
bypassSpecialRoomTypes: state.showAsTextRoom),
),
),
RoomSidePanel(
Expand Down
14 changes: 9 additions & 5 deletions commet/lib/ui/pages/main/main_page_view_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ class _MainPageViewMobileState extends State<MainPageViewMobile> {
Expanded(
child: RoomPrimaryView(
widget.state.currentRoom!,
bypassSpecialRoomTypes: !widget.state.showAsTextRoom,
),
),
],
Expand Down Expand Up @@ -357,7 +358,9 @@ class _MainPageViewMobileState extends State<MainPageViewMobile> {
directMessages: widget.state.clientManager.directMessages,
onSelected: (room) {
setState(() {
selectRoom(room);
selectRoom(
room,
);
});
},
),
Expand Down Expand Up @@ -391,8 +394,9 @@ class _MainPageViewMobileState extends State<MainPageViewMobile> {
widget.state.currentSpace!,
key: ValueKey(
"space-view-key-${widget.state.currentSpace!.localId}"),
onRoomSelected: (room) async {
selectRoom(room);
onRoomSelected: (room, {bypassSpecialRoomType = false}) async {
selectRoom(room,
bypassSpecialRoomType: bypassSpecialRoomType);
},
),
)),
Expand All @@ -412,12 +416,12 @@ class _MainPageViewMobileState extends State<MainPageViewMobile> {
widget.state.clearRoomSelection();
}

void selectRoom(Room room) {
void selectRoom(Room room, {bypassSpecialRoomType = false}) {
panelsKey.currentState!.reveal(RevealSide.main);
setState(() {
shouldMainIgnoreInput = false;
});

widget.state.selectRoom(room);
widget.state.selectRoom(room, bypassSpecialRoomType: bypassSpecialRoomType);
}
}
56 changes: 30 additions & 26 deletions commet/lib/ui/pages/main/room_primary_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,44 @@ import 'package:commet/ui/organisms/voip_room_view/voip_room_view.dart';
import 'package:flutter/material.dart';

class RoomPrimaryView extends StatelessWidget {
const RoomPrimaryView(this.room, {super.key});
const RoomPrimaryView(this.room,
{super.key, this.bypassSpecialRoomTypes = false});
final Room room;
final bool bypassSpecialRoomTypes;

@override
Widget build(BuildContext context) {
var photos = room.getComponent<PhotoAlbumRoom>();
var voip = room.getComponent<VoipRoomComponent>();
var calendar = room.getComponent<CalendarRoom>();
if (!bypassSpecialRoomTypes) {
var photos = room.getComponent<PhotoAlbumRoom>();
var voip = room.getComponent<VoipRoomComponent>();
var calendar = room.getComponent<CalendarRoom>();

var key = ValueKey("room-primary-view-${room.localId}");
var key = ValueKey("room-primary-view-${room.localId}");

if (voip != null) {
return ScaledSafeArea(
bottom: true,
top: false,
child: VoipRoomView(
voip,
key: key,
),
);
}
if (voip != null) {
return ScaledSafeArea(
bottom: true,
top: false,
child: VoipRoomView(
voip,
key: key,
),
);
}

if (photos != null) {
return PhotoAlbumView(
photos,
key: key,
);
}
if (photos != null) {
return PhotoAlbumView(
photos,
key: key,
);
}

if (calendar?.isCalendarRoom == true) {
return CalendarRoomView(
calendar!,
key: key,
);
if (calendar?.isCalendarRoom == true) {
return CalendarRoomView(
calendar!,
key: key,
);
}
}

final call = clientManager?.callManager.getCallInRoom(
Expand Down